diff options
author | Yifan Hong <elsk@google.com> | 2023-06-06 22:43:29 -0700 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2023-06-06 22:43:30 -0700 |
commit | 308d2be0b43f9a7f618837c3babb47fb43a49e91 (patch) | |
tree | b473ebfb44572e45626718705fa0f3020d51e023 | |
parent | 774b5299ee260fdf3c2b99f775588ec40f95e1fe (diff) | |
download | bazel_common_rules-308d2be0b43f9a7f618837c3babb47fb43a49e91.tar.gz |
exec: Explains non-hermeticity.
Explains that exec / exec_test / exec_rule, just like
genrule, does not guarantees hermeticity because PATH
is pass through.
For Kleaf projects, hermetic_exec / hermetic_exec_test
is recommended. There are no Roboleaf counterparts yet
at the moment of this writing.
Bug: 285605996
Change-Id: I2a1c32604f95c30438fe4b4d42cd99d7f9d7d3ba
-rw-r--r-- | exec/exec.bzl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/exec/exec.bzl b/exec/exec.bzl index a561939..91e6385 100644 --- a/exec/exec.bzl +++ b/exec/exec.bzl @@ -48,6 +48,11 @@ exec = rule( doc = """Run a script when `bazel run` this target. See [documentation] for the `args` attribute. + +**NOTE**: Like [genrule](https://bazel.build/reference/be/general#genrule)s, +hermeticity is not enforced or guaranteed, especially if `script` accesses PATH. +See [`Genrule Environment`](https://bazel.build/reference/be/general#genrule-environment) +for details. """, attrs = { "data": attr.label_list(aspects = [exec_aspect], allow_files = True, doc = """A list of labels providing runfiles. Labels may be used in `script`. @@ -75,6 +80,11 @@ exec_test = rule( doc = """Run a test script when `bazel test` this target. See [documentation] for the `args` attribute. + +**NOTE**: Like [genrule](https://bazel.build/reference/be/general#genrule)s, +hermeticity is not enforced or guaranteed, especially if `script` accesses PATH. +See [`Genrule Environment`](https://bazel.build/reference/be/general#genrule-environment) +for details. """, attrs = { "data": attr.label_list(aspects = [exec_aspect], allow_files = True, doc = """A list of labels providing runfiles. Labels may be used in `script`. @@ -102,12 +112,20 @@ def exec_rule( attrs = None): """Returns a rule() that is similar to `exec`, but with the given incoming transition. + **NOTE**: Like [genrule](https://bazel.build/reference/be/general#genrule)s, + hermeticity is not enforced or guaranteed for targets of the returned + rule, especially if a target specifies `script` that accesses PATH. + See [`Genrule Environment`](https://bazel.build/reference/be/general#genrule-environment) + for details. + Args: cfg: [Incoming edge transition](https://bazel.build/extending/config#incoming-edge-transitions) on the rule attrs: Additional attributes to be added to the rule. Specify `_allowlist_function_transition` if you need a transition. + Returns: + a rule """ fixed_attrs = { |