diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-30 21:44:57 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-30 21:44:57 +0000 |
commit | 49eeb3ea97878618f969413241d0a5b293547380 (patch) | |
tree | ea6b8944dd62b590f46bccbf26839769104f41db | |
parent | 5e8aadccef64048b8dd6995b76a046e01059b341 (diff) | |
parent | 212bca45fa9e280adc98081483f649814baf4b61 (diff) | |
download | bazel_common_rules-build-tools-release.tar.gz |
Snap for 11784721 from 212bca45fa9e280adc98081483f649814baf4b61 to build-tools-releasebuild-tools-release
Change-Id: Ie1099e24b1cab7194110575f3b098da975fe67cb
29 files changed, 427 insertions, 741 deletions
diff --git a/dist/dist.bzl b/dist/dist.bzl index 3d3ac66..154d09b 100644 --- a/dist/dist.bzl +++ b/dist/dist.bzl @@ -1,8 +1,9 @@ -# Rule to support Bazel in copying its output files to the dist dir outside of -# the standard Bazel output user root. +"""Rule to support Bazel in copying its output files to the dist dir outside of +the standard Bazel output user root. +""" load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("//build/bazel_common_rules/exec:embedded_exec.bzl", "embedded_exec") +load("//build/bazel_common_rules/exec/impl:embedded_exec.bzl", "embedded_exec") def _label_list_to_manifest(lst): """Convert the outputs of a label list to manifest content.""" @@ -140,7 +141,7 @@ def copy_to_dist_dir( on reverse dependencies. See `dist.py` for allowed values and the default value. - kwargs: Additional attributes to the internal rule, e.g. + **kwargs: Additional attributes to the internal rule, e.g. [`visibility`](https://docs.bazel.build/versions/main/visibility.html). These additional attributes are only passed to the underlying embedded_exec rule. @@ -1,4 +1,4 @@ -# Copyright (C) 2022 The Android Open Source Project +# 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. @@ -18,6 +18,9 @@ bzl_library( name = "exec_aspect", srcs = ["exec_aspect.bzl"], visibility = ["//visibility:public"], + deps = [ + "//build/bazel_common_rules/exec/impl:exec_aspect", + ], ) bzl_library( @@ -26,6 +29,7 @@ bzl_library( visibility = ["//visibility:public"], deps = [ ":exec_aspect", + "//build/bazel_common_rules/exec/impl:embedded_exec", "@bazel_skylib//lib:shell", ], ) @@ -36,6 +40,7 @@ bzl_library( visibility = ["//visibility:public"], deps = [ ":exec_aspect", + "//build/bazel_common_rules/exec/impl:exec", "@bazel_skylib//lib:shell", ], ) diff --git a/exec/embedded_exec.bzl b/exec/embedded_exec.bzl index 482902e..e54f74d 100644 --- a/exec/embedded_exec.bzl +++ b/exec/embedded_exec.bzl @@ -1,4 +1,4 @@ -# Copyright (C) 2022 The Android Open Source Project +# 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. @@ -12,54 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//lib:shell.bzl", "shell") -load(":exec_aspect.bzl", "ExecAspectInfo", "exec_aspect") +"""Helps embedding `args` of an executable target.""" -def _impl(ctx): - target = ctx.attr.actual - files_to_run = target[DefaultInfo].files_to_run - if not files_to_run or not files_to_run.executable: - fail("{}: {} is not an executable".format(ctx.label, target)) - - out_file = ctx.actions.declare_file(ctx.label.name) - - content = "#!{}\n".format(ctx.attr.hashbang) - - expand_location_targets = [] - for dependant_attr in ("data", "srcs", "deps"): - dependants = getattr(target[ExecAspectInfo], dependant_attr) - if dependants: - expand_location_targets += dependants - - args = target[ExecAspectInfo].args - if not args: - args = [] - quoted_args = " ".join([shell.quote(ctx.expand_location(arg, expand_location_targets)) for arg in args]) - - env = target[ExecAspectInfo].env - if not env: - env = {} - - quoted_env = " ".join(["{}={}".format(k, shell.quote(ctx.expand_location(v, expand_location_targets))) for k, v in env.items()]) - - content += '{} {} {} "$@"'.format(quoted_env, target[DefaultInfo].files_to_run.executable.short_path, quoted_args) - - ctx.actions.write(out_file, content, is_executable = True) - - runfiles = ctx.runfiles(files = ctx.files.actual) - runfiles = runfiles.merge_all([target[DefaultInfo].default_runfiles]) +load( + "//build/bazel_common_rules/exec/impl:embedded_exec.bzl", + _embedded_exec = "embedded_exec", +) - return DefaultInfo( - files = depset([out_file]), - executable = out_file, - runfiles = runfiles, - ) +visibility("public") -embedded_exec = rule( - implementation = _impl, - attrs = { - "actual": attr.label(doc = "The actual executable.", aspects = [exec_aspect]), - "hashbang": attr.string(doc = "The hashbang of the script", default = "/bin/bash -e"), - }, - executable = True, -) +embedded_exec = _embedded_exec diff --git a/exec/exec.bzl b/exec/exec.bzl index 91e6385..f64cbdc 100644 --- a/exec/exec.bzl +++ b/exec/exec.bzl @@ -1,4 +1,4 @@ -# Copyright (C) 2022 The Android Open Source Project +# 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. @@ -12,101 +12,128 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//lib:shell.bzl", "shell") -load(":exec_aspect.bzl", "ExecAspectInfo", "exec_aspect") +"""Helps embedding `args` of an executable target.""" -_DEFAULT_HASHBANG = "/bin/bash -e" +load( + "//build/bazel_common_rules/exec/impl:exec.bzl", + _exec = "exec", + _exec_rule = "exec_rule", + _exec_test = "exec_test", +) -def _impl(ctx): - out_file = ctx.actions.declare_file(ctx.label.name) +visibility("public") - for target in ctx.attr.data: - if ExecAspectInfo not in target: - continue - if target[ExecAspectInfo].args: - fail("{}: {} must not have args. Use embedded_exec to wrap it.".format(ctx.label, target.label)) - if target[ExecAspectInfo].env: - fail("{}: {} must not have env. Use embedded_exec to wrap it.".format(ctx.label, target.label)) +def exec( + name, + data = None, + hashbang = None, + script = None, + **kwargs): + """Runs a script when `bazel run` this target. - content = "#!{}\n".format(ctx.attr.hashbang) - content += ctx.attr.script + See [documentation] for the `args` attribute. - content = ctx.expand_location(content, ctx.attr.data) - ctx.actions.write(out_file, content, is_executable = True) + **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. - runfiles = ctx.runfiles(files = ctx.files.data + [out_file]) - runfiles = runfiles.merge_all([target[DefaultInfo].default_runfiles for target in ctx.attr.data]) + Args: + name: name of the target + data: A list of labels providing runfiles. Labels may be used in `script`. - return DefaultInfo( - files = depset([out_file]), - executable = out_file, - runfiles = runfiles, - ) + 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. -exec = rule( - implementation = _impl, - doc = """Run a script when `bazel run` this target. + Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See + [documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). -See [documentation] for the `args` attribute. + Use `$@` to refer to the args attribute of this target. -**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`. + See `build/bazel_common_rules/exec/tests/BUILD` for examples. + **kwargs: Additional attributes to the internal rule, e.g. + [`visibility`](https://docs.bazel.build/versions/main/visibility.html). + See complete list + [here](https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes). -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": attr.string(default = _DEFAULT_HASHBANG, doc = "Hashbang of the script."), - "script": attr.string(doc = """The script. + Deprecated: + Use `hermetic_exec` for stronger hermeticity. + """ -Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See -[documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). + # buildifier: disable=print + print("WARNING: {}: exec is deprecated. Use `hermetic_exec` instead.".format( + native.package_relative_label(name), + )) -Use `$@` to refer to the args attribute of this target. + kwargs.setdefault("deprecation", "Use hermetic_exec for stronger hermeticity") -See `build/bazel_common_rules/exec/tests/BUILD` for examples. -"""), - }, - executable = True, -) + _exec( + name = name, + data = data, + hashbang = hashbang, + script = script, + **kwargs + ) + +def exec_test( + name, + data = None, + hashbang = None, + script = None, + **kwargs): + """Runs a 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. -exec_test = rule( - implementation = _impl, - doc = """Run a test script when `bazel test` this target. + Args: + name: name of the target + data: A list of labels providing runfiles. Labels may be used in `script`. -See [documentation] for the `args` attribute. + 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. -**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`. + Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See + [documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). -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": attr.string(default = _DEFAULT_HASHBANG, doc = "Hashbang of the script."), - "script": attr.string(doc = """The script. + Use `$@` to refer to the args attribute of this target. -Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See -[documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). + See `build/bazel_common_rules/exec/tests/BUILD` for examples. + **kwargs: Additional attributes to the internal rule, e.g. + [`visibility`](https://docs.bazel.build/versions/main/visibility.html). + See complete list + [here](https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes). -Use `$@` to refer to the args attribute of this target. + Deprecated: + Use `hermetic_exec` for stronger hermeticity. + """ -See `build/bazel_common_rules/exec/tests/BUILD` for examples. -"""), - }, - test = True, -) + # buildifier: disable=print + print("WARNING: {}: exec_test is deprecated. Use `hermetic_exec_test` instead.".format( + native.package_relative_label(name), + )) + kwargs.setdefault("deprecation", "Use hermetic_exec_test for stronger hermeticity") + + _exec_test( + name = name, + data = data, + hashbang = hashbang, + script = script, + **kwargs + ) + +# buildifier: disable=unnamed-macro def exec_rule( cfg = None, attrs = None): @@ -128,19 +155,10 @@ def exec_rule( a rule """ - fixed_attrs = { - "data": attr.label_list(aspects = [exec_aspect], allow_files = True), - "hashbang": attr.string(default = _DEFAULT_HASHBANG), - "script": attr.string(), - } + # buildifier: disable=print + print("WARNING: exec_rule is deprecated.") - if attrs == None: - attrs = {} - attrs = attrs | fixed_attrs - - return rule( - implementation = _impl, - attrs = attrs, + _exec_rule( cfg = cfg, - executable = True, + attrs = attrs, ) diff --git a/exec/exec_aspect.bzl b/exec/exec_aspect.bzl index 900e10c..6e7aa1f 100644 --- a/exec/exec_aspect.bzl +++ b/exec/exec_aspect.bzl @@ -1,4 +1,4 @@ -# Copyright (C) 2022 The Android Open Source Project +# 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. @@ -12,22 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -_attrs = ["args", "env", "data", "srcs", "deps"] +"""Helps embedding `args` of an executable target. -ExecAspectInfo = provider( - doc = "See [`exec_aspect`](#exec_aspect).", - fields = {attr: attr + " of the target" for attr in _attrs}, +**DEPRECTED**. This is an implementation detail and should not be relied upon. +""" + +load( + "//build/bazel_common_rules/exec/impl:exec_aspect.bzl", + _ExecAspectInfo = "ExecAspectInfo", + _exec_aspect = "exec_aspect", ) -def _aspect_impl(target, ctx): - kwargs = {} - for attr in _attrs: - value = getattr(ctx.rule.attr, attr, None) - kwargs[attr] = value - return ExecAspectInfo(**kwargs) +# TODO(b/329305827): make this private +visibility("public") -exec_aspect = aspect( - implementation = _aspect_impl, - doc = "Make arguments available for targets depending on executables.", - attr_aspects = _attrs, -) +ExecAspectInfo = _ExecAspectInfo +exec_aspect = _exec_aspect diff --git a/test_mappings/BUILD b/exec/impl/BUILD index 24c5e7d..e5e9cff 100644 --- a/test_mappings/BUILD +++ b/exec/impl/BUILD @@ -12,6 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -exports_files([ - "test_mappings.sh", -]) +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "exec_aspect", + srcs = ["exec_aspect.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "embedded_exec", + srcs = ["embedded_exec.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":exec_aspect", + "@bazel_skylib//lib:shell", + ], +) + +bzl_library( + name = "exec", + srcs = ["exec.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":exec_aspect", + "@bazel_skylib//lib:shell", + ], +) diff --git a/exec/impl/embedded_exec.bzl b/exec/impl/embedded_exec.bzl new file mode 100644 index 0000000..2ff33d9 --- /dev/null +++ b/exec/impl/embedded_exec.bzl @@ -0,0 +1,72 @@ +# Copyright (C) 2022 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. + +"""Impl of `embedded_exec`.""" + +load("@bazel_skylib//lib:shell.bzl", "shell") +load(":exec_aspect.bzl", "ExecAspectInfo", "exec_aspect") + +visibility([ + "//build/bazel_common_rules/exec/...", + "//build/bazel_common_rules/dist/...", +]) + +def _impl(ctx): + target = ctx.attr.actual + files_to_run = target[DefaultInfo].files_to_run + if not files_to_run or not files_to_run.executable: + fail("{}: {} is not an executable".format(ctx.label, target)) + + out_file = ctx.actions.declare_file(ctx.label.name) + + content = "#!{}\n".format(ctx.attr.hashbang) + + expand_location_targets = [] + for dependant_attr in ("data", "srcs", "deps"): + dependants = getattr(target[ExecAspectInfo], dependant_attr) + if dependants: + expand_location_targets += dependants + + args = target[ExecAspectInfo].args + if not args: + args = [] + quoted_args = " ".join([shell.quote(ctx.expand_location(arg, expand_location_targets)) for arg in args]) + + env = target[ExecAspectInfo].env + if not env: + env = {} + + quoted_env = " ".join(["{}={}".format(k, shell.quote(ctx.expand_location(v, expand_location_targets))) for k, v in env.items()]) + + content += '{} {} {} "$@"'.format(quoted_env, target[DefaultInfo].files_to_run.executable.short_path, quoted_args) + + ctx.actions.write(out_file, content, is_executable = True) + + runfiles = ctx.runfiles(files = ctx.files.actual) + runfiles = runfiles.merge_all([target[DefaultInfo].default_runfiles]) + + return DefaultInfo( + files = depset([out_file]), + executable = out_file, + runfiles = runfiles, + ) + +embedded_exec = rule( + implementation = _impl, + attrs = { + "actual": attr.label(doc = "The actual executable.", aspects = [exec_aspect]), + "hashbang": attr.string(doc = "The hashbang of the script", default = "/bin/bash -e"), + }, + executable = True, +) diff --git a/exec/impl/exec.bzl b/exec/impl/exec.bzl new file mode 100644 index 0000000..b78728b --- /dev/null +++ b/exec/impl/exec.bzl @@ -0,0 +1,152 @@ +# Copyright (C) 2022 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. + +"""Impl of `exec`.""" + +load(":exec_aspect.bzl", "ExecAspectInfo", "exec_aspect") + +visibility([ + "//build/bazel_common_rules/exec/...", + "//build/kernel/kleaf/...", +]) + +_DEFAULT_HASHBANG = "/bin/bash -e" + +def _impl(ctx): + out_file = ctx.actions.declare_file(ctx.label.name) + + for target in ctx.attr.data: + if ExecAspectInfo not in target: + continue + if target[ExecAspectInfo].args: + fail("{}: {} must not have args. Use embedded_exec to wrap it.".format(ctx.label, target.label)) + if target[ExecAspectInfo].env: + fail("{}: {} must not have env. Use embedded_exec to wrap it.".format(ctx.label, target.label)) + + content = "#!{}\n".format(ctx.attr.hashbang) + content += ctx.attr.script + + content = ctx.expand_location(content, ctx.attr.data) + ctx.actions.write(out_file, content, is_executable = True) + + runfiles = ctx.runfiles(files = ctx.files.data + [out_file]) + runfiles = runfiles.merge_all([target[DefaultInfo].default_runfiles for target in ctx.attr.data]) + + return DefaultInfo( + files = depset([out_file]), + executable = out_file, + runfiles = runfiles, + ) + +exec = rule( + implementation = _impl, + 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`. + +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": attr.string(default = _DEFAULT_HASHBANG, doc = "Hashbang of the script."), + "script": attr.string(doc = """The script. + +Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See +[documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). + +Use `$@` to refer to the args attribute of this target. + +See `build/bazel_common_rules/exec/tests/BUILD` for examples. +"""), + }, + executable = True, +) + +exec_test = rule( + implementation = _impl, + 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`. + +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": attr.string(default = _DEFAULT_HASHBANG, doc = "Hashbang of the script."), + "script": attr.string(doc = """The script. + +Use `$(rootpath <label>)` to refer to the path of a target specified in `data`. See +[documentation](https://bazel.build/reference/be/make-variables#predefined_label_variables). + +Use `$@` to refer to the args attribute of this target. + +See `build/bazel_common_rules/exec/tests/BUILD` for examples. +"""), + }, + test = True, +) + +def exec_rule( + cfg = None, + 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 = { + "data": attr.label_list(aspects = [exec_aspect], allow_files = True), + "hashbang": attr.string(default = _DEFAULT_HASHBANG), + "script": attr.string(), + } + + if attrs == None: + attrs = {} + attrs = attrs | fixed_attrs + + return rule( + implementation = _impl, + attrs = attrs, + cfg = cfg, + executable = True, + ) diff --git a/exec/impl/exec_aspect.bzl b/exec/impl/exec_aspect.bzl new file mode 100644 index 0000000..cd0c101 --- /dev/null +++ b/exec/impl/exec_aspect.bzl @@ -0,0 +1,37 @@ +# Copyright (C) 2022 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. + +"""Impl of `exec_aspect`.""" + +visibility("//build/bazel_common_rules/exec/...") + +_attrs = ["args", "env", "data", "srcs", "deps"] + +ExecAspectInfo = provider( + doc = "See [`exec_aspect`](#exec_aspect).", + fields = {attr: attr + " of the target" for attr in _attrs}, +) + +def _aspect_impl(_target, ctx): + kwargs = {} + for attr in _attrs: + value = getattr(ctx.rule.attr, attr, None) + kwargs[attr] = value + return ExecAspectInfo(**kwargs) + +exec_aspect = aspect( + implementation = _aspect_impl, + doc = "Make arguments available for targets depending on executables.", + attr_aspects = _attrs, +) diff --git a/exec/tests/BUILD b/exec/tests/BUILD index 299fe45..0a89a40 100644 --- a/exec/tests/BUILD +++ b/exec/tests/BUILD @@ -13,8 +13,8 @@ # limitations under the License. # BUILD -load("//build/bazel_common_rules/exec:embedded_exec.bzl", "embedded_exec") -load("//build/bazel_common_rules/exec:exec.bzl", "exec") +load("//build/bazel_common_rules/exec/impl:embedded_exec.bzl", "embedded_exec") +load("//build/bazel_common_rules/exec/impl:exec.bzl", "exec") exec( name = "script_a", diff --git a/rules/java/rules_java/BUILD b/rules/java/rules_java/BUILD deleted file mode 100644 index e69de29..0000000 --- a/rules/java/rules_java/BUILD +++ /dev/null diff --git a/rules/java/rules_java/WORKSPACE b/rules/java/rules_java/WORKSPACE deleted file mode 100644 index e69de29..0000000 --- a/rules/java/rules_java/WORKSPACE +++ /dev/null diff --git a/rules/java/rules_java/java/BUILD b/rules/java/rules_java/java/BUILD deleted file mode 100644 index e7d4265..0000000 --- a/rules/java/rules_java/java/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -""" -Copyright (C) 2023 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. -""" - -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -bzl_library( - name = "rules", - srcs = ["defs.bzl"], - visibility = ["//visibility:public"], -) diff --git a/rules/java/rules_java/java/defs.bzl b/rules/java/rules_java/java/defs.bzl deleted file mode 100644 index 33d1ab3..0000000 --- a/rules/java/rules_java/java/defs.bzl +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2023 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. - -""" -Helper macros to forward to native equivalents. -""" - -def java_binary(**attrs): - native.java_binary(**attrs) - -def java_import(**attrs): - native.java_import(**attrs) - -def java_library(**attrs): - native.java_library(**attrs) - -def java_lite_proto_library(**attrs): - native.java_lite_proto_library(**attrs) - -def java_proto_library(**attrs): - native.java_proto_library(**attrs) - -def java_test(**attrs): - native.java_test(**attrs) - -def java_package_configuration(**attrs): - native.java_package_configuration(**attrs) - -def java_plugin(**attrs): - native.java_plugin(**attrs) - -def java_runtime(**attrs): - native.java_runtime(**attrs) - -def java_toolchain(**attrs): - native.java_toolchain(**attrs) diff --git a/rules/python/stubs/WORKSPACE b/rules/python/stubs/WORKSPACE deleted file mode 100644 index 1cfe581..0000000 --- a/rules/python/stubs/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -workspace(name = "rules_python") diff --git a/rules/python/stubs/python/BUILD b/rules/python/stubs/python/BUILD deleted file mode 100644 index 5a203b3..0000000 --- a/rules/python/stubs/python/BUILD +++ /dev/null @@ -1 +0,0 @@ -exports_files(["defs.bzl"]) diff --git a/rules/python/stubs/python/defs.bzl b/rules/python/stubs/python/defs.bzl deleted file mode 100644 index 422ef1a..0000000 --- a/rules/python/stubs/python/defs.bzl +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2023 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. - -"""rules_python stub workspace until AOSP has the real rules_python external dep.""" - -# TODO(b/200202912): Delete this when rules_python is pulled into AOSP. - -# https://bazel.build/reference/be/python -# Also see --noincompatible_python_disallow_native_rules -py_binary = native.py_binary -py_test = native.py_test -py_library = native.py_library -py_runtime = native.py_runtime diff --git a/rules/remote_device/BUILD.bazel b/rules/remote_device/BUILD.bazel deleted file mode 100644 index 41b9d6c..0000000 --- a/rules/remote_device/BUILD.bazel +++ /dev/null @@ -1,51 +0,0 @@ -load("//build/bazel_common_rules/rules/remote_device/device:cuttlefish_device.bzl", "cuttlefish_device") -load("//build/bazel_common_rules/rules/remote_device/device:single_local_device.bzl", "local_device") -load("//build/bazel_common_rules/rules/remote_device/downloader:download_cvd_artifact.bzl", "download_cvd_artifact") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") - -package(default_visibility = ["//visibility:public"]) - -string_flag( - name = "build_id", - build_setting_default = "", -) - -string_flag( - name = "branch", - build_setting_default = "aosp-main", -) - -string_flag( - name = "target", - build_setting_default = "aosp_cf_x86_64_phone-trunk_staging-userdebug", -) - -string_flag( - name = "exec_mode", - build_setting_default = "local", -) - -download_cvd_artifact( - name = "cvd_artifacts", - branch = ":branch", - build_id = ":build_id", - tags = ["manual"], - target = ":target", -) - -cuttlefish_device( - name = "cf_x86_64_phone", - out = "android_cuttlefish.sh", - cvd_build_artifacts = ":cvd_artifacts", - tags = ["manual"], -) - -local_device( - name = "local_device", - out = "single_local_device.sh", -) - -label_flag( - name = "target_device", - build_setting_default = ":local_device", -) diff --git a/rules/remote_device/device/BUILD.bazel b/rules/remote_device/device/BUILD.bazel deleted file mode 100644 index 3c25c29..0000000 --- a/rules/remote_device/device/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -exports_files([ - "create_cuttlefish.sh.template", - "single_local_device.sh", -]) diff --git a/rules/remote_device/device/create_cuttlefish.sh.template b/rules/remote_device/device/create_cuttlefish.sh.template deleted file mode 100644 index 39eded4..0000000 --- a/rules/remote_device/device/create_cuttlefish.sh.template +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -export PATH="/bin:/usr/bin:/usr/local/bin:/tradefed:${PATH}" -DEVICE_IMAGE_PATH="{img_path}" -DEVICE_IMAGE_DIR=$(dirname "$DEVICE_IMAGE_PATH") -CVD_HOST_PACKAGE_PATH="{cvd_host_package_path}" - -PATH_ADDITIONS="{path_additions}" - -LOCAL_TOOL="$(dirname "$CVD_HOST_PACKAGE_PATH")" - -user="$(whoami)" - -su - << EOF -export PATH="${LOCAL_TOOL}:${PATH_ADDITIONS}:${PATH}" -/usr/sbin/service rsyslog restart -/etc/init.d/cuttlefish-common start -/usr/sbin/usermod -aG kvm "${USER}" - -pushd "${LOCAL_TOOL}" -tar xvf "${CVD_HOST_PACKAGE_PATH}" -popd - -pushd "${DEVICE_IMAGE_DIR}" -unzip -o "${DEVICE_IMAGE_PATH}" -popd - -HOME="${LOCAL_TOOL}" "${LOCAL_TOOL}"/bin/launch_cvd \ - -daemon \ - -config=phone \ - -system_image_dir "${DEVICE_IMAGE_DIR}" \ - -undefok=report_anonymous_usage_stats,config \ - -report_anonymous_usage_stats=y \ - -instance_dir=/tmp/cvd \ - -guest_enforce_security=false -export PATH="${LOCAL_TOOL}/bin:${PATH}" -adb connect localhost:6520 -exit -EOF diff --git a/rules/remote_device/device/cuttlefish_device.bzl b/rules/remote_device/device/cuttlefish_device.bzl deleted file mode 100644 index 0f266ff..0000000 --- a/rules/remote_device/device/cuttlefish_device.bzl +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2021 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. - -"""Rule used to generate a Cuttlefish device environment. - -This rule creates a device environment rule to run tests on a Cuttlefish Android -Virtual Device. Test targets that run in this environment will start a new -dedicated virtual device for each execution. - -Device properties such as the image used can be configured via an attribute. -""" - -load("//build/bazel_common_rules/rules/remote_device/device:device_environment.bzl", "DeviceEnvironment") -load("//build/bazel_common_rules/rules/remote_device/downloader:download_cvd_artifact.bzl", "ImageProvider") - -_BAZEL_WORK_DIR = "${TEST_SRCDIR}/${TEST_WORKSPACE}/" - -def _cuttlefish_device_impl(ctx): - path_additions = [_BAZEL_WORK_DIR] - image_file = ctx.attr.cvd_build_artifacts[ImageProvider].image - cvd_host_file = ctx.attr.cvd_build_artifacts[ImageProvider].cvd_host_package - ctx.actions.expand_template( - template = ctx.file._create_script_template, - output = ctx.outputs.out, - is_executable = True, - substitutions = { - "{img_path}": _BAZEL_WORK_DIR + image_file.short_path, - "{cvd_host_package_path}": _BAZEL_WORK_DIR + cvd_host_file.short_path, - "{path_additions}": ":".join(path_additions), - }, - ) - - return DeviceEnvironment( - runner = depset([ctx.outputs.out]), - data = ctx.runfiles(files = [ - cvd_host_file, - ctx.outputs.out, - image_file, - ]), - ) - -cuttlefish_device = rule( - attrs = { - "cvd_build_artifacts": attr.label( - providers = [ImageProvider], - mandatory = True, - ), - "out": attr.output(mandatory = True), - "_create_script_template": attr.label( - default = ":create_cuttlefish.sh.template", - allow_single_file = True, - ), - }, - implementation = _cuttlefish_device_impl, -) diff --git a/rules/remote_device/device/device_environment.bzl b/rules/remote_device/device/device_environment.bzl deleted file mode 100644 index 4924f51..0000000 --- a/rules/remote_device/device/device_environment.bzl +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (C) 2023 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. - -"""A provider to create a Cuttlefish device environment.""" - -DeviceEnvironment = provider( - "Represents the environment a test will run under. Concretely this is an " + - "executable and any runfiles required to trigger execution in the " + - "environment.", - fields = { - "runner": "depset of executable to to setup test environment and execute test.", - "data": "runfiles of all needed artifacts in the executable.", - }, -) diff --git a/rules/remote_device/device/single_local_device.bzl b/rules/remote_device/device/single_local_device.bzl deleted file mode 100644 index 542d1b0..0000000 --- a/rules/remote_device/device/single_local_device.bzl +++ /dev/null @@ -1,24 +0,0 @@ -load("//build/bazel_common_rules/rules/remote_device/device:device_environment.bzl", "DeviceEnvironment") - -def _local_device_impl(ctx): - ctx.actions.expand_template( - template = ctx.file._source_script, - output = ctx.outputs.out, - is_executable = True, - ) - - return DeviceEnvironment( - runner = depset([ctx.outputs.out]), - data = ctx.runfiles(files = [ctx.outputs.out]), - ) - -local_device = rule( - attrs = { - "_source_script": attr.label( - default = ":single_local_device.sh", - allow_single_file = True, - ), - "out": attr.output(mandatory = True), - }, - implementation = _local_device_impl, -) diff --git a/rules/remote_device/device/single_local_device.sh b/rules/remote_device/device/single_local_device.sh deleted file mode 100644 index e69de29..0000000 --- a/rules/remote_device/device/single_local_device.sh +++ /dev/null diff --git a/rules/remote_device/downloader/BUILD.bazel b/rules/remote_device/downloader/BUILD.bazel deleted file mode 100644 index 600db87..0000000 --- a/rules/remote_device/downloader/BUILD.bazel +++ /dev/null @@ -1,3 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -exports_files(["download_cvd_build.sh.template"])
\ No newline at end of file diff --git a/rules/remote_device/downloader/download_cvd_artifact.bzl b/rules/remote_device/downloader/download_cvd_artifact.bzl deleted file mode 100644 index ea77831..0000000 --- a/rules/remote_device/downloader/download_cvd_artifact.bzl +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright (C) 2023 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. - -load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") - -ImageProvider = provider( - "Provide device image and host package files", - fields = { - "image": "device image file to launch virtual device", - "cvd_host_package": "cvd host package to launch virtual device", - }, -) - -# TODO(b/273846592): Move to a common file, same for other files. -_BAZEL_WORK_DIR = "${TEST_SRCDIR}/${TEST_WORKSPACE}/" - -_IMAGE_ARTIFACT_PATH = "cf_x86_64_phone-img-{BUILD_ID}.zip" -_HOST_PACKAGE_ARTIFACT_PATH = "cvd-host_package.tar.gz" - -def _download_cvd_artifact_impl(ctx): - build_id = ctx.attr.build_id[BuildSettingInfo].value - branch = ctx.attr.branch[BuildSettingInfo].value - image_artifact_path = _IMAGE_ARTIFACT_PATH.replace("{BUILD_ID}", build_id) - target = ctx.attr.target[BuildSettingInfo].value - if not build_id: - fail("build_id must be specified to download build image.") - if not branch: - fail("branch must be specified to download build image.") - if not target: - fail("Target must be specified to download build image.") - - # Add "aosp_" prefix to target and artifact name if the branch is AOSP. - if "aosp" in branch: - image_artifact_path = "aosp_" + image_artifact_path - - image_out_file = _download_helper( - ctx, - image_artifact_path, - build_id, - branch, - target, - ) - cvd_host_out_file = _download_helper( - ctx, - _HOST_PACKAGE_ARTIFACT_PATH, - build_id, - branch, - target, - ) - return ImageProvider( - image = image_out_file, - cvd_host_package = cvd_host_out_file, - ) - -def _download_helper(ctx, artifact_path, build_id, branch, target): - script = ctx.actions.declare_file("download_cvd_build_%s_%s.sh" % - (ctx.label.name, artifact_path)) - - out_file = ctx.actions.declare_file(artifact_path) - ctx.actions.expand_template( - template = ctx.file._create_script_template, - output = script, - is_executable = True, - substitutions = { - "{build_id}": build_id, - "{artifact_path}": artifact_path, - "{output_dir}": out_file.dirname, - "{branch}": branch, - "{target}": target, - }, - ) - ctx.actions.run_shell( - inputs = [script], - outputs = [out_file], - mnemonic = "DownloadCvd", - command = "source %s" % (script.path), - progress_message = "Downloading Android Build artifact %s for Build ID %s." % (artifact_path, build_id), - ) - return out_file - -download_cvd_artifact = rule( - attrs = { - "_create_script_template": attr.label( - default = ":download_cvd_build.sh.template", - allow_single_file = True, - ), - "build_id": attr.label( - mandatory = True, - doc = "sets the build id of the Android image", - ), - "target": attr.label( - mandatory = True, - doc = "sets the build target of the Android image. Example: " + - "aosp_cf_x86_64_phone-trunk_staging-userdebug.", - ), - "branch": attr.label( - mandatory = True, - doc = "sets the branch of the Android image", - ), - }, - implementation = _download_cvd_artifact_impl, - doc = "A rule used to download cuttlefish image files.", -) diff --git a/rules/remote_device/downloader/download_cvd_build.sh.template b/rules/remote_device/downloader/download_cvd_build.sh.template deleted file mode 100644 index 6a67e6b..0000000 --- a/rules/remote_device/downloader/download_cvd_build.sh.template +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -BUILD_ID="{build_id}" -ARTIFACT_PATH="{artifact_path}" -OUTPUT_DIR="{output_dir}" -BRANCH="{branch}" -TARGET="{target}" - -recipe_file=/tradefed/android_build_downloader/recipe -cat > "$recipe_file" << EOF -build_artifact_group { - build_id: "$BUILD_ID", - branch: "$BRANCH" - target: "$TARGET", - artifact_path: "$ARTIFACT_PATH" -} - -EOF - -/tradefed/android_build_downloader/downloader.sh \ - --output_dir $OUTPUT_DIR \ - --recipe_file /tradefed/android_build_downloader/recipe diff --git a/test_mappings/test_mappings.bzl b/test_mappings/test_mappings.bzl deleted file mode 100644 index fca527e..0000000 --- a/test_mappings/test_mappings.bzl +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2022 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. - -load("//build/bazel_common_rules/exec:embedded_exec.bzl", "embedded_exec") - -def test_mappings_dist( - name, - dist_dir = None, - **kwargs): - """Run this target to generate test mapping archive to the location given - by `--dist_dir` command-line argument. If `--dist_dir` command-line argument - is not specified, default to the `dist_dir` argument of this rule. - - For example: - - ``` - test_mappings( - name = "my_test_mappings", - args = ["--dist_dir", "out/dist"], - ) - ``` - - ``` - # generate to <workspace_root>/out/dist - $ bazel run my_test_mappings - - # generate to <workspace_root>/path - $ bazel run my_test_mappings -- --dist_dir=path - - # generate to /tmp/path - $ bazel run my_test_mappings -- --dist_dir=/tmp/path - ``` - - Args: - name: name of this target. - kwargs: Additional arguments to the internal rule, e.g. `visibility`. - """ - - native.sh_binary( - name = name + "_internal", - srcs = ["//build/bazel_common_rules/test_mappings:test_mappings.sh"], - data = ["//prebuilts/build-tools:linux-x86"], - args = ["--dist_dir", dist_dir] if dist_dir else None, - **kwargs - ) - - embedded_exec( - name = name, - actual = name + "_internal", - ) diff --git a/test_mappings/test_mappings.sh b/test_mappings/test_mappings.sh deleted file mode 100755 index 8a8ca5a..0000000 --- a/test_mappings/test_mappings.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -e - -# Copyright (C) 2022 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. - -# Ensure hermeticity. -PATH="$PWD/prebuilts/build-tools/path/linux-x86/:$PWD/prebuilts/build-tools/linux-x86/bin/" - -while [[ $# -gt 0 ]]; do - case $1 in - --dist_dir) - DIST_DIR="$2" - shift # past argument - shift # past value - ;; - --dist_dir=*) - DIST_DIR=$1 - DIST_DIR="${DIST_DIR#*=}" - shift # past argument=value - ;; - -*|--*) - # There may be additional arguments passed to copy_to_dist_dir. Ignore them. - shift - ;; - *) - # There may be additional arguments passed to copy_to_dist_dir. Ignore them. - shift - ;; - esac -done - -# BUILD_WORKSPACE_DIRECTORY is the root of the Bazel workspace containing -# this binary target. -# https://docs.bazel.build/versions/main/user-manual.html#run -ROOT_DIR=$BUILD_WORKSPACE_DIRECTORY -if [[ -z "$ROOT_DIR" ]]; then - echo "ERROR: Only execute this script with bazel run." >&2 - exit 1 -fi - -if [[ -z "$DIST_DIR" ]]; then - echo "ERROR: --dist_dir is not specified." >&2 - exit 1 -fi - -if [[ ! "$DIST_DIR" == /* ]]; then - DIST_DIR=${ROOT_DIR}/${DIST_DIR} -fi -mkdir -p ${DIST_DIR} - -OUTPUT_FILE=${DIST_DIR}/test_mappings.zip -echo "Generating ${OUTPUT_FILE}" - -trap 'rm -f "$TMPFILE"' EXIT -TEST_MAPPING_FILES=$(mktemp) -find ${ROOT_DIR} -path "${ROOT_DIR}/out*" -prune -o \ - -name TEST_MAPPING -type f \ - -not -path "${ROOT_DIR}/\.git*" \ - -not -path "${ROOT_DIR}/\.repo*" \ - -print > ${TEST_MAPPING_FILES} -soong_zip -o ${OUTPUT_FILE} -C ${ROOT_DIR} -l ${TEST_MAPPING_FILES} -rm -f ${TEST_MAPPING_FILES} |