From f15152746c2c978e6f1f79d3c355b4da74337e4d Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Tue, 19 Jul 2022 09:10:38 -0700 Subject: [PATCH] Replace uses of `cfg = "host"` with `cfg = "exec"` This increases the compatibility for builds where host and exec platform are different (e.g., with remote execution). Closes #15785. PiperOrigin-RevId: 461897893 Change-Id: I734ccdd1ae13e7c625cc22c894bc482fe080d70b --- site/en/docs/creating-workers.md | 7 ++++--- site/en/rules/aspects.md | 2 +- src/embedded_tools.bzl | 2 +- src/main/res/winsdk_toolchain.bzl | 2 +- .../function_wrap_multiple_lines_test/input.bzl | 2 +- .../build/skydoc/testdata/misc_apis_test/input.bzl | 2 +- src/test/py/bazel/bazel_windows_cpp_test.py | 2 +- src/test/py/bazel/bazel_windows_test.py | 2 +- src/test/py/bazel/native_test.bzl | 2 +- src/test/shell/bazel/apple/apple_common.sh | 2 +- src/test/shell/bazel/bazel_rules_test.sh | 2 +- src/test/shell/bazel/cc_integration_test.sh | 4 ++-- .../shell/bazel/remote/build_without_the_bytes_test.sh | 2 +- src/test/shell/bazel/starlark_rule_test.sh | 2 +- src/test/shell/integration/action_aspect_test.sh | 10 +++++----- src/test/shell/integration/py_args_escaping_test.sh | 2 +- src/test/shell/integration/run_test.sh | 2 +- .../integration/starlark_dependency_pruning_test.sh | 2 +- src/test/shell/integration/validation_actions_test.sh | 4 ++-- tools/build_defs/hash/hash.bzl | 2 +- tools/build_defs/pkg/pkg.bzl | 2 +- tools/ctexplain/lib_test.py | 4 ++-- tools/jdk/java_toolchain_alias.bzl | 2 +- 23 files changed, 33 insertions(+), 32 deletions(-) diff --git a/site/en/docs/creating-workers.md b/site/en/docs/creating-workers.md index 41d690145063c9..59414091d0b38d 100644 --- a/site/en/docs/creating-workers.md +++ b/site/en/docs/creating-workers.md @@ -166,12 +166,13 @@ level of the build, this might be the attribute definition: "worker": attr.label( default = Label("//work:worker"), executable = True, - cfg = "host", + cfg = "exec", ) ``` -`cfg = "host"` indicates that the worker should be built to run on your host -platform. +`cfg = "exec"` indicates that the worker should be built to run on your +execution platform rather than on the target platform (i.e., the worker is used +as tool during the build). ### Work action requirements {:#work-action-requirements} diff --git a/site/en/rules/aspects.md b/site/en/rules/aspects.md index ed340944d2dd7c..c152ec5d75b5f6 100644 --- a/site/en/rules/aspects.md +++ b/site/en/rules/aspects.md @@ -283,7 +283,7 @@ demonstrates how you could pass in a tool to an aspect: '_protoc' : attr.label( default = Label('//tools:protoc'), executable = True, - cfg = "host" + cfg = "exec" ) } ... diff --git a/src/embedded_tools.bzl b/src/embedded_tools.bzl index e6456595549abb..d18e21848ef44f 100644 --- a/src/embedded_tools.bzl +++ b/src/embedded_tools.bzl @@ -35,7 +35,7 @@ embedded_tools = rule( "out": attr.output(mandatory = True), "tool": attr.label( executable = True, - cfg = "host", + cfg = "exec", allow_files = True, default = Label("//src:create_embedded_tools_sh"), ), diff --git a/src/main/res/winsdk_toolchain.bzl b/src/main/res/winsdk_toolchain.bzl index fa2a9560fe27fd..7a9217d455a021 100644 --- a/src/main/res/winsdk_toolchain.bzl +++ b/src/main/res/winsdk_toolchain.bzl @@ -62,7 +62,7 @@ windows_resource_compiler_toolchain = rule( "rc_exe": attr.label( allow_files = True, executable = True, - cfg = "host", + cfg = "exec", doc = "Label of the resource compiler (or a wrapper script)", ), }, diff --git a/src/test/java/com/google/devtools/build/skydoc/testdata/function_wrap_multiple_lines_test/input.bzl b/src/test/java/com/google/devtools/build/skydoc/testdata/function_wrap_multiple_lines_test/input.bzl index bdb2a08d5bebf9..1991ec3de6dd5f 100644 --- a/src/test/java/com/google/devtools/build/skydoc/testdata/function_wrap_multiple_lines_test/input.bzl +++ b/src/test/java/com/google/devtools/build/skydoc/testdata/function_wrap_multiple_lines_test/input.bzl @@ -47,7 +47,7 @@ dependencies here. "Xwatchconversion": attr.bool(default = False, doc = "Don't delete temporary lexers generated from combined grammars."), "_tool": attr.label( executable = True, - cfg = "host", + cfg = "exec", ), }, ) diff --git a/src/test/java/com/google/devtools/build/skydoc/testdata/misc_apis_test/input.bzl b/src/test/java/com/google/devtools/build/skydoc/testdata/misc_apis_test/input.bzl index 86dea8b4268d88..c0e602e6c9e045 100644 --- a/src/test/java/com/google/devtools/build/skydoc/testdata/misc_apis_test/input.bzl +++ b/src/test/java/com/google/devtools/build/skydoc/testdata/misc_apis_test/input.bzl @@ -44,7 +44,7 @@ A list of dependencies. doc = "The location of the tool to use.", allow_files = True, default = Label("//foo/bar/baz:target"), - cfg = "host", + cfg = "exec", executable = True, ), "out": attr.output( diff --git a/src/test/py/bazel/bazel_windows_cpp_test.py b/src/test/py/bazel/bazel_windows_cpp_test.py index 3020017653b49f..6d9ca54f356a13 100644 --- a/src/test/py/bazel/bazel_windows_cpp_test.py +++ b/src/test/py/bazel/bazel_windows_cpp_test.py @@ -857,7 +857,7 @@ def testCcCompileWithTreeArtifactAsSource(self): ' attrs = {', ' "_tool": attr.label(', ' executable = True,', - ' cfg = "host",', + ' cfg = "exec",', ' allow_files = True,', ' default = Label("//:genccs"),', ' )', diff --git a/src/test/py/bazel/bazel_windows_test.py b/src/test/py/bazel/bazel_windows_test.py index b102bbba96b91e..126ecffcba54fa 100644 --- a/src/test/py/bazel/bazel_windows_test.py +++ b/src/test/py/bazel/bazel_windows_test.py @@ -177,7 +177,7 @@ def testRunPowershellInAction(self): ' "out": attr.output(mandatory = True),', ' "tool": attr.label(', ' executable = True,', - ' cfg = "host",', + ' cfg = "exec",', ' allow_files = True,', ' default = Label("//:write.bat"),', ' ),', diff --git a/src/test/py/bazel/native_test.bzl b/src/test/py/bazel/native_test.bzl index 4b087cbdf09295..20e5dce70b7911 100644 --- a/src/test/py/bazel/native_test.bzl +++ b/src/test/py/bazel/native_test.bzl @@ -68,7 +68,7 @@ exe_test = rule( attrs = { "src": attr.label( allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, ), }, diff --git a/src/test/shell/bazel/apple/apple_common.sh b/src/test/shell/bazel/apple/apple_common.sh index a9f7e749e194e2..0207023a070fb2 100644 --- a/src/test/shell/bazel/apple/apple_common.sh +++ b/src/test/shell/bazel/apple/apple_common.sh @@ -80,7 +80,7 @@ starlark_apple_binary = rule( ), ), "_xcrunwrapper": attr.label( - cfg = "host", + cfg = "exec", default = Label("@bazel_tools//tools/objc:xcrunwrapper"), executable = True, ), diff --git a/src/test/shell/bazel/bazel_rules_test.sh b/src/test/shell/bazel/bazel_rules_test.sh index 5807d4fd45085e..f4d69224e261e4 100755 --- a/src/test/shell/bazel/bazel_rules_test.sh +++ b/src/test/shell/bazel/bazel_rules_test.sh @@ -583,7 +583,7 @@ out_rule = rule(_out_rule, attrs = { "_hello_bin": attr.label( default = ":hello_bin", executable = True, - cfg = "host", + cfg = "exec", ), }) EOF diff --git a/src/test/shell/bazel/cc_integration_test.sh b/src/test/shell/bazel/cc_integration_test.sh index 2212acdf347701..bb2f65466abdc0 100755 --- a/src/test/shell/bazel/cc_integration_test.sh +++ b/src/test/shell/bazel/cc_integration_test.sh @@ -705,11 +705,11 @@ def _tree_art_impl(ctx): tree_art_rule = rule(implementation = _tree_art_impl, attrs = { "_makes_tree" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//${package}:makes_tree_artifacts.sh"), "_write" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//${package}:write.sh")}) diff --git a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh index 4528ab18e3d167..6257b3b557375f 100755 --- a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh +++ b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh @@ -1086,7 +1086,7 @@ test_rule = rule( attrs = { "inputs": attr.label_list(allow_files = True), "out": attr.output(), - "_executable": attr.label(executable = True, cfg = "host", default = "//:exe"), + "_executable": attr.label(executable = True, cfg = "exec", default = "//:exe"), }, ) EOF diff --git a/src/test/shell/bazel/starlark_rule_test.sh b/src/test/shell/bazel/starlark_rule_test.sh index 0b6d81e57b364b..bdcdbeb16ba3a9 100755 --- a/src/test/shell/bazel/starlark_rule_test.sh +++ b/src/test/shell/bazel/starlark_rule_test.sh @@ -120,7 +120,7 @@ def _impl(ctx): foo = rule( implementation = _impl, attrs = { - "tool": attr.label(allow_single_file = True, executable = True, cfg = "host"), + "tool": attr.label(allow_single_file = True, executable = True, cfg = "exec"), "out": attr.output(mandatory = True), }, ) diff --git a/src/test/shell/integration/action_aspect_test.sh b/src/test/shell/integration/action_aspect_test.sh index 069c0fa5fbc507..a7a20dac99b980 100755 --- a/src/test/shell/integration/action_aspect_test.sh +++ b/src/test/shell/integration/action_aspect_test.sh @@ -110,11 +110,11 @@ def _actions_test_impl(target, ctx): tree_art_rule = rule(implementation = _tree_art_impl, attrs = { "_makes_tree" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//package:makes_tree_artifacts.sh"), "_write" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//package:write.sh")}) @@ -200,11 +200,11 @@ def _actions_test_impl(target, ctx): tree_art_rule = rule(implementation = _tree_art_impl, attrs = { "_makes_tree" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//package:makes_tree_artifacts.sh"), "_write" : attr.label(allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//package:write.sh")}) @@ -382,7 +382,7 @@ aspect_b = aspect( attrs = { "_write": attr.label( allow_single_file = True, - cfg = "host", + cfg = "exec", executable = True, default = "//${package}:write.sh") } diff --git a/src/test/shell/integration/py_args_escaping_test.sh b/src/test/shell/integration/py_args_escaping_test.sh index b4c91bef5f413c..e209c12da41b37 100755 --- a/src/test/shell/integration/py_args_escaping_test.sh +++ b/src/test/shell/integration/py_args_escaping_test.sh @@ -303,7 +303,7 @@ def _impl(ctx): run_host_configured = rule( implementation = _impl, attrs = { - "tool": attr.label(executable = True, cfg = "host"), + "tool": attr.label(executable = True, cfg = "exec"), "out": attr.output(), }, ) diff --git a/src/test/shell/integration/run_test.sh b/src/test/shell/integration/run_test.sh index ccf64d9fc00701..e41791009379f0 100755 --- a/src/test/shell/integration/run_test.sh +++ b/src/test/shell/integration/run_test.sh @@ -403,7 +403,7 @@ def _tool_impl(ctx): arguments = [f.path] ) return DefaultInfo(files = depset([f])) -my_tool_rule = rule(_tool_impl, attrs = { 'tool' : attr.label(executable = True, cfg = "host") }) +my_tool_rule = rule(_tool_impl, attrs = { 'tool' : attr.label(executable = True, cfg = "exec") }) EOF cat > a/BUILD <