From 1baf14f65c6abb3855e159b6609b14fa4108c904 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Mon, 22 Jan 2024 21:03:31 -0800 Subject: [PATCH] chore: add example of using write_source_file to merge output tree artifact files with source files that are already in an output directory (#730) --- .../write_source_files/merged_dir/BUILD.bazel | 20 +++++++++++++++++++ .../merged_dir/out/BUILD.bazel | 1 + .../merged_dir/out/somefile | 1 + .../write_source_files/merged_dir/somefile | 1 + 4 files changed, 23 insertions(+) create mode 100644 lib/tests/write_source_files/merged_dir/BUILD.bazel create mode 100644 lib/tests/write_source_files/merged_dir/out/BUILD.bazel create mode 100644 lib/tests/write_source_files/merged_dir/out/somefile create mode 100644 lib/tests/write_source_files/merged_dir/somefile diff --git a/lib/tests/write_source_files/merged_dir/BUILD.bazel b/lib/tests/write_source_files/merged_dir/BUILD.bazel new file mode 100644 index 0000000..e3b9782 --- /dev/null +++ b/lib/tests/write_source_files/merged_dir/BUILD.bazel @@ -0,0 +1,20 @@ +load("//lib:copy_to_directory.bzl", "copy_to_directory") +load("//lib/private:write_source_file.bzl", "write_source_file") + +copy_to_directory( + name = "desired", + srcs = [ + "somefile", + "//lib/tests/write_source_files/merged_dir/out:BUILD.bazel", + ], + root_paths = [ + ".", + "lib/tests/write_source_files/merged_dir/out", + ], +) + +write_source_file( + name = "merged_dir_test", + in_file = ":desired", + out_file = ":out", +) diff --git a/lib/tests/write_source_files/merged_dir/out/BUILD.bazel b/lib/tests/write_source_files/merged_dir/out/BUILD.bazel new file mode 100644 index 0000000..ed4e50d --- /dev/null +++ b/lib/tests/write_source_files/merged_dir/out/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["BUILD.bazel"]) diff --git a/lib/tests/write_source_files/merged_dir/out/somefile b/lib/tests/write_source_files/merged_dir/out/somefile new file mode 100644 index 0000000..7c4a013 --- /dev/null +++ b/lib/tests/write_source_files/merged_dir/out/somefile @@ -0,0 +1 @@ +aaa \ No newline at end of file diff --git a/lib/tests/write_source_files/merged_dir/somefile b/lib/tests/write_source_files/merged_dir/somefile new file mode 100644 index 0000000..7c4a013 --- /dev/null +++ b/lib/tests/write_source_files/merged_dir/somefile @@ -0,0 +1 @@ +aaa \ No newline at end of file