diff options
author | Jingwen Chen <jingwen@google.com> | 2023-05-08 05:44:07 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-05-08 05:44:07 +0000 |
commit | 69b431bc4fb16f7c1f8d4accbfb41a4f239c180f (patch) | |
tree | 44555b4c60232dabab67728a031cb2ffdd0f83bf | |
parent | db61e4fd20f83f07a9e21bd3d7ac65eb5532e7d4 (diff) | |
parent | 774b5299ee260fdf3c2b99f775588ec40f95e1fe (diff) | |
download | bazel_common_rules-69b431bc4fb16f7c1f8d4accbfb41a4f239c180f.tar.gz |
Support disting testonly deps. am: 774b5299ee
Original change: https://android-review.googlesource.com/c/platform/build/bazel_common_rules/+/2578634
Change-Id: I0f42cbd211aa49d1e97d3c9111dab1e4d10a178e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | dist/BUILD | 14 | ||||
-rw-r--r-- | dist/dist.bzl | 8 |
2 files changed, 22 insertions, 0 deletions
@@ -21,3 +21,17 @@ copy_to_dist_dir( "//bionic/libdl", ], ) + +# For testing that `testonly` deps can be dist'd. +genrule( + name = "testonly_sample", + testonly = True, + outs = ["testonly.txt"], + cmd = "touch $@", +) + +copy_to_dist_dir( + name = "dist_testonly_sample", + testonly = True, + data = [":testonly_sample"], +) diff --git a/dist/dist.bzl b/dist/dist.bzl index cb60d99..3d3ac66 100644 --- a/dist/dist.bzl +++ b/dist/dist.bzl @@ -69,6 +69,7 @@ def copy_to_dist_dir( allow_duplicate_filenames = None, mode_overrides = None, log = None, + testonly = False, **kwargs): """A dist rule to copy files out of Bazel's output directory into a custom location. @@ -134,6 +135,10 @@ def copy_to_dist_dir( log: If specified, `--log <log>` is provided to the script by default. This sets the default log level of the script. + testonly: If enabled, testonly will also be set on the internal targets + for Bazel analysis to succeed due to the nature of testonly enforcement + on reverse dependencies. + See `dist.py` for allowed values and the default value. kwargs: Additional attributes to the internal rule, e.g. [`visibility`](https://docs.bazel.build/versions/main/visibility.html). @@ -168,6 +173,7 @@ def copy_to_dist_dir( name = name + "_dist_manifest", data = data, archives = archives, + testonly = testonly, ) copy_file( @@ -186,11 +192,13 @@ def copy_to_dist_dir( python_version = "PY3", visibility = ["//visibility:public"], data = [name + "_dist_manifest"], + testonly = testonly, args = default_args, ) embedded_exec( name = name, actual = name + "_internal", + testonly = testonly, **kwargs ) |