# Copyright (C) 2024 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Helps embedding `args` of an executable target.""" load( "//build/bazel_common_rules/exec/impl:exec.bzl", _exec = "exec", _exec_rule = "exec_rule", _exec_test = "exec_test", ) visibility("public") def exec( name, data = None, hashbang = None, script = None, **kwargs): """Runs 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. Args: name: name of the target data: A list of labels providing runfiles. Labels may be used in `script`. Executables in `data` must not have the `args` and `env` attribute. Use [`embedded_exec`](#embedded_exec) to wrap the depended target so its env and args are preserved. hashbang: hashbang of the script, default is `"/bin/bash -e"`. script: The script. Use `$(rootpath