diff options
author | 2018-01-03 12:20:57 -0800 | |
---|---|---|
committer | 2018-01-03 12:22:55 -0800 | |
commit | ceaed5145f5ad27facd103a79d047cf0e301b4b5 (patch) | |
tree | 86d92a80caa06522c5f21ea971b3b692d3520016 /tools | |
parent | e981d20dafc268ff9c1b5e23452e060327a0ace2 (diff) |
Remove usages of `+` on dicts
The `+` operator on dicts is deprecated and will be removed. This change makes
Bazel files compatible with the new behavior.
Fixes #4346.
PiperOrigin-RevId: 180702882
Diffstat (limited to 'tools')
-rw-r--r-- | tools/build_defs/apple/shared.bzl | 18 | ||||
-rw-r--r-- | tools/build_defs/docker/build.bzl | 4 | ||||
-rw-r--r-- | tools/build_defs/docker/bundle.bzl | 4 | ||||
-rw-r--r-- | tools/build_defs/repo/git.bzl | 6 | ||||
-rw-r--r-- | tools/build_defs/repo/maven_rules.bzl | 6 | ||||
-rw-r--r-- | tools/build_rules/java_rules_skylark.bzl | 16 | ||||
-rw-r--r-- | tools/cpp/unix_cc_configure.bzl | 6 |
7 files changed, 31 insertions, 29 deletions
diff --git a/tools/build_defs/apple/shared.bzl b/tools/build_defs/apple/shared.bzl index f4c973772a..0e3721f26f 100644 --- a/tools/build_defs/apple/shared.bzl +++ b/tools/build_defs/apple/shared.bzl @@ -58,8 +58,8 @@ def apple_action(ctx, **kw): Call it similar to how you would call ctx.action: apple_action(ctx, outputs=[...], inputs=[...],...) """ - execution_requirements = kw.get("execution_requirements", {}) - execution_requirements += DARWIN_EXECUTION_REQUIREMENTS + execution_requirements = dict(kw.get("execution_requirements", {})) + execution_requirements.update(DARWIN_EXECUTION_REQUIREMENTS) no_sandbox = kw.pop("no_sandbox", False) if no_sandbox: @@ -76,11 +76,13 @@ def xcrun_env(ctx): if hasattr(apple_common, "apple_host_system_env"): xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] - return (apple_common.target_apple_env(xcode_config, platform) + - apple_common.apple_host_system_env(xcode_config)) + env = apple_common.target_apple_env(xcode_config, platform) + env.update(apple_common.apple_host_system_env(xcode_config)) else: - return (ctx.fragments.apple.target_apple_env(platform) + - ctx.fragments.apple.apple_host_system_env()) + env = ctx.fragments.apple.target_apple_env(platform) + env.update(ctx.fragments.apple.apple_host_system_env()) + + return env def xcrun_action(ctx, **kw): @@ -92,7 +94,7 @@ def xcrun_action(ctx, **kw): This method takes the same keyword arguments as ctx.action, however you don't need to specify the executable. """ - env = kw.get("env", {}) - kw["env"] = env + xcrun_env(ctx) + kw["env"] = dict(kw.get("env", {})) + kw["env"].update(xcrun_env(ctx)) apple_action(ctx, executable=ctx.executable._xcrunwrapper, **kw) diff --git a/tools/build_defs/docker/build.bzl b/tools/build_defs/docker/build.bzl index f60ccbdea8..bd9da71848 100644 --- a/tools/build_defs/docker/build.bzl +++ b/tools/build_defs/docker/build.bzl @@ -315,7 +315,7 @@ def _docker_build_impl(ctx): docker_build_ = rule( implementation = _docker_build_impl, - attrs = { + attrs = dict({ "base": attr.label(allow_files=docker_filetype), "data_path": attr.string(), "directory": attr.string(default="/"), @@ -358,7 +358,7 @@ docker_build_ = rule( cfg="host", executable=True, allow_files=True) - } + _hash_tools + _layer_tools, + }.items() + _hash_tools.items() + _layer_tools.items()), outputs = { "out": "%{name}.tar", "layer": "%{name}-layer.tar", diff --git a/tools/build_defs/docker/bundle.bzl b/tools/build_defs/docker/bundle.bzl index fa11b12f5b..7aca21553b 100644 --- a/tools/build_defs/docker/bundle.bzl +++ b/tools/build_defs/docker/bundle.bzl @@ -68,12 +68,12 @@ def _docker_bundle_impl(ctx): docker_bundle_ = rule( implementation = _docker_bundle_impl, - attrs = { + attrs = dict({ "images": attr.string_dict(), # Implicit dependencies. "image_targets": attr.label_list(allow_files=True), "image_target_strings": attr.string_list(), - } + _layer_tools, + }.items() + _layer_tools.items()), outputs = { "out": "%{name}.tar", }, diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl index 2375b21f71..514795108f 100644 --- a/tools/build_defs/repo/git.bzl +++ b/tools/build_defs/repo/git.bzl @@ -79,11 +79,11 @@ _common_attrs = { new_git_repository = repository_rule( - implementation=_new_git_repository_implementation, - attrs=_common_attrs + { + implementation = _new_git_repository_implementation, + attrs = dict(_common_attrs.items() + { 'build_file': attr.label(allow_single_file=True), 'build_file_content': attr.string(), - } + }.items()) ) """Clone an external git repository. diff --git a/tools/build_defs/repo/maven_rules.bzl b/tools/build_defs/repo/maven_rules.bzl index a27431cf97..a17bf6f1cd 100644 --- a/tools/build_defs/repo/maven_rules.bzl +++ b/tools/build_defs/repo/maven_rules.bzl @@ -292,12 +292,12 @@ def _maven_aar_impl(ctx): _maven_artifact_impl(ctx, "aar", _maven_aar_build_file_template) maven_jar = repository_rule( - implementation=_maven_jar_impl, - attrs=_common_maven_rule_attrs + { + implementation = _maven_jar_impl, + attrs = dict(_common_maven_rule_attrs.items() + { # Needed for compatability reasons with the native maven_jar rule. "repository": attr.string(default = ""), "server": attr.label(default = None), - }, + }.items()), local=False, ) diff --git a/tools/build_rules/java_rules_skylark.bzl b/tools/build_rules/java_rules_skylark.bzl index 4b12958c2a..ec103830d2 100644 --- a/tools/build_rules/java_rules_skylark.bzl +++ b/tools/build_rules/java_rules_skylark.bzl @@ -211,14 +211,14 @@ bootstrap_java_library = rule( fragments = ['java'], ) -java_binary_attrs_common = java_library_attrs + { +java_binary_attrs_common = dict(java_library_attrs) +java_binary_attrs_common.update({ "jvm_flags": attr.string_list(), "jvm": attr.label(default=Label("//tools/jdk:jdk"), allow_files=True), -} +}) -java_binary_attrs = java_binary_attrs_common + { - "main_class": attr.string(mandatory=True), -} +java_binary_attrs = dict(java_binary_attrs_common) +java_binary_attrs["main_class"] = attr.string(mandatory=True) java_binary_outputs = { "class_jar": "lib%{name}.jar", @@ -243,12 +243,12 @@ bootstrap_java_binary = rule(java_binary_impl, java_test = rule(java_binary_impl, executable = True, - attrs = java_binary_attrs_common + { - "main_class": attr.string(default="org.junit.runner.JUnitCore"), + attrs = dict(java_binary_attrs_common.items() + [ + ("main_class", attr.string(default="org.junit.runner.JUnitCore")), # TODO(bazel-team): it would be better if we could offer a # test_class attribute, but the "args" attribute is hard # coded in the bazel infrastructure. - }, + ]), outputs = java_binary_outputs, test = True, fragments = ['java', 'cpp'], diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 4657ba4ebb..1df03d2b02 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -103,7 +103,7 @@ def _find_tool(repository_ctx, tool, overriden_tools): def _get_tool_paths(repository_ctx, darwin, cc, overriden_tools): """Compute the path to the various tools. Doesn't %-escape the result!""" - return {k: _find_tool(repository_ctx, k, overriden_tools) + return dict({k: _find_tool(repository_ctx, k, overriden_tools) for k in [ "ld", "cpp", @@ -113,11 +113,11 @@ def _get_tool_paths(repository_ctx, darwin, cc, overriden_tools): "objcopy", "objdump", "strip", - ]} + { + ]}.items() + { "gcc": cc, "ar": "/usr/bin/libtool" if darwin else which(repository_ctx, "ar", "/usr/bin/ar") - } + }.items()) def _escaped_cplus_include_paths(repository_ctx): |