instance_id
stringlengths
17
39
repo
stringclasses
8 values
issue_id
stringlengths
14
34
pr_id
stringlengths
14
34
linking_methods
listlengths
1
3
base_commit
stringlengths
40
40
merge_commit
stringlengths
0
40
hints_text
listlengths
0
106
resolved_comments
listlengths
0
119
created_at
timestamp[ns, tz=UTC]
labeled_as
listlengths
0
7
problem_title
stringlengths
7
174
problem_statement
stringlengths
0
55.4k
gold_files
listlengths
0
10
gold_files_postpatch
listlengths
1
10
test_files
listlengths
0
60
gold_patch
stringlengths
220
5.83M
test_patch
stringlengths
386
194k
split_random
stringclasses
3 values
split_time
stringclasses
3 values
issue_start_time
timestamp[ns]
issue_created_at
timestamp[ns, tz=UTC]
issue_by_user
stringlengths
3
21
split_repo
stringclasses
3 values
bazelbuild/bazel/17085_19900
bazelbuild/bazel
bazelbuild/bazel/17085
bazelbuild/bazel/19900
[ "keyword_pr_to_issue" ]
9e8ae1aaac2409824aab7c7204858d12fabb60a1
2cb3159aed5b73eb13a866d8fe63953d388cd30b
[ "Definitely not an expert on this, so take any of the following with a grain of salt. \n\nNote that there are two relevant Java toolchain types: the one for the JDK used for compilation (@bazel_tools//tools/jdk:toolchain_type) and the one for the JDK/JRE used as the runtime for executing a java_binary (@bazel_tools...
[]
2023-10-19T17:36:30Z
[ "type: bug", "P2", "team-Rules-Java", "next_month" ]
Bazel 6 Remote JDK Toolchains Incorrect Configuration
### Description of the bug: Upgrading to Bazel 6.0.0, I get some toolchain resolution and build failures around java_library/java_binary rules. My environment is cross-compile heavy and has remote executors on a number of platforms (linux, darwin both x86 and arm64, windows) and bazel itself is invoked on any of those platforms building for any other. I get issues when, due to peculiarities in execution platform selection order, an exec platform is chosen for java that is distinct from the target platform. For instance, target platform is macos_arm64, but the exec platform is @local_config_platform//:host on linux, or a remote linux platform. For instance, here is toolchain_resolution_debug from a cross compile: ``` INFO: ToolchainResolution: Type @bazel_tools//tools/jdk:runtime_toolchain_type: target platform //:macos_arm: execution //:macos_arm: Selected toolchain @remotejdk11_macos_aarch64//:jdk INFO: ToolchainResolution: Type @bazel_tools//tools/jdk:runtime_toolchain_type: target platform //:macos_arm: execution //:macos: Selected toolchain @remotejdk11_macos_aarch64//:jdk INFO: ToolchainResolution: Type @bazel_tools//tools/jdk:runtime_toolchain_type: target platform //:macos_arm: execution //:linux: Selected toolchain @remotejdk11_macos_aarch64//:jdk INFO: ToolchainResolution: Type @bazel_tools//tools/jdk:runtime_toolchain_type: target platform //:macos_arm: execution //test:downloader: Selected toolchain @remotejdk11_macos_aarch64//:jdk INFO: ToolchainResolution: Type @bazel_tools//tools/jdk:runtime_toolchain_type: target platform //:macos_arm: execution @local_config_platform//:host: Selected toolchain @remotejdk11_macos_aarch64//:jdk ``` A number of these selections are wrong: remotejdk11_macos_aarch64 will not run on the host platform (it is linux), nor will it run on the //:linux remote execution platform. Nor will it run on the //test:downloader platform which specifies no OS constraints to match at all. If bazel happens to choose any but the first configuration with identical target and exec platform, it will try to execute a darwin arm64 binary on linux with predictable fireworks. In the ultimate case where the target and set of exec platforms are distinct, this is guaranteed to fail. This also fails when targeting a platform that has no JDK such as Android. In Bazel 5.1 it worked just fine to have a java_library depended on by an android_library, now toolchain resolution just fails if you set --platforms to one with @platforms//os:android because there is no openjdk for android (and if there were, my remote exec environment has no android runners) It seems that d5559c16ac008b86345fbbade5d600181a2fce6f changed the definition of the java toolchains to specify only target_compatible_with, not exec_compatible_with, even though the jdk itself is platform-specific. I'm not sure I understand the benefits of that change, but at a minimum it seems like exec_compatible_with should _also_ be specified for those toolchains. ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. See https://github.com/jlaxson/bazel_java_toolchain_bug for the simple reduction involving android platforms. ### Which operating system are you running Bazel on? Macos, linux ### What is the output of `bazel info release`? release 6.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ ".bazelrc", "BUILD", "MODULE.bazel", "MODULE.bazel.lock", "distdir_deps.bzl", "src/BUILD", "src/MODULE.tools", "tools/jdk/local_java_repository.bzl", "tools/jdk/remote_java_repository.bzl" ]
[ ".bazelrc", "BUILD", "MODULE.bazel", "MODULE.bazel.lock", "distdir_deps.bzl", "src/BUILD", "src/MODULE.tools", "tools/jdk/local_java_repository.bzl", "tools/jdk/remote_java_repository.bzl" ]
[ "src/test/java/com/google/devtools/build/android/dexer/BUILD", "src/test/py/bazel/test_base.py", "src/test/shell/bazel/bazel_java17_test.sh", "src/test/shell/bazel/bazel_java_test_defaults.sh", "src/test/shell/bazel/bazel_with_jdk_test.sh", "src/test/shell/integration/bazel_java_test.sh", "src/test/shel...
diff --git a/.bazelrc b/.bazelrc index 9fbb5ece42fe72..d6be9f065df2f0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -14,6 +14,9 @@ build:remote_shared --tool_java_runtime_version=rbe_jdk build:remote_shared --noexperimental_check_desugar_deps # Configuration to build and test Bazel on RBE on Ubuntu 18.04 with Java 11 +# Workaround for https://github.com/bazelbuild/bazel/issues/19837. +# TODO(bazel-team): Remove this toolchain when .bazelversion is 7.0.0rc2 or later. +build:ubuntu2004_java11 --extra_toolchains=//:bazel_rbe_java_toolchain_definition build:ubuntu2004_java11 --extra_toolchains=@rbe_ubuntu2004_java11//java:all build:ubuntu2004_java11 --crosstool_top=@rbe_ubuntu2004_java11//cc:toolchain build:ubuntu2004_java11 --extra_toolchains=@rbe_ubuntu2004_java11//config:cc-toolchain @@ -34,6 +37,9 @@ build:windows --extra_toolchains=@bazel_tools//tools/python:autodetecting_toolch build:windows_arm64 --platforms=//:windows_arm64 build:windows_arm64 --extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows +# When cross-compiling, the local Java runtime, which is used by default, will not be compatible +# with the target. +build:windows_arm64 --java_runtime_version=remotejdk_11 # Enable Bzlmod common:bzlmod --enable_bzlmod diff --git a/BUILD b/BUILD index 56b79c87eac07d..07eb0bc076c0a1 100644 --- a/BUILD +++ b/BUILD @@ -1,6 +1,7 @@ # Bazel - Google's Build System load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain") load("@rules_license//rules:license.bzl", "license") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@rules_python//python:defs.bzl", "py_binary") @@ -293,3 +294,19 @@ REMOTE_PLATFORMS = ("rbe_ubuntu2004_java11",) ) for platform_name in REMOTE_PLATFORMS ] + +# Workaround for https://github.com/bazelbuild/bazel/issues/19837. +# TODO(bazel-team): Remove these two targets when .bazelversion is 7.0.0rc2 or later. +default_java_toolchain( + name = "bazel_java_toolchain", + bootclasspath = ["@rules_java//toolchains:platformclasspath"], + source_version = "11", + tags = ["manual"], + target_version = "11", +) + +default_java_toolchain( + name = "bazel_rbe_java_toolchain", + source_version = "11", + target_version = "11", +) diff --git a/MODULE.bazel b/MODULE.bazel index e39f58d2909469..d04304e6a043be 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -24,7 +24,7 @@ bazel_dep(name = "zstd-jni", version = "1.5.2-3.bcr.1") bazel_dep(name = "blake3", version = "1.3.3.bcr.1") bazel_dep(name = "zlib", version = "1.3") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_java", version = "6.3.1") +bazel_dep(name = "rules_java", version = "7.0.6") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") bazel_dep(name = "rules_jvm_external", version = "5.2") bazel_dep(name = "rules_python", version = "0.24.0") @@ -231,10 +231,10 @@ use_repo( "remotejdk17_macos_aarch64", "remotejdk17_win", "remotejdk17_win_arm64", - "remotejdk20_linux", - "remotejdk20_macos", - "remotejdk20_macos_aarch64", - "remotejdk20_win", + "remotejdk21_linux", + "remotejdk21_macos", + "remotejdk21_macos_aarch64", + "remotejdk21_win", ) # ========================================= @@ -309,6 +309,10 @@ register_toolchains("@local_config_winsdk//:all") register_toolchains("//src/main/res:empty_rc_toolchain") +# Workaround for https://github.com/bazelbuild/bazel/issues/19837. +# TODO(bazel-team): Remove when .bazelversion is 7.0.0rc2 or later. +register_toolchains("//:bazel_java_toolchain_definition") + # ========================================= # Android tools dependencies # ========================================= diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index dee726962f0a5a..01f1f68a99e5ab 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "50de843d4bf36021313d6db4e8f2656ed1d2aadbcc3d26791537d366111eb6be", + "moduleFileHash": "9ee47c2efef5f33f69b8cf617fba1fb6e38fb35e79345ce524924bee781cb72e", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -29,7 +29,8 @@ "toolchainsToRegister": [ "@bazel_tools//tools/python:autodetecting_toolchain", "@local_config_winsdk//:all", - "//src/main/res:empty_rc_toolchain" + "//src/main/res:empty_rc_toolchain", + "//:bazel_java_toolchain_definition" ], "extensionUsages": [ { @@ -329,7 +330,7 @@ "devDependency": false, "location": { "file": "@@//:MODULE.bazel", - "line": 317, + "line": 321, "column": 22 } } @@ -367,10 +368,10 @@ "remotejdk17_macos_aarch64": "remotejdk17_macos_aarch64", "remotejdk17_win": "remotejdk17_win", "remotejdk17_win_arm64": "remotejdk17_win_arm64", - "remotejdk20_linux": "remotejdk20_linux", - "remotejdk20_macos": "remotejdk20_macos", - "remotejdk20_macos_aarch64": "remotejdk20_macos_aarch64", - "remotejdk20_win": "remotejdk20_win" + "remotejdk21_linux": "remotejdk21_linux", + "remotejdk21_macos": "remotejdk21_macos", + "remotejdk21_macos_aarch64": "remotejdk21_macos_aarch64", + "remotejdk21_win": "remotejdk21_win" }, "devImports": [], "tags": [], @@ -543,7 +544,7 @@ "usingModule": "<root>", "location": { "file": "@@//:MODULE.bazel", - "line": 339, + "line": 343, "column": 35 }, "imports": { @@ -560,7 +561,7 @@ "usingModule": "<root>", "location": { "file": "@@//:MODULE.bazel", - "line": 342, + "line": 346, "column": 42 }, "imports": { @@ -585,7 +586,7 @@ "blake3": "blake3@1.3.3.bcr.1", "zlib": "zlib@1.3", "rules_cc": "rules_cc@0.0.9", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_proto": "rules_proto@5.3.0-21.7", "rules_jvm_external": "rules_jvm_external@5.2", "rules_python": "rules_python@0.24.0", @@ -715,7 +716,7 @@ "rules_python": "rules_python@0.24.0", "rules_cc": "rules_cc@0.0.9", "rules_proto": "rules_proto@5.3.0-21.7", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_pkg": "rules_pkg@0.9.1", "com_google_abseil": "abseil-cpp@20220623.1", "zlib": "zlib@1.3", @@ -801,7 +802,7 @@ "rules_proto": "rules_proto@5.3.0-21.7", "upb": "upb@0.0.0-20220923-a547704", "zlib": "zlib@1.3", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "io_bazel_rules_go": "rules_go@0.39.1", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -891,7 +892,7 @@ "extensionUsages": [], "deps": { "bazel_skylib": "bazel_skylib@1.4.1", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -1056,45 +1057,46 @@ } } }, - "rules_java@6.3.1": { + "rules_java@7.0.6": { "name": "rules_java", - "version": "6.3.1", - "key": "rules_java@6.3.1", + "version": "7.0.6", + "key": "rules_java@7.0.6", "repoName": "rules_java", "executionPlatformsToRegister": [], "toolchainsToRegister": [ "//toolchains:all", "@local_jdk//:runtime_toolchain_definition", - "@remotejdk11_linux_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_ppc64le_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_s390x_toolchain_config_repo//:toolchain", - "@remotejdk11_macos_toolchain_config_repo//:toolchain", - "@remotejdk11_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk11_win_toolchain_config_repo//:toolchain", - "@remotejdk11_win_arm64_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_ppc64le_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_s390x_toolchain_config_repo//:toolchain", - "@remotejdk17_macos_toolchain_config_repo//:toolchain", - "@remotejdk17_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk17_win_toolchain_config_repo//:toolchain", - "@remotejdk17_win_arm64_toolchain_config_repo//:toolchain", - "@remotejdk20_linux_toolchain_config_repo//:toolchain", - "@remotejdk20_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk20_macos_toolchain_config_repo//:toolchain", - "@remotejdk20_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk20_win_toolchain_config_repo//:toolchain" + "@local_jdk//:bootstrap_runtime_toolchain_definition", + "@remotejdk11_linux_toolchain_config_repo//:all", + "@remotejdk11_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk11_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk11_linux_s390x_toolchain_config_repo//:all", + "@remotejdk11_macos_toolchain_config_repo//:all", + "@remotejdk11_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk11_win_toolchain_config_repo//:all", + "@remotejdk11_win_arm64_toolchain_config_repo//:all", + "@remotejdk17_linux_toolchain_config_repo//:all", + "@remotejdk17_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk17_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk17_linux_s390x_toolchain_config_repo//:all", + "@remotejdk17_macos_toolchain_config_repo//:all", + "@remotejdk17_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk17_win_toolchain_config_repo//:all", + "@remotejdk17_win_arm64_toolchain_config_repo//:all", + "@remotejdk21_linux_toolchain_config_repo//:all", + "@remotejdk21_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk21_macos_toolchain_config_repo//:all", + "@remotejdk21_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk21_win_toolchain_config_repo//:all" ], "extensionUsages": [ { "extensionBzlFile": "@rules_java//java:extensions.bzl", "extensionName": "toolchains", - "usingModule": "rules_java@6.3.1", + "usingModule": "rules_java@7.0.6", "location": { - "file": "https://bcr.bazel.build/modules/rules_java/6.3.1/MODULE.bazel", - "line": 17, + "file": "https://bcr.bazel.build/modules/rules_java/7.0.6/MODULE.bazel", + "line": 18, "column": 27 }, "imports": { @@ -1120,11 +1122,11 @@ "remotejdk17_macos_aarch64_toolchain_config_repo": "remotejdk17_macos_aarch64_toolchain_config_repo", "remotejdk17_win_toolchain_config_repo": "remotejdk17_win_toolchain_config_repo", "remotejdk17_win_arm64_toolchain_config_repo": "remotejdk17_win_arm64_toolchain_config_repo", - "remotejdk20_linux_toolchain_config_repo": "remotejdk20_linux_toolchain_config_repo", - "remotejdk20_linux_aarch64_toolchain_config_repo": "remotejdk20_linux_aarch64_toolchain_config_repo", - "remotejdk20_macos_toolchain_config_repo": "remotejdk20_macos_toolchain_config_repo", - "remotejdk20_macos_aarch64_toolchain_config_repo": "remotejdk20_macos_aarch64_toolchain_config_repo", - "remotejdk20_win_toolchain_config_repo": "remotejdk20_win_toolchain_config_repo" + "remotejdk21_linux_toolchain_config_repo": "remotejdk21_linux_toolchain_config_repo", + "remotejdk21_linux_aarch64_toolchain_config_repo": "remotejdk21_linux_aarch64_toolchain_config_repo", + "remotejdk21_macos_toolchain_config_repo": "remotejdk21_macos_toolchain_config_repo", + "remotejdk21_macos_aarch64_toolchain_config_repo": "remotejdk21_macos_aarch64_toolchain_config_repo", + "remotejdk21_win_toolchain_config_repo": "remotejdk21_win_toolchain_config_repo" }, "devImports": [], "tags": [], @@ -1145,11 +1147,11 @@ "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1", + "name": "rules_java~7.0.6", "urls": [ - "https://github.com/bazelbuild/rules_java/releases/download/6.3.1/rules_java-6.3.1.tar.gz" + "https://github.com/bazelbuild/rules_java/releases/download/7.0.6/rules_java-7.0.6.tar.gz" ], - "integrity": "sha256-EXoSJ82vgTogobunip8tj7MIQQAMM+Ly0qZAvSJMkoI=", + "integrity": "sha256-6B6d6q4NnZnvPdX2wbMjOER/4W1VZBVVMepOt+84hUs=", "strip_prefix": "", "remote_patches": {}, "remote_patch_strip": 0 @@ -1461,7 +1463,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_proto": "rules_proto@5.3.0-21.7", "com_google_protobuf": "protobuf@21.7", "googleapis": "googleapis@_", @@ -1480,7 +1482,7 @@ "extensionUsages": [], "deps": { "rules_license": "rules_license@0.0.7", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_proto": "rules_proto@5.3.0-21.7", "com_google_protobuf": "protobuf@21.7", "io_bazel": "<root>", @@ -1894,7 +1896,7 @@ ], "deps": { "rules_cc": "rules_cc@0.0.9", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_license": "rules_license@0.0.7", "rules_proto": "rules_proto@5.3.0-21.7", "rules_python": "rules_python@0.24.0", @@ -2104,7 +2106,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "yseV59Gli/QtNiWYztGw/BCEfbZOAJ97MKMy8mbTpbg=", + "bzlTransitiveDigest": "n3Rv2PmmDuw7aJr+nz1ckn3VyB5UDfB7IIh1wMuc+4s=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2129,9 +2131,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "yseV59Gli/QtNiWYztGw/BCEfbZOAJ97MKMy8mbTpbg=", + "bzlTransitiveDigest": "n3Rv2PmmDuw7aJr+nz1ckn3VyB5UDfB7IIh1wMuc+4s=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "e321d417e120f584c05c82bc03b878d62887d36f65809ecfd343b00f75778d6d" + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "3690079fb96225220955f4e04363ba87470cb4cfb0f2b6deddd9929822ecc3ad" }, "envVariables": {}, "generatedRepoSpecs": { @@ -2155,7 +2157,7 @@ "name": "_main~bazel_build_deps~bazel_tools_repo_cache", "repos": [ "rules_cc~0.0.9", - "rules_java~6.3.1", + "rules_java~7.0.6", "rules_license~0.0.7", "rules_proto~4.0.0", "rules_python~0.4.0", @@ -2231,7 +2233,7 @@ "platforms", "rules_cc~0.0.9", "rules_go~0.39.1", - "rules_java~6.3.1", + "rules_java~7.0.6", "rules_jvm_external~5.2", "rules_license~0.0.7", "rules_pkg~0.9.1", @@ -2345,7 +2347,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "yseV59Gli/QtNiWYztGw/BCEfbZOAJ97MKMy8mbTpbg=", + "bzlTransitiveDigest": "n3Rv2PmmDuw7aJr+nz1ckn3VyB5UDfB7IIh1wMuc+4s=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -3593,64 +3595,80 @@ } } }, - "@rules_java~6.3.1//java:extensions.bzl%toolchains": { + "@rules_java~7.0.6//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "Rz6TuBbGewHQwuehc1H9tRP+L5ORZKpeG+bcabQWP1c=", + "bzlTransitiveDigest": "S4ACUNQWaXa0wT3rT0IlpEuyljTfb611fi6lw+/WX3M=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { - "remotejdk20_linux": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "remotejdk21_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "0386418db7f23ae677d05045d30224094fc13423593ce9cd087d455069893bac", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-linux_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_x64.tar.gz" - ] + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\n" } }, "remotejdk17_linux_s390x_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" } }, "remotejdk17_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\n" } }, "remotejdk17_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "2a7a99a3ea263dbd8d32a67d1e6e363ba8b25c645c826f5e167a02bbafaff1fa", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz" + ] } }, "remotejdk17_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" } }, "remotejdk17_macos_aarch64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "515dd56ec99bb5ae8966621a2088aadfbe72631818ffbba6e4387b7ee292ab09", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-macosx_aarch64", "urls": [ @@ -3663,11 +3681,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_windows", - "sha256": "bae6a03b5aeead5804ba7bcdcc8b14ec3ed05b37f3db5519f788ab060bc53b05", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_windows", + "sha256": "0224bb368b98f14d97afb749f3f956a177b60f753213b6c57db16deb2706c5dc", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_windows-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_windows-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_windows-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_windows-v13.0.zip" ] } }, @@ -3675,49 +3693,35 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "a106c77389a63b6bd963a087d5f01171bd32aa3ee7377ecef87531390dcb9050", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-win_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-win_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-win_x64.zip", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-win_x64.zip" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip" ] } }, "remotejdk11_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" - } - }, - "remotejdk20_win": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "ac5f6a7d84dbbb0bb4d376feb331cc4c49a9920562f2a5e85b7a6b4863b10e1e", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-win_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-win_x64.zip", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-win_x64.zip" - ] + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" } }, "remotejdk11_linux_aarch64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "fc7c41a0005180d4ca471c90d01e049469e0614cf774566d4cf383caa29d1a97", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-linux_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_aarch64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu-embedded/bin/zulu11.56.19-ca-jdk11.0.15-linux_aarch64.tar.gz", - "https://cdn.azul.com/zulu-embedded/bin/zulu11.56.19-ca-jdk11.0.15-linux_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz" ] } }, @@ -3725,8 +3729,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "20c91a922eec795f3181eaa70def8b99d8eac56047c9a14bfb257c85b991df1b", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-linux_x64", "urls": [ @@ -3736,40 +3740,32 @@ } }, "remotejdk11_linux_s390x_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" - } - }, - "remotejdk20_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" } }, "remotejdk11_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" } }, "remotejdk11_macos": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "2614e5c5de8e989d4d81759de4c333aa5b867b17ab9ee78754309ba65c7f6f55", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-macosx_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_x64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz" ] } }, @@ -3777,8 +3773,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_arm64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", "strip_prefix": "jdk-11.0.13+8", "urls": [ @@ -3790,8 +3786,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "e6317cee4d40995f0da5b702af3f04a6af2bbd55febf67927696987d11113b53", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-macosx_x64", "urls": [ @@ -3800,34 +3796,42 @@ ] } }, - "remotejdk17_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_macos_aarch64": { + "remotejdk21_macos": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "a2eff6a940c2df3a2352278027e83f5959f34dcfc8663034fe92be0f1b91ce6f", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-macosx_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "9639b87db586d0c89f7a9892ae47f421e442c64b97baebdff31788fbe23265bd", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz" ] } }, + "remotejdk21_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" + } + }, "remotejdk17_win": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "9972c5b62a61b45785d3d956c559e079d9e91f144ec46225f5deeda214d48f27", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-win_x64", "urls": [ @@ -3837,47 +3841,89 @@ } }, "remotejdk11_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" } }, "remotejdk11_linux_ppc64le_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk21_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "0c0eadfbdc47a7ca64aeab51b9c061f71b6e4d25d2d87674512e9b6387e9e3a6", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz" + ] } }, "remote_java_tools_linux": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_linux", - "sha256": "a346b9a291b6db1bb06f7955f267e47522d99963fe14e337da1d75d125a8599f", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_linux", + "sha256": "f950ecc09cbc2ca110016095fe2a46e661925115975c84039f4370db1e70fe27", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_linux-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_linux-v13.0.zip" + ] + } + }, + "remotejdk21_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "e9959d500a0d9a7694ac243baf657761479da132f0f94720cbffd092150bd802", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-win_x64", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_linux-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_linux-v12.7.zip" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip" + ] + } + }, + "remotejdk21_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "1fb64b8036c5d463d8ab59af06bf5b6b006811e6012e3b0eb6bccf57f1c55835", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz" ] } }, "remotejdk11_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" } }, "remotejdk11_linux_s390x": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_s390x", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", "strip_prefix": "jdk-11.0.15+10", "urls": [ @@ -3890,8 +3936,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "dbc6ae9163e7ff469a9ab1f342cd1bc1f4c1fb78afc3c4f2228ee3b32c4f3e43", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-linux_aarch64", "urls": [ @@ -3901,49 +3947,49 @@ } }, "remotejdk17_win_arm64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_arm64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" } }, "remotejdk11_linux": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "e064b61d93304012351242bf0823c6a2e41d9e28add7ea7f05378b7243d34247", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-linux_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz" ] } }, "remotejdk11_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" } }, "remotejdk17_linux_ppc64le_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" } }, "remotejdk17_win_arm64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_arm64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "bc3476f2161bf99bc9a243ff535b8fc033b34ce9a2fa4b62fb8d79b6bfdc427f", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-win_aarch64", "urls": [ @@ -3956,11 +4002,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_darwin_arm64", - "sha256": "ecedf6305768dfd51751d0ad732898af092bd7710d497c6c6c3214af7e49395f", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_darwin_arm64", + "sha256": "1ecd91bf870b4f246960c11445218798113b766762e26a3de09cfcf3e9b4c646", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_darwin_arm64-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_darwin_arm64-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_darwin_arm64-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_darwin_arm64-v13.0.zip" ] } }, @@ -3968,8 +4014,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_ppc64le", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "cbedd0a1428b3058d156e99e8e9bc8769e0d633736d6776a4c4d9136648f2fd1", "strip_prefix": "jdk-17.0.4.1+1", "urls": [ @@ -3978,93 +4024,41 @@ ] } }, - "remotejdk20_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_macos//:jdk\",\n)\n" - } - }, - "remotejdk20_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "remotejdk21_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_macos_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_win//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\n" } }, "remotejdk11_win_arm64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_arm64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" } }, "local_jdk": { - "bzlFile": "@@rules_java~6.3.1//toolchains:local_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:local_java_repository.bzl", "ruleClassName": "_local_java_repository_rule", "attributes": { - "name": "rules_java~6.3.1~toolchains~local_jdk", + "name": "rules_java~7.0.6~toolchains~local_jdk", "java_home": "", "version": "", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = {RUNTIME_VERSION},\n)\n" - } - }, - "remotejdk20_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_linux_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_macos": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "fde6cc17a194ea0d9b0c6c0cb6178199d8edfc282d649eec2c86a9796e843f86", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-macosx_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_x64.tar.gz" - ] + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = {RUNTIME_VERSION},\n)\n" } }, "remote_java_tools_darwin_x86_64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_darwin_x86_64", - "sha256": "e116c649c0355ab57ffcc870ce1139e5e1528cabac458bd50263d2b84ea4ffb2", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_darwin_x86_64", + "sha256": "3edf102f683bfece8651f206aee864628825b4f6e614d183154e6bdf98b8c494", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_darwin_x86_64-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_darwin_x86_64-v12.7.zip" - ] - } - }, - "remotejdk20_linux_aarch64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "47ce58ead9a05d5d53b96706ff6fa0eb2e46755ee67e2b416925e28f5b55038a", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-linux_aarch64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_aarch64.tar.gz" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_darwin_x86_64-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_darwin_x86_64-v13.0.zip" ] } }, @@ -4072,11 +4066,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools", - "sha256": "aa11ecd5fc0af2769f0f2bdd25e2f4de7c1291ed24326fb23fa69bdd5dcae2b5", + "name": "rules_java~7.0.6~toolchains~remote_java_tools", + "sha256": "610e40b1a89c9941638e33c56cf1be58f2d9d24cf9ac5a34b63270e08bb7000a", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools-v13.0.zip" ] } }, @@ -4084,8 +4078,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_s390x", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "fdc82f4b06c880762503b0cb40e25f46cf8190d06011b3b768f4091d3334ef7f", "strip_prefix": "jdk-17.0.4.1+1", "urls": [ @@ -4095,19 +4089,19 @@ } }, "remotejdk17_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" } }, "remotejdk11_linux_ppc64le": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_ppc64le", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", "strip_prefix": "jdk-11.0.15+10", "urls": [ @@ -4120,15 +4114,23 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "6bb0d2c6e8a29dcd9c577bbb2986352ba12481a9549ac2c0bcfd00ed60e538d2", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-macosx_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz" ] } + }, + "remotejdk21_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\n" + } } } } @@ -7919,7 +7921,7 @@ }, "@rules_python~0.24.0//python/extensions:pip.bzl%pip": { "general": { - "bzlTransitiveDigest": "Ft3hTgShxX/7p6AciATaTUQJgVShv/1SJ64filkse6c=", + "bzlTransitiveDigest": "TEllPVzarB4s4TpELB3gWHqo8xpekIiVpXI5FLmg+CQ=", "accumulatedFileDigests": { "@@//:requirements.txt": "ff12967a755bb8e9b4c92524f6471a99e14c30474a3d428547c55745ec8f23a0" }, @@ -7954,7 +7956,7 @@ "repo": "bazel_pip_dev_deps_38", "repo_prefix": "bazel_pip_dev_deps_38_", "python_interpreter": "", - "python_interpreter_target": "@@rules_python~0.24.0~python~python_3_8_x86_64-unknown-linux-gnu//:bin/python3", + "python_interpreter_target": "@@rules_python~0.24.0~python~python_3_8_aarch64-apple-darwin//:bin/python3", "quiet": true, "timeout": 600, "isolated": true, diff --git a/distdir_deps.bzl b/distdir_deps.bzl index 8c2f8e20c78ebc..7eeaf24ad8b424 100644 --- a/distdir_deps.bzl +++ b/distdir_deps.bzl @@ -106,9 +106,9 @@ DIST_DEPS = { "rules_java_builtin", "rules_java_builtin_for_testing", ], - "archive": "rules_java-6.3.1.tar.gz", - "sha256": "117a1227cdaf813a20a1bba78a9f2d8fb30841000c33e2f2d2a640bd224c9282", - "urls": ["https://github.com/bazelbuild/rules_java/releases/download/6.3.1/rules_java-6.3.1.tar.gz"], + "archive": "rules_java-7.0.6.tar.gz", + "sha256": "e81e9deaae0d9d99ef3dd5f6c1b32338447fe16d5564155531ea4eb7ef38854b", + "urls": ["https://github.com/bazelbuild/rules_java/releases/download/7.0.6/rules_java-7.0.6.tar.gz"], "workspace_file_content": "", "used_in": [ "additional_distfiles", @@ -116,7 +116,7 @@ DIST_DEPS = { "license_kinds": [ "@rules_license//licenses/spdx:Apache-2.0", ], - "package_version": "6.1.1", + "package_version": "7.0.6", }, # Used in src/test/java/com/google/devtools/build/lib/blackbox/framework/blackbox.WORKSAPCE "rules_proto": { diff --git a/src/BUILD b/src/BUILD index eee29967ce96f8..8f70304152da0c 100644 --- a/src/BUILD +++ b/src/BUILD @@ -585,7 +585,7 @@ filegroup( "@rules_testing//:LICENSE", ] + [ "@remotejdk%s_%s//:WORKSPACE" % (version, os) - for version in ("17", "20") + for version in ("17", "21") for os in ("macos", "macos_aarch64", "linux", "win") ] + ["@bazel_tools_repo_cache//:files"], ) diff --git a/src/MODULE.tools b/src/MODULE.tools index 33993075290286..c134770a2ba2d9 100644 --- a/src/MODULE.tools +++ b/src/MODULE.tools @@ -1,10 +1,11 @@ # NOTE: When editing this file, also update the lockfile. # bazel run //src/test/tools/bzlmod:update_default_lock_file +# bazel mod deps --lockfile_mode=update module(name = "bazel_tools") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_java", version = "6.3.1") +bazel_dep(name = "rules_java", version = "7.0.6") bazel_dep(name = "rules_license", version = "0.0.3") bazel_dep(name = "rules_proto", version = "4.0.0") bazel_dep(name = "rules_python", version = "0.4.0") diff --git a/tools/jdk/local_java_repository.bzl b/tools/jdk/local_java_repository.bzl index 416db4a1541a8f..f8554a1ac6310f 100644 --- a/tools/jdk/local_java_repository.bzl +++ b/tools/jdk/local_java_repository.bzl @@ -19,5 +19,6 @@ load("@rules_java//toolchains:local_java_repository.bzl", _local_java_repository def local_java_repository(name, **kwargs): _local_java_repository(name, **kwargs) native.register_toolchains("@" + name + "//:runtime_toolchain_definition") + native.register_toolchains("@" + name + "//:bootstrap_runtime_toolchain_definition") local_java_runtime = _local_java_runtime diff --git a/tools/jdk/remote_java_repository.bzl b/tools/jdk/remote_java_repository.bzl index b4ab1da279330b..32f4c1fdacb351 100644 --- a/tools/jdk/remote_java_repository.bzl +++ b/tools/jdk/remote_java_repository.bzl @@ -18,4 +18,4 @@ load("@rules_java//toolchains:remote_java_repository.bzl", _remote_java_reposito def remote_java_repository(name, **kwargs): _remote_java_repository(name, **kwargs) - native.register_toolchains("@" + name + "_toolchain_config_repo//:toolchain") + native.register_toolchains("@" + name + "_toolchain_config_repo//:all")
diff --git a/src/test/java/com/google/devtools/build/android/dexer/BUILD b/src/test/java/com/google/devtools/build/android/dexer/BUILD index 9a29e00b6e149f..ac14ee2489ec0d 100644 --- a/src/test/java/com/google/devtools/build/android/dexer/BUILD +++ b/src/test/java/com/google/devtools/build/android/dexer/BUILD @@ -28,7 +28,7 @@ java_library( ), "//conditions:default": ["NoAndroidSdkStubTest.java"], }), - javacopts = ["-source 7 -target 7"], # we run this through dx for testing, so no lambdas! + javacopts = ["-source 8 -target 8"], resources = ["testresource.txt"], deps = [ "//src/test/java/com/google/devtools/build/lib/testutil", diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 33a37092b279a3..b7459b50939a6d 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -89,11 +89,11 @@ class TestBase(absltest.TestCase): 'remotejdk17_macos_aarch64', 'remotejdk17_win', 'remotejdk17_win_arm64', - 'remotejdk20_linux', - 'remotejdk20_macos', - 'remotejdk20_macos_aarch64', - 'remotejdk20_win', - 'remotejdk20_win_arm64', + 'remotejdk21_linux', + 'remotejdk21_macos', + 'remotejdk21_macos_aarch64', + 'remotejdk21_win', + 'remotejdk21_win_arm64', 'rules_cc', 'rules_java', 'rules_java_builtin_for_testing', diff --git a/src/test/shell/bazel/bazel_java17_test.sh b/src/test/shell/bazel/bazel_java17_test.sh index 3507d089d271b8..a977927e608fb9 100755 --- a/src/test/shell/bazel/bazel_java17_test.sh +++ b/src/test/shell/bazel/bazel_java17_test.sh @@ -173,11 +173,11 @@ EOF bazel build //pkg:Main \ --extra_toolchains=//pkg:java_toolchain_definition \ --java_language_version=17 \ - --java_runtime_version=remotejdk_20 \ + --java_runtime_version=remotejdk_21 \ &>"${TEST_log}" && fail "Expected build to fail" expect_log "error: \[BazelJavaConfiguration\] The Java 17 runtime used to run javac is not " \ - "recent enough to compile for the Java 20 runtime in external/remotejdk20_[a-z0-9]*\. Either " \ + "recent enough to compile for the Java 21 runtime in external/remotejdk21_[a-z0-9]*\. Either " \ "register a Java toolchain with a newer java_runtime or specify a lower " \ "--java_runtime_version\." } @@ -220,11 +220,11 @@ EOF bazel build //pkg:gen \ --extra_toolchains=//pkg:java_toolchain_definition \ --tool_java_language_version=17 \ - --tool_java_runtime_version=remotejdk_20 \ + --tool_java_runtime_version=remotejdk_21 \ &>"${TEST_log}" && fail "Expected build to fail" expect_log "error: \[BazelJavaConfiguration\] The Java 17 runtime used to run javac is not " \ - "recent enough to compile for the Java 20 runtime in external/remotejdk20_[a-z0-9]*\. Either " \ + "recent enough to compile for the Java 21 runtime in external/remotejdk21_[a-z0-9]*\. Either " \ "register a Java toolchain with a newer java_runtime or specify a lower " \ "--tool_java_runtime_version\." } diff --git a/src/test/shell/bazel/bazel_java_test_defaults.sh b/src/test/shell/bazel/bazel_java_test_defaults.sh index 3b91929031a2d7..c97b040aa16466 100755 --- a/src/test/shell/bazel/bazel_java_test_defaults.sh +++ b/src/test/shell/bazel/bazel_java_test_defaults.sh @@ -306,6 +306,52 @@ EOF //pkg:foo_deploy.jar &>"$TEST_log" || fail "Build should succeed" } +function test_java_library_compiles_for_any_platform_with_local_jdk() { + mkdir -p pkg + cat > pkg/BUILD.bazel <<'EOF' +platform(name = "exotic_platform") +java_library( + name = "foo", + srcs = ["Foo.java"], +) +EOF + + cat > pkg/Foo.java <<'EOF' +package com.example; +public class Foo { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} +EOF + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=local_jdk \ + //pkg:foo &>"$TEST_log" || fail "Build should succeed" +} + +function test_java_library_compiles_for_any_platform_with_remote_jdk() { + mkdir -p pkg + cat > pkg/BUILD.bazel <<'EOF' +platform(name = "exotic_platform") +java_library( + name = "foo", + srcs = ["Foo.java"], +) +EOF + + cat > pkg/Foo.java <<'EOF' +package com.example; +public class Foo { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} +EOF + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=remotejdk_11 \ + //pkg:foo &>"$TEST_log" || fail "Build should succeed" +} + function test_non_executable_java_binary_compiles_for_any_platform_with_local_jdk() { mkdir -p pkg cat > pkg/BUILD.bazel <<'EOF' @@ -332,4 +378,89 @@ EOF //pkg:foo_deploy.jar &>"$TEST_log" || fail "Build should succeed" } +function test_non_executable_java_binary_compiles_for_any_platform_with_remote_jdk() { + mkdir -p pkg + cat > pkg/BUILD.bazel <<'EOF' +platform(name = "exotic_platform") +java_binary( + name = "foo", + srcs = ["Foo.java"], + create_executable = False, +) +EOF + + cat > pkg/Foo.java <<'EOF' +package com.example; +public class Foo { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} +EOF + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=remotejdk_11 \ + //pkg:foo &>"$TEST_log" || fail "Build should succeed" + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=remotejdk_11 \ + //pkg:foo_deploy.jar &>"$TEST_log" || fail "Build should succeed" +} + +function test_executable_java_binary_fails_without_runtime_with_local_jdk() { + mkdir -p pkg + cat > pkg/BUILD.bazel <<'EOF' +platform(name = "exotic_platform") +java_binary( + name = "foo", + srcs = ["Foo.java"], + main_class = "com.example.Foo", +) +EOF + + cat > pkg/Foo.java <<'EOF' +package com.example; +public class Foo { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} +EOF + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=local_jdk \ + //pkg:foo &>"$TEST_log" && fail "Build should fail" + expect_log "While resolving toolchains for target //pkg:foo ([0-9a-f]*): No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type" + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=local_jdk \ + //pkg:foo_deploy.jar &>"$TEST_log" && fail "Build should fail" + expect_log "While resolving toolchains for target //pkg:foo_deployjars_internal_rule ([0-9a-f]*): No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type" +} + +function test_executable_java_binary_fails_without_runtime_with_remote_jdk() { + mkdir -p pkg + cat > pkg/BUILD.bazel <<'EOF' +platform(name = "exotic_platform") +java_binary( + name = "foo", + srcs = ["Foo.java"], + main_class = "com.example.Foo", +) +EOF + + cat > pkg/Foo.java <<'EOF' +package com.example; +public class Foo { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} +EOF + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=remotejdk_11 \ + //pkg:foo &>"$TEST_log" && fail "Build should fail" + expect_log "While resolving toolchains for target //pkg:foo ([0-9a-f]*): No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type" + + bazel build --platforms=//pkg:exotic_platform --java_runtime_version=remotejdk_11 \ + //pkg:foo_deploy.jar &>"$TEST_log" && fail "Build should fail" + expect_log "While resolving toolchains for target //pkg:foo_deployjars_internal_rule ([0-9a-f]*): No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type" +} + run_suite "Java toolchains tests, configured using flags or the default_java_toolchain macro." diff --git a/src/test/shell/bazel/bazel_with_jdk_test.sh b/src/test/shell/bazel/bazel_with_jdk_test.sh index 6d1e83a698be5f..bbc44423f9f54d 100755 --- a/src/test/shell/bazel/bazel_with_jdk_test.sh +++ b/src/test/shell/bazel/bazel_with_jdk_test.sh @@ -92,9 +92,10 @@ function set_up() { mkdir -p java/main cat >java/main/BUILD <<EOF -java_library( +java_binary( name = 'JavaExample', srcs = ['JavaExample.java'], + main_class = 'JavaExample', ) EOF diff --git a/src/test/shell/integration/bazel_java_test.sh b/src/test/shell/integration/bazel_java_test.sh index 3ac75a97a9ed02..c72e2b58fa8e4f 100755 --- a/src/test/shell/integration/bazel_java_test.sh +++ b/src/test/shell/integration/bazel_java_test.sh @@ -21,6 +21,10 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CURRENT_DIR}/../integration_test_setup.sh" \ || { echo "integration_test_setup.sh not found!" >&2; exit 1; } +# should match the java_runtime in `_BASE_TOOLCHAIN_CONFIGURATION` in +# `@rules_java//toolchains/default_java_toolchain.bzl` +DEFAULT_JAVA_RUNTIME_VERSION="remotejdk21" + function test_server_javabase() { mkdir -p test_server_javabase/bin MAGIC="the cake is a lie" @@ -71,16 +75,16 @@ EOF # We expect the given host_javabase does not appear in the command line of # java_library actions. bazel aquery --output=text --tool_java_runtime_version='host_javabase' //java:javalib >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" expect_not_log "exec external/host_javabase/bin/java" # If we don't specify anything, we expect the remote JDK to be used. bazel aquery --output=text //java:javalib >& $TEST_log expect_not_log "exec external/embedded_jdk/bin/java" - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" bazel aquery --output=text --java_runtime_version='host_javabase' //java:javalib >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" expect_not_log "exec external/host_javabase/bin/java" } @@ -102,13 +106,13 @@ EOF touch foobar/bin/java bazel aquery --output=text --java_language_version=8 //java:javalib >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" bazel aquery --output=text --java_language_version=11 //java:javalib >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" bazel aquery --output=text --java_language_version=17 //java:javalib >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" } # Javabuilder shall be executed using JDK defined in java_toolchain's java_runtime attribute, not tool_java_runtime. @@ -155,21 +159,21 @@ EOF # We expect the given host_javabase does not appear in the command line of # java_library actions. bazel aquery --output=text --tool_java_runtime_version='host_javabase' 'deps(//java:sample,1)' >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" expect_not_log "exec external/host_javabase/bin/java" # If we don't specify anything, we expect the remote JDK to be used. # Note that this will change in the future but is the current state. bazel aquery --output=text 'deps(//java:sample,1)' >& $TEST_log expect_not_log "exec external/embedded_jdk/bin/java" - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" bazel aquery --output=text --tool_java_runtime_version='host_javabase' 'deps(//java:sample,1)' >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" expect_not_log "exec external/host_javabase/bin/java" bazel aquery --output=text --tool_java_language_version=17 --tool_java_runtime_version='host_javabase' 'deps(//java:sample,1)' >& $TEST_log - expect_log "exec external/rules_java~.*~toolchains~remotejdk17_.*/bin/java" + expect_log "exec external/rules_java~.*~toolchains~${DEFAULT_JAVA_RUNTIME_VERSION}_.*/bin/java" expect_not_log "exec external/host_javabase/bin/java" } diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index c887367d89ec0e..e7795aa3657ce4 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -304,11 +304,11 @@ EOF "remotejdk17_macos_aarch64" "remotejdk17_win" "remotejdk17_win_arm64" - "remotejdk20_linux" - "remotejdk20_macos" - "remotejdk20_macos_aarch64" - "remotejdk20_win" - "remotejdk20_win_arm64" + "remotejdk21_linux" + "remotejdk21_macos" + "remotejdk21_macos_aarch64" + "remotejdk21_win" + "remotejdk21_win_arm64" "rules_cc" "rules_java" "rules_java_builtin_for_testing" diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index c396712279610b..237766b0ae6590 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -13,7 +13,7 @@ "compatibilityMode": "ERROR" }, "localOverrideHashes": { - "bazel_tools": "32c7d903c5371feba2a1ab3f89f649918e55c40be0cff0c1aed01741a613938e" + "bazel_tools": "18ffd442cf258c9048798a0d9bc49bbb06aba5ccb141dd357ce0c13c56f1ae78" }, "moduleDepGraph": { "<root>": { @@ -46,7 +46,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 16, + "line": 17, "column": 29 }, "imports": { @@ -64,7 +64,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 20, + "line": 21, "column": 32 }, "imports": { @@ -81,7 +81,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 23, + "line": 24, "column": 32 }, "imports": { @@ -103,7 +103,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 34, + "line": 35, "column": 39 }, "imports": { @@ -120,7 +120,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 38, + "line": 39, "column": 48 }, "imports": { @@ -137,7 +137,7 @@ "usingModule": "bazel_tools@_", "location": { "file": "@@bazel_tools//:MODULE.bazel", - "line": 41, + "line": 42, "column": 42 }, "imports": { @@ -152,7 +152,7 @@ ], "deps": { "rules_cc": "rules_cc@0.0.9", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "rules_license": "rules_license@0.0.7", "rules_proto": "rules_proto@4.0.0", "rules_python": "rules_python@0.4.0", @@ -226,45 +226,46 @@ } } }, - "rules_java@6.3.1": { + "rules_java@7.0.6": { "name": "rules_java", - "version": "6.3.1", - "key": "rules_java@6.3.1", + "version": "7.0.6", + "key": "rules_java@7.0.6", "repoName": "rules_java", "executionPlatformsToRegister": [], "toolchainsToRegister": [ "//toolchains:all", "@local_jdk//:runtime_toolchain_definition", - "@remotejdk11_linux_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_ppc64le_toolchain_config_repo//:toolchain", - "@remotejdk11_linux_s390x_toolchain_config_repo//:toolchain", - "@remotejdk11_macos_toolchain_config_repo//:toolchain", - "@remotejdk11_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk11_win_toolchain_config_repo//:toolchain", - "@remotejdk11_win_arm64_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_ppc64le_toolchain_config_repo//:toolchain", - "@remotejdk17_linux_s390x_toolchain_config_repo//:toolchain", - "@remotejdk17_macos_toolchain_config_repo//:toolchain", - "@remotejdk17_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk17_win_toolchain_config_repo//:toolchain", - "@remotejdk17_win_arm64_toolchain_config_repo//:toolchain", - "@remotejdk20_linux_toolchain_config_repo//:toolchain", - "@remotejdk20_linux_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk20_macos_toolchain_config_repo//:toolchain", - "@remotejdk20_macos_aarch64_toolchain_config_repo//:toolchain", - "@remotejdk20_win_toolchain_config_repo//:toolchain" + "@local_jdk//:bootstrap_runtime_toolchain_definition", + "@remotejdk11_linux_toolchain_config_repo//:all", + "@remotejdk11_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk11_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk11_linux_s390x_toolchain_config_repo//:all", + "@remotejdk11_macos_toolchain_config_repo//:all", + "@remotejdk11_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk11_win_toolchain_config_repo//:all", + "@remotejdk11_win_arm64_toolchain_config_repo//:all", + "@remotejdk17_linux_toolchain_config_repo//:all", + "@remotejdk17_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk17_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk17_linux_s390x_toolchain_config_repo//:all", + "@remotejdk17_macos_toolchain_config_repo//:all", + "@remotejdk17_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk17_win_toolchain_config_repo//:all", + "@remotejdk17_win_arm64_toolchain_config_repo//:all", + "@remotejdk21_linux_toolchain_config_repo//:all", + "@remotejdk21_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk21_macos_toolchain_config_repo//:all", + "@remotejdk21_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk21_win_toolchain_config_repo//:all" ], "extensionUsages": [ { "extensionBzlFile": "@rules_java//java:extensions.bzl", "extensionName": "toolchains", - "usingModule": "rules_java@6.3.1", + "usingModule": "rules_java@7.0.6", "location": { - "file": "https://bcr.bazel.build/modules/rules_java/6.3.1/MODULE.bazel", - "line": 17, + "file": "https://bcr.bazel.build/modules/rules_java/7.0.6/MODULE.bazel", + "line": 18, "column": 27 }, "imports": { @@ -290,11 +291,11 @@ "remotejdk17_macos_aarch64_toolchain_config_repo": "remotejdk17_macos_aarch64_toolchain_config_repo", "remotejdk17_win_toolchain_config_repo": "remotejdk17_win_toolchain_config_repo", "remotejdk17_win_arm64_toolchain_config_repo": "remotejdk17_win_arm64_toolchain_config_repo", - "remotejdk20_linux_toolchain_config_repo": "remotejdk20_linux_toolchain_config_repo", - "remotejdk20_linux_aarch64_toolchain_config_repo": "remotejdk20_linux_aarch64_toolchain_config_repo", - "remotejdk20_macos_toolchain_config_repo": "remotejdk20_macos_toolchain_config_repo", - "remotejdk20_macos_aarch64_toolchain_config_repo": "remotejdk20_macos_aarch64_toolchain_config_repo", - "remotejdk20_win_toolchain_config_repo": "remotejdk20_win_toolchain_config_repo" + "remotejdk21_linux_toolchain_config_repo": "remotejdk21_linux_toolchain_config_repo", + "remotejdk21_linux_aarch64_toolchain_config_repo": "remotejdk21_linux_aarch64_toolchain_config_repo", + "remotejdk21_macos_toolchain_config_repo": "remotejdk21_macos_toolchain_config_repo", + "remotejdk21_macos_aarch64_toolchain_config_repo": "remotejdk21_macos_aarch64_toolchain_config_repo", + "remotejdk21_win_toolchain_config_repo": "remotejdk21_win_toolchain_config_repo" }, "devImports": [], "tags": [], @@ -315,11 +316,11 @@ "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1", + "name": "rules_java~7.0.6", "urls": [ - "https://github.com/bazelbuild/rules_java/releases/download/6.3.1/rules_java-6.3.1.tar.gz" + "https://github.com/bazelbuild/rules_java/releases/download/7.0.6/rules_java-7.0.6.tar.gz" ], - "integrity": "sha256-EXoSJ82vgTogobunip8tj7MIQQAMM+Ly0qZAvSJMkoI=", + "integrity": "sha256-6B6d6q4NnZnvPdX2wbMjOER/4W1VZBVVMepOt+84hUs=", "strip_prefix": "", "remote_patches": {}, "remote_patch_strip": 0 @@ -481,7 +482,7 @@ "rules_python": "rules_python@0.4.0", "rules_cc": "rules_cc@0.0.9", "rules_proto": "rules_proto@4.0.0", - "rules_java": "rules_java@6.3.1", + "rules_java": "rules_java@7.0.6", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -747,64 +748,80 @@ } } }, - "@rules_java~6.3.1//java:extensions.bzl%toolchains": { + "@rules_java~7.0.6//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "42zU2TJ0nDBFOigt11wj3De2m25mcH3K8SRoG0nGgIA=", + "bzlTransitiveDigest": "MgCo2BSYmyPA2WdKpPo9jP+FL4/VRknyohG5Q/Vm5hY=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { - "remotejdk20_linux": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", + "remotejdk21_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "0386418db7f23ae677d05045d30224094fc13423593ce9cd087d455069893bac", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-linux_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_x64.tar.gz" - ] + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\n" } }, "remotejdk17_linux_s390x_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" } }, "remotejdk17_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\n" } }, "remotejdk17_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "2a7a99a3ea263dbd8d32a67d1e6e363ba8b25c645c826f5e167a02bbafaff1fa", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz" + ] } }, "remotejdk17_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" } }, "remotejdk17_macos_aarch64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "515dd56ec99bb5ae8966621a2088aadfbe72631818ffbba6e4387b7ee292ab09", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-macosx_aarch64", "urls": [ @@ -817,11 +834,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_windows", - "sha256": "bae6a03b5aeead5804ba7bcdcc8b14ec3ed05b37f3db5519f788ab060bc53b05", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_windows", + "sha256": "0224bb368b98f14d97afb749f3f956a177b60f753213b6c57db16deb2706c5dc", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_windows-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_windows-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_windows-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_windows-v13.0.zip" ] } }, @@ -829,49 +846,35 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "a106c77389a63b6bd963a087d5f01171bd32aa3ee7377ecef87531390dcb9050", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-win_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-win_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-win_x64.zip", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-win_x64.zip" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip" ] } }, "remotejdk11_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" - } - }, - "remotejdk20_win": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "ac5f6a7d84dbbb0bb4d376feb331cc4c49a9920562f2a5e85b7a6b4863b10e1e", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-win_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-win_x64.zip", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-win_x64.zip" - ] + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" } }, "remotejdk11_linux_aarch64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "fc7c41a0005180d4ca471c90d01e049469e0614cf774566d4cf383caa29d1a97", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-linux_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_aarch64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu-embedded/bin/zulu11.56.19-ca-jdk11.0.15-linux_aarch64.tar.gz", - "https://cdn.azul.com/zulu-embedded/bin/zulu11.56.19-ca-jdk11.0.15-linux_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz" ] } }, @@ -879,8 +882,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "20c91a922eec795f3181eaa70def8b99d8eac56047c9a14bfb257c85b991df1b", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-linux_x64", "urls": [ @@ -890,40 +893,32 @@ } }, "remotejdk11_linux_s390x_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" - } - }, - "remotejdk20_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" } }, "remotejdk11_linux_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" } }, "remotejdk11_macos": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "2614e5c5de8e989d4d81759de4c333aa5b867b17ab9ee78754309ba65c7f6f55", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-macosx_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_x64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz" ] } }, @@ -931,8 +926,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_arm64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", "strip_prefix": "jdk-11.0.13+8", "urls": [ @@ -944,8 +939,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "e6317cee4d40995f0da5b702af3f04a6af2bbd55febf67927696987d11113b53", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-macosx_x64", "urls": [ @@ -954,34 +949,42 @@ ] } }, - "remotejdk17_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_macos_aarch64": { + "remotejdk21_macos": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "a2eff6a940c2df3a2352278027e83f5959f34dcfc8663034fe92be0f1b91ce6f", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-macosx_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "9639b87db586d0c89f7a9892ae47f421e442c64b97baebdff31788fbe23265bd", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz" ] } }, + "remotejdk21_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" + } + }, "remotejdk17_win": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "9972c5b62a61b45785d3d956c559e079d9e91f144ec46225f5deeda214d48f27", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-win_x64", "urls": [ @@ -991,47 +994,89 @@ } }, "remotejdk11_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" } }, "remotejdk11_linux_ppc64le_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk21_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "0c0eadfbdc47a7ca64aeab51b9c061f71b6e4d25d2d87674512e9b6387e9e3a6", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz" + ] } }, "remote_java_tools_linux": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_linux", - "sha256": "a346b9a291b6db1bb06f7955f267e47522d99963fe14e337da1d75d125a8599f", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_linux", + "sha256": "f950ecc09cbc2ca110016095fe2a46e661925115975c84039f4370db1e70fe27", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_linux-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_linux-v13.0.zip" + ] + } + }, + "remotejdk21_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "e9959d500a0d9a7694ac243baf657761479da132f0f94720cbffd092150bd802", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip" + ] + } + }, + "remotejdk21_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "1fb64b8036c5d463d8ab59af06bf5b6b006811e6012e3b0eb6bccf57f1c55835", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_aarch64", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_linux-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_linux-v12.7.zip" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz" ] } }, "remotejdk11_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" } }, "remotejdk11_linux_s390x": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_s390x", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", "strip_prefix": "jdk-11.0.15+10", "urls": [ @@ -1044,8 +1089,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "dbc6ae9163e7ff469a9ab1f342cd1bc1f4c1fb78afc3c4f2228ee3b32c4f3e43", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-linux_aarch64", "urls": [ @@ -1055,49 +1100,49 @@ } }, "remotejdk17_win_arm64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_arm64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" } }, "remotejdk11_linux": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "e064b61d93304012351242bf0823c6a2e41d9e28add7ea7f05378b7243d34247", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-linux_x64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_x64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz" ] } }, "remotejdk11_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" } }, "remotejdk17_linux_ppc64le_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" } }, "remotejdk17_win_arm64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_arm64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "bc3476f2161bf99bc9a243ff535b8fc033b34ce9a2fa4b62fb8d79b6bfdc427f", "strip_prefix": "zulu17.38.21-ca-jdk17.0.5-win_aarch64", "urls": [ @@ -1110,11 +1155,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_darwin_arm64", - "sha256": "ecedf6305768dfd51751d0ad732898af092bd7710d497c6c6c3214af7e49395f", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_darwin_arm64", + "sha256": "1ecd91bf870b4f246960c11445218798113b766762e26a3de09cfcf3e9b4c646", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_darwin_arm64-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_darwin_arm64-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_darwin_arm64-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_darwin_arm64-v13.0.zip" ] } }, @@ -1122,8 +1167,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_ppc64le", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "cbedd0a1428b3058d156e99e8e9bc8769e0d633736d6776a4c4d9136648f2fd1", "strip_prefix": "jdk-17.0.4.1+1", "urls": [ @@ -1132,93 +1177,41 @@ ] } }, - "remotejdk20_macos_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_macos//:jdk\",\n)\n" - } - }, - "remotejdk20_macos_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "remotejdk21_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_macos_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_win//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk21_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\n" } }, "remotejdk11_win_arm64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_win_arm64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk11_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" } }, "local_jdk": { - "bzlFile": "@@rules_java~6.3.1//toolchains:local_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:local_java_repository.bzl", "ruleClassName": "_local_java_repository_rule", "attributes": { - "name": "rules_java~6.3.1~toolchains~local_jdk", + "name": "rules_java~7.0.6~toolchains~local_jdk", "java_home": "", "version": "", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = {RUNTIME_VERSION},\n)\n" - } - }, - "remotejdk20_linux_aarch64_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", - "ruleClassName": "_toolchain_config", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_aarch64_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_20\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"20\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk20_linux_aarch64//:jdk\",\n)\n" - } - }, - "remotejdk20_macos": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_macos", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "fde6cc17a194ea0d9b0c6c0cb6178199d8edfc282d649eec2c86a9796e843f86", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-macosx_x64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_x64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-macosx_x64.tar.gz" - ] + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = {RUNTIME_VERSION},\n)\n" } }, "remote_java_tools_darwin_x86_64": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools_darwin_x86_64", - "sha256": "e116c649c0355ab57ffcc870ce1139e5e1528cabac458bd50263d2b84ea4ffb2", + "name": "rules_java~7.0.6~toolchains~remote_java_tools_darwin_x86_64", + "sha256": "3edf102f683bfece8651f206aee864628825b4f6e614d183154e6bdf98b8c494", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools_darwin_x86_64-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools_darwin_x86_64-v12.7.zip" - ] - } - }, - "remotejdk20_linux_aarch64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk20_linux_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 20,\n)\n", - "sha256": "47ce58ead9a05d5d53b96706ff6fa0eb2e46755ee67e2b416925e28f5b55038a", - "strip_prefix": "zulu20.28.85-ca-jdk20.0.0-linux_aarch64", - "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu20.28.85-ca-jdk20.0.0-linux_aarch64.tar.gz" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools_darwin_x86_64-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools_darwin_x86_64-v13.0.zip" ] } }, @@ -1226,11 +1219,11 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remote_java_tools", - "sha256": "aa11ecd5fc0af2769f0f2bdd25e2f4de7c1291ed24326fb23fa69bdd5dcae2b5", + "name": "rules_java~7.0.6~toolchains~remote_java_tools", + "sha256": "610e40b1a89c9941638e33c56cf1be58f2d9d24cf9ac5a34b63270e08bb7000a", "urls": [ - "https://mirror.bazel.build/bazel_java_tools/releases/java/v12.7/java_tools-v12.7.zip", - "https://github.com/bazelbuild/java_tools/releases/download/java_v12.7/java_tools-v12.7.zip" + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.0/java_tools-v13.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.0/java_tools-v13.0.zip" ] } }, @@ -1238,8 +1231,8 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_linux_s390x", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 17,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk17_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", "sha256": "fdc82f4b06c880762503b0cb40e25f46cf8190d06011b3b768f4091d3334ef7f", "strip_prefix": "jdk-17.0.4.1+1", "urls": [ @@ -1249,19 +1242,19 @@ } }, "remotejdk17_win_toolchain_config_repo": { - "bzlFile": "@@rules_java~6.3.1//toolchains:remote_java_repository.bzl", + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", "ruleClassName": "_toolchain_config", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk17_win_toolchain_config_repo", - "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" + "name": "rules_java~7.0.6~toolchains~remotejdk17_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" } }, "remotejdk11_linux_ppc64le": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_linux_ppc64le", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", + "name": "rules_java~7.0.6~toolchains~remotejdk11_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", "sha256": "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", "strip_prefix": "jdk-11.0.15+10", "urls": [ @@ -1274,15 +1267,23 @@ "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "rules_java~6.3.1~toolchains~remotejdk11_macos_aarch64", - "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n version = 11,\n)\n", - "sha256": "6bb0d2c6e8a29dcd9c577bbb2986352ba12481a9549ac2c0bcfd00ed60e538d2", - "strip_prefix": "zulu11.56.19-ca-jdk11.0.15-macosx_aarch64", + "name": "rules_java~7.0.6~toolchains~remotejdk11_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64", "urls": [ - "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_aarch64.tar.gz", - "https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_aarch64.tar.gz" + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz" ] } + }, + "remotejdk21_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.0.6//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.0.6~toolchains~remotejdk21_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\n" + } } } }
train
test
2023-10-19T20:44:55
2022-12-29T06:21:31Z
jlaxson
test
bazelbuild/bazel/20000_20018
bazelbuild/bazel
bazelbuild/bazel/20000
bazelbuild/bazel/20018
[ "keyword_pr_to_issue" ]
1ccd9ccd3f99ccdc7f718dafb82182e1dd82ba13
843ac0093f72e1c4f34412ddd8e454322521b997
[ "@bazel-io flag", "CC @meteorcloudy @Wyverald ", "I think I have a fix for this, will submit it soon.", "@bazel-io fork 7.0.0", "Congrats on winning the 20k issue/pr number! 🎉 😄", "A fix for this issue has been included in [Bazel 7.0.0 RC5](https://releases.bazel.build/7.0.0/rc5/index.html). Please test...
[]
2023-11-01T19:59:01Z
[ "type: bug", "team-Rules-Java", "untriaged" ]
[7.0.0rc2 regression] Can't load from `@bazel_tools//tools/jdk` `.bzl` files from module extension
### Description of the bug: When a module extension used with `use_extension` transitively loads from a `.bzl` file in `@bazel_tools//tools/jdk`, the load fails since `@bazel_tools` forwards to `@rules_java`, but [uses an empty repo mapping for `load`s](https://github.com/bazelbuild/bazel/blob/835512a65e97f77101af5411897a3371ec6df3fe/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java#L947-L953). This wasn't an issue before https://github.com/bazelbuild/bazel/commit/3029a7db8a877e8a616b2ebe304573fae9ea9962, where `@bazel_tools` did not load from an external repo. ### Which category does this issue belong to? External Dependency ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. In a `.bzl` file containing a module extension, transitively `load` from e.g. `@bazel_tools//tools/jdk:toolchain_utils.bzl`. Concretely, I noticed this while working on Bzlmodifying the deps of `bazel_jar_jar` in https://github.com/bazeltools/bazel_jar_jar/blob/main/jar_jar.bzl, which transitively loads `find_java_toolchain`. ### Which operating system are you running Bazel on? _No response_ ### What is the output of `bazel info release`? _No response_ ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. 3029a7db8a877e8a616b2ebe304573fae9ea9962 ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java" ]
[ "src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java" ]
[ "src/test/py/bazel/bzlmod/bazel_module_test.py" ]
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java index a1b882aab2100f..6b285c7375edb9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BzlLoadFunction.java @@ -622,6 +622,10 @@ private static boolean requiresBuiltinsInjection(BzlLoadValue.Key key) { || (key instanceof BzlLoadValue.KeyForBzlmod && !isFileSafeForUninjectedEvaluation(key)); } + private static final PackageIdentifier BAZEL_TOOLS_BOOTSTRAP_RULES_PACKAGE = + PackageIdentifier.create( + RepositoryName.BAZEL_TOOLS, PathFragment.create("tools/build_defs/repo")); + private static boolean isFileSafeForUninjectedEvaluation(BzlLoadValue.Key key) { // We don't inject _builtins for repo rules to avoid a Skyframe cycle. // The cycle is caused only with bzlmod because the `@_builtins` repo does not declare its own @@ -629,9 +633,7 @@ private static boolean isFileSafeForUninjectedEvaluation(BzlLoadValue.Key key) { // Bazel module resolution, and if there are any non-registry overrides in the root MODULE.bazel // file (such as `git_override` or `archive_override`), the corresponding bzl files will be // evaluated. - return PackageIdentifier.create( - RepositoryName.BAZEL_TOOLS, PathFragment.create("tools/build_defs/repo")) - .equals(key.getLabel().getPackageIdentifier()); + return key.getLabel().getPackageIdentifier().equals(BAZEL_TOOLS_BOOTSTRAP_RULES_PACKAGE); } /** @@ -944,12 +946,12 @@ private static RepositoryMapping getRepositoryMapping( } if (key instanceof BzlLoadValue.KeyForBzlmod) { - if (repoName.equals(RepositoryName.BAZEL_TOOLS)) { - // Special case: we're only here to get the @bazel_tools repo (for example, for - // http_archive). This repo shouldn't have visibility into anything else (during repo - // generation), so we just return an empty repo mapping. - // TODO(wyv): disallow fallback. - return RepositoryMapping.ALWAYS_FALLBACK; + if (key.getLabel().getPackageIdentifier().equals(BAZEL_TOOLS_BOOTSTRAP_RULES_PACKAGE)) { + // Special case: we're only here to get one of the rules in the @bazel_tools repo that + // load Bazel modules. At this point we can't load from any other modules and thus use a + // repository mapping that contains only @bazel_tools itself. + return RepositoryMapping.create( + ImmutableMap.of("bazel_tools", RepositoryName.BAZEL_TOOLS), RepositoryName.BAZEL_TOOLS); } if (repoName.isMain()) { // Special case: when we try to run an extension in the main repo, we need to grab the repo
diff --git a/src/test/py/bazel/bzlmod/bazel_module_test.py b/src/test/py/bazel/bzlmod/bazel_module_test.py index 42cef63678125d..bbb66e13121ad0 100644 --- a/src/test/py/bazel/bzlmod/bazel_module_test.py +++ b/src/test/py/bazel/bzlmod/bazel_module_test.py @@ -755,6 +755,36 @@ def testLocationNonRegistry(self): _, _, stderr = self.RunBazel(['build', '@what'], allow_failure=True) self.assertIn('ERROR: @@hello~override//:MODULE.bazel', '\n'.join(stderr)) + def testLoadRulesJavaSymbolThroughBazelTools(self): + """Tests that loads from @bazel_tools that delegate to other modules resolve.""" + self.ScratchFile( + 'MODULE.bazel', + [ + 'ext = use_extension("//:ext.bzl", "ext")', + 'use_repo(ext, "data")', + ], + ) + self.ScratchFile('BUILD') + self.ScratchFile( + 'ext.bzl', + [ + ( + "load('@bazel_tools//tools/jdk:toolchain_utils.bzl'," + " 'find_java_toolchain')" + ), + 'def _repo_impl(ctx):', + " ctx.file('WORKSPACE')", + " ctx.file('BUILD', 'exports_files([\"data.txt\"])')", + " ctx.file('data.txt', 'hi')", + 'repo = repository_rule(implementation = _repo_impl)', + 'def _ext_impl(ctx):', + " repo(name='data')", + 'ext = module_extension(implementation = _ext_impl)', + ], + ) + + self.RunBazel(['build', '@data//:data.txt']) + if __name__ == '__main__': absltest.main()
train
test
2023-11-01T19:08:34
2023-10-31T11:47:07Z
fmeum
test
bazelbuild/bazel/19952_20021
bazelbuild/bazel
bazelbuild/bazel/19952
bazelbuild/bazel/20021
[ "keyword_pr_to_issue" ]
13ea6b4e1da341863d5af4588cc0961aedac1276
8f44ab78be47eed67ba02f2a6034c496c855b229
[ "@SalmaSamy @meteorcloudy ", "I'm going to preemptively mark this as a release blocker. 3x slowdown is unacceptable", "@bazel-io fork 7.0.0", "@purkhusid Could you share the output of `bazel info` after each of these builds?", "With `lockfile_mode=off` (25s runtime):\r\n```\r\nbazel-bin: /workspaces/bazel_o...
[]
2023-11-02T04:40:59Z
[ "type: bug", "P1", "team-ExternalDeps", "area-Bzlmod" ]
Analysis performance regression when lockfile is enabled
### Description of the bug: While migrating our repo to bzlmod we encountered an 3x slowdown in analysis when using bzlmod. Looking further into it it seems like it's caused by the newly introduced lockfile because the performance returns back to normal when `--lockfile_mode=off` is set. I can unfortunately not share an reproduction since the repo is private. The repo is using MODULE.bazel and WORKSPACE.bzlmod since not all of our external deps have been migrated to bzlmod. I'll share a profile with and without the lockfile: [timing_profile_with_lockfile.gz](https://github.com/bazelbuild/bazel/files/13175335/timing_profile_with_lockfile.gz) [timing_profile_without_lockfile.gz](https://github.com/bazelbuild/bazel/files/13175338/timing_profile_without_lockfile.gz) Tagging @fmeum and @Wyverald since I had talked to them on Slack ### Which operating system are you running Bazel on? Linux Fedora 38 ### What is the output of `bazel info release`? release 7.0.0rc2
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java", "src/main/java/com/google/devtools/build/lib/events/Reportable.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java", "src/main/java/com/google/devtools/build/lib/events/Reportable.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java index b2e0f6f3a5b40f..cd9c1e6d5bcddf 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelModuleResolutionEvent.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.bazel.bzlmod; -import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableTable; import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable; @@ -22,20 +21,39 @@ * After resolving bazel module this event is sent from {@link BazelDepGraphFunction} holding the * lockfile value with module updates, and the module extension usages. It will be received in * {@link BazelLockFileModule} to be used to update the lockfile content + * + * <p>Instances of this class are retained in Skyframe nodes and subject to frequent {@link + * java.util.Set}-based deduplication. As such, it <b>must</b> have a cheap implementation of {@link + * #hashCode()} and {@link #equals(Object)}. It currently uses reference equality since the logic + * that creates instances of this class already ensures that there is only one instance per build. */ -@AutoValue -public abstract class BazelModuleResolutionEvent implements Postable { +public final class BazelModuleResolutionEvent implements Postable { + + private final BazelLockFileValue lockfileValue; + private final ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> + extensionUsagesById; + + private BazelModuleResolutionEvent( + BazelLockFileValue lockfileValue, + ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> extensionUsagesById) { + this.lockfileValue = lockfileValue; + this.extensionUsagesById = extensionUsagesById; + } public static BazelModuleResolutionEvent create( BazelLockFileValue lockFileValue, ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> extensionUsagesById) { - return new AutoValue_BazelModuleResolutionEvent(lockFileValue, extensionUsagesById); + return new BazelModuleResolutionEvent(lockFileValue, extensionUsagesById); } - public abstract BazelLockFileValue getLockfileValue(); + public BazelLockFileValue getLockfileValue() { + return lockfileValue; + } - public abstract ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> - getExtensionUsagesById(); + public ImmutableTable<ModuleExtensionId, ModuleKey, ModuleExtensionUsage> + getExtensionUsagesById() { + return extensionUsagesById; + } @Override public boolean storeForReplay() { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java index 6b93cc4e77332a..893608bef70afe 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionResolutionEvent.java @@ -14,30 +14,53 @@ package com.google.devtools.build.lib.bazel.bzlmod; -import com.google.auto.value.AutoValue; import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable; /** * After evaluating any module extension this event is sent from {@link SingleExtensionEvalFunction} * holding the extension id and the resolution data LockFileModuleExtension. It will be received in - * {@link BazelLockFileModule} to be used to update the lockfile content + * {@link BazelLockFileModule} to be used to update the lockfile content. + * + * <p>Instances of this class are retained in Skyframe nodes and subject to frequent {@link + * java.util.Set}-based deduplication. As such, it <b>must</b> have a cheap implementation of {@link + * #hashCode()} and {@link #equals(Object)}. It currently uses reference equality since the logic + * that creates instances of this class already ensures that there is only one instance per + * extension id. */ -@AutoValue -public abstract class ModuleExtensionResolutionEvent implements Postable { +public final class ModuleExtensionResolutionEvent implements Postable { + + private final ModuleExtensionId extensionId; + private final ModuleExtensionEvalFactors extensionFactors; + private final LockFileModuleExtension moduleExtension; + + private ModuleExtensionResolutionEvent( + ModuleExtensionId extensionId, + ModuleExtensionEvalFactors extensionFactors, + LockFileModuleExtension moduleExtension) { + this.extensionId = extensionId; + this.extensionFactors = extensionFactors; + this.moduleExtension = moduleExtension; + } public static ModuleExtensionResolutionEvent create( ModuleExtensionId extensionId, ModuleExtensionEvalFactors extensionFactors, LockFileModuleExtension lockfileModuleExtension) { - return new AutoValue_ModuleExtensionResolutionEvent( + return new ModuleExtensionResolutionEvent( extensionId, extensionFactors, lockfileModuleExtension); } - public abstract ModuleExtensionId getExtensionId(); + public ModuleExtensionId getExtensionId() { + return extensionId; + } - public abstract ModuleExtensionEvalFactors getExtensionFactors(); + public ModuleExtensionEvalFactors getExtensionFactors() { + return extensionFactors; + } - public abstract LockFileModuleExtension getModuleExtension(); + public LockFileModuleExtension getModuleExtension() { + return moduleExtension; + } @Override public boolean storeForReplay() { diff --git a/src/main/java/com/google/devtools/build/lib/events/Reportable.java b/src/main/java/com/google/devtools/build/lib/events/Reportable.java index 4601fc4ef172c1..cf8f757c5a665c 100644 --- a/src/main/java/com/google/devtools/build/lib/events/Reportable.java +++ b/src/main/java/com/google/devtools/build/lib/events/Reportable.java @@ -47,6 +47,9 @@ public interface Reportable { * * <p>This method is not relevant for events which do not originate from {@link * com.google.devtools.build.skyframe.SkyFunction} evaluation. + * + * <p>Classes returning {@code true} should have cheap {@link Object#hashCode()} and {@link + * Object#equals(Object)} implementations. */ default boolean storeForReplay() { return false;
null
test
test
2023-11-01T22:14:29
2023-10-26T09:06:40Z
purkhusid
test
bazelbuild/bazel/19937_20022
bazelbuild/bazel
bazelbuild/bazel/19937
bazelbuild/bazel/20022
[ "keyword_pr_to_issue" ]
8f44ab78be47eed67ba02f2a6034c496c855b229
f71be9c7ade3081e95b2bd8319fbf7c459bfe997
[ "I also think that this should be solved in 7.0 since this will make migrations to bzlmod more painful.", "Exposing the repo mapping on `FilesToRunProvider` seems very low risk to me, but only allows you to get the repo mapping for existing executable targets, not arbitrary collections of runfiles. When packaging...
[]
2023-11-02T04:53:08Z
[ "type: feature request", "untriaged", "team-Rules-API" ]
Allow access or generation of repo mapping files in Starlark
### Description of the feature request: There is currently no way to access the repo mapping file in Starlark. This causes problems when you need to make an binary that uses a runfiles libraries runnable outside of Bazel e.g. in an container or if you just want to package the binary in some way. To make the binary runnable outside of bazel the `.repo_mapping` file is required so that runfiles lookups don't fail. That means that there needs to be an way to either generate or copy the `.repo_mapping` file in starlark so that e.g. a tar rule can list the repo mapping file in it's inputs. There is currently an workaround for this for Python zip that is not available to others: https://github.com/bazelbuild/bazel/commit/4e60992432a49dda255eb005544ae8c03b30e243#diff-06b3fa5571583c2c73ec269859f1b9194038c26cc6c0e9c8897f53b992731658R382 This API could be publicly exposed or if it's possible the repo mapping could be exposed on the `FilesToRunProvider` like the runfiles manifest is exposed today. Tagging @fmeum and @Wyverald since there is some context in a couple of Slack threads that they were part of: https://bazelbuild.slack.com/archives/C014RARENH0/p1698153613312699 https://bazelbuild.slack.com/archives/CA3NW13MH/p1697050350018059?thread_ts=1697034827.979009&cid=CA3NW13MH ### Which category does this issue belong to? Rules API
[ "src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java", "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java" ]
[ "src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java", "src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java" ]
[ "src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java index ee5a12ae32a568..f07c201aede21a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java @@ -95,6 +95,13 @@ public final Artifact getRunfilesManifest() { return runfilesSupport != null ? runfilesSupport.getRunfilesManifest() : null; } + @Nullable + @Override + public Artifact getRepoMappingManifest() { + var runfilesSupport = getRunfilesSupport(); + return runfilesSupport != null ? runfilesSupport.getRepoMappingManifest() : null; + } + /** Returns a {@link RunfilesSupplier} encapsulating runfiles for this tool. */ public final RunfilesSupplier getRunfilesSupplier() { return firstNonNull(getRunfilesSupport(), EmptyRunfilesSupplier.INSTANCE); diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java index 7dab417d98e9e4..5c0006bf053905 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/FilesToRunProviderApi.java @@ -39,4 +39,12 @@ public interface FilesToRunProviderApi<FileT extends FileApi> extends StarlarkVa allowReturnNones = true) @Nullable FileT getRunfilesManifest(); + + @StarlarkMethod( + name = "repo_mapping_manifest", + doc = "The repo mapping manifest or None if it does not exist.", + structField = true, + allowReturnNones = true) + @Nullable + FileT getRepoMappingManifest(); }
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java index e7949ebee49215..21cd1832c3ba50 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesRepoMappingManifestTest.java @@ -391,6 +391,32 @@ public void hasMappingForSymlinks() throws Exception { .inOrder(); } + @Test + public void repoMappingOnFilesToRunProvider() throws Exception { + scratch.overwriteFile("MODULE.bazel", "bazel_dep(name='bare_rule',version='1.0')"); + scratch.overwriteFile( + "defs.bzl", + "def _get_repo_mapping_impl(ctx):", + " files_to_run = ctx.attr.bin[DefaultInfo].files_to_run", + " return [", + " DefaultInfo(files = depset([files_to_run.repo_mapping_manifest])),", + " ]", + "get_repo_mapping = rule(", + " implementation = _get_repo_mapping_impl,", + " attrs = {'bin':attr.label(cfg='target',executable=True)}", + ")"); + scratch.overwriteFile( + "BUILD", + "load('@bare_rule//:defs.bzl', 'bare_binary')", + "load('//:defs.bzl', 'get_repo_mapping')", + "bare_binary(name='aaa')", + "get_repo_mapping(name='get_repo_mapping', bin=':aaa')"); + invalidatePackages(); + + assertThat(getFilesToBuild(getConfiguredTarget("//:get_repo_mapping")).toList()) + .containsExactly(getRunfilesSupport("//:aaa").getRepoMappingManifest()); + } + /** * Similar to {@link BuildViewTestCase#rewriteWorkspace(String...)}, but does not call {@link * BuildViewTestCase#invalidatePackages()}.
val
test
2023-11-02T11:12:04
2023-10-25T09:38:38Z
purkhusid
test
bazelbuild/bazel/20081_20134
bazelbuild/bazel
bazelbuild/bazel/20081
bazelbuild/bazel/20134
[ "keyword_pr_to_issue" ]
06352cb0a4d21df26d975ca595f2c7a7a6df9137
86fe599f7fc67d09c2f9ab4ef0c177a0fb8445f7
[ "Which commands besides `build` (and its logical descendents, like `test` and `cquery`) do you think need support for `--flag_alias`?", "> Which commands besides `build` (and its logical descendents, like `test` and `cquery`) do you think need support for `--flag_alias`?\r\n\r\nFor our use case, none and I'm not ...
[]
2023-11-10T05:50:42Z
[ "type: feature request", "P2", "team-Configurability" ]
`common` does not work with `flag_alias`
### Description of the bug: Using the new `common` in a .bazelrc with `flag_alias` returns the following error: ```sh ERROR: /Users/<user>/Development/cash-ios/.bazelrc: "common --flag_alias=build_config=//:build_config" disallowed. --flag_alias only supports the "build" command. ``` ### Which category does this issue belong to? CLI, Configurability ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. - Create a custom `config_setting` - Create a .bazelrc - Attempt to add a flag alias with the `common` command ```bzl common --flag_alias=release_variant=//:release_variant ``` ### Which operating system are you running Bazel on? macOS ### What is the output of `bazel info release`? release 6.3.2 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? Not entirely sure if this is expected but it feels like its not given how `common` works for other flags.
[ "src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java" ]
[ "src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java" ]
[ "src/test/shell/integration/starlark_configurations_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java index 4756e023ff7387..9c862cb7019863 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java @@ -87,6 +87,10 @@ public final class BlazeOptionHandler { // being ignored as long as they are recognized by at least one (other) command. private static final String COMMON_PSEUDO_COMMAND = "common"; + private static final String BUILD_COMMAND = "build"; + private static final ImmutableSet<String> BUILD_COMMAND_ANCESTORS = + ImmutableSet.of(BUILD_COMMAND, COMMON_PSEUDO_COMMAND, ALWAYS_PSEUDO_COMMAND); + // Marks an event to indicate a parsing error. static final String BAD_OPTION_TAG = "invalidOption"; // Separates the invalid tag from the full error message for easier parsing. @@ -611,12 +615,16 @@ static ListMultimap<String, RcChunkOfArgs> structureRcOptionsAndConfigs( // In production, "build" is always a valid command, but not necessarily in tests. // Particularly C0Command, which some tests use for low-level options parsing logic. We // don't want to interfere with those. - && validCommands.contains("build") - && !override.command.equals("build")) { + && validCommands.contains(BUILD_COMMAND) + && !BUILD_COMMAND_ANCESTORS.contains(override.command)) { throw new OptionsParsingException( String.format( - "%s: \"%s %s\" disallowed. --%s only supports the \"build\" command.", - rcFile, override.command, override.option, Converters.BLAZE_ALIASING_FLAG)); + "%s: \"%s %s\" disallowed. --%s only supports these commands: %s", + rcFile, + override.command, + override.option, + Converters.BLAZE_ALIASING_FLAG, + String.join(", ", BUILD_COMMAND_ANCESTORS))); } String command = override.command; int index = command.indexOf(':');
diff --git a/src/test/shell/integration/starlark_configurations_test.sh b/src/test/shell/integration/starlark_configurations_test.sh index b5ad195218098a..3cad6b08857c01 100755 --- a/src/test/shell/integration/starlark_configurations_test.sh +++ b/src/test/shell/integration/starlark_configurations_test.sh @@ -640,6 +640,19 @@ function test_rc_flag_alias_canonicalizes() { expect_log "--//$pkg:type=coffee" } +function test_rc_flag_alias_supported_under_common_command() { + local -r pkg=$FUNCNAME + mkdir -p $pkg + + add_to_bazelrc "common --flag_alias=drink=//$pkg:type" + write_build_setting_bzl + + bazel canonicalize-flags -- --drink=coffee \ + >& "$TEST_log" || fail "Expected success" + + bazel build //$pkg:my_drink >& "$TEST_log" || fail "Expected success" +} + function test_rc_flag_alias_unsupported_under_test_command() { local -r pkg=$FUNCNAME mkdir -p $pkg @@ -650,11 +663,11 @@ function test_rc_flag_alias_unsupported_under_test_command() { bazel canonicalize-flags -- --drink=coffee \ >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias=drink=//$pkg:type\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" bazel build //$pkg:my_drink >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias=drink=//$pkg:type\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" # Post-test cleanup_workspace() calls "bazel clean", which would also fail # unless we reset the bazelrc. @@ -671,11 +684,11 @@ function test_rc_flag_alias_unsupported_under_conditional_build_command() { bazel canonicalize-flags -- --drink=coffee \ >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias=drink=//$pkg:type\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" bazel build //$pkg:my_drink >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias=drink=//$pkg:type\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" # Post-test cleanup_workspace() calls "bazel clean", which would also fail # unless we reset the bazelrc. @@ -692,11 +705,11 @@ function test_rc_flag_alias_unsupported_with_space_assignment_syntax() { bazel canonicalize-flags -- --drink=coffee \ >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" bazel build //$pkg:my_drink >& "$TEST_log" && fail "Expected failure" expect_log "--flag_alias\" disallowed. --flag_alias only "\ -"supports the \"build\" command." +"supports these commands: build, common, always" # Post-test cleanup_workspace() calls "bazel clean", which would also fail # unless we reset the bazelrc.
train
test
2023-11-10T15:06:10
2023-11-07T16:48:34Z
luispadron
test
bazelbuild/bazel/19915_20136
bazelbuild/bazel
bazelbuild/bazel/19915
bazelbuild/bazel/20136
[ "keyword_pr_to_issue" ]
92beb02436315896e4cb69362f00c78ff1471555
fe85936f7d38c4a279eec78eee7371b37f800000
[ "@lberki I created this issue to get downstream coverage. Assuming CI is green, would you support flipping this for 7.0.0?", "Flipping this flag SGTM. It looks like the incompatible changes pipeline didn't find any incompatibilities." ]
[]
2023-11-10T09:50:42Z
[ "type: process", "incompatible-change", "team-Local-Exec", "migration-ready", "breaking-change-7.0" ]
incompatible_sandbox_hermetic_tmp
Historically, on Linux, Bazel mounted the host machine's `/tmp` directory into each sandbox as `/tmp`. Since each sandbox maintains its own PID namespace, this [causes problems](https://github.com/bazelbuild/bazel/issues/3236) with actions that create files in `/tmp` using only the PID as a distinguishing element of the filename, e.g. well-known sockets. With `--incompatible_sandbox_hermetic_tmp`, Bazel creates and later cleans up a dedicated, initially empty temporary directory for each sandboxed action on Linux. **Migration:** If any actions in your build depend on access to the host's `/tmp` directory, for example to exchange data with non-hermetic daemons running on the host, you can either temporarily disable this new behavior via `--noincompatible_sandbox_hermetic_tmp` (not recommended as the flag will be removed in the future) or explicitly mount the host temporary directory via `--sandbox_add_mount_pair=/tmp`.
[ "src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java" ]
[ "src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java" ]
[ "src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java", "src/test/shell/bazel/bazel_sandboxing_networking_test.sh", "src/test/shell/integration/execution_strategies_test.sh", "src/test/shell/integration/sandboxing_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java index 768c07511fd795..8833e8615d53a3 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxOptions.java @@ -350,12 +350,12 @@ public ImmutableSet<Path> getInaccessiblePaths(FileSystem fs) { @Option( name = "incompatible_sandbox_hermetic_tmp", - defaultValue = "false", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.EXECUTION_STRATEGY, effectTags = {OptionEffectTag.EXECUTION}, help = "If set to true, each Linux sandbox will have its own dedicated empty directory mounted" - + " as /tmp rather thansharing /tmp with the host filesystem. Use" + + " as /tmp rather than sharing /tmp with the host filesystem. Use" + " --sandbox_add_mount_pair=/tmp to keep seeing the host's /tmp in all sandboxes.") public boolean sandboxHermeticTmp;
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java b/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java index e7b1dc8a677bbc..b5d194d86c2db4 100644 --- a/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildtool/EditDuringBuildTest.java @@ -44,9 +44,8 @@ public void testEditDuringBuild() throws Exception { Path in = write("edit/in", "line1"); in.setLastModifiedTime(123456789); - // Make in writable from sandbox (in case sandbox strategy is used). - String absoluteInPath = in.getPathString(); - addOptions("--sandbox_writable_path=" + absoluteInPath); + // Modify the actual source file, not a sandboxed copy. + addOptions("--spawn_strategy=local"); // The "echo" effects editing of the source file during the build: write("edit/BUILD", diff --git a/src/test/shell/bazel/bazel_sandboxing_networking_test.sh b/src/test/shell/bazel/bazel_sandboxing_networking_test.sh index 51b9fd8cd944d9..6a32f51bc64395 100755 --- a/src/test/shell/bazel/bazel_sandboxing_networking_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_networking_test.sh @@ -36,6 +36,8 @@ source ${CURRENT_DIR}/remote_helpers.sh \ function set_up() { add_to_bazelrc "build --spawn_strategy=sandboxed" add_to_bazelrc "build --genrule_strategy=sandboxed" + # Allow the network socket to be seen in the sandbox. + add_to_bazelrc "build --sandbox_add_mount_pair=/tmp" sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc } diff --git a/src/test/shell/integration/execution_strategies_test.sh b/src/test/shell/integration/execution_strategies_test.sh index 94109cba33b919..6dc1e4f6164945 100755 --- a/src/test/shell/integration/execution_strategies_test.sh +++ b/src/test/shell/integration/execution_strategies_test.sh @@ -223,6 +223,7 @@ EOF bazel build --internal_spawn_scheduler --genrule_strategy=dynamic \ --dynamic_remote_strategy=sandboxed \ --dynamic_local_strategy=standalone \ + --noincompatible_sandbox_hermetic_tmp \ --experimental_dynamic_ignore_local_signals=8,9,10 \ --experimental_local_lockfree_output \ --experimental_local_execution_delay=0 \ diff --git a/src/test/shell/integration/sandboxing_test.sh b/src/test/shell/integration/sandboxing_test.sh index f23d95c9977252..b6723aabe37804 100755 --- a/src/test/shell/integration/sandboxing_test.sh +++ b/src/test/shell/integration/sandboxing_test.sh @@ -735,6 +735,7 @@ EOF touch "${temp_dir}/file" bazel test //pkg:tmp_test \ + --sandbox_add_mount_pair=/tmp \ --test_output=errors &>$TEST_log || fail "Expected test to pass" } @@ -812,6 +813,7 @@ EOF chmod +x pkg/tmp_test.sh bazel test //pkg:tmp_test \ + --sandbox_add_mount_pair=/tmp \ --test_output=errors &>$TEST_log || fail "Expected test to pass" [[ -f "${temp_dir}/file" ]] || fail "Expected ${temp_dir}/file to exist" }
val
test
2023-11-10T21:29:12
2023-10-21T11:03:20Z
fmeum
test
bazelbuild/bazel/20116_20141
bazelbuild/bazel
bazelbuild/bazel/20116
bazelbuild/bazel/20141
[ "keyword_pr_to_issue" ]
86fe599f7fc67d09c2f9ab4ef0c177a0fb8445f7
bb43e248f03b60151405fa484774555709bf1138
[ "This reproduces with bazel version set to `7.0.0rc2`", "cc @fmeum ", "You are passing a dict from strings to tuples to `sdk`, but that's not a supported attribute type. Instead, you should pass a dict from strings to lists. But yes, Bazel shouldn't crash in this case.", "I see, so we should also probably adj...
[]
2023-11-10T17:04:53Z
[ "type: bug", "team-ExternalDeps", "untriaged", "area-Bzlmod" ]
[bzlmod] bazel mod graph fails with tuples in MODULE.bazel
### Description of the bug: I run `bazel mod graph` and I get this failure: ``` checking cached actions FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.IllegalArgumentException: Unsupported type: class net.starlark.java.eval.Tuple at com.google.devtools.build.lib.bazel.bzlmod.AttributeValuesAdapter.serializeObject(AttributeValuesAdapter.java:98) at com.google.devtools.build.lib.bazel.bzlmod.AttributeValuesAdapter.serializeObject(AttributeValuesAdapter.java:88) at com.google.devtools.build.lib.bazel.bzlmod.AttributeValuesAdapter.write(AttributeValuesAdapter.java:53) at com.google.devtools.build.lib.bazel.bzlmod.AttributeValuesAdapter.write(AttributeValuesAdapter.java:44) at com.google.devtools.build.lib.bazel.bzlmod.Tag_GsonTypeAdapter.write(Tag_GsonTypeAdapter.java:57) at com.google.devtools.build.lib.bazel.bzlmod.Tag_GsonTypeAdapter.write(Tag_GsonTypeAdapter.java:12) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) at com.google.devtools.build.lib.bazel.bzlmod.DelegateTypeAdapterFactory$1.write(DelegateTypeAdapterFactory.java:128) at com.google.devtools.build.lib.bazel.bzlmod.ModuleExtensionUsage_GsonTypeAdapter.write(ModuleExtensionUsage_GsonTypeAdapter.java:130) at com.google.devtools.build.lib.bazel.bzlmod.ModuleExtensionUsage_GsonTypeAdapter.write(ModuleExtensionUsage_GsonTypeAdapter.java:17) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) at com.google.devtools.build.lib.bazel.bzlmod.DelegateTypeAdapterFactory$1.write(DelegateTypeAdapterFactory.java:128) at com.google.devtools.build.lib.bazel.bzlmod.Module_GsonTypeAdapter.write(Module_GsonTypeAdapter.java:115) at com.google.devtools.build.lib.bazel.bzlmod.Module_GsonTypeAdapter.write(Module_GsonTypeAdapter.java:14) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:239) at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.write(MapTypeAdapterFactory.java:145) at com.google.devtools.build.lib.bazel.bzlmod.DelegateTypeAdapterFactory$1.write(DelegateTypeAdapterFactory.java:128) at com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileValue_GsonTypeAdapter.write(BazelLockFileValue_GsonTypeAdapter.java:90) at com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileValue_GsonTypeAdapter.write(BazelLockFileValue_GsonTypeAdapter.java:13) at com.google.gson.Gson.toJson(Gson.java:704) at com.google.gson.Gson.toJson(Gson.java:683) at com.google.gson.Gson.toJson(Gson.java:638) at com.google.gson.Gson.toJson(Gson.java:618) at com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileModule.updateLockfile(BazelLockFileModule.java:234) at com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileModule.afterCommand(BazelLockFileModule.java:114) at com.google.devtools.build.lib.runtime.BlazeRuntime.afterCommand(BlazeRuntime.java:625) at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:678) at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:246) at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:550) at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:614) at io.grpc.Context$1.run(Context.java:566) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) ``` ### Which category does this issue belong to? CLI ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. Create a MODULE.bazel with a go_sdk that looks like this: ``` go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") go_sdk.download( name = "go_sdk", patches = [ "//...patches_to_stdlib",... ], sdks = { "linux_amd64": ( "go{}.linux-amd64".format(go_version), "3f5c50e592d8845d30eebd08ddb9c670fd2d909e032b6c2b83ecf97afb34660c", ), "linux_arm64": ( "go{}.linux-arm64".format(go_version), "30ce0b015c9c238e0c73014a6f92a22b8fe31ffded5b62a23840e3f13a90c842", ), "darwin_amd64": ( "go{}.darwin-amd64".format(go_version), "3b941e669e22b517db8ff65924666abfe306847a0d918967e202b468d3733d2e", ), "darwin_arm64": ( "go{}.darwin-arm64".format(go_version), "fbe78beee7861da09de9319498a1521bc41a8b79d3ead2218ce307b9fa5503e5", ), }, urls = [ "some urls" ], version = go_version, ) use_repo(go_sdk, "go_sdk") ``` Then run `bazel mod tidy` ### Which operating system are you running Bazel on? Linux AMD 64 ### What is the output of `bazel info release`? 6.4.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java" ]
[ "src/test/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapterTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java index 248d1060975d91..85fdd2a767eb2c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java @@ -88,9 +88,11 @@ private JsonElement serializeObject(Object obj) { jsonObject.add(serializeObjToString(entry.getKey()), serializeObject(entry.getValue())); } return jsonObject; - } else if (obj instanceof StarlarkList) { + } else if (obj instanceof Iterable) { + // ListType supports any kind of Iterable, including Tuples and StarlarkLists. All of them + // are converted to an equivalent StarlarkList during deserialization. JsonArray jsonArray = new JsonArray(); - for (Object item : (StarlarkList<?>) obj) { + for (Object item : (Iterable<?>) obj) { jsonArray.add(serializeObject(item)); } return jsonArray;
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapterTest.java b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapterTest.java index 45fcbd7d322ea6..b5c0cda5ae66bb 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapterTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapterTest.java @@ -30,6 +30,7 @@ import net.starlark.java.eval.Mutability; import net.starlark.java.eval.StarlarkInt; import net.starlark.java.eval.StarlarkList; +import net.starlark.java.eval.Tuple; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -89,4 +90,24 @@ public void testAttributeValuesAdapter() throws IOException { assertThat(jsonString).contains(":\"Hello String\""); assertThat((Map<?, ?>) attributeValues.attributes()).containsExactlyEntriesIn(builtDict); } + + @Test + public void testTuple() throws IOException { + Dict.Builder<String, Object> dict = new Dict.Builder<>(); + dict.put("Tuple", Tuple.of("bzl", "mod")); + + Dict<String, Object> builtDict = dict.buildImmutable(); + AttributeValuesAdapter attrAdapter = new AttributeValuesAdapter(); + String jsonString; + try (StringWriter stringWriter = new StringWriter()) { + attrAdapter.write(new JsonWriter(stringWriter), AttributeValues.create(builtDict)); + jsonString = stringWriter.toString(); + } + AttributeValues attributeValues; + try (StringReader stringReader = new StringReader(jsonString)) { + attributeValues = attrAdapter.read(new JsonReader(stringReader)); + } + assertThat((Map<?, ?>) attributeValues.attributes()) + .containsExactly("Tuple", StarlarkList.of(Mutability.IMMUTABLE, "bzl", "mod")); + } }
test
test
2023-11-10T15:43:22
2023-11-09T04:51:32Z
tyler-french
test
bazelbuild/bazel/19749_20147
bazelbuild/bazel
bazelbuild/bazel/19749
bazelbuild/bazel/20147
[ "keyword_pr_to_issue" ]
fe85936f7d38c4a279eec78eee7371b37f800000
a6f8923d6f0ddf37cd101f348779dd93335fca6e
[ "I think of this a bit different than @fmeum (in the closed PR).\r\n\r\nImo for WORKSPACE downloads, the download cache deduplication should only matter “much” across source code revisions(git commits) and not within the same revision. In practice, you would want to group most duplication within a single http_archi...
[]
2023-11-10T19:59:16Z
[ "type: bug", "P2", "team-ExternalDeps" ]
unflip --repository_cache_urls_as_default_canonical_id
### Description of the bug: Looks like https://github.com/bazelbuild/bazel/pull/19549 flipped `--repository_cache_urls_as_default_canonical_id` flag on by default which hurts `rctx.download` performance and breaks rules_oci's layer deduping mechanism completely. Cross-ref: https://github.com/bazel-contrib/rules_oci/issues/387 ### Which category does this issue belong to? External Dependency ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. - clone https://github.com/bazel-contrib/rules_oci - run `bazel build //oci/tests/... --repository_cache_urls_as_default_canonical_id` ### Which operating system are you running Bazel on? darwin/arm64 ### What is the output of `bazel info release`? release 6.3.2 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "scripts/bootstrap/bootstrap.sh", "src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManag...
[ "MODULE.bazel.lock", "scripts/bootstrap/bootstrap.sh", "src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManag...
[ "src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java", "src/test/py/bazel/bzlmod/bazel_fetch_test.py", "src/test/py/bazel/test_base.py", "src/test/shell/bazel/bazel_repository_cache_test.sh", "src/test/shell/testenv.sh.tmpl", "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index d9e52f66ae9f1a..766eaed0864425 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2158,7 +2158,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "U0PdF0Y6pi1ibjV47I9znaKyMppoEOhJX/RSf+0SYm8=", + "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2177,9 +2177,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "U0PdF0Y6pi1ibjV47I9znaKyMppoEOhJX/RSf+0SYm8=", + "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "57004ac9cc0c88944c08f5156a299addbe3ff1caa9209ec0809edda9a4315b31", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "8d144d3e597e69c9cb6f572e9cae8333cc991ba75d61fff1c4d9bd2ad4e2d429", "@@//:MODULE.bazel": "016812bd09c1de57c7cbfd60192cc76e75a4f564caafc4af0a018cd66ffb0cae" }, "envVariables": {}, @@ -2428,7 +2428,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "U0PdF0Y6pi1ibjV47I9znaKyMppoEOhJX/RSf+0SYm8=", + "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2478,7 +2478,7 @@ }, "//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "EFYd5Zc37KUKoseMe8brwJ5A2j/kUvPs5pIvTfGf3ok=", + "bzlTransitiveDigest": "hL6dUUghnqmrcFrs2bvFCvxPHBnPOY3ymycjIbgRQac=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2505,7 +2505,7 @@ }, "//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "wd0+Kn35gYWv/xzdEzWg7vRQz6FZcfpne4WcwCs9d+o=", + "bzlTransitiveDigest": "DEE4EmNqW6/brpzbLQMxPvdWKALzpq/MeZyydMFsjLI=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh index 87b9df5579cdbb..9c7cdbee60b2d5 100755 --- a/scripts/bootstrap/bootstrap.sh +++ b/scripts/bootstrap/bootstrap.sh @@ -31,11 +31,14 @@ fi : ${JAVA_VERSION:="11"} +# TODO: remove `--repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0` once all dependencies are +# mirrored. See https://github.com/bazelbuild/bazel/pull/19549 for more context. _BAZEL_ARGS="--spawn_strategy=standalone \ --nojava_header_compilation \ --strategy=Javac=worker --worker_quit_after_build --ignore_unsupported_sandboxing \ --compilation_mode=opt \ --repository_cache=derived/repository_cache \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ --extra_toolchains=//scripts/bootstrap:all \ --extra_toolchains=@bazel_tools//tools/python:autodetecting_toolchain \ --enable_bzlmod \ diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java index c4e466422db0a4..0a2661fde95dc7 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java @@ -349,7 +349,6 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException { if (repoOptions.repositoryDownloaderRetries >= 0) { downloadManager.setRetries(repoOptions.repositoryDownloaderRetries); } - downloadManager.setUrlsAsDefaultCanonicalId(repoOptions.urlsAsDefaultCanonicalId); repositoryCache.setHardlink(repoOptions.useHardlinks); if (repoOptions.experimentalScaleTimeouts > 0.0) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java index 0e6a234a8c56f8..e984bad9e35c94 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java @@ -264,15 +264,15 @@ public Converter() { @Option( name = "experimental_repository_cache_urls_as_default_canonical_id", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS, - effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, - metadataTags = {OptionMetadataTag.EXPERIMENTAL}, - help = - "If true, use a string derived from the URLs of repository downloads as the canonical_id " - + "if not specified. This causes a change in the URLs to result in a redownload even " - + "if the cache contains a download with the same hash. This can be used to verify " - + "that URL changes don't result in broken repositories being masked by the cache.") + defaultValue = "true", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + metadataTags = OptionMetadataTag.DEPRECATED, + effectTags = {OptionEffectTag.NO_OP}, + deprecationWarning = + "This behavior is enabled by default for http_* and jvm_* rules and no " + + "longer controlled by this flag. Use " + + "--repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 to disable it instead.", + help = "No-op.") public boolean urlsAsDefaultCanonicalId; @Option( diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java index ae9fe3543a2806..02656d8221f3e8 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java @@ -42,7 +42,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.Nullable; /** @@ -59,7 +58,6 @@ public class DownloadManager { private final Downloader downloader; private boolean disableDownload = false; private int retries = 0; - private boolean urlsAsDefaultCanonicalId; @Nullable private Credentials netrcCreds; private CredentialFactory credentialFactory = StaticCredentials::new; @@ -90,10 +88,6 @@ public void setRetries(int retries) { this.retries = retries; } - public void setUrlsAsDefaultCanonicalId(boolean urlsAsDefaultCanonicalId) { - this.urlsAsDefaultCanonicalId = urlsAsDefaultCanonicalId; - } - public void setNetrcCreds(Credentials netrcCreds) { this.netrcCreds = netrcCreds; } @@ -134,9 +128,6 @@ public Path download( if (Thread.interrupted()) { throw new InterruptedException(); } - if (Strings.isNullOrEmpty(canonicalId) && urlsAsDefaultCanonicalId) { - canonicalId = originalUrls.stream().map(URL::toExternalForm).collect(Collectors.joining(" ")); - } // TODO(andreisolo): This code path is inconsistent as the authHeaders are fetched from a // .netrc only if it comes from a http_{archive,file,jar} - and it is handled directly diff --git a/tools/build_defs/repo/BUILD b/tools/build_defs/repo/BUILD index 09dfa068a9f108..b545c12ad475bd 100644 --- a/tools/build_defs/repo/BUILD +++ b/tools/build_defs/repo/BUILD @@ -15,6 +15,7 @@ filegroup( filegroup( name = "http_src", srcs = [ + "cache.bzl", "http.bzl", "utils.bzl", ], diff --git a/tools/build_defs/repo/cache.bzl b/tools/build_defs/repo/cache.bzl new file mode 100644 index 00000000000000..8381446da242ff --- /dev/null +++ b/tools/build_defs/repo/cache.bzl @@ -0,0 +1,50 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# 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. + +# WARNING: +# https://github.com/bazelbuild/bazel/issues/17713 +# .bzl files in this package (tools/build_defs/repo) are evaluated +# in a Starlark environment without "@_builtins" injection, and must not refer +# to symbols associated with build/workspace .bzl files + +"""Returns the default canonical id to use for downloads.""" + +visibility("private") + +DEFAULT_CANONICAL_ID_ENV = "BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID" + +CANONICAL_ID_DOC = """A canonical ID of the file downloaded. + +If specified and non-empty, Bazel will not take the file from cache, unless it +was added to the cache by a request with the same canonical ID. + +If unspecified or empty, Bazel by default uses the URLs of the file as the +canonical ID. This helps catch the common mistake of updating the URLs without +also updating the hash, resulting in builds that succeed locally but fail on +machines without the file in the cache. This behavior can be disabled with +--repo_env={env}=0. +""".format(env = DEFAULT_CANONICAL_ID_ENV) + +def get_default_canonical_id(repository_ctx, urls): + """Returns the default canonical id to use for downloads.""" + if repository_ctx.os.environ.get(DEFAULT_CANONICAL_ID_ENV) == "0": + return "" + + # Do not sort URLs to prevent the following scenario: + # 1. http_archive with urls = [B, A] created. + # 2. Successful fetch from B results in canonical ID "A B". + # 3. Order of urls is flipped to [A, B]. + # 4. Fetch would reuse cache entry for "A B", even though A may be broken (it has never been + # fetched before). + return " ".join(urls) diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl index f1e79da78cc105..b61c4046197ead 100644 --- a/tools/build_defs/repo/http.bzl +++ b/tools/build_defs/repo/http.bzl @@ -37,6 +37,12 @@ These rules are improved versions of the native http rules and will eventually replace the native rules. """ +load( + ":cache.bzl", + "CANONICAL_ID_DOC", + "DEFAULT_CANONICAL_ID_ENV", + "get_default_canonical_id", +) load( ":utils.bzl", "patch", @@ -142,7 +148,7 @@ def _http_archive_impl(ctx): ctx.attr.sha256, ctx.attr.type, ctx.attr.strip_prefix, - canonical_id = ctx.attr.canonical_id, + canonical_id = ctx.attr.canonical_id or get_default_canonical_id(ctx, all_urls), auth = auth, integrity = ctx.attr.integrity, ) @@ -182,7 +188,7 @@ def _http_file_impl(ctx): "file/" + downloaded_file_path, ctx.attr.sha256, ctx.attr.executable, - canonical_id = ctx.attr.canonical_id, + canonical_id = ctx.attr.canonical_id or get_default_canonical_id(ctx, all_urls), auth = auth, integrity = ctx.attr.integrity, ) @@ -219,7 +225,7 @@ def _http_jar_impl(ctx): all_urls, "jar/" + downloaded_file_name, ctx.attr.sha256, - canonical_id = ctx.attr.canonical_id, + canonical_id = ctx.attr.canonical_id or get_default_canonical_id(ctx, all_urls), auth = auth, integrity = ctx.attr.integrity, ) @@ -257,11 +263,7 @@ easier but either this attribute or `sha256` should be set before shipping.""", doc = _AUTH_PATTERN_DOC, ), "canonical_id": attr.string( - doc = """A canonical id of the archive downloaded. - -If specified and non-empty, bazel will not take the archive from cache, -unless it was added to the cache by a request with the same canonical id. -""", + doc = CANONICAL_ID_DOC, ), "strip_prefix": attr.string( doc = """A directory prefix to strip from the extracted files. @@ -382,6 +384,7 @@ following: `"zip"`, `"jar"`, `"war"`, `"aar"`, `"tar"`, `"tar.gz"`, `"tgz"`, http_archive = repository_rule( implementation = _http_archive_impl, attrs = _http_archive_attrs, + environ = [DEFAULT_CANONICAL_ID_ENV], doc = """Downloads a Bazel repository as a compressed archive file, decompresses it, and makes its targets available for binding. @@ -457,11 +460,7 @@ field will make your build non-hermetic. It is optional to make development easier but either this attribute or `sha256` should be set before shipping.""", ), "canonical_id": attr.string( - doc = """A canonical id of the archive downloaded. - -If specified and non-empty, bazel will not take the archive from cache, -unless it was added to the cache by a request with the same canonical id. -""", + doc = CANONICAL_ID_DOC, ), "url": attr.string(doc = _URL_DOC), "urls": attr.string_list(doc = _URLS_DOC), @@ -476,6 +475,7 @@ unless it was added to the cache by a request with the same canonical id. http_file = repository_rule( implementation = _http_file_impl, attrs = _http_file_attrs, + environ = [DEFAULT_CANONICAL_ID_ENV], doc = """Downloads a file from a URL and makes it available to be used as a file group. @@ -517,11 +517,7 @@ field will make your build non-hermetic. It is optional to make development easier but either this attribute or `sha256` should be set before shipping.""", ), "canonical_id": attr.string( - doc = """A canonical id of the archive downloaded. - -If specified and non-empty, bazel will not take the archive from cache, -unless it was added to the cache by a request with the same canonical id. -""", + doc = CANONICAL_ID_DOC, ), "url": attr.string(doc = _URL_DOC + "\n\nThe URL must end in `.jar`."), "urls": attr.string_list(doc = _URLS_DOC + "\n\nAll URLs must end in `.jar`."), @@ -540,6 +536,7 @@ unless it was added to the cache by a request with the same canonical id. http_jar = repository_rule( implementation = _http_jar_impl, attrs = _http_jar_attrs, + environ = [DEFAULT_CANONICAL_ID_ENV], doc = """Downloads a jar from a URL and makes it available as java_import diff --git a/tools/build_defs/repo/jvm.bzl b/tools/build_defs/repo/jvm.bzl index 98ce90133e1529..c7e87d2f4a97bd 100644 --- a/tools/build_defs/repo/jvm.bzl +++ b/tools/build_defs/repo/jvm.bzl @@ -38,6 +38,13 @@ the following macros are defined below that utilize jvm_import_external: - java_import_external - uses `java_import` as the underlying build rule """ +load( + ":cache.bzl", + "CANONICAL_ID_DOC", + "DEFAULT_CANONICAL_ID_ENV", + "get_default_canonical_id", +) + _HEADER = "# DO NOT EDIT: generated by jvm_import_external()" _PASS_PROPS = ( @@ -116,7 +123,7 @@ def _jvm_import_external(repository_ctx): urls, path, sha, - canonical_id = repository_ctx.attr.canonical_id, + canonical_id = repository_ctx.attr.canonical_id or get_default_canonical_id(repository_ctx, urls), ) if srcurls and _should_fetch_sources_in_current_env(repository_ctx): repository_ctx.download( @@ -239,7 +246,9 @@ jvm_import_external = repository_rule( "additional_rule_attrs": attr.string_dict(), "srcjar_urls": attr.string_list(), "srcjar_sha256": attr.string(), - "canonical_id": attr.string(), + "canonical_id": attr.string( + doc = CANONICAL_ID_DOC, + ), "deps": attr.string_list(), "runtime_deps": attr.string_list(), "testonly_": attr.bool(), @@ -250,7 +259,10 @@ jvm_import_external = repository_rule( "default_visibility": attr.string_list(default = ["//visibility:public"]), "extra_build_file_content": attr.string(), }, - environ = [_FETCH_SOURCES_ENV_VAR], + environ = [ + _FETCH_SOURCES_ENV_VAR, + DEFAULT_CANONICAL_ID_ENV, + ], implementation = _jvm_import_external, )
diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java index 916175736adce7..48394f478222fa 100644 --- a/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java +++ b/src/test/java/com/google/devtools/build/lib/blackbox/bazel/DefaultToolsSetup.java @@ -78,6 +78,9 @@ public void setup(BlackBoxTestContext context) throws IOException { String sharedRepoCache = System.getenv("REPOSITORY_CACHE"); if (sharedRepoCache != null) { lines.add("common --repository_cache=" + sharedRepoCache); + // TODO: Remove this flag once all dependencies are mirrored. + // See https://github.com/bazelbuild/bazel/pull/19549 for more context. + lines.add("common --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0"); if (OS.getCurrent() == OS.DARWIN) { // For reducing SSD usage on our physical Mac machines. lines.add("common --experimental_repository_cache_hardlinks"); diff --git a/src/test/py/bazel/bzlmod/bazel_fetch_test.py b/src/test/py/bazel/bzlmod/bazel_fetch_test.py index 8799a8e9f3ea84..d7867d6d4e99dc 100644 --- a/src/test/py/bazel/bzlmod/bazel_fetch_test.py +++ b/src/test/py/bazel/bzlmod/bazel_fetch_test.py @@ -61,6 +61,10 @@ def generatBuiltinModules(self): self.ScratchFile('tools_mock/WORKSPACE') self.ScratchFile('tools_mock/MODULE.bazel', ['module(name="bazel_tools")']) self.ScratchFile('tools_mock/tools/build_defs/repo/BUILD') + self.CopyFile( + self.Rlocation('io_bazel/tools/build_defs/repo/cache.bzl'), + 'tools_mock/tools/build_defs/repo/cache.bzl', + ) self.CopyFile( self.Rlocation('io_bazel/tools/build_defs/repo/http.bzl'), 'tools_mock/tools/build_defs/repo/http.bzl', diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 9366f97cf853cc..a9362e9f73b5b3 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -127,6 +127,12 @@ def setUp(self): shared_repo_cache = os.environ.get('REPOSITORY_CACHE') if shared_repo_cache: f.write('common --repository_cache={}\n'.format(shared_repo_cache)) + # TODO(pcloudy): Remove this flag once all dependencies are mirrored. + # See https://github.com/bazelbuild/bazel/pull/19549 for more context. + f.write( + 'common' + ' --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0\n' + ) if TestBase.IsDarwin(): # For reducing SSD usage on our physical Mac machines. f.write('common --experimental_repository_cache_hardlinks\n') diff --git a/src/test/shell/bazel/bazel_repository_cache_test.sh b/src/test/shell/bazel/bazel_repository_cache_test.sh index 28235a0557c272..4836db5b09ebef 100755 --- a/src/test/shell/bazel/bazel_repository_cache_test.sh +++ b/src/test/shell/bazel/bazel_repository_cache_test.sh @@ -221,6 +221,9 @@ function test_fetch_value_with_existing_cache_and_no_network() { cache_entry="$repo_cache_dir/content_addressable/sha256/$sha256" mkdir -p "$cache_entry" cp "$repo2_zip" "$cache_entry/file" # Artifacts are named uniformly as "file" in the cache + http_archive_url="http://localhost:$nc_port/bleh" + canonical_id_hash=$(printf "$http_archive_url" | sha256sum | cut -f 1 -d ' ') + touch "$cache_entry/id-$canonical_id_hash" # Fetch without a server shutdown_server @@ -271,6 +274,7 @@ EOF # to do without checksum. But we can safely do so, as the loopback device # is reasonably safe against man-in-the-middle attacks. bazel fetch --repository_cache="$repo_cache_dir" \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ //zoo:breeding-program >& $TEST_log \ || fail "expected fetch to succeed" @@ -283,6 +287,7 @@ EOF # As we don't have a predicted cache, we expect fetching to fail now. bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ && fail "expected failure" || : # However, if we add the hash, the value is taken from cache @@ -298,6 +303,7 @@ http_archive( ) EOF bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ || fail "expected fetch to succeed" } @@ -465,15 +471,19 @@ EOF expect_log "Error downloading" } -function test_break_url() { +function test_http_archive_no_default_canonical_id() { setup_repository - bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ + bazel fetch --repository_cache="$repo_cache_dir" \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ + //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" shutdown_server - bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ + bazel fetch --repository_cache="$repo_cache_dir" \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ + //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" # Break url in WORKSPACE @@ -489,24 +499,27 @@ http_archive( ) EOF - # By default, cache entry will still match by sha256, even if url is changed. - bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ + # Without the default canonical id, cache entry will still match by sha256, even if url is + # changed. + bazel fetch --repository_cache="$repo_cache_dir" \ + --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0 \ + //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" } -function test_experimental_repository_cache_urls_as_default_canonical_id() { + +function test_http_archive_urls_as_default_canonical_id() { + # TODO: Remove when the integration test setup itself no longer relies on this. + add_to_bazelrc "common --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=1" + setup_repository - bazel fetch --repository_cache="$repo_cache_dir" \ - --experimental_repository_cache_urls_as_default_canonical_id \ - //zoo:breeding-program >& $TEST_log \ + bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" shutdown_server - bazel fetch --repository_cache="$repo_cache_dir" \ - --experimental_repository_cache_urls_as_default_canonical_id \ - //zoo:breeding-program >& $TEST_log \ + bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ || echo "Expected fetch to succeed" # Break url in WORKSPACE @@ -523,9 +536,7 @@ http_archive( EOF # As repository cache key should depend on urls, we expect fetching to fail now. - bazel fetch --repository_cache="$repo_cache_dir" \ - --experimental_repository_cache_urls_as_default_canonical_id \ - //zoo:breeding-program >& $TEST_log \ + bazel fetch --repository_cache="$repo_cache_dir" //zoo:breeding-program >& $TEST_log \ && fail "expected failure" || : } diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index e7f53f1c8820c9..80d15b6df85e54 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -327,6 +327,9 @@ EOF if [[ -n ${REPOSITORY_CACHE:-} ]]; then echo "testenv.sh: Using repository cache at $REPOSITORY_CACHE." echo "common --repository_cache=$REPOSITORY_CACHE" >> $TEST_TMPDIR/bazelrc + # TODO: Remove this flag once all dependencies are mirrored. + # See https://github.com/bazelbuild/bazel/pull/19549 for more context. + echo "common --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0" >> $TEST_TMPDIR/bazelrc if is_darwin; then # For reducing SSD usage on our physical Mac machines. echo "testenv.sh: Enabling --experimental_repository_cache_hardlinks" diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 98461cff5ac2b6..ef16ccfb6da976 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -646,7 +646,7 @@ }, "@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "EFYd5Zc37KUKoseMe8brwJ5A2j/kUvPs5pIvTfGf3ok=", + "bzlTransitiveDigest": "hL6dUUghnqmrcFrs2bvFCvxPHBnPOY3ymycjIbgRQac=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -730,7 +730,7 @@ }, "@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "wd0+Kn35gYWv/xzdEzWg7vRQz6FZcfpne4WcwCs9d+o=", + "bzlTransitiveDigest": "DEE4EmNqW6/brpzbLQMxPvdWKALzpq/MeZyydMFsjLI=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -750,7 +750,7 @@ }, "@rules_java~7.1.0//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "EXsxSX2vQjCcI8jYez/O+Yb9H5reAMhLL3WXGPD6Scw=", + "bzlTransitiveDigest": "QHrMRjNPjXXgiGx8x2I1hGry4XALDWB19awlz4iYfwg=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1290,7 +1290,7 @@ }, "@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { "general": { - "bzlTransitiveDigest": "fWWk0VJDA4P65oiSwJr5IKwxMWlFzootX8ZiYu5ETv8=", + "bzlTransitiveDigest": "jfaPoItGn7QX/GUEdWPqrBf5a380ATtgwvSoPQF/t/Q=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
val
test
2023-11-10T22:35:55
2023-10-06T17:14:01Z
thesayyn
test
bazelbuild/bazel/17803_20177
bazelbuild/bazel
bazelbuild/bazel/17803
bazelbuild/bazel/20177
[ "keyword_pr_to_issue" ]
e3ab08195131b4b2db012ec7430a053f3c581213
df881be41074d042683d84c295b14b7119892c38
[ "It looks like this might be related to https://github.com/bazelbuild/bazel/issues/17123 and https://github.com/bazelbuild/bazel/issues/17124\r\n\r\nI think this is more urgent than P2, since a mismatching/incorrect value is printed when the integrity is wrong.", "this has been helping us locally:\r\n\r\n**in `~/...
[]
2023-11-13T15:50:20Z
[ "type: bug", "P2", "team-ExternalDeps", "bad error messaging", "area-Bzlmod" ]
bzlmod integrity error messages are inaccurate and confusing
### Description of the bug: It is extremely difficult to try to figure out how to add an `integrity` value to a Bzlmod override, and the logs are generally completely incorrect for suggestions. I add an archive override: ``` archive_override( module_name = "gazelle", patches = [ "//patches:bzlmod.patch", ], patch_strip = 1, strip_prefix = "bazel-gazelle-master", urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/refs/heads/master.zip"], ) ``` The logs output: ``` DEBUG: Rule 'gazelle~override' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "a29f02861da70387de1193e17acdc9902aa3636ac3979a18e8d52289c23df676" ``` I try this, but get the error: ``` Error in archive_override: archive_override() got unexpected keyword argument 'sha256' ``` So, I then look up the `archive_override` fields, and add `integrity` field, to get the following errors: ``` Error in download_and_extract: Checksum error in repository @gazelle~override: Invalid SHA-256 SRI checksum 'sha256-a29f02861da70387de1193e17acdc9902aa3636ac3979a18e8d52289c23df676' ``` I try to go look on https://github.com/bazelbuild/bazel-central-registry/tree/main/modules to find the formatting of existing integrity values, but can't find anything. So I go find an example: https://github.com/meteorcloudy/bzlmod-examples/blob/main/examples/06-archive-override/MODULE.bazel, and try to attach the `integrity = "sha256-zyeBn+s3YRUpFz1NjJ3WcZI9moLg7ImxZIkAksUNPJo="`, but then the logs show this: ``` Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-gazelle/archive/refs/heads/master.zip] to /home/user/.cache/bazel/_bazel_tfrench/b97476d719d716accead0f2d5b93104f/external/gazelle~override/temp15987837649025287268/master.zip: Checksum was a29f02861da70387de1193e17acdc9902aa3636ac3979a18e8d52289c23df676 but wanted cf27819feb37611529173d4d8c9dd671923d9a82e0ec89b164890092c50d3c9a ERROR: Error computing the main repository mapping: unknown error during computation of main repo mapping ``` But this isn't even the value that I added to the rule. ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. Add any incorrect `integrity` value to an override, and try to fix is using the error logs. ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? release 6.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? I was unable to find any documentation to help fix the issue. ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl" ]
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl" ]
[ "src/test/shell/bazel/bazel_repository_cache_test.sh", "src/test/shell/bazel/workspace_resolved_test.sh", "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 766eaed0864425..d96714c88e0c36 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2158,7 +2158,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", + "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2177,9 +2177,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", + "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "8d144d3e597e69c9cb6f572e9cae8333cc991ba75d61fff1c4d9bd2ad4e2d429", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "10b96bd3c1eb194b0efe3a13fd06f2051abf36efb33414ad92048883ba471c7f", "@@//:MODULE.bazel": "016812bd09c1de57c7cbfd60192cc76e75a4f564caafc4af0a018cd66ffb0cae" }, "envVariables": {}, @@ -2428,7 +2428,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "JIUppb9cYpap/pfU76BpY/F/Qd6Qld7XVEsAa78X0T4=", + "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2478,7 +2478,7 @@ }, "//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "hL6dUUghnqmrcFrs2bvFCvxPHBnPOY3ymycjIbgRQac=", + "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2505,7 +2505,7 @@ }, "//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "DEE4EmNqW6/brpzbLQMxPvdWKALzpq/MeZyydMFsjLI=", + "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl index b61c4046197ead..81fc3f96dc77ab 100644 --- a/tools/build_defs/repo/http.bzl +++ b/tools/build_defs/repo/http.bzl @@ -129,10 +129,10 @@ def _get_auth(ctx, urls): netrc = read_user_netrc(ctx) return use_netrc(netrc, urls, ctx.attr.auth_patterns) -def _update_sha256_attr(ctx, attrs, download_info): - # We don't need to override the sha256 attribute if integrity is already specified. - sha256_override = {} if ctx.attr.integrity else {"sha256": download_info.sha256} - return update_attrs(ctx.attr, attrs.keys(), sha256_override) +def _update_integrity_attr(ctx, attrs, download_info): + # We don't need to override the integrity attribute if sha256 is already specified. + integrity_override = {} if ctx.attr.sha256 else {"integrity": download_info.integrity} + return update_attrs(ctx.attr, attrs.keys(), integrity_override) def _http_archive_impl(ctx): """Implementation of the http_archive rule.""" @@ -155,7 +155,7 @@ def _http_archive_impl(ctx): workspace_and_buildfile(ctx) patch(ctx, auth = auth) - return _update_sha256_attr(ctx, _http_archive_attrs, download_info) + return _update_integrity_attr(ctx, _http_archive_attrs, download_info) _HTTP_FILE_BUILD = """\ package(default_visibility = ["//visibility:public"]) @@ -195,7 +195,7 @@ def _http_file_impl(ctx): ctx.file("WORKSPACE", "workspace(name = \"{name}\")".format(name = ctx.name)) ctx.file("file/BUILD", _HTTP_FILE_BUILD.format(downloaded_file_path)) - return _update_sha256_attr(ctx, _http_file_attrs, download_info) + return _update_integrity_attr(ctx, _http_file_attrs, download_info) _HTTP_JAR_BUILD = """\ load("{rules_java_defs}", "java_import") @@ -235,7 +235,7 @@ def _http_jar_impl(ctx): rules_java_defs = str(Label("@rules_java//java:defs.bzl")), )) - return _update_sha256_attr(ctx, _http_jar_attrs, download_info) + return _update_integrity_attr(ctx, _http_jar_attrs, download_info) _http_archive_attrs = { "url": attr.string(doc = _URL_DOC),
diff --git a/src/test/shell/bazel/bazel_repository_cache_test.sh b/src/test/shell/bazel/bazel_repository_cache_test.sh index 4836db5b09ebef..c6c2c38394bc4d 100755 --- a/src/test/shell/bazel/bazel_repository_cache_test.sh +++ b/src/test/shell/bazel/bazel_repository_cache_test.sh @@ -124,6 +124,7 @@ EOF zip -0 -ry "$repo2_zip" WORKSPACE fox >& $TEST_log repo2_name=$(basename "$repo2_zip") sha256=$(sha256sum "$repo2_zip" | cut -f 1 -d ' ') + integrity="sha256-$(cat "$repo2_zip" | openssl dgst -sha256 -binary | openssl base64 -A)" fi serve_file "$repo2_zip" @@ -278,7 +279,7 @@ EOF //zoo:breeding-program >& $TEST_log \ || fail "expected fetch to succeed" - expect_log "${sha256}" + expect_log "${integrity}" # Shutdown the server; so fetching again won't work shutdown_server diff --git a/src/test/shell/bazel/workspace_resolved_test.sh b/src/test/shell/bazel/workspace_resolved_test.sh index f3abd91f1a9912..6cbaa188d7e383 100755 --- a/src/test/shell/bazel/workspace_resolved_test.sh +++ b/src/test/shell/bazel/workspace_resolved_test.sh @@ -335,10 +335,10 @@ test_http_return_value() { touch a/f.txt zip a.zip a/* - expected_sha256="$(sha256sum "${EXTREPODIR}/a.zip" | head -c 64)" + expected_integrity="sha256-$(cat "${EXTREPODIR}/a.zip" | openssl dgst -sha256 -binary | openssl base64 -A)" rm -rf a - # http_archive rule doesn't specify the sha256 attribute + # http_archive rule doesn't specify the integrity attribute mkdir -p main cat > main/WORKSPACE <<EOF workspace(name = "main") @@ -355,7 +355,7 @@ EOF bazel sync \ --experimental_repository_resolved_file=../repo.bzl - grep ${expected_sha256} ../repo.bzl || fail "didn't return commit" + grep ${expected_integrity} ../repo.bzl || fail "didn't return integrity" } test_sync_calls_all() { diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index ef16ccfb6da976..80fcbbd46be616 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -621,7 +621,7 @@ } }, "moduleExtensions": { - "@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { + "@@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=", "accumulatedFileDigests": {}, @@ -644,9 +644,9 @@ } } }, - "@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { + "@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "hL6dUUghnqmrcFrs2bvFCvxPHBnPOY3ymycjIbgRQac=", + "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -671,7 +671,7 @@ } } }, - "@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { + "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { "general": { "bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=", "accumulatedFileDigests": {}, @@ -694,7 +694,7 @@ } } }, - "@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": { + "@@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": { "general": { "bzlTransitiveDigest": "Qh2bWTU6QW6wkrd87qrU4YeY+SG37Nvw3A0PR4Y0L2Y=", "accumulatedFileDigests": {}, @@ -712,7 +712,7 @@ } } }, - "@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { + "@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { "general": { "bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=", "accumulatedFileDigests": {}, @@ -728,9 +728,9 @@ } } }, - "@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { + "@@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "DEE4EmNqW6/brpzbLQMxPvdWKALzpq/MeZyydMFsjLI=", + "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -748,9 +748,9 @@ } } }, - "@rules_java~7.1.0//java:extensions.bzl%toolchains": { + "@@rules_java~7.1.0//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "QHrMRjNPjXXgiGx8x2I1hGry4XALDWB19awlz4iYfwg=", + "bzlTransitiveDigest": "iUIRqCK7tkhvcDJCAfPPqSd06IHG0a8HQD0xeQyVAqw=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1288,9 +1288,9 @@ } } }, - "@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { + "@@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { "general": { - "bzlTransitiveDigest": "jfaPoItGn7QX/GUEdWPqrBf5a380ATtgwvSoPQF/t/Q=", + "bzlTransitiveDigest": "rTru6D/C8vlaQDk4HOKyx4U/l6PCnj3Aq/gLraAqHgQ=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
test
test
2023-11-13T18:05:09
2023-03-16T15:37:50Z
tyler-french
test
bazelbuild/bazel/19829_20215
bazelbuild/bazel
bazelbuild/bazel/19829
bazelbuild/bazel/20215
[ "keyword_pr_to_issue" ]
466d58cb0a0f453af7ba4bb2a4e1e5d2ed60c3ac
5ad64b2570134560969b23963427f016538b4eaa
[ "Is this a blocker for flipping the flag? If one of the android rules would fail with it?", "I've marked it as a blocker for Bazel 7 release (not for starting the release, but for finishing it), but we need someone from the rules_android team to investigate because the code is pretty confusing.", "@bazel-io for...
[]
2023-11-15T18:05:46Z
[ "type: bug", "P1", "team-Android" ]
`android_local_test` isn't compatible with Android Platforms
Forked from #18262. The `android_local_test` rule is a strange beast which wants to do two things: it wants to [build an APK](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/android/AndroidLocalTestBase.java;drc=196515539edb352f10835f38aeea4d7efa832643;l=99), using a [valid Android SDK](https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/rules/android/BazelAndroidLocalTestRule.java;drc=5efeaa5a8562f8517917c875c93a05c5fc6a72b2;l=104). But, it also wants to run a Java binary on the local platform, with that APK as a data file. This worked before #18262, but now that we are being honest about Java versions, the cracks show up. This sounds like a case for execution groups to me, but I also don't actually understand how this works under the hood. For now, this means that we need to disable testing `android_local_test` with Android Platforms, and get the code cleaned up. We probably also need to fix the Starlark version in bazelbuild/rules_android.
[ "tools/android/android_sdk_repository_template.bzl" ]
[ "tools/android/android_sdk_repository_template.bzl" ]
[ "src/test/shell/bazel/android/android_helper.sh", "src/test/shell/bazel/android/android_local_test_integration_test.sh" ]
diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl index 0da0416429b214..04c073000c784c 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl @@ -199,9 +199,6 @@ def create_android_sdk_rules( native.toolchain( name = "sdk-%d-toolchain" % api_level, exec_compatible_with = HOST_CONSTRAINTS, - target_compatible_with = [ - "@platforms//os:android", - ], toolchain = ":sdk-%d" % api_level, toolchain_type = "@bazel_tools//tools/android:sdk_toolchain_type", )
diff --git a/src/test/shell/bazel/android/android_helper.sh b/src/test/shell/bazel/android/android_helper.sh index a8b942d506dd58..2cb7864a4c2867 100755 --- a/src/test/shell/bazel/android/android_helper.sh +++ b/src/test/shell/bazel/android/android_helper.sh @@ -115,7 +115,7 @@ function resolve_android_toolchains() { echo "This test uses platform-based Android toolchain resolution." add_to_bazelrc "build --incompatible_enable_android_toolchain_resolution" add_to_bazelrc "build --incompatible_enable_cc_toolchain_resolution" - add_to_bazelrc "build --platforms=//test_android_platforms:simple" + add_to_bazelrc "build --android_platforms=//test_android_platforms:simple" else echo "This test uses legacy Android toolchains." add_to_bazelrc "build --noincompatible_enable_android_toolchain_resolution" diff --git a/src/test/shell/bazel/android/android_local_test_integration_test.sh b/src/test/shell/bazel/android/android_local_test_integration_test.sh index 3aa761ff11c791..0c5cf553450e01 100755 --- a/src/test/shell/bazel/android/android_local_test_integration_test.sh +++ b/src/test/shell/bazel/android/android_local_test_integration_test.sh @@ -34,11 +34,6 @@ fail_if_no_android_sdk source "${CURRENT_DIR}/../../integration_test_setup.sh" \ || { echo "integration_test_setup.sh not found!" >&2; exit 1; } -if [[ "$1" = '--with_platforms' ]]; then - # TODO(https://github.com/bazelbuild/bazel/issues/19829): Re-enable when - # android_local_test works properly with Android platforms. - exit 0 -fi resolve_android_toolchains "$1" function setup_android_local_test_env() {
val
test
2023-11-15T17:55:03
2023-10-16T15:02:15Z
katre
test
bazelbuild/bazel/19920_20228
bazelbuild/bazel
bazelbuild/bazel/19920
bazelbuild/bazel/20228
[ "keyword_pr_to_issue" ]
6eb3a12d303df00e236528cff48e8cf3e7656197
8c4b1c908e5b520126a2480b0855c0c1e58d1ae0
[ "Could you check whether this is fixed with `USE_BAZEL_VERSION=d15ea929e2382b7354cb900b89fc22480b60ff4d`? Could be the same root cause as https://github.com/bazelbuild/bazel/issues/19822.", "No, unfortunately USE_BAZEL_VERSION=d15ea929e2382b7354cb900b89fc22480b60ff4d does not fix it, exactly the same error messag...
[]
2023-11-16T15:48:24Z
[ "type: bug", "team-Rules-CPP", "untriaged" ]
7.0.0rc2 regression from 6.4.0 (new throw_linked_but_not_exported_errors)
### Description of the bug: I have a number of header-file-only libraries, and link these into a number of our shared libraries: Since upgrading from bazel 6.4.0 to bazel 7.0.0rc2, I am getting this error: ``` ERROR: D:/units/cb_bazel/src/path/to/BUILD.bazel:3:21: in cc_shared_library rule //src/path/to/z:libz: Traceback (most recent call last): File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 661, column 114, in _cc_shared_library_impl File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 527, column 42, in _filter_inputs File "/virtual_builtins_bzl/common/cc/cc_shared_library.bzl", line 545, column 9, in _throw_linked_but_not_exported_errors Error in fail: The following libraries were linked statically by different cc_shared_libraries but not exported: cc_shared_library @@//src/path/to/lib:lib: "@@//src/path/to:include_root", "@@x//:libx_headers", "@@cpputils//:cpputils", If you are sure that the previous libraries are exported by the cc_shared_libraries because: 1. You have visibility declarations in the source code 2. Or you are passing a visibility script to the linker to export symbols from them then add those libraries to roots or exports_filter for each cc_shared_library. ``` what these dependent libraries have in common is that they are include-only: ``` cc_library( name = "cpputils", hdrs = glob(["include/cpputils/fmt/*.h", "include/cpputils/*.hxx"]), includes = ["include"], ) ``` ### Which category does this issue belong to? C++/Objective-C Rules ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. _No response_ ### Which operating system are you running Bazel on? Windows ### What is the output of `bazel info release`? release 7.0.0rc2 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. Yes, 6.4.0 did not have this issue ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl", "src/main/starlark/builtins_bzl/common/cc/semantics.bzl" ]
[ "src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl", "src/main/starlark/builtins_bzl/common/cc/semantics.bzl" ]
[ "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test" ]
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl index 7faa8086d49d5a..a70dea701550b3 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl @@ -454,6 +454,11 @@ def _filter_inputs( _add_linker_input_to_dict(linker_input.owner, transitive_exports[owner]) linker_inputs_count += 1 elif owner in targets_to_be_linked_statically_map: + if semantics.is_bazel and not linker_input.libraries: + # TODO(bazel-team): semantics.should_create_empty_archive() should be + # cleaned up and return False in every case. cc_libraries shouldn't + # produce empty archives. For now issue #19920 is only fixed in Bazel. + continue if owner in link_once_static_libs_map: # We are building a dictionary that will allow us to give # proper errors for libraries that have been linked multiple diff --git a/src/main/starlark/builtins_bzl/common/cc/semantics.bzl b/src/main/starlark/builtins_bzl/common/cc/semantics.bzl index 4e94de7a36c15a..922e24dffd2e12 100644 --- a/src/main/starlark/builtins_bzl/common/cc/semantics.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/semantics.bzl @@ -193,4 +193,5 @@ semantics = struct( check_cc_shared_library_tags = _check_cc_shared_library_tags, BUILD_INFO_TRANLATOR_LABEL = "@bazel_tools//tools/build_defs/build_info:cc_build_info", CC_PROTO_TOOLCHAIN = "@rules_cc//cc/proto:toolchain_type", + is_bazel = True, )
diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test index c60473a3c432e3..dd99fbbfd35b77 100644 --- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test @@ -156,7 +156,7 @@ cc_library( "//conditions:default": [], }), deps = select({ - ":is_bazel": ["qux2"], + ":is_bazel": ["qux2", "hdr_only"], "//conditions:default": [], }) + [ "bar", @@ -298,7 +298,7 @@ cc_library( deps = [ "barX", ] + select({ - ":is_bazel": ["qux2"], + ":is_bazel": ["qux2", "hdr_only"], "//conditions:default": [], }), ) @@ -449,6 +449,17 @@ cc_library( srcs = [":private_cc_library.cc"] ) +genrule( + name = "hdr_only_hdr", + outs = ["hdr_only_hdr.h"], + cmd = "touch $@", +) + +cc_library( + name = "hdr_only", + hdrs = [":hdr_only_hdr"], +) + build_failure_test( name = "two_dynamic_deps_same_export_in_so_test", message = "Two shared libraries in dependencies export the same symbols",
train
test
2023-11-16T20:17:09
2023-10-23T14:43:06Z
peakschris
test
bazelbuild/bazel/20276_20287
bazelbuild/bazel
bazelbuild/bazel/20276
bazelbuild/bazel/20287
[ "keyword_pr_to_issue" ]
e29d928269ca6387a03ebd3b562ee0e9ca541b05
c241246c590c5cd62807ccc721dd4bd78f7cd63a
[ "The issue seems not to be present in 77eacce3f56ce6b5b466337c123a5cdfd671f2ee .", "Bisection says that the culprit is unfortunately 51bddee96bc357d8131efba606420227c7a8ebc5 , an Abseil version bump. I'm pretty certain: after this change, I got 2/20 restarts, before, 0/50 .", "Interesting,\r\n\r\n> This issue d...
[]
2023-11-22T09:56:14Z
[ "type: bug", "P1", "untriaged", "team-Core" ]
Bazel @HEAD frequently kills the server process
### Description of the bug: When running Bazel in a loop, it occasionally kills the server for no good reason, on about every second invocation, with the error message `Killed non-responsive server process (pid=<number>)` ### Which category does this issue belong to? _No response_ ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ``` touch WORKSPACE cat > BUILD <<'EOF' genrule( name = "gg", outs = ["go"], cmd = "sleep 1; echo O > $@", ) EOF for i in $(seq 1 20); do bazel build //:gg; done ``` Looping 20 times is usually enough to reproduce the issue frequently. ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? development version ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. From HEAD, commithash 08407743e903627d7e64c669f27b3f2b81316e33. This issue doesn't seem to happen with 7.0.0rc4. ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? ```text See the commithash above. ``` ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. Somewhere between 7.0.0rc4 and 08407743e903627d7e64c669f27b3f2b81316e33; I haven't done the bisection. ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel", "MODULE.bazel.lock" ]
[ "MODULE.bazel", "MODULE.bazel.lock" ]
[]
diff --git a/MODULE.bazel b/MODULE.bazel index a4fbb21e997f84..03f1dce5d811cf 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -53,7 +53,7 @@ local_path_override( # The following Bazel modules are not direct dependencies for building Bazel, # but are required for visibility from DIST_ARCHIVE_REPOS in repositories.bzl bazel_dep(name = "apple_support", version = "1.5.0") -bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1") +bazel_dep(name = "abseil-cpp", version = "20230125.1") bazel_dep(name = "c-ares", version = "1.15.0") bazel_dep(name = "rules_go", version = "0.39.1") bazel_dep(name = "upb", version = "0.0.0-20220923-a547704") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 7e44db5d68a997..3646c7e15bfa9c 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "fe0ab69d5b93d0aa2a00d76cfc5058fbc4ac5e63bd3b5e47cd7b5551bd33fcdb", + "moduleFileHash": "63625ac7809ba5bc83e0814e16f223ac28a98df884897ddd5bfbd69fd4e3ddbf", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -596,7 +596,7 @@ "remoteapis": "remoteapis@_", "googleapis": "googleapis@_", "apple_support": "apple_support@1.5.0", - "abseil-cpp": "abseil-cpp@20230802.0.bcr.1", + "abseil-cpp": "abseil-cpp@20230125.1", "c-ares": "c-ares@1.15.0", "rules_go": "rules_go@0.39.1", "upb": "upb@0.0.0-20220923-a547704", @@ -719,7 +719,7 @@ "rules_proto": "rules_proto@5.3.0-21.7", "rules_java": "rules_java@7.1.0", "rules_pkg": "rules_pkg@0.9.1", - "com_google_abseil": "abseil-cpp@20230802.0.bcr.1", + "com_google_abseil": "abseil-cpp@20230125.1", "zlib": "zlib@1.3", "upb": "upb@0.0.0-20220923-a547704", "rules_jvm_external": "rules_jvm_external@5.2", @@ -797,7 +797,7 @@ "bazel_skylib": "bazel_skylib@1.4.1", "boringssl": "boringssl@0.0.0-20211025-d4f1ab9", "com_github_cares_cares": "c-ares@1.15.0", - "com_google_absl": "abseil-cpp@20230802.0.bcr.1", + "com_google_absl": "abseil-cpp@20230125.1", "com_google_protobuf": "protobuf@21.7", "com_googlesource_code_re2": "re2@2021-09-01", "rules_proto": "rules_proto@5.3.0-21.7", @@ -1435,7 +1435,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "com_google_absl": "abseil-cpp@20230802.0.bcr.1", + "com_google_absl": "abseil-cpp@20230125.1", "platforms": "platforms@0.0.8", "rules_cc": "rules_cc@0.0.9", "bazel_tools": "bazel_tools@_", @@ -1544,10 +1544,10 @@ } } }, - "abseil-cpp@20230802.0.bcr.1": { + "abseil-cpp@20230125.1": { "name": "abseil-cpp", - "version": "20230802.0.bcr.1", - "key": "abseil-cpp@20230802.0.bcr.1", + "version": "20230125.1", + "key": "abseil-cpp@20230125.1", "repoName": "abseil-cpp", "executionPlatformsToRegister": [], "toolchainsToRegister": [], @@ -1556,7 +1556,6 @@ "rules_cc": "rules_cc@0.0.9", "platforms": "platforms@0.0.8", "bazel_skylib": "bazel_skylib@1.4.1", - "com_google_googletest": "googletest@1.14.0", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" }, @@ -1564,14 +1563,14 @@ "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "name": "abseil-cpp~20230802.0.bcr.1", + "name": "abseil-cpp~20230125.1", "urls": [ - "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.tar.gz" + "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230125.1.tar.gz" ], - "integrity": "sha256-WdKXavnW7PABqBo1dJpuVRozW5SdNJGM+t4Hc3udk8U=", - "strip_prefix": "abseil-cpp-20230802.0", + "integrity": "sha256-gTEcF1mbNxIGne0gzKCaYqsL8qid+haZN4bIeCt+0UU=", + "strip_prefix": "abseil-cpp-20230125.1", "remote_patches": { - "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/patches/module_dot_bazel.patch": "sha256-Ku6wJ7uNqANq3fVmW03ySSUddevratZDsJ67NqtXIEY=" + "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/patches/module_dot_bazel.patch": "sha256-L1wChhBmDOnRbPbD4MENVXHjOBT2KFrDxT6D+aoThxk=" }, "remote_patch_strip": 0 } @@ -1756,7 +1755,7 @@ "bazel_skylib": "bazel_skylib@1.4.1", "rules_proto": "rules_proto@5.3.0-21.7", "com_google_protobuf": "protobuf@21.7", - "com_google_absl": "abseil-cpp@20230802.0.bcr.1", + "com_google_absl": "abseil-cpp@20230125.1", "platforms": "platforms@0.0.8", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -2181,7 +2180,7 @@ "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", "accumulatedFileDigests": { "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "10b96bd3c1eb194b0efe3a13fd06f2051abf36efb33414ad92048883ba471c7f", - "@@//:MODULE.bazel": "fe0ab69d5b93d0aa2a00d76cfc5058fbc4ac5e63bd3b5e47cd7b5551bd33fcdb" + "@@//:MODULE.bazel": "63625ac7809ba5bc83e0814e16f223ac28a98df884897ddd5bfbd69fd4e3ddbf" }, "envVariables": {}, "generatedRepoSpecs": { @@ -2261,7 +2260,7 @@ "attributes": { "name": "_main~bazel_build_deps~bootstrap_repo_cache", "repos": [ - "abseil-cpp~20230802.0.bcr.1", + "abseil-cpp~20230125.1", "apple_support~1.5.0", "bazel_skylib~1.4.1", "blake3~1.3.3.bcr.1",
null
test
test
2023-11-21T22:32:53
2023-11-21T09:52:21Z
lberki
test
bazelbuild/bazel/20371_20412
bazelbuild/bazel
bazelbuild/bazel/20371
bazelbuild/bazel/20412
[ "keyword_pr_to_issue" ]
6b2b8709820b71b52595b3c7da2ada226eafb869
1b214d2c13d4f8841c459e80ff455021b997fddb
[ "`/DBAZEL_CURRENT_REPOSITORY=\"\"` actually isn't the escaped form, the value of this preprocessor variable is really meant to be an empty string *literal*, not the empty string.\r\n\r\nThis class in Bazel is responsible for the escaping and mentions double quotes as special characters that `gcc` and `clang` requir...
[]
2023-12-01T20:45:35Z
[ "type: bug", "team-Rules-CPP", "untriaged" ]
BAZEL_CURRENT_REPOSITORY double escaped when using param files
### Description of the bug: When using --features=compiler_param_file to compile a C file, the string added to the param file is "double escaped" so that the result is `/DBAZEL_CURRENT_REPOSITORY=\"\"` instead of `/DBAZEL_CURRENT_REPOSITORY=""` This does not appear to cause an issue in the clang/gcc compilation, but causes my toolchain with a non-standard compiler (based on clang) to crash. My compiler can't handle /"/" as a define. Without --features=compiler_param_file set (and using the -s flag) , I can see that the command line is correctly escaped as `/DBAZEL_CURRENT_REPOSITORY=""` on the command line The param file should directly mimic the non-param file build, where the the string is properly escaped. ### Which category does this issue belong to? C++/Objective-C Rules, External Dependency ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. Clone the Examples from https://github.com/bazelbuild/examples change directory to cpp-tutorial/stage3 Run `bazel build //main:hello-world --features=compiler_param_file -s --compiler=clang-cl` Observe the .params file at cpp-tutorial\stage3\bazel-out\x64_windows-fastbuild\bin\main\_objs\hello-greet\hello-greet.obj.params `bazel clean`, then run `bazel build //main:hello-world -s --compiler=clang-cl` to compare BAZEL_CURRENT_REPOSITORY between the two runs ### Which operating system are you running Bazel on? Windows ### What is the output of `bazel info release`? release 6.4.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? It appears the problem was introduced as part of #16216 ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl", "src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl", "src/main/starlark/builtins_bzl/common/cc/cc_library.bzl", "tools/cpp/runfiles/runfiles_src.h" ]
[ "src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl", "src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl", "src/main/starlark/builtins_bzl/common/cc/cc_library.bzl", "tools/cpp/runfiles/runfiles_src.h" ]
[ "src/test/shell/bazel/cc_integration_test.sh" ]
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl index ea967bc0976a14..39479fe3a3ff3a 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl @@ -634,7 +634,7 @@ def cc_binary_impl(ctx, additional_linkopts): cc_toolchain = cc_toolchain, user_compile_flags = cc_helper.get_copts(ctx, feature_configuration, additional_make_variable_substitutions), defines = cc_helper.defines(ctx, additional_make_variable_substitutions), - local_defines = cc_helper.local_defines(ctx, additional_make_variable_substitutions) + cc_helper.get_local_defines_for_runfiles_lookup(ctx), + local_defines = cc_helper.local_defines(ctx, additional_make_variable_substitutions) + cc_helper.get_local_defines_for_runfiles_lookup(ctx, ctx.attr.deps), system_includes = cc_helper.system_include_dirs(ctx, additional_make_variable_substitutions), private_hdrs = cc_helper.get_private_hdrs(ctx), public_hdrs = cc_helper.get_public_hdrs(ctx), diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl index a0ceefdae959e7..8a7468b78fc0f7 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl @@ -965,8 +965,13 @@ def _is_stamping_enabled_for_aspect(ctx): stamp = ctx.rule.attr.stamp return stamp -def _get_local_defines_for_runfiles_lookup(ctx): - return ["BAZEL_CURRENT_REPOSITORY=\"{}\"".format(ctx.label.workspace_name)] +_RUNFILES_LIBRARY_TARGET = Label("@bazel_tools//tools/cpp/runfiles") + +def _get_local_defines_for_runfiles_lookup(ctx, all_deps): + for dep in all_deps: + if dep.label == _RUNFILES_LIBRARY_TARGET: + return ["BAZEL_CURRENT_REPOSITORY=\"{}\"".format(ctx.label.workspace_name)] + return [] # This should be enough to assume if two labels are equal. def _are_labels_equal(a, b): diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl index a396bb5fe137a5..5902c0d0875328 100755 --- a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl @@ -57,7 +57,7 @@ def _cc_library_impl(ctx): feature_configuration = feature_configuration, user_compile_flags = cc_helper.get_copts(ctx, feature_configuration, additional_make_variable_substitutions), defines = cc_helper.defines(ctx, additional_make_variable_substitutions), - local_defines = cc_helper.local_defines(ctx, additional_make_variable_substitutions) + cc_helper.get_local_defines_for_runfiles_lookup(ctx), + local_defines = cc_helper.local_defines(ctx, additional_make_variable_substitutions) + cc_helper.get_local_defines_for_runfiles_lookup(ctx, ctx.attr.deps + ctx.attr.implementation_deps), system_includes = cc_helper.system_include_dirs(ctx, additional_make_variable_substitutions), copts_filter = cc_helper.copts_filter(ctx, additional_make_variable_substitutions), purpose = "cc_library-compile", diff --git a/tools/cpp/runfiles/runfiles_src.h b/tools/cpp/runfiles/runfiles_src.h index 242b834856553f..93e9da198d330d 100644 --- a/tools/cpp/runfiles/runfiles_src.h +++ b/tools/cpp/runfiles/runfiles_src.h @@ -48,6 +48,8 @@ // ... // // The code above creates a Runfiles object and retrieves a runfile path. +// The BAZEL_CURRENT_REPOSITORY macro is available in every target that +// depends on the runfiles library. // // The Runfiles::Create function uses the runfiles manifest and the // runfiles directory from the RUNFILES_MANIFEST_FILE and RUNFILES_DIR
diff --git a/src/test/shell/bazel/cc_integration_test.sh b/src/test/shell/bazel/cc_integration_test.sh index 72a3ae6025e384..2512dc300c3bb5 100755 --- a/src/test/shell/bazel/cc_integration_test.sh +++ b/src/test/shell/bazel/cc_integration_test.sh @@ -1519,19 +1519,26 @@ cc_library( name = "library", srcs = ["library.cpp"], hdrs = ["library.h"], + implementation_deps = ["@bazel_tools//tools/cpp/runfiles"], visibility = ["//visibility:public"], ) cc_binary( name = "binary", srcs = ["binary.cpp"], - deps = [":library"], + deps = [ + ":library", + "@bazel_tools//tools/cpp/runfiles", + ], ) cc_test( name = "test", srcs = ["test.cpp"], - deps = [":library"], + deps = [ + ":library", + "@bazel_tools//tools/cpp/runfiles", + ], ) EOF @@ -1573,13 +1580,19 @@ EOF cc_binary( name = "binary", srcs = ["binary.cpp"], - deps = ["@//pkg:library"], + deps = [ + "@//pkg:library", + "@bazel_tools//tools/cpp/runfiles", + ], ) cc_test( name = "test", srcs = ["test.cpp"], - deps = ["@//pkg:library"], + deps = [ + "@//pkg:library", + "@bazel_tools//tools/cpp/runfiles", + ], ) EOF
test
test
2023-11-30T21:51:41
2023-11-29T19:48:39Z
lwelch
test
bazelbuild/bazel/20354_20430
bazelbuild/bazel
bazelbuild/bazel/20354
bazelbuild/bazel/20430
[ "keyword_pr_to_issue" ]
e35c29fe4670c779e8b96133450959eddf2dae5e
d2dbad3fbb55fd1a932298ea5b6b5660b6084a4c
[ "cc @meteorcloudy ", "One possible solution I see is to change the order of registration to the following in order of decreasing precedence:\r\n1. Toolchains registered in the root module's MODULE.bazel file\r\n2. Toolchains registered in the WORKSPACE file\r\n3. Toolchains registered in dependencies' MODULE.baze...
[]
2023-12-04T21:49:19Z
[ "type: bug", "P2", "team-ExternalDeps", "area-Bzlmod" ]
Unexpected interaction between toolchain resolution and bzlmod
### Description of the bug: When bzlmod is enabled (as it is the case in Bazel 7.0.0), toolchain registered by default can unexpectedly shadow toolchains declared in the `WORKSPACE` file. This makes the oucome of toolchain resolution dependent on whether bzlmod is enabled, even if the `MODULE.bazel` file of the main repository is empty (as it is by default) The root cause seems to be different from #17289 : there, AFAIU that one is caused by a subtle interaction between label mapping and toolchain resolution, here it's much more straightforward. Some debugging indicates that what happens is that `RegisteredToolchainsFunction` creates the list of registered toolchains by concatenating two lists: those from bzlmod, then those from the WORKSPACE file. `rules_python` is by default and immutably (except if bzlmod is disabled) a bzlmod module and it registers `@bazel_tools//tools/python:_autodetecting_py_runtime_pair` as a Python toolchain. Since that toolchain doesn't have any exec or target constraints, it seems to win toolchain selection by default, regardless of what other toolchains come after. Therefore, no matter what is written in the `WORKSPACE` file, one gets the autodetecting Python toolchain. I'm not sure if this is WAI; it could be construed as such, but it sure is surprising and a hindrance to migration to bzlmod. ### Which category does this issue belong to? _No response_ ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ``` cat > WORKSPACE <<'EOF' register_toolchains("//tc:py_toolchain") EOF cat > BUILD <<'EOF' py_binary( name = "py", srcs = ["py.py"], ) EOF cat > py.py <<'EOF' print("Hello, Python!") EOF mkdir tc cat > tc/BUILD <<'EOF' load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") py_runtime( name = "python2", files = ["ok.py2"], interpreter = "ok.py2", python_version = "PY2", ) py_runtime( name = "python3", files = ["ok.py3"], interpreter = "ok.py3", python_version = "PY3", ) py_runtime_pair( name = "pair", py2_runtime = ":python2", py3_runtime = ":python3", ) toolchain( name = "py_toolchain", toolchain = ":pair", toolchain_type = "@bazel_tools//tools/python:toolchain_type", ) EOF bazel run --enable_bzlmod :py # BUG: Prints "Hello, Python!", ignoring the toolchain bazel run --noenable_bzlmod :py # WORKS: Fails to find the dummy interpreter defined above ``` ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? development version ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. From sources ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? ```text 4a29f0851d1cde0240793cdc7a2e2cab926d31b7 ``` ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. Pretty obviously when `--enable_bzlmod` was flipped to true. ### Have you found anything relevant by searching the web? There are a number of pertinent bugs: * https://github.com/bazelbuild/bazel/issues/17289 (but that has a different root cause, if I understand correctly) * https://github.com/bazelbuild/rules_python/issues/1313 (seems to be very similar, but I haven't seen evidence that the bzlmod folks looked at this and has less information as to why this happens) ### Any other information, logs, or outputs that you want to share? _No response_
[ "site/en/external/migration.md", "src/main/java/com/google/devtools/build/lib/packages/Package.java", "src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java", "src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java", "src/main/java/com/google/devtools/build/lib...
[ "site/en/external/migration.md", "src/main/java/com/google/devtools/build/lib/packages/Package.java", "src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java", "src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java", "src/main/java/com/google/devtools/build/lib...
[ "src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java", "src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java", "src/test/java/com/google/devtools/build/lib/repository/ExternalPackageHelperTest.java", "src/test/java/com/google/devtools/build/lib/rules/platform...
diff --git a/site/en/external/migration.md b/site/en/external/migration.md index efd1cd1bc51bd9..c4eb0c4050dbab 100644 --- a/site/en/external/migration.md +++ b/site/en/external/migration.md @@ -453,6 +453,19 @@ toolchain. register_toolchains("@local_config_sh//:local_sh_toolchain") ``` +The toolchains and execution platforms registered in `WORKSPACE`, +`WORKSPACE.bzlmod` and each Bazel module's `MODULE.bazel` file follow this +order of precedence during toolchain selection (from highest to lowest): + +1. toolchains and execution platforms registered in the root module's + `MODULE.bazel` file. +2. toolchains and execution platforms registered in the `WORKSPACE` or + `WORKSPACE.bzlmod` file. +3. toolchains and execution platforms registered by modules that are + (transitive) dependencies of the root module. +4. when not using `WORKSPACE.bzlmod`: toolchains registered in the `WORKSPACE` + [suffix](/external/migration#builtin-default-deps). + [register_execution_platforms]: /rules/lib/globals/module#register_execution_platforms ### Introduce local repositories {:#introduce-local-deps} diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java index 742c237f096ecc..09dfa240a3a0db 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Package.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java @@ -72,6 +72,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.OptionalInt; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.Semaphore; @@ -239,7 +240,7 @@ public enum ConfigSettingVisibilityPolicy { private ImmutableList<TargetPattern> registeredExecutionPlatforms; private ImmutableList<TargetPattern> registeredToolchains; - + private OptionalInt firstWorkspaceSuffixRegisteredToolchain; private long computationSteps; // These two fields are mutually exclusive. Which one is set depends on @@ -402,6 +403,7 @@ private void finishInit(Builder builder) { this.failureDetail = builder.getFailureDetail(); this.registeredExecutionPlatforms = ImmutableList.copyOf(builder.registeredExecutionPlatforms); this.registeredToolchains = ImmutableList.copyOf(builder.registeredToolchains); + this.firstWorkspaceSuffixRegisteredToolchain = builder.firstWorkspaceSuffixRegisteredToolchain; this.repositoryMapping = Preconditions.checkNotNull(builder.repositoryMapping); this.mainRepositoryMapping = Preconditions.checkNotNull(builder.mainRepositoryMapping); ImmutableMap.Builder<RepositoryName, ImmutableMap<String, RepositoryName>> @@ -722,6 +724,23 @@ public ImmutableList<TargetPattern> getRegisteredToolchains() { return registeredToolchains; } + public ImmutableList<TargetPattern> getUserRegisteredToolchains() { + return getRegisteredToolchains() + .subList( + 0, firstWorkspaceSuffixRegisteredToolchain.orElse(getRegisteredToolchains().size())); + } + + public ImmutableList<TargetPattern> getWorkspaceSuffixRegisteredToolchains() { + return getRegisteredToolchains() + .subList( + firstWorkspaceSuffixRegisteredToolchain.orElse(getRegisteredToolchains().size()), + getRegisteredToolchains().size()); + } + + OptionalInt getFirstWorkspaceSuffixRegisteredToolchain() { + return firstWorkspaceSuffixRegisteredToolchain; + } + @Override public String toString() { return "Package(" @@ -936,8 +955,16 @@ default boolean precomputeTransitiveLoads() { private final List<TargetPattern> registeredToolchains = new ArrayList<>(); /** - * True iff the "package" function has already been called in this package. + * Tracks the index within {@link #registeredToolchains} of the first toolchain registered from + * the WORKSPACE suffixes rather than the WORKSPACE file (if any). + * + * <p>This is needed to distinguish between these toolchains during resolution: toolchains + * registered in WORKSPACE have precedence over those defined in non-root Bazel modules, which + * in turn have precedence over those from the WORKSPACE suffixes. */ + private OptionalInt firstWorkspaceSuffixRegisteredToolchain = OptionalInt.empty(); + + /** True iff the "package" function has already been called in this package. */ private boolean packageFunctionUsed; /** @@ -1620,10 +1647,18 @@ void addRegisteredExecutionPlatforms(List<TargetPattern> platforms) { this.registeredExecutionPlatforms.addAll(platforms); } - void addRegisteredToolchains(List<TargetPattern> toolchains) { + void addRegisteredToolchains(List<TargetPattern> toolchains, boolean forWorkspaceSuffix) { + if (forWorkspaceSuffix && firstWorkspaceSuffixRegisteredToolchain.isEmpty()) { + firstWorkspaceSuffixRegisteredToolchain = OptionalInt.of(registeredToolchains.size()); + } this.registeredToolchains.addAll(toolchains); } + void setFirstWorkspaceSuffixRegisteredToolchain( + OptionalInt firstWorkspaceSuffixRegisteredToolchain) { + this.firstWorkspaceSuffixRegisteredToolchain = firstWorkspaceSuffixRegisteredToolchain; + } + @CanIgnoreReturnValue private Builder beforeBuild(boolean discoverAssumedInputFiles) throws NoSuchPackageException { Preconditions.checkNotNull(pkg); diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java index d5901190b10058..095fd305412c78 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java @@ -185,7 +185,10 @@ public void setParent( builder.setFailureDetailOverride(aPackage.getFailureDetail()); } builder.addRegisteredExecutionPlatforms(aPackage.getRegisteredExecutionPlatforms()); - builder.addRegisteredToolchains(aPackage.getRegisteredToolchains()); + builder.addRegisteredToolchains( + aPackage.getRegisteredToolchains(), /* forWorkspaceSuffix= */ false); + builder.setFirstWorkspaceSuffixRegisteredToolchain( + aPackage.getFirstWorkspaceSuffixRegisteredToolchain()); builder.addRepositoryMappings(aPackage); for (Rule rule : aPackage.getTargets(Rule.class)) { try { diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java index 1f514a4f43cbcc..0f2847470d452d 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactoryHelper.java @@ -36,6 +36,13 @@ /** A helper for the {@link WorkspaceFactory} to create repository rules */ public final class WorkspaceFactoryHelper { + public static final String DEFAULT_WORKSPACE_SUFFIX_FILE = "/DEFAULT.WORKSPACE.SUFFIX"; + + public static boolean originatesInWorkspaceSuffix( + ImmutableList<StarlarkThread.CallStackEntry> callstack) { + return callstack.get(0).location.file().equals(DEFAULT_WORKSPACE_SUFFIX_FILE); + } + @CanIgnoreReturnValue public static Rule createAndAddRepositoryRule( Package.Builder pkg, @@ -70,7 +77,7 @@ public static Rule createAndAddRepositoryRule( throw new LabelSyntaxException(e.getMessage()); } } - pkg.addRegisteredToolchains(toolchains.build()); + pkg.addRegisteredToolchains(toolchains.build(), originatesInWorkspaceSuffix(callstack)); return rule; } diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java index 61255637295fc9..1ef44d40f422d2 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceGlobals.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.packages; +import static com.google.devtools.build.lib.packages.WorkspaceFactoryHelper.originatesInWorkspaceSuffix; import static net.starlark.java.eval.Starlark.NONE; import com.google.common.collect.ImmutableList; @@ -114,7 +115,9 @@ public void registerToolchains(Sequence<?> toolchainLabels, StarlarkThread threa // Add to the package definition for later. Package.Builder builder = PackageFactory.getContext(thread).pkgBuilder; List<String> patterns = Sequence.cast(toolchainLabels, String.class, "toolchain_labels"); - builder.addRegisteredToolchains(parsePatterns(patterns, builder, thread)); + builder.addRegisteredToolchains( + parsePatterns(patterns, builder, thread), + originatesInWorkspaceSuffix(thread.getCallStack())); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java index 8ae2ad808423fc..6d6186548494a0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.skyframe; +import static com.google.devtools.build.lib.packages.WorkspaceFactoryHelper.DEFAULT_WORKSPACE_SUFFIX_FILE; import static com.google.devtools.build.lib.rules.repository.ResolvedFileValue.ATTRIBUTES; import static com.google.devtools.build.lib.rules.repository.ResolvedFileValue.NATIVE; import static com.google.devtools.build.lib.rules.repository.ResolvedFileValue.REPOSITORIES; @@ -220,7 +221,7 @@ public SkyValue compute(SkyKey skyKey, Environment env) StarlarkFile file = StarlarkFile.parse( ParserInput.fromString( - ruleClassProvider.getDefaultWorkspaceSuffix(), "/DEFAULT.WORKSPACE.SUFFIX"), + ruleClassProvider.getDefaultWorkspaceSuffix(), DEFAULT_WORKSPACE_SUFFIX_FILE), // The DEFAULT.WORKSPACE.SUFFIX file breaks through the usual privacy mechanism. options.toBuilder().allowLoadPrivateSymbols(true).build()); if (!file.ok()) { diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD index 15c3c703e1d64f..e08f783554c4ab 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD @@ -90,6 +90,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration", "//src/main/java/com/google/devtools/build/lib/analysis/platform", "//src/main/java/com/google/devtools/build/lib/analysis/platform:utils", + "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:common", "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/packages", @@ -160,6 +161,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration", "//src/main/java/com/google/devtools/build/lib/analysis/platform", "//src/main/java/com/google/devtools/build/lib/analysis/platform:utils", + "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:common", "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:exception", "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution", "//src/main/java/com/google/devtools/build/lib/cmdline", diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunction.java index 4fb87c27f2b02e..671f9f906d676e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunction.java @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.bazel.bzlmod.BazelDepGraphValue; import com.google.devtools.build.lib.bazel.bzlmod.Module; +import com.google.devtools.build.lib.bazel.bzlmod.ModuleKey; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelConstants; import com.google.devtools.build.lib.cmdline.RepositoryName; @@ -104,21 +105,31 @@ public SkyValue compute(SkyKey skyKey, Environment env) } } - // Get registered execution platforms from bzlmod. - ImmutableList<TargetPattern> bzlmodExecutionPlatforms = - getBzlmodExecutionPlatforms(starlarkSemantics, env); - if (bzlmodExecutionPlatforms == null) { + // Get registered execution platforms from the root Bazel module. + ImmutableList<TargetPattern> bzlmodRootModuleExecutionPlatforms = + getBzlmodExecutionPlatforms(starlarkSemantics, env, /* forRootModule= */ true); + if (bzlmodRootModuleExecutionPlatforms == null) { return null; } - targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodExecutionPlatforms)); + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodRootModuleExecutionPlatforms)); // Get the registered execution platforms from the WORKSPACE. + // The WORKSPACE suffixes don't register any execution platforms, so we can register all + // platforms in WORKSPACE before those in non-root Bazel modules. ImmutableList<TargetPattern> workspaceExecutionPlatforms = getWorkspaceExecutionPlatforms(env); if (workspaceExecutionPlatforms == null) { return null; } targetPatternBuilder.addAll(TargetPatternUtil.toSigned(workspaceExecutionPlatforms)); + // Get registered execution platforms from the non-root Bazel modules. + ImmutableList<TargetPattern> bzlmodNonRootModuleExecutionPlatforms = + getBzlmodExecutionPlatforms(starlarkSemantics, env, /* forRootModule= */ false); + if (bzlmodNonRootModuleExecutionPlatforms == null) { + return null; + } + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodNonRootModuleExecutionPlatforms)); + // Expand target patterns. ImmutableList<Label> platformLabels; try { @@ -164,7 +175,7 @@ public static ImmutableList<TargetPattern> getWorkspaceExecutionPlatforms(Enviro @Nullable private static ImmutableList<TargetPattern> getBzlmodExecutionPlatforms( - StarlarkSemantics semantics, Environment env) + StarlarkSemantics semantics, Environment env, boolean forRootModule) throws InterruptedException, RegisteredExecutionPlatformsFunctionException { if (!semantics.getBool(BuildLanguageOptions.ENABLE_BZLMOD)) { return ImmutableList.of(); @@ -176,6 +187,9 @@ private static ImmutableList<TargetPattern> getBzlmodExecutionPlatforms( } ImmutableList.Builder<TargetPattern> executionPlatforms = ImmutableList.builder(); for (Module module : bazelDepGraphValue.getDepGraph().values()) { + if (forRootModule != module.getKey().equals(ModuleKey.ROOT)) { + continue; + } TargetPattern.Parser parser = new TargetPattern.Parser( PathFragment.EMPTY_FRAGMENT, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunction.java index cec918ff94e919..c01b3e6ee712f9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunction.java @@ -28,6 +28,7 @@ import com.google.devtools.build.lib.bazel.bzlmod.BazelDepGraphValue; import com.google.devtools.build.lib.bazel.bzlmod.ExternalDepsException; import com.google.devtools.build.lib.bazel.bzlmod.Module; +import com.google.devtools.build.lib.bazel.bzlmod.ModuleKey; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelConstants; import com.google.devtools.build.lib.cmdline.RepositoryName; @@ -95,19 +96,37 @@ public SkyValue compute(SkyKey skyKey, Environment env) new InvalidToolchainLabelException(e), Transience.PERSISTENT); } - // Get registered toolchains from bzlmod. - ImmutableList<TargetPattern> bzlmodToolchains = getBzlmodToolchains(starlarkSemantics, env); - if (bzlmodToolchains == null) { + // Get registered toolchains from the root Bazel module. + ImmutableList<TargetPattern> bzlmodRootModuleToolchains = + getBzlmodToolchains(starlarkSemantics, env, /* forRootModule= */ true); + if (bzlmodRootModuleToolchains == null) { return null; } - targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodToolchains)); + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodRootModuleToolchains)); - // Get the registered toolchains from the WORKSPACE. - ImmutableList<TargetPattern> workspaceToolchains = getWorkspaceToolchains(env); - if (workspaceToolchains == null) { + // Get the toolchains from the user-supplied WORKSPACE file. + ImmutableList<TargetPattern> userRegisteredWorkspaceToolchains = + getWorkspaceToolchains(env, /* userRegistered= */ true); + if (userRegisteredWorkspaceToolchains == null) { return null; } - targetPatternBuilder.addAll(TargetPatternUtil.toSigned(workspaceToolchains)); + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(userRegisteredWorkspaceToolchains)); + + // Get registered toolchains from non-root Bazel modules. + ImmutableList<TargetPattern> bzlmodNonRootModuleToolchains = + getBzlmodToolchains(starlarkSemantics, env, /* forRootModule= */ false); + if (bzlmodNonRootModuleToolchains == null) { + return null; + } + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(bzlmodNonRootModuleToolchains)); + + // Get the toolchains from the Bazel-supplied WORKSPACE suffix. + ImmutableList<TargetPattern> workspaceSuffixToolchains = + getWorkspaceToolchains(env, /* userRegistered= */ false); + if (workspaceSuffixToolchains == null) { + return null; + } + targetPatternBuilder.addAll(TargetPatternUtil.toSigned(workspaceSuffixToolchains)); // Expand target patterns. ImmutableList<Label> toolchainLabels; @@ -140,8 +159,8 @@ public SkyValue compute(SkyKey skyKey, Environment env) */ @Nullable @VisibleForTesting - public static ImmutableList<TargetPattern> getWorkspaceToolchains(Environment env) - throws InterruptedException { + public static ImmutableList<TargetPattern> getWorkspaceToolchains( + Environment env, boolean userRegistered) throws InterruptedException { PackageValue externalPackageValue = (PackageValue) env.getValue(LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER); if (externalPackageValue == null) { @@ -149,12 +168,16 @@ public static ImmutableList<TargetPattern> getWorkspaceToolchains(Environment en } Package externalPackage = externalPackageValue.getPackage(); - return externalPackage.getRegisteredToolchains(); + if (userRegistered) { + return externalPackage.getUserRegisteredToolchains(); + } else { + return externalPackage.getWorkspaceSuffixRegisteredToolchains(); + } } @Nullable private static ImmutableList<TargetPattern> getBzlmodToolchains( - StarlarkSemantics semantics, Environment env) + StarlarkSemantics semantics, Environment env, boolean forRootModule) throws InterruptedException, RegisteredToolchainsFunctionException { if (!semantics.getBool(BuildLanguageOptions.ENABLE_BZLMOD)) { return ImmutableList.of(); @@ -166,6 +189,9 @@ private static ImmutableList<TargetPattern> getBzlmodToolchains( } ImmutableList.Builder<TargetPattern> toolchains = ImmutableList.builder(); for (Module module : bazelDepGraphValue.getDepGraph().values()) { + if (forRootModule != module.getKey().equals(ModuleKey.ROOT)) { + continue; + } TargetPattern.Parser parser = new TargetPattern.Parser( PathFragment.EMPTY_FRAGMENT,
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java index bdcf861e3571d3..ba0fbd957955c4 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java @@ -501,7 +501,8 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten "def rules_java_dependencies():", " pass", "def rules_java_toolchains():", - " pass"); + " native.register_toolchains('//java/toolchains/runtime:all')", + " native.register_toolchains('//java/toolchains/javac:all')"); config.create( "rules_java_workspace/java/toolchains/runtime/BUILD", diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java b/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java index 9cc9715233fce6..bc49f4c2fd0129 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java @@ -39,4 +39,8 @@ public PackageFactoryBuilderWithSkyframeForTesting getPackageFactoryBuilderForTe public ConfiguredRuleClassProvider createRuleClassProvider() { return TestRuleClassProvider.getRuleClassProviderWithClearedSuffix(); } + + public ConfiguredRuleClassProvider createRuleClassProviderWithSuffix() { + return TestRuleClassProvider.getRuleClassProvider(); + } } diff --git a/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageHelperTest.java b/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageHelperTest.java index 3e6388aa44f923..289d61b157cff0 100644 --- a/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageHelperTest.java +++ b/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageHelperTest.java @@ -82,6 +82,7 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Stream; import javax.annotation.Nullable; import org.junit.Before; import org.junit.Test; @@ -411,13 +412,19 @@ private static final class GetRegisteredToolchainsFunction implements SkyFunctio @Override public SkyValue compute(SkyKey skyKey, Environment env) throws SkyFunctionException, InterruptedException { - List<TargetPattern> registeredToolchains = - RegisteredToolchainsFunction.getWorkspaceToolchains(env); - if (registeredToolchains == null) { + ImmutableList<TargetPattern> userRegisteredToolchains = + RegisteredToolchainsFunction.getWorkspaceToolchains(env, /* userRegistered= */ true); + if (userRegisteredToolchains == null) { + return null; + } + ImmutableList<TargetPattern> workspaceSuffixRegisteredToolchains = + RegisteredToolchainsFunction.getWorkspaceToolchains(env, /* userRegistered= */ false); + if (workspaceSuffixRegisteredToolchains == null) { return null; } return GetRegisteredToolchainsValue.create( - registeredToolchains.stream() + Stream.concat( + userRegisteredToolchains.stream(), workspaceSuffixRegisteredToolchains.stream()) .map(TargetPattern::getOriginalPattern) .collect(toImmutableList())); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java index 78e06b21e93940..3e21c1e58c6555 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java @@ -224,7 +224,8 @@ public void createToolchains() throws Exception { scratch.file( "toolchain/BUILD", "toolchain_type(name = 'test_toolchain')", - "toolchain_type(name = 'optional_toolchain')"); + "toolchain_type(name = 'optional_toolchain')", + "toolchain_type(name = 'workspace_suffix_toolchain')"); testToolchainTypeLabel = Label.parseCanonicalUnchecked("//toolchain:test_toolchain"); testToolchainType = ToolchainTypeRequirement.create(testToolchainTypeLabel); @@ -247,6 +248,22 @@ public void createToolchains() throws Exception { ImmutableList.of("//constraints:mac"), ImmutableList.of("//constraints:linux"), "bar"); + Label suffixToolchainTypeLabel = + Label.parseCanonicalUnchecked("//toolchain:workspace_suffix_toolchain"); + addToolchain( + "toolchain", + "suffix_toolchain_1", + suffixToolchainTypeLabel, + ImmutableList.of(), + ImmutableList.of(), + "suffix1"); + addToolchain( + "toolchain", + "suffix_toolchain_2", + suffixToolchainTypeLabel, + ImmutableList.of(), + ImmutableList.of(), + "suffix2"); } protected EvaluationResult<RegisteredToolchainsValue> requestToolchainsFromSkyframe( diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD index 943c9ddea6a78c..08252c34a218c8 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD +++ b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/BUILD @@ -66,14 +66,10 @@ java_test( deps = [ "//src/main/java/com/google/devtools/build/lib/analysis:view_creation_failed_exception", "//src/main/java/com/google/devtools/build/lib/analysis/platform", - "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution_impl", - "//src/main/java/com/google/devtools/build/lib/bazel/repository:repository_options", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_key", - "//src/main/java/com/google/devtools/build/lib/skyframe:precomputed_value", "//src/main/java/com/google/devtools/build/lib/skyframe/toolchains:platform_lookup_util", "//src/main/java/com/google/devtools/build/lib/skyframe/toolchains:registered_execution_platforms_value", - "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/test/java/com/google/devtools/build/lib/bazel/bzlmod:util", @@ -92,17 +88,16 @@ java_test( name = "RegisteredToolchainsFunctionTest", srcs = ["RegisteredToolchainsFunctionTest.java"], deps = [ + "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/analysis/platform", - "//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution_impl", - "//src/main/java/com/google/devtools/build/lib/bazel/repository:repository_options", "//src/main/java/com/google/devtools/build/lib/cmdline", - "//src/main/java/com/google/devtools/build/lib/skyframe:precomputed_value", "//src/main/java/com/google/devtools/build/lib/skyframe/toolchains:registered_toolchains_value", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/test/java/com/google/devtools/build/lib/bazel/bzlmod:util", "//src/test/java/com/google/devtools/build/lib/rules/platform:testutil", + "//src/test/java/com/google/devtools/build/lib/testutil", "//src/test/java/com/google/devtools/build/skyframe:testutil", "//third_party:guava", "//third_party:guava-testlib", diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunctionTest.java index 5d9688faa85b33..91b3981b8f518a 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredExecutionPlatformsFunctionTest.java @@ -339,8 +339,13 @@ public void testRegisteredExecutionPlatforms_bzlmod() throws Exception { "platform(name='plat')"); } scratch.overwriteFile( - "BUILD", "platform(name='plat')", "platform(name='dev_plat')", "platform(name='wsplat')"); - rewriteWorkspace("register_execution_platforms('//:wsplat')"); + "BUILD", + "platform(name='plat')", + "platform(name='dev_plat')", + "platform(name='wsplat')", + "platform(name='wsplat2')"); + rewriteWorkspace( + "register_execution_platforms('//:wsplat')", "register_execution_platforms('//:wsplat2')"); SkyKey executionPlatformsKey = RegisteredExecutionPlatformsValue.key(targetConfigKey); EvaluationResult<RegisteredExecutionPlatformsValue> result = @@ -354,13 +359,17 @@ public void testRegisteredExecutionPlatforms_bzlmod() throws Exception { // WORKSPACE registrations. assertExecutionPlatformLabels(result.get(executionPlatformsKey)) .containsExactly( + // Root module platforms Label.parseCanonical("//:plat"), Label.parseCanonical("//:dev_plat"), + // WORKSPACE platforms + Label.parseCanonical("//:wsplat"), + Label.parseCanonical("//:wsplat2"), + // Other modules' toolchains Label.parseCanonical("@@bbb~1.0//:plat"), Label.parseCanonical("@@ccc~1.1//:plat"), Label.parseCanonical("@@eee~1.0//:plat"), - Label.parseCanonical("@@ddd~1.1//:plat"), - Label.parseCanonical("//:wsplat")) + Label.parseCanonical("@@ddd~1.1//:plat")) .inOrder(); } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunctionTest.java index 0892a303c2a771..15b934e3befd61 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/toolchains/RegisteredToolchainsFunctionTest.java @@ -20,15 +20,18 @@ import com.google.common.collect.ImmutableList; import com.google.common.testing.EqualsTester; +import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.platform.DeclaredToolchainInfo; import com.google.devtools.build.lib.analysis.platform.ToolchainTypeInfo; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.rules.platform.ToolchainTestCase; +import com.google.devtools.build.lib.testutil.TestRuleClassProvider; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skyframe.EvaluationResult; import com.google.devtools.build.skyframe.SkyKey; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -37,6 +40,17 @@ @RunWith(JUnit4.class) public class RegisteredToolchainsFunctionTest extends ToolchainTestCase { + @Override + protected ConfiguredRuleClassProvider createRuleClassProvider() { + // testRegisteredToolchains_bzlmod uses the WORKSPACE suffixes. + ConfiguredRuleClassProvider.Builder builder = new ConfiguredRuleClassProvider.Builder(); + TestRuleClassProvider.addStandardRules(builder); + builder.clearWorkspaceFileSuffixForTesting(); + builder.addWorkspaceFileSuffix( + "register_toolchains('//toolchain:suffix_toolchain_1', '//toolchain:suffix_toolchain_2')"); + return builder.build(); + } + @Test public void testRegisteredToolchains() throws Exception { // Request the toolchains. @@ -423,8 +437,24 @@ public void testRegisteredToolchains_bzlmod() throws Exception { "load('@toolchain_def//:toolchain_def.bzl', 'declare_toolchain')", "declare_toolchain(name='dev_tool')", "declare_toolchain(name='tool')", - "declare_toolchain(name='wstool')"); - rewriteWorkspace("register_toolchains('//:wstool')"); + "declare_toolchain(name='wstool')", + "declare_toolchain(name='wstool2')"); + scratch.overwriteFile( + "WORKSPACE", + Stream.concat( + analysisMock.getWorkspaceContents(mockToolsConfig).stream() + // The register_toolchains calls usually live in the WORKSPACE suffixes. + // BazelAnalysisMock moves the mock registrations to the actual WORKSPACE file + // as most Java tests don't run with the suffixes. This test class does, so we + // skip over the "unnatural" registrations. + .filter(line -> !line.startsWith("register_toolchains(")), + // Register a toolchain explicitly that is also registered in the WORKSPACE suffix. + Stream.of( + "register_toolchains('//:wstool')", + "register_toolchains('//toolchain:suffix_toolchain_2')", + "register_toolchains('//:wstool2')")) + .toArray(String[]::new)); + invalidatePackages(); SkyKey toolchainsKey = RegisteredToolchainsValue.key(targetConfigKey); EvaluationResult<RegisteredToolchainsValue> result = @@ -438,13 +468,20 @@ public void testRegisteredToolchains_bzlmod() throws Exception { // registrations. assertToolchainLabels(result.get(toolchainsKey)) .containsAtLeast( + // Root module toolchains Label.parseCanonical("//:tool_impl"), Label.parseCanonical("//:dev_tool_impl"), + // WORKSPACE toolchains + Label.parseCanonical("//:wstool_impl"), + Label.parseCanonical("//toolchain:suffix_toolchain_2_impl"), + Label.parseCanonical("//:wstool2_impl"), + // Other modules' toolchains Label.parseCanonical("@@bbb~1.0//:tool_impl"), Label.parseCanonical("@@ccc~1.1//:tool_impl"), Label.parseCanonical("@@eee~1.0//:tool_impl"), Label.parseCanonical("@@ddd~1.1//:tool_impl"), - Label.parseCanonical("//:wstool_impl")) + // WORKSPACE suffix toolchains + Label.parseCanonical("//toolchain:suffix_toolchain_1_impl")) .inOrder(); }
train
test
2023-12-04T19:44:30
2023-11-29T09:47:07Z
lberki
test
bazelbuild/bazel/13463_20649
bazelbuild/bazel
bazelbuild/bazel/13463
bazelbuild/bazel/20649
[ "keyword_pr_to_issue" ]
4362d97fee91009a5be31510c537e292d90af8cb
3194d85f2e33c6e25c440350249ce91588bbb2b4
[ "Interesting observation thanks. I'll dig in some to find the root cause and report back...", "Some breakpoint debugging shows me this is what fails:\r\n\r\nhttps://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java...
[]
2023-12-21T21:41:35Z
[ "type: bug", "P3", "team-Configurability", "not stale" ]
bool_flag in config_setting via alias seems broken
### Description of the problem / feature request: When referencing a `bool_flag` in a `config_setting` via an `alias` indirection, the flag value set on the command line seems to be ignored. NOTE: it isn't necessarily only broken for `bool_flags`, but that's just a simple example that illustrate the issue. I suspect other flag types would have the same problem. ### Feature requests: what underlying problem are you trying to solve with this feature? I want to enable some sort of late-binding for enabling/disabling features, in a way that would 'point' to different workspaces based on a flag (boolean or otherwise). Since `select()` isn't possible in a `WORKSPACE`, it seems that a recommended alternative is to go through a `select`, `config_setting` + `alias` indirection. I have tried to simplify my example to a minimum size, so this doesn't exactly illustrate what I'm trying to archive, but it does illustrate the bug I see when following that approach ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. With the following files, run `run_all.sh` which will run 4 builds, one by one, and execute the result, printing `feature a: 0` or `feature a: 1` depending on the outcome of the `select` in the `BUILD` file. As we can see, we get `0` and `1` (depending on the `--//:enable_feature_a=xxx` command line option) when the `select` is for a `config_setting` that references a `bool_flag` directly, but we always get `0` regardless of the command line option when using a `config_setting` that references a `bool_flag` via an alias. ``` ❯ cat WORKSPACE load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_skylib", urls = [ "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", ], sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", ) load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() ❯ cat BUILD load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") config_setting( name = "feature_a_enabled", flag_values = { ":enable_feature_a": "true" } ) config_setting( name = "feature_a_enabled_aliased", flag_values = { ":enable_feature_a_aliased": "true" } ) bool_flag( name = "enable_feature_a", build_setting_default = False, ) alias( name = "enable_feature_a_aliased", actual = "enable_feature_a" ) cc_binary( name = "my_binary", srcs = ["main.c"] + select({ ":feature_a_enabled": ["feature_a.c"], "//conditions:default": ["default_a.c"] }) ) cc_binary( name = "my_binary_aliased", srcs = ["main.c"] + select({ ":feature_a_enabled_aliased": ["feature_a.c"], "//conditions:default": ["default_a.c"] }) ) ❯ cat main.c #include <stdio.h> extern int get_feature_a_value(void); int main(int argc, char** argv) { printf("feature a: %d\n", get_feature_a_value()); } ❯ cat feature_a.c int get_feature_a_value(void) { return 1; } ❯ cat default_a.c int get_feature_a_value(void) { return 0; } ❯ cat run_all.sh bazel build --//:enable_feature_a=false :my_binary bazel-bin/my_binary bazel build --//:enable_feature_a=true :my_binary bazel-bin/my_binary bazel build --//:enable_feature_a=false :my_binary_aliased bazel-bin/my_binary_aliased bazel build --//:enable_feature_a=true :my_binary_aliased bazel-bin/my_binary_aliased ``` ### What operating system are you running Bazel on? macOS Big Sur 11.3.1 ### What's the output of `bazel info release`? `release 4.0.0` ### Have you found anything relevant by searching the web? Looked online, couldn't find anything. The original reference to using `alias` with `select` when selecting things in a WORKSPACE was found here: https://docs.bazel.build/versions/master/configurable-attributes.html (see "Why doesn’t select() work with bind()?")
[ "src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java" ]
[ "src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java" ]
[ "src/test/java/com/google/devtools/build/lib/rules/LabelBuildSettingTest.java", "src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java index cc06b86450274f..cb70244ed28eea 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java @@ -497,10 +497,14 @@ static UserDefinedFlagMatch fromAttributeValueAndPrerequisites( } else if (target.satisfies(BuildSettingProvider.REQUIRE_BUILD_SETTING_PROVIDER)) { // build setting BuildSettingProvider provider = target.getProvider(BuildSettingProvider.class); - Object configurationValue = - optionDetails.getOptionValue(specifiedLabel) != null - ? optionDetails.getOptionValue(specifiedLabel) - : provider.getDefaultValue(); + + Object configurationValue; + if (optionDetails.getOptionValue(provider.getLabel()) != null) { + configurationValue = optionDetails.getOptionValue(provider.getLabel()); + } else { + configurationValue = provider.getDefaultValue(); + } + Object convertedSpecifiedValue; try { // We don't need to supply a base package or repo mapping for the conversion here,
diff --git a/src/test/java/com/google/devtools/build/lib/rules/LabelBuildSettingTest.java b/src/test/java/com/google/devtools/build/lib/rules/LabelBuildSettingTest.java index 5500ab253823fc..013cc9a02580d3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/LabelBuildSettingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/LabelBuildSettingTest.java @@ -116,6 +116,35 @@ public void testLabelFlag_set() throws Exception { assertThat(b.get("value")).isEqualTo("command_line_value"); } + @Test + public void withSelectThroughAlias() throws Exception { + writeRulesBzl("flag"); + scratch.file( + "test/BUILD", + "load('//test:rules.bzl', 'my_rule', 'simple_rule')", + "simple_rule(name = 'default', value = 'default_value')", + "simple_rule(name = 'command_line', value = 'command_line_value')", + "label_flag(name = 'my_label_flag', build_setting_default = ':default')", + "alias(name = 'my_label_flag_alias', actual = ':my_label_flag')", + "config_setting(", + " name = 'is_default_label',", + " flag_values = {':my_label_flag_alias': '//test:default'}", + ")", + "simple_rule(name = 'selector', value = select({':is_default_label': 'valid'}))"); + + useConfiguration(); + getConfiguredTarget("//test:selector"); + assertNoEvents(); + + reporter.removeHandler(failFastHandler); + useConfiguration( + ImmutableMap.of( + "//test:my_label_flag", Label.parseCanonicalUnchecked("//test:command_line"))); + getConfiguredTarget("//test:selector"); + assertContainsEvent( + "configurable attribute \"value\" in //test:selector doesn't match this configuration"); + } + @Test public void withSelect() throws Exception { writeRulesBzl("flag"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java index e96fb2f94d8e63..84ef07d33a286d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java @@ -2174,6 +2174,27 @@ public void ruleLicensesUsed() throws Exception { assertThat(getLicenses("//test:match")).containsExactly(LicenseType.NONE); } + @Test + public void aliasedStarlarkFlag() throws Exception { + scratch.file( + "test/flagdef.bzl", + "def _impl(ctx):", + " return []", + "my_flag = rule(", + " implementation = _impl,", + " build_setting = config.string(flag = True))"); + + scratch.file( + "test/BUILD", + "load('//test:flagdef.bzl', 'my_flag')", + "my_flag(name = 'flag', build_setting_default = 'default')", + "alias(name = 'alias', actual = ':flag')", + "config_setting(name = 'alias_setting', flag_values = {':alias': 'specified'})"); + + useConfiguration(ImmutableMap.of("//test:flag", "specified")); + assertThat(getConfigMatchingProviderResultAsBoolean("//test:alias_setting")).isTrue(); + } + @Test public void simpleStarlarkFlag() throws Exception { scratch.file(
test
test
2024-01-03T22:37:04
2021-05-11T02:37:47Z
barbibulle
test
bazelbuild/bazel/20515_20718
bazelbuild/bazel
bazelbuild/bazel/20515
bazelbuild/bazel/20718
[ "keyword_pr_to_issue" ]
e86f9b524db43b74adf7a83e520a4f41a5abadef
99dcdb007ee7a9a47df57744439e5e7a1fcaa923
[ "Thanks for the highly detailed report! I will look into this tomorrow.\n\nCc @lberki ", "Woah, that was a very detailed report, thanks for investing the time and energy into it :) It helped me to zero in on the problem:\r\n\r\n\r\nI can reproduce this. It's due to this snippet:\r\n\r\nhttps://github.com/bazelbui...
[]
2024-01-02T23:46:23Z
[ "type: bug", "team-Local-Exec" ]
Paths to Param Files in Command Lines Refer to Host Execroot Paths (instead of sandbox execroot paths) With `--incompatible_sandbox_hermetic_tmp=true`
## Issue Building Bazel at HEAD with Bazel 7.0.0 (with `--incompatible_sandbox_hermetic_tmp=true`, as is the [default in Bazel 7](https://github.com/bazelbuild/bazel/pull/19943)) and an output base on `/tmp` yields the following error about a `.params` file not being found: ```console ❯ bazel-7.0.0-linux-x86_64 --output_user_root=/tmp/rrbutani-bazel build //src:bazel -c opt ERROR: /src/dev/bazel/src/main/java/com/google/devtools/build/lib/analysis/BUILD:153:13: Compiling Java headers src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar (109 source files) failed: (Exit 1): linux-sandbox failed: error executing Turbine command (cd /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main && \ exec env - \ LC_CTYPE=en_US.UTF-8 \ PATH=/usr/local/bin:/usr/bin:/bin \ TMPDIR=/tmp \ /tmp/bazel-rrbutani/install/89a68939cbf63eb54205fdf943a58b15/linux-sandbox -W /tmp/bazel-working-directory/_main -t 15 -w /tmp/bazel-execroot/_main -w /tmp -w /dev/shm -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 -M /src/dev/bazel -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp -m /tmp -S /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/stats.out -D /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/debug.out -- external/rules_java~7.3.1~toolchains~remote_java_tools_linux/java_tools/turbine_direct_graal '-Dturbine.ctSymPath=external/rules_java~7.3.1~toolchains~remotejdk21_linux/lib/ct.sym' @bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params) java.lang.AssertionError: params file does not exist: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params at com.google.turbine.options.TurbineOptionsParser.expandParamsFiles(TurbineOptionsParser.java:182) at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:49) at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:38) at com.google.turbine.main.Main.compile(Main.java:133) at com.google.turbine.main.Main.main(Main.java:89) Target //src:bazel failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 1.225s, Critical Path: 0.15s INFO: 3 processes: 3 internal. ERROR: Build did NOT complete successfully ``` If `--incompatible_sandbox_hermetic_tmp=false` is passed, the above command succeeds. ## Details Running with `--sandbox_debug` produces the following: <details><summary>Click to expand</summary> ``` DEBUG: Sandbox debug output for Turbine //src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster: 1702418703.999694695: src/main/tools/linux-sandbox.cc:156: calling pipe(2)... 1702418703.999718491: src/main/tools/linux-sandbox.cc:165: Netns is 0 1702418703.999720291: src/main/tools/linux-sandbox.cc:176: calling clone(2)... 1702418704.000568193: src/main/tools/linux-sandbox.cc:185: linux-sandbox-pid1 has PID 30502 1702418704.000590115: src/main/tools/linux-sandbox-pid1.cc:700: Pid1Main started 1702418704.000652861: src/main/tools/linux-sandbox.cc:202: done manipulating pipes 1702418704.000775265: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot 1702418704.000791794: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory 1702418704.000799418: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 1702418704.000809258: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 1702418704.000815958: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /src/dev/bazel -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 1702418704.000834430: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp -> /tmp 1702418704.000848407: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp/bazel-execroot/_main 1702418704.000854112: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp 1702418704.000869304: src/main/tools/linux-sandbox-pid1.cc:311: writable: /dev/shm 1702418704.000876579: src/main/tools/linux-sandbox-pid1.cc:327: working dir: /tmp/bazel-working-directory/_main 1702418704.000949533: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: / 1702418704.000959313: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev 1702418704.000963615: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm 1702418704.000967575: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/pts 1702418704.000971798: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/hugepages 1702418704.000975643: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/mqueue 1702418704.000979660: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc 1702418704.000993590: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys 1702418704.001141631: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run 1702418704.001206959: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /var 1702418704.001215631: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp <unrelated paths snipped> 1702418704.002958323: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot 1702418704.002966211: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002970402: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory 1702418704.002972290: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002974770: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 1702418704.002976413: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002988558: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 1702418704.002990230: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002997175: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 1702418704.002998951: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.003001364: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp 1702418704.003004727: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-execroot 1702418704.003008764: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-working-directory 1702418704.003012225: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/0 1702418704.003015831: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/1 1702418704.003029328: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/2 1702418704.003033205: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-execroot/_main 1702418704.003036504: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp 1702418704.003039277: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-execroot 1702418704.003042065: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-execroot/_main 1702418704.003044940: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-working-directory 1702418704.003047774: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/0 1702418704.003050505: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/1 1702418704.003057570: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/2 1702418704.003060582: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm 1702418704.003064295: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-working-directory/_main 1702418704.003087515: src/main/tools/linux-sandbox-pid1.cc:496: calling fork... 1702418704.003209294: src/main/tools/linux-sandbox-pid1.cc:533: child started with PID 2 1702418704.005588552: src/main/tools/linux-sandbox-pid1.cc:550: wait returned pid=2, status=0x100 1702418704.005591954: src/main/tools/linux-sandbox-pid1.cc:568: child exited normally with code 1 1702418704.034940719: src/main/tools/linux-sandbox.cc:243: child exited normally with code 1 ``` </details> Inspecting the mounts and their ordering above confirms that contents in Bazel source roots and execroot should be visible: these mounts are bind mounted into the hermetic tmp location (not `/tmp` directly) before `/tmp` is pivoted to the hermetic tmp location (the final `bind mount:` in the above). --- By altering the `linux-sandbox` invocation above we can confirm that the `bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params` file is a dangling symlink, within the sandbox: ```bash /tmp/bazel-rrbutani/install/89a68939cbf63eb54205fdf943a58b15/linux-sandbox \ -W /tmp/bazel-working-directory/_main \ -t 15 \ -w /tmp/bazel-execroot/_main \ -w /tmp \ -w /dev/shm \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 \ -M /src/dev/bazel \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp \ -m /tmp \ -S /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/stats.out \ -D /dev/null \ -- ls --color -l bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ``` ```console-output lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ``` Inspecting `bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params` within this action's execroot (`/tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/`) confirms that the file is a symlink that refers to the host's execroot path rather than that of the sandbox (i.e. `/tmp/bazel-execroot/`): ```console ❯ ls /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -l lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ❯ ls /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/ -l | head total 16 drwxr-x--- 2 rrbutani users 4096 Dec 12 14:05 libactions lrwxrwxrwx 1 rrbutani users 128 Dec 12 14:05 libactions_provider-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libactions_provider-hjar.jar lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params lrwxrwxrwx 1 rrbutani users 141 Dec 12 14:05 libaspect_aware_attribute_mapper-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libaspect_aware_attribute_mapper-hjar.jar lrwxrwxrwx 1 rrbutani users 129 Dec 12 14:05 libaspect_collection-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libaspect_collection-hjar.jar lrwxrwxrwx 1 rrbutani users 130 Dec 12 14:05 libblaze_version_info-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libblaze_version_info-hjar.jar lrwxrwxrwx 1 rrbutani users 134 Dec 12 14:05 libbuild_setting_provider-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libbuild_setting_provider-hjar.jar drwxr-x--- 3 rrbutani users 4096 Dec 12 14:05 libconfig lrwxrwxrwx 1 rrbutani users 129 Dec 12 14:05 libconfigured_target-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libconfigured_target-hjar.jar ``` (note how the other files in the above are symlinks to `/tmp/bazel-execroot/`) ## Cause Poking around a bit, I think this is the relevant part of `rules_java`: https://github.com/bazelbuild/bazel/blob/379ee5fd888c8f3a83ed3751bee700287fa5d7de/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java#L486-L489 Notably `rules_cc` generated param files for link actions do not seem to have this issue (note the `/tmp/bazel-execroot` in the destinations): ```console ❯ fd . /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/ | grep params | xargs ls -l --color lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:25 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3006/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params lrwxrwxrwx 1 rrbutani users 80 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3098/execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/daemonize-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/daemonize-2.params lrwxrwxrwx 1 rrbutani users 83 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3114/execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/liblogging.a-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/liblogging.a-2.params lrwxrwxrwx 1 rrbutani users 111 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3149/execroot/_main/bazel-out/k8-dbg/bin/src/main/java/net/starlark/java/eval/libcpu_profiler.so-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/java/net/starlark/java/eval/libcpu_profiler.so-2.params ``` I _think_ that's because `rules_cc` generates its param files (for link actions) on its own using separate actions + files that are added as dependencies and doesn't use the `CommandLines.Builder` machinery: https://github.com/bazelbuild/bazel/blob/0aacc74776ec824cc403e5c040d97a4618c64429/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java#L950-L971 --- I am not familiar with this part of the Bazel codebase but it seems likely the problematic bit (placing host-execroot paths for the params file onto the command line) lives here: https://github.com/bazelbuild/bazel/blob/29f1db231f2a1c1197ae6b71cb60c3360e7fcd30/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java#L121-L154 And here: https://github.com/bazelbuild/bazel/blob/41ca39a38857fbb78566f40da008f087afbe22e8/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java#L348-L360 (note the use of `getPrimaryOutput().getExecPath()` for `paramFileBasePath`)
[ "src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java", "src/main/java/com/google/devtools/build/lib/sandbox/BUILD", "src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java", "src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java...
[ "src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java", "src/main/java/com/google/devtools/build/lib/sandbox/BUILD", "src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java", "src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java...
[ "src/test/java/com/google/devtools/build/lib/sandbox/BUILD", "src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java", "src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java", "src/test/shell/bazel/bazel_sandboxing_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java index 1afcd70e2b533b..be99bbd147220b 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java @@ -169,11 +169,19 @@ protected boolean couldBeModifiedByMetadata(FileArtifactValue lastKnown) { /** * Optional materialization path. * - * <p>If present, this artifact is a copy of another artifact. It is still tracked as a - * non-symlink by Bazel, but materialized in the local filesystem as a symlink to the original - * artifact, whose contents live at this location. This is used by {@link - * com.google.devtools.build.lib.remote.AbstractActionInputPrefetcher} to implement zero-cost - * copies of remotely stored artifacts. + * <p>If present, this artifact is a copy of another artifact whose contents live at this path. + * This can happen when it is declared as a file and not as an unresolved symlink but the action + * that creates it materializes it in the filesystem as a symlink to another output artifact. This + * information is useful in two situations: + * + * <ol> + * <li>When the symlink target is a remotely stored artifact, we can avoid downloading it + * multiple times when building without the bytes (see AbstractActionInputPrefetcher). + * <li>When the symlink target is inaccessible from the sandboxed environment an action runs + * under, we can rewrite it accordingly (see SandboxHelpers). + * </ol> + * + * @see com.google.devtools.build.lib.skyframe.TreeArtifactValue#getMaterializationExecPath(). */ public Optional<PathFragment> getMaterializationExecPath() { return Optional.empty(); @@ -214,6 +222,12 @@ public static FileArtifactValue createForSourceArtifact( xattrProvider); } + public static FileArtifactValue createForResolvedSymlink( + PathFragment realPath, FileArtifactValue metadata, @Nullable byte[] digest) { + return new ResolvedSymlinkFileArtifactValue( + realPath, digest, metadata.getContentsProxy(), metadata.getSize()); + } + public static FileArtifactValue createFromInjectedDigest( FileArtifactValue metadata, @Nullable byte[] digest) { return createForNormalFile(digest, metadata.getContentsProxy(), metadata.getSize()); @@ -439,7 +453,25 @@ public String toString() { } } - private static final class RegularFileArtifactValue extends FileArtifactValue { + private static final class ResolvedSymlinkFileArtifactValue extends RegularFileArtifactValue { + private final PathFragment realPath; + + private ResolvedSymlinkFileArtifactValue( + PathFragment realPath, + @Nullable byte[] digest, + @Nullable FileContentsProxy proxy, + long size) { + super(digest, proxy, size); + this.realPath = realPath; + } + + @Override + public Optional<PathFragment> getMaterializationExecPath() { + return Optional.of(realPath); + } + } + + private static class RegularFileArtifactValue extends FileArtifactValue { private final byte[] digest; @Nullable private final FileContentsProxy proxy; private final long size; @@ -462,7 +494,8 @@ public boolean equals(Object o) { RegularFileArtifactValue that = (RegularFileArtifactValue) o; return Arrays.equals(digest, that.digest) && Objects.equals(proxy, that.proxy) - && size == that.size; + && size == that.size + && Objects.equals(getMaterializationExecPath(), that.getMaterializationExecPath()); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/BUILD b/src/main/java/com/google/devtools/build/lib/sandbox/BUILD index 091dc914276592..9e92eb4750b833 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/BUILD +++ b/src/main/java/com/google/devtools/build/lib/sandbox/BUILD @@ -17,6 +17,7 @@ java_library( deps = [ "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", + "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", "//src/main/java/com/google/devtools/build/lib/analysis:test/test_configuration", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/vfs", diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java index 40cd3499675d27..3ad9c32531e0f0 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java @@ -228,6 +228,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java index 3dacaeaa05ee9a..971b05cd11b99b 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java @@ -226,6 +226,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index df6f5fbeaed26a..5e5e0a825d9cbf 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -280,6 +280,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, withinSandboxExecRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java index a01a4e6da25131..14d2a63545a734 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java @@ -100,6 +100,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java index fb72d591e0781e..dfc18bda2c839a 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java @@ -20,6 +20,7 @@ import static com.google.devtools.build.lib.vfs.Dirent.Type.SYMLINK; import com.google.auto.value.AutoValue; +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -29,6 +30,8 @@ import com.google.common.flogger.GoogleLogger; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.FileArtifactValue; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.UserExecException; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; @@ -444,6 +447,29 @@ private static RootedPath processFilesetSymlink( symlink.getPathString())); } + private static RootedPath processResolvedSymlink( + Root absoluteRoot, + PathFragment execRootRelativeSymlinkTarget, + Root execRootWithinSandbox, + PathFragment execRootFragment, + ImmutableList<Root> packageRoots, + Function<Root, Root> sourceRooWithinSandbox) { + PathFragment symlinkTarget = execRootFragment.getRelative(execRootRelativeSymlinkTarget); + for (Root packageRoot : packageRoots) { + if (packageRoot.contains(symlinkTarget)) { + return RootedPath.toRootedPath( + sourceRooWithinSandbox.apply(packageRoot), packageRoot.relativize(symlinkTarget)); + } + } + + if (symlinkTarget.startsWith(execRootFragment)) { + return RootedPath.toRootedPath( + execRootWithinSandbox, symlinkTarget.relativeTo(execRootFragment)); + } + + return RootedPath.toRootedPath(absoluteRoot, symlinkTarget); + } + /** * Returns the inputs of a Spawn as a map of PathFragments relative to an execRoot to paths in the * host filesystem where the input files can be found. @@ -458,6 +484,7 @@ private static RootedPath processFilesetSymlink( */ public SandboxInputs processInputFiles( Map<PathFragment, ActionInput> inputMap, + InputMetadataProvider inputMetadataProvider, Path execRootPath, Path withinSandboxExecRootPath, ImmutableList<Root> packageRoots, @@ -468,12 +495,24 @@ public SandboxInputs processInputFiles( withinSandboxExecRootPath.equals(execRootPath) ? withinSandboxExecRoot : Root.fromPath(execRootPath); + Root absoluteRoot = Root.absoluteRoot(execRootPath.getFileSystem()); Map<PathFragment, RootedPath> inputFiles = new TreeMap<>(); Map<PathFragment, PathFragment> inputSymlinks = new TreeMap<>(); Map<VirtualActionInput, byte[]> virtualInputs = new HashMap<>(); Map<Root, Root> sourceRootToSandboxSourceRoot = new TreeMap<>(); + Function<Root, Root> sourceRootWithinSandbox = + r -> { + if (!sourceRootToSandboxSourceRoot.containsKey(r)) { + int next = sourceRootToSandboxSourceRoot.size(); + sourceRootToSandboxSourceRoot.put( + r, Root.fromPath(sandboxSourceRoots.getRelative(Integer.toString(next)))); + } + + return sourceRootToSandboxSourceRoot.get(r); + }; + for (Map.Entry<PathFragment, ActionInput> e : inputMap.entrySet()) { if (Thread.interrupted()) { throw new InterruptedException(); @@ -503,23 +542,63 @@ public SandboxInputs processInputFiles( if (actionInput instanceof EmptyActionInput) { inputPath = null; + } else if (actionInput instanceof VirtualActionInput) { + inputPath = RootedPath.toRootedPath(withinSandboxExecRoot, actionInput.getExecPath()); } else if (actionInput instanceof Artifact) { Artifact inputArtifact = (Artifact) actionInput; - if (inputArtifact.isSourceArtifact() && sandboxSourceRoots != null) { - Root sourceRoot = inputArtifact.getRoot().getRoot(); - if (!sourceRootToSandboxSourceRoot.containsKey(sourceRoot)) { - int next = sourceRootToSandboxSourceRoot.size(); - sourceRootToSandboxSourceRoot.put( - sourceRoot, - Root.fromPath(sandboxSourceRoots.getRelative(Integer.toString(next)))); - } - - inputPath = - RootedPath.toRootedPath( - sourceRootToSandboxSourceRoot.get(sourceRoot), - inputArtifact.getRootRelativePath()); - } else { + if (sandboxSourceRoots == null) { inputPath = RootedPath.toRootedPath(withinSandboxExecRoot, inputArtifact.getExecPath()); + } else { + if (inputArtifact.isSourceArtifact()) { + Root sourceRoot = inputArtifact.getRoot().getRoot(); + inputPath = + RootedPath.toRootedPath( + sourceRootWithinSandbox.apply(sourceRoot), + inputArtifact.getRootRelativePath()); + } else { + PathFragment materializationExecPath = null; + if (inputArtifact.isChildOfDeclaredDirectory()) { + FileArtifactValue parentMetadata = + inputMetadataProvider.getInputMetadata(inputArtifact.getParent()); + if (parentMetadata.getMaterializationExecPath().isPresent()) { + materializationExecPath = + parentMetadata + .getMaterializationExecPath() + .get() + .getRelative(inputArtifact.getParentRelativePath()); + } + } else if (!inputArtifact.isTreeArtifact()) { + // Normally, one would not see tree artifacts here because they have already been + // expanded by the time the code gets here. However, there is one very special case: + // when an action has an archived tree artifact on its output and is executed on the + // local branch of the dynamic execution strategy, the tree artifact is zipped up + // in a little extra spawn, which has direct tree artifact on its inputs. Sadly, + // it's not easy to fix this because there isn't an easy way to inject this new + // tree artifact into the artifact expander being used. + // + // The best would be to not rely on spawn strategies for executing that little + // command: it's entirely under the control of Bazel so we can guarantee that it + // does not cause mischief. + FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(actionInput); + if (metadata.getMaterializationExecPath().isPresent()) { + materializationExecPath = metadata.getMaterializationExecPath().get(); + } + } + + if (materializationExecPath != null) { + inputPath = + processResolvedSymlink( + absoluteRoot, + materializationExecPath, + withinSandboxExecRoot, + execRootPath.asFragment(), + packageRoots, + sourceRootWithinSandbox); + } else { + inputPath = + RootedPath.toRootedPath(withinSandboxExecRoot, inputArtifact.getExecPath()); + } + } } } else { PathFragment execPath = actionInput.getExecPath(); @@ -544,6 +623,7 @@ public SandboxInputs processInputFiles( return new SandboxInputs(inputFiles, virtualInputs, inputSymlinks, sandboxRootToSourceRoot); } + /** The file and directory outputs of a sandboxed spawn. */ @AutoValue public abstract static class SandboxOutputs { diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java index c7996e38582fa1..505e2417850161 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java @@ -76,6 +76,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs readablePaths = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java index a1b1a77d3d0cbb..1bc2f4c7c0ac6a 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java @@ -264,7 +264,15 @@ private TreeArtifactValue constructTreeArtifactValueFromFilesystem(SpecialArtifa Path treeDir = artifactPathResolver.toPath(parent); boolean chmod = executionMode.get(); - FileStatus stat = treeDir.statIfFound(Symlinks.FOLLOW); + FileStatus lstat = treeDir.statIfFound(Symlinks.NOFOLLOW); + FileStatus stat; + if (lstat == null) { + stat = null; + } else if (!lstat.isSymbolicLink()) { + stat = lstat; + } else { + stat = treeDir.statIfFound(Symlinks.FOLLOW); + } // Make sure the tree artifact root exists and is a regular directory. Note that this is how the // action is initialized, so this should hold unless the action itself has deleted the root. @@ -332,12 +340,18 @@ private TreeArtifactValue constructTreeArtifactValueFromFilesystem(SpecialArtifa } // Same rationale as for constructFileArtifactValue. - if (anyRemote.get() && treeDir.isSymbolicLink() && stat instanceof FileStatusWithMetadata) { - FileArtifactValue metadata = ((FileStatusWithMetadata) stat).getMetadata(); - tree.setMaterializationExecPath( - metadata - .getMaterializationExecPath() - .orElse(treeDir.resolveSymbolicLinks().asFragment().relativeTo(execRoot))); + if (lstat.isSymbolicLink()) { + PathFragment materializationExecPath = null; + if (stat instanceof FileStatusWithMetadata) { + materializationExecPath = + ((FileStatusWithMetadata) stat).getMetadata().getMaterializationExecPath().orElse(null); + } + + if (materializationExecPath == null) { + materializationExecPath = treeDir.resolveSymbolicLinks().asFragment().relativeTo(execRoot); + } + + tree.setMaterializationExecPath(materializationExecPath); } return tree.build(); @@ -509,7 +523,13 @@ private FileArtifactValue constructFileArtifactValue( return value; } - if (type.isFile() && fileDigest != null) { + boolean isResolvedSymlink = + statAndValue.statNoFollow() != null + && statAndValue.statNoFollow().isSymbolicLink() + && statAndValue.realPath() != null + && !value.isRemote(); + + if (type.isFile() && !isResolvedSymlink && fileDigest != null) { // The digest is in the file value and that is all that is needed for this file's metadata. return value; } @@ -525,22 +545,30 @@ private FileArtifactValue constructFileArtifactValue( artifactPathResolver.toPath(artifact).getLastModifiedTime()); } - if (injectedDigest == null && type.isFile()) { + byte[] actualDigest = fileDigest != null ? fileDigest : injectedDigest; + + if (actualDigest == null && type.isFile()) { // We don't have an injected digest and there is no digest in the file value (which attempts a // fast digest). Manually compute the digest instead. - Path path = statAndValue.pathNoFollow(); - if (statAndValue.statNoFollow() != null - && statAndValue.statNoFollow().isSymbolicLink() - && statAndValue.realPath() != null) { - // If the file is a symlink, we compute the digest using the target path so that it's - // possible to hit the digest cache - we probably already computed the digest for the - // target during previous action execution. - path = statAndValue.realPath(); - } - injectedDigest = DigestUtils.manuallyComputeDigest(path, value.getSize()); + // If the file is a symlink, we compute the digest using the target path so that it's + // possible to hit the digest cache - we probably already computed the digest for the + // target during previous action execution. + Path pathToDigest = isResolvedSymlink ? statAndValue.realPath() : statAndValue.pathNoFollow(); + actualDigest = DigestUtils.manuallyComputeDigest(pathToDigest, value.getSize()); } - return FileArtifactValue.createFromInjectedDigest(value, injectedDigest); + + if (!isResolvedSymlink) { + return FileArtifactValue.createFromInjectedDigest(value, actualDigest); + } + + PathFragment realPathAsFragment = statAndValue.realPath().asFragment(); + PathFragment execRootRelativeRealPath = + realPathAsFragment.startsWith(execRoot) + ? realPathAsFragment.relativeTo(execRoot) + : realPathAsFragment; + return FileArtifactValue.createForResolvedSymlink( + execRootRelativeRealPath, value, actualDigest); } /** diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java index 6718b7e709a561..c21eb8e6bdc6b2 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java @@ -188,6 +188,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) helpers.processInputFiles( context.getInputMapping( PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots,
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/BUILD b/src/test/java/com/google/devtools/build/lib/sandbox/BUILD index 74873ef72d3311..671997db568c43 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/BUILD +++ b/src/test/java/com/google/devtools/build/lib/sandbox/BUILD @@ -59,12 +59,14 @@ java_test( deps = [ "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", + "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", "//src/main/java/com/google/devtools/build/lib/exec:bin_tools", "//src/main/java/com/google/devtools/build/lib/exec:tree_deleter", "//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers", "//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_options", "//src/main/java/com/google/devtools/build/lib/sandbox:sandboxed_spawns", "//src/main/java/com/google/devtools/build/lib/sandbox:tree_deleter", + "//src/main/java/com/google/devtools/build/lib/skyframe:tree_artifact_value", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java b/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java index 8df844739de17e..78fe5c244ee282 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java +++ b/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java @@ -24,17 +24,23 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionInput; +import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; +import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.ArtifactRoot; import com.google.devtools.build.lib.actions.CommandLines.ParamFileActionInput; +import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType; import com.google.devtools.build.lib.actions.PathMapper; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.exec.BinTools; +import com.google.devtools.build.lib.exec.util.FakeActionInputFileCache; import com.google.devtools.build.lib.exec.util.SpawnBuilder; import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxInputs; import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxOutputs; +import com.google.devtools.build.lib.skyframe.TreeArtifactValue; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.TestUtils; import com.google.devtools.build.lib.vfs.DigestHashFunction; @@ -68,6 +74,7 @@ /** Tests for {@link SandboxHelpers}. */ @RunWith(JUnit4.class) public class SandboxHelpersTest { + private static final byte[] FAKE_DIGEST = new byte[] {1}; private final Scratch scratch = new Scratch(); private Path execRootPath; @@ -94,6 +101,79 @@ private RootedPath execRootedPath(String execPath) { return RootedPath.toRootedPath(execRoot, PathFragment.create(execPath)); } + @Test + public void processInputFiles_resolvesMaterializationPath_fileArtifact() throws Exception { + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(execRootPath, ArtifactRoot.RootType.Output, "outputs"); + Path sandboxSourceRoot = scratch.dir("/faketmp/sandbox-source-roots"); + + Artifact input = ActionsTestUtil.createArtifact(outputRoot, "a/a"); + FileArtifactValue symlinkTargetMetadata = + FileArtifactValue.createForNormalFile(FAKE_DIGEST, null, 0L); + FileArtifactValue inputMetadata = + FileArtifactValue.createForResolvedSymlink( + PathFragment.create("b/b"), symlinkTargetMetadata, FAKE_DIGEST); + + FakeActionInputFileCache inputMetadataProvider = new FakeActionInputFileCache(); + inputMetadataProvider.put(input, inputMetadata); + + SandboxHelpers sandboxHelpers = new SandboxHelpers(); + SandboxInputs inputs = + sandboxHelpers.processInputFiles( + inputMap(input), + inputMetadataProvider, + execRootPath, + execRootPath, + ImmutableList.of(), + sandboxSourceRoot); + + assertThat(inputs.getFiles()) + .containsEntry( + input.getExecPath(), RootedPath.toRootedPath(execRoot, PathFragment.create("b/b"))); + } + + @Test + public void processInputFiles_resolvesMaterializationPath_treeArtifact() throws Exception { + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(execRootPath, ArtifactRoot.RootType.Output, "outputs"); + Path sandboxSourceRoot = scratch.dir("/faketmp/sandbox-source-roots"); + SpecialArtifact parent = + ActionsTestUtil.createTreeArtifactWithGeneratingAction( + outputRoot, "bin/config/other_dir/subdir"); + + TreeFileArtifact childA = TreeFileArtifact.createTreeOutput(parent, "a/a"); + TreeFileArtifact childB = TreeFileArtifact.createTreeOutput(parent, "b/b"); + FileArtifactValue childMetadata = FileArtifactValue.createForNormalFile(FAKE_DIGEST, null, 0L); + TreeArtifactValue parentMetadata = + TreeArtifactValue.newBuilder(parent) + .putChild(childA, childMetadata) + .putChild(childB, childMetadata) + .setMaterializationExecPath(PathFragment.create("materialized")) + .build(); + + FakeActionInputFileCache inputMetadataProvider = new FakeActionInputFileCache(); + inputMetadataProvider.put(parent, parentMetadata.getMetadata()); + + SandboxHelpers sandboxHelpers = new SandboxHelpers(); + SandboxInputs inputs = + sandboxHelpers.processInputFiles( + inputMap(childA, childB), + inputMetadataProvider, + execRootPath, + execRootPath, + ImmutableList.of(), + sandboxSourceRoot); + + assertThat(inputs.getFiles()) + .containsEntry( + childA.getExecPath(), + RootedPath.toRootedPath(execRoot, PathFragment.create("materialized/a/a"))); + assertThat(inputs.getFiles()) + .containsEntry( + childB.getExecPath(), + RootedPath.toRootedPath(execRoot, PathFragment.create("materialized/b/b"))); + } + @Test public void processInputFiles_materializesParamFile() throws Exception { SandboxHelpers sandboxHelpers = new SandboxHelpers(); @@ -106,7 +186,12 @@ public void processInputFiles_materializesParamFile() throws Exception { SandboxInputs inputs = sandboxHelpers.processInputFiles( - inputMap(paramFile), execRootPath, execRootPath, ImmutableList.of(), null); + inputMap(paramFile), + new FakeActionInputFileCache(), + execRootPath, + execRootPath, + ImmutableList.of(), + null); assertThat(inputs.getFiles()) .containsExactly(PathFragment.create("paramFile"), execRootedPath("paramFile")); @@ -127,7 +212,12 @@ public void processInputFiles_materializesBinToolsFile() throws Exception { SandboxInputs inputs = sandboxHelpers.processInputFiles( - inputMap(tool), execRootPath, execRootPath, ImmutableList.of(), null); + inputMap(tool), + new FakeActionInputFileCache(), + execRootPath, + execRootPath, + ImmutableList.of(), + null); assertThat(inputs.getFiles()) .containsExactly(PathFragment.create("_bin/say_hello"), execRootedPath("_bin/say_hello")); @@ -173,7 +263,12 @@ protected void setExecutable(PathFragment path, boolean executable) throws IOExc try { var unused = sandboxHelpers.processInputFiles( - inputMap(input), customExecRoot, customExecRoot, ImmutableList.of(), null); + inputMap(input), + new FakeActionInputFileCache(), + customExecRoot, + customExecRoot, + ImmutableList.of(), + null); finishProcessingSemaphore.release(); } catch (IOException | InterruptedException e) { throw new IllegalArgumentException(e); @@ -181,7 +276,12 @@ protected void setExecutable(PathFragment path, boolean executable) throws IOExc }); var unused = sandboxHelpers.processInputFiles( - inputMap(input), customExecRoot, customExecRoot, ImmutableList.of(), null); + inputMap(input), + new FakeActionInputFileCache(), + customExecRoot, + customExecRoot, + ImmutableList.of(), + null); finishProcessingSemaphore.release(); future.get(); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java index 430e809fb50f31..afcf8281bb36b8 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java @@ -82,10 +82,6 @@ private enum TreeComposition { FULLY_LOCAL, FULLY_REMOTE, MIXED; - - boolean isPartiallyRemote() { - return this == FULLY_REMOTE || this == MIXED; - } } private final Map<Path, Integer> chmodCalls = Maps.newConcurrentMap(); @@ -422,11 +418,10 @@ public void fileArtifactMaterializedAsSymlink( .getPath(outputArtifact.getPath().getPathString()) .createSymbolicLink(targetArtifact.getPath().asFragment()); - PathFragment expectedMaterializationExecPath = null; - if (location == FileLocation.REMOTE) { - expectedMaterializationExecPath = - preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); - } + PathFragment expectedMaterializationExecPath = + location == FileLocation.REMOTE && preexistingPath != null + ? preexistingPath + : targetArtifact.getExecPath(); assertThat(store.getOutputMetadata(outputArtifact)) .isEqualTo(createFileMetadataForSymlinkTest(location, expectedMaterializationExecPath)); @@ -436,7 +431,12 @@ private FileArtifactValue createFileMetadataForSymlinkTest( FileLocation location, @Nullable PathFragment materializationExecPath) { switch (location) { case LOCAL: - return FileArtifactValue.createForNormalFile(new byte[] {1, 2, 3}, /* proxy= */ null, 10); + FileArtifactValue target = + FileArtifactValue.createForNormalFile(new byte[] {1, 2, 3}, /* proxy= */ null, 10); + return materializationExecPath == null + ? target + : FileArtifactValue.createForResolvedSymlink( + materializationExecPath, target, target.getDigest()); case REMOTE: return RemoteFileArtifactValue.create( new byte[] {1, 2, 3}, 10, 1, -1, materializationExecPath); @@ -481,11 +481,8 @@ public void treeArtifactMaterializedAsSymlink( .getPath(outputArtifact.getPath().getPathString()) .createSymbolicLink(targetArtifact.getPath().asFragment()); - PathFragment expectedMaterializationExecPath = null; - if (composition.isPartiallyRemote()) { - expectedMaterializationExecPath = - preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); - } + PathFragment expectedMaterializationExecPath = + preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); assertThat(store.getTreeArtifactValue(outputArtifact)) .isEqualTo( @@ -814,7 +811,7 @@ public void fileArtifactValueForSymlink_readFromCache() throws Exception { var symlinkMetadata = store.getOutputMetadata(symlink); - assertThat(symlinkMetadata).isEqualTo(targetMetadata); + assertThat(symlinkMetadata.getDigest()).isEqualTo(targetMetadata.getDigest()); assertThat(DigestUtils.getCacheStats().hitCount()).isEqualTo(1); } } diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 3e65184291777a..86fa7ad1807cd4 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -334,6 +334,95 @@ EOF assert_contains GOOD bazel-bin/pkg/gen.txt } +function test_symlink_with_output_base_under_tmp() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + mkdir -p pkg + cat > pkg/BUILD <<'EOF' +load(":r.bzl", "symlink_rule") + +genrule(name="r1", srcs=[], outs=[":r1"], cmd="echo CONTENT > $@") +symlink_rule(name="r2", input=":r1") +genrule(name="r3", srcs=[":r2"], outs=[":r3"], cmd="cp $< $@") +EOF + + cat > pkg/r.bzl <<'EOF' +def _symlink_impl(ctx): + output = ctx.actions.declare_file(ctx.label.name) + ctx.actions.symlink(output = output, target_file = ctx.file.input) + return [DefaultInfo(files = depset([output]))] + +symlink_rule = rule( + implementation = _symlink_impl, + attrs = {"input": attr.label(allow_single_file=True)}) +EOF + + local tmp_output_base=$(mktemp -d "/tmp/bazel_output_base.XXXXXXXX") + trap "chmod -R u+w $tmp_output_base && rm -fr $tmp_output_base" EXIT + + bazel --output_base="$tmp_output_base" build //pkg:r3 + assert_contains CONTENT bazel-bin/pkg/r3 + bazel --output_base="$tmp_output_base" shutdown +} + +function test_symlink_to_directory_with_output_base_under_tmp() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + mkdir -p pkg + cat > pkg/BUILD <<'EOF' +load(":r.bzl", "symlink_rule", "tree_rule") + +tree_rule(name="t1") +symlink_rule(name="t2", input=":t1") +genrule(name="t3", srcs=[":t2"], outs=[":t3"], cmd=";\n".join( + ["cat $(location :t2)/{a/a,b/b} > $@"])) +EOF + + cat > pkg/r.bzl <<'EOF' +def _symlink_impl(ctx): + output = ctx.actions.declare_directory(ctx.label.name) + ctx.actions.symlink(output = output, target_file = ctx.file.input) + return [DefaultInfo(files = depset([output]))] + +symlink_rule = rule( + implementation = _symlink_impl, + attrs = {"input": attr.label(allow_single_file=True)}) + +def _tree_impl(ctx): + output = ctx.actions.declare_directory(ctx.label.name) + ctx.actions.run_shell( + outputs = [output], + command = "export TREE=%s && mkdir $TREE/a $TREE/b && echo -n A > $TREE/a/a && echo -n B > $TREE/b/b" % output.path) + return [DefaultInfo(files = depset([output]))] + +tree_rule = rule( + implementation = _tree_impl, + attrs = {}) + +EOF + + local tmp_output_base=$(mktemp -d "/tmp/bazel_output_base.XXXXXXXX") + trap "chmod -R u+w $tmp_output_base && rm -fr $tmp_output_base" EXIT + + bazel --output_base="$tmp_output_base" build //pkg:t3 + assert_contains AB bazel-bin/pkg/t3 + bazel --output_base="$tmp_output_base" shutdown +} + # The test shouldn't fail if the environment doesn't support running it. check_sandbox_allowed || exit 0
val
test
2024-01-03T22:05:59
2023-12-12T23:12:52Z
rrbutani
test
bazelbuild/bazel/20527_20749
bazelbuild/bazel
bazelbuild/bazel/20527
bazelbuild/bazel/20749
[ "keyword_pr_to_issue" ]
b5fa4929be04f01e27b03fb320452064a846d304
47de7f0450ca30a9ff0e30f6c6fba4f9dc8ff4a8
[ "CC @lberki \r\n\r\nA simple workaround would be to just disable the hermetic `/tmp` in this case, similar to what we do for tmpfs paths. What do you think of this?\r\n\r\n```java\r\ndiff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/b...
[]
2024-01-04T23:17:36Z
[ "type: bug", "team-Local-Exec" ]
Bazel 7: `--sandbox_add_mount_pair` under `/tmp` fails
### Description of the bug: With Bazel 7, but neither Bazel 6.4.0 nor `--noincompatible_sandbox_hermetic_tmp`, builds with `--sandbox_add_mount_pair` referencing a path under `/tmp` fail since `/tmp` has been remounted before the manually specified mount pair is applied. ### Which category does this issue belong to? Local Execution ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ```shell touch WORKSPACE cat > .bazelrc <<'EOF' build --sandbox_add_mount_pair=/tmp/some/path:/etc EOF cat > BUILD <<'EOF' genrule( name = "gen", outs = ["data.txt"], cmd = "ls /etc > $@", ) EOF ``` Then: ``` $ mkdir -p /tmp/some/path $ bazel clean --expunge && bazel shutdown && bazel build //:gen ... src/main/tools/linux-sandbox-pid1.cc:305: "mount(/tmp/some/path, /etc, nullptr, MS_BIND | MS_REC, nullptr)": No such file or directory Target //:gen failed to build ... # bazel clean --expunge && bazel shutdown && bazel build //:gen --noincompatible_sandbox_hermetic_tmp ... INFO: Build completed successfully, 2 total actions ``` ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? 7.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java" ]
[ "src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java" ]
[ "src/test/shell/bazel/bazel_sandboxing_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index 5e5e0a825d9cbf..8c333be0553f73 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -14,13 +14,13 @@ package com.google.devtools.build.lib.sandbox; +import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.devtools.build.lib.sandbox.LinuxSandboxCommandLineBuilder.NetworkNamespace.NETNS_WITH_LOOPBACK; import static com.google.devtools.build.lib.sandbox.LinuxSandboxCommandLineBuilder.NetworkNamespace.NO_NETNS; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import com.google.common.io.ByteStreams; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ExecException; @@ -61,6 +61,7 @@ import java.util.Map; import java.util.Optional; import java.util.SortedMap; +import java.util.TreeMap; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; @@ -313,7 +314,8 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context .addExecutionInfo(spawn.getExecutionInfo()) .setWritableFilesAndDirectories(writableDirs) .setTmpfsDirectories(ImmutableSet.copyOf(getSandboxOptions().sandboxTmpfsPath)) - .setBindMounts(getBindMounts(blazeDirs, inputs, sandboxExecRootBase, sandboxTmp)) + .setBindMounts( + prepareAndGetBindMounts(blazeDirs, inputs, sandboxExecRootBase, sandboxTmp)) .setUseFakeHostname(getSandboxOptions().sandboxFakeHostname) .setEnablePseudoterminal(getSandboxOptions().sandboxExplicitPseudoterminal) .setCreateNetworkNamespace(createNetworkNamespace ? NETNS_WITH_LOOPBACK : NO_NETNS) @@ -403,50 +405,73 @@ protected ImmutableSet<Path> getWritableDirs( return writableDirs.build(); } - private ImmutableList<BindMount> getBindMounts( + private ImmutableList<BindMount> prepareAndGetBindMounts( BlazeDirectories blazeDirs, SandboxInputs inputs, Path sandboxExecRootBase, @Nullable Path sandboxTmp) - throws UserExecException { - Path tmpPath = fileSystem.getPath("/tmp"); - final SortedMap<Path, Path> bindMounts = Maps.newTreeMap(); + throws UserExecException, IOException { + Path tmpPath = fileSystem.getPath(SLASH_TMP); + final SortedMap<Path, Path> userBindMounts = new TreeMap<>(); SandboxHelpers.mountAdditionalPaths( - getSandboxOptions().sandboxAdditionalMounts, sandboxExecRootBase, bindMounts); + getSandboxOptions().sandboxAdditionalMounts, sandboxExecRootBase, userBindMounts); for (Path inaccessiblePath : getInaccessiblePaths()) { if (inaccessiblePath.isDirectory(Symlinks.NOFOLLOW)) { - bindMounts.put(inaccessiblePath, inaccessibleHelperDir); + userBindMounts.put(inaccessiblePath, inaccessibleHelperDir); } else { - bindMounts.put(inaccessiblePath, inaccessibleHelperFile); + userBindMounts.put(inaccessiblePath, inaccessibleHelperFile); } } - LinuxSandboxUtil.validateBindMounts(bindMounts); - ImmutableList.Builder<BindMount> result = ImmutableList.builder(); - bindMounts.forEach((k, v) -> result.add(BindMount.of(k, v))); + LinuxSandboxUtil.validateBindMounts(userBindMounts); - if (sandboxTmp != null) { - // First mount the real exec root and the empty directory created as the working dir of the - // action under $SANDBOX/_tmp - result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_EXECROOT), blazeDirs.getExecRootBase())); - result.add( - BindMount.of(sandboxTmp.getRelative(BAZEL_WORKING_DIRECTORY), sandboxExecRootBase)); - - // Then mount the individual package roots under $SANDBOX/_tmp/bazel-source-roots - inputs - .getSourceRootBindMounts() - .forEach( - (withinSandbox, real) -> { - PathFragment sandboxTmpSourceRoot = withinSandbox.asPath().relativeTo(tmpPath); - result.add(BindMount.of(sandboxTmp.getRelative(sandboxTmpSourceRoot), real)); - }); - - // Then mount $SANDBOX/_tmp at /tmp. At this point, even if the output base (and execroot) - // and individual source roots are under /tmp, they are accessible at /tmp/bazel-* - result.add(BindMount.of(tmpPath, sandboxTmp)); + if (sandboxTmp == null) { + return userBindMounts.entrySet().stream() + .map(e -> BindMount.of(e.getKey(), e.getValue())) + .collect(toImmutableList()); } + SortedMap<Path, Path> bindMounts = new TreeMap<>(); + for (var entry : userBindMounts.entrySet()) { + Path mountPoint = entry.getKey(); + Path content = entry.getValue(); + if (mountPoint.startsWith(tmpPath)) { + // sandboxTmp should be null if /tmp is an explicit mount point since useHermeticTmp() + // returns false in that case. + if (mountPoint.equals(tmpPath)) { + throw new IOException( + "Cannot mount /tmp explicitly with hermetic /tmp. Please file a bug at" + + " https://github.com/bazelbuild/bazel/issues/new/choose."); + } + // We need to rewrite the mount point to be under the sandbox tmp directory, which will be + // mounted onto /tmp as the final mount. + mountPoint = sandboxTmp.getRelative(mountPoint.relativeTo(tmpPath)); + mountPoint.createDirectoryAndParents(); + } + bindMounts.put(mountPoint, content); + } + + ImmutableList.Builder<BindMount> result = ImmutableList.builder(); + bindMounts.forEach((k, v) -> result.add(BindMount.of(k, v))); + + // First mount the real exec root and the empty directory created as the working dir of the + // action under $SANDBOX/_tmp + result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_EXECROOT), blazeDirs.getExecRootBase())); + result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_WORKING_DIRECTORY), sandboxExecRootBase)); + + // Then mount the individual package roots under $SANDBOX/_tmp/bazel-source-roots + inputs + .getSourceRootBindMounts() + .forEach( + (withinSandbox, real) -> { + PathFragment sandboxTmpSourceRoot = withinSandbox.asPath().relativeTo(tmpPath); + result.add(BindMount.of(sandboxTmp.getRelative(sandboxTmpSourceRoot), real)); + }); + + // Then mount $SANDBOX/_tmp at /tmp. At this point, even if the output base (and execroot) and + // individual source roots are under /tmp, they are accessible at /tmp/bazel-* + result.add(BindMount.of(tmpPath, sandboxTmp)); return result.build(); }
diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 86fa7ad1807cd4..ec7655ac36d53b 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -316,21 +316,84 @@ function test_add_mount_pair_tmp_source() { sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + local mounted=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") + trap "rm -fr $mounted" EXIT + echo GOOD > "$mounted/data.txt" + mkdir -p pkg - cat > pkg/BUILD <<'EOF' + cat > pkg/BUILD <<EOF +genrule( + name = "gen", + outs = ["gen.txt"], + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${mounted}/data.txt" ] && cp /etc/data.txt \$@""", +) +EOF + + # This assumes the existence of /etc on the host system + bazel build --sandbox_add_mount_pair="$mounted:/etc" //pkg:gen || fail "build failed" + assert_contains GOOD bazel-bin/pkg/gen.txt +} + +function test_add_mount_pair_tmp_target() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + local source_dir=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") + trap "rm -fr $source_dir" EXIT + echo BAD > "$source_dir/data.txt" + + mkdir -p pkg + cat > pkg/BUILD <<EOF genrule( name = "gen", outs = ["gen.txt"], - cmd = "cp /etc/data.txt $@", + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${source_dir}/data.txt" ] && ls "$source_dir" > \$@""", ) EOF + + # This assumes the existence of /etc on the host system + bazel build --sandbox_add_mount_pair="/etc:$source_dir" //pkg:gen || fail "build failed" + assert_contains passwd bazel-bin/pkg/gen.txt +} + +function test_add_mount_pair_tmp_target_and_source() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + local mounted=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") trap "rm -fr $mounted" EXIT echo GOOD > "$mounted/data.txt" - # This assumes the existence of /etc on the host system - bazel build --sandbox_add_mount_pair="$mounted:/etc" //pkg:gen || fail "build failed" + local tmp_file=$(mktemp "/tmp/bazel_tmp.XXXXXXXX") + trap "rm $tmp_file" EXIT + echo BAD > "$tmp_file" + + mkdir -p pkg + cat > pkg/BUILD <<EOF +genrule( + name = "gen", + outs = ["gen.txt"], + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${tmp_file}" ] && cp "$mounted/data.txt" \$@""", +) +EOF + + bazel build --sandbox_add_mount_pair="$mounted" //pkg:gen || fail "build failed" assert_contains GOOD bazel-bin/pkg/gen.txt }
test
test
2024-01-05T01:21:06
2023-12-13T17:26:37Z
fmeum
test
bazelbuild/bazel/20515_20766
bazelbuild/bazel
bazelbuild/bazel/20515
bazelbuild/bazel/20766
[ "keyword_pr_to_issue" ]
6f07e40bf3b6afea4024da1dc8265ef56f3ab5f4
806556d214a8735575444966948e6ab3d8b4159d
[ "Thanks for the highly detailed report! I will look into this tomorrow.\n\nCc @lberki ", "Woah, that was a very detailed report, thanks for investing the time and energy into it :) It helped me to zero in on the problem:\r\n\r\n\r\nI can reproduce this. It's due to this snippet:\r\n\r\nhttps://github.com/bazelbui...
[]
2024-01-05T23:54:40Z
[ "type: bug", "team-Local-Exec" ]
Paths to Param Files in Command Lines Refer to Host Execroot Paths (instead of sandbox execroot paths) With `--incompatible_sandbox_hermetic_tmp=true`
## Issue Building Bazel at HEAD with Bazel 7.0.0 (with `--incompatible_sandbox_hermetic_tmp=true`, as is the [default in Bazel 7](https://github.com/bazelbuild/bazel/pull/19943)) and an output base on `/tmp` yields the following error about a `.params` file not being found: ```console ❯ bazel-7.0.0-linux-x86_64 --output_user_root=/tmp/rrbutani-bazel build //src:bazel -c opt ERROR: /src/dev/bazel/src/main/java/com/google/devtools/build/lib/analysis/BUILD:153:13: Compiling Java headers src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar (109 source files) failed: (Exit 1): linux-sandbox failed: error executing Turbine command (cd /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main && \ exec env - \ LC_CTYPE=en_US.UTF-8 \ PATH=/usr/local/bin:/usr/bin:/bin \ TMPDIR=/tmp \ /tmp/bazel-rrbutani/install/89a68939cbf63eb54205fdf943a58b15/linux-sandbox -W /tmp/bazel-working-directory/_main -t 15 -w /tmp/bazel-execroot/_main -w /tmp -w /dev/shm -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 -M /src/dev/bazel -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp -m /tmp -S /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/stats.out -D /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/debug.out -- external/rules_java~7.3.1~toolchains~remote_java_tools_linux/java_tools/turbine_direct_graal '-Dturbine.ctSymPath=external/rules_java~7.3.1~toolchains~remotejdk21_linux/lib/ct.sym' @bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params) java.lang.AssertionError: params file does not exist: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params at com.google.turbine.options.TurbineOptionsParser.expandParamsFiles(TurbineOptionsParser.java:182) at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:49) at com.google.turbine.options.TurbineOptionsParser.parse(TurbineOptionsParser.java:38) at com.google.turbine.main.Main.compile(Main.java:133) at com.google.turbine.main.Main.main(Main.java:89) Target //src:bazel failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 1.225s, Critical Path: 0.15s INFO: 3 processes: 3 internal. ERROR: Build did NOT complete successfully ``` If `--incompatible_sandbox_hermetic_tmp=false` is passed, the above command succeeds. ## Details Running with `--sandbox_debug` produces the following: <details><summary>Click to expand</summary> ``` DEBUG: Sandbox debug output for Turbine //src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster: 1702418703.999694695: src/main/tools/linux-sandbox.cc:156: calling pipe(2)... 1702418703.999718491: src/main/tools/linux-sandbox.cc:165: Netns is 0 1702418703.999720291: src/main/tools/linux-sandbox.cc:176: calling clone(2)... 1702418704.000568193: src/main/tools/linux-sandbox.cc:185: linux-sandbox-pid1 has PID 30502 1702418704.000590115: src/main/tools/linux-sandbox-pid1.cc:700: Pid1Main started 1702418704.000652861: src/main/tools/linux-sandbox.cc:202: done manipulating pipes 1702418704.000775265: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot 1702418704.000791794: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory 1702418704.000799418: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 1702418704.000809258: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 1702418704.000815958: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /src/dev/bazel -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 1702418704.000834430: src/main/tools/linux-sandbox-pid1.cc:302: bind mount: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp -> /tmp 1702418704.000848407: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp/bazel-execroot/_main 1702418704.000854112: src/main/tools/linux-sandbox-pid1.cc:311: writable: /tmp 1702418704.000869304: src/main/tools/linux-sandbox-pid1.cc:311: writable: /dev/shm 1702418704.000876579: src/main/tools/linux-sandbox-pid1.cc:327: working dir: /tmp/bazel-working-directory/_main 1702418704.000949533: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: / 1702418704.000959313: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev 1702418704.000963615: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm 1702418704.000967575: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/pts 1702418704.000971798: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/hugepages 1702418704.000975643: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /dev/mqueue 1702418704.000979660: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /proc 1702418704.000993590: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /sys 1702418704.001141631: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /run 1702418704.001206959: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /var 1702418704.001215631: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp <unrelated paths snipped> 1702418704.002958323: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot 1702418704.002966211: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002970402: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory 1702418704.002972290: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002974770: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 1702418704.002976413: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002988558: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 1702418704.002990230: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.002997175: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 1702418704.002998951: src/main/tools/linux-sandbox-pid1.cc:427: remount(nullptr, /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2, nullptr, 2101281, nullptr) failure (No such file or directory) ignored 1702418704.003001364: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp 1702418704.003004727: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-execroot 1702418704.003008764: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-working-directory 1702418704.003012225: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/0 1702418704.003015831: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/1 1702418704.003029328: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/2 1702418704.003033205: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-execroot/_main 1702418704.003036504: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp 1702418704.003039277: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-execroot 1702418704.003042065: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-execroot/_main 1702418704.003044940: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-working-directory 1702418704.003047774: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/0 1702418704.003050505: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/1 1702418704.003057570: src/main/tools/linux-sandbox-pid1.cc:405: remount ro: /tmp/bazel-source-roots/2 1702418704.003060582: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /dev/shm 1702418704.003064295: src/main/tools/linux-sandbox-pid1.cc:405: remount rw: /tmp/bazel-working-directory/_main 1702418704.003087515: src/main/tools/linux-sandbox-pid1.cc:496: calling fork... 1702418704.003209294: src/main/tools/linux-sandbox-pid1.cc:533: child started with PID 2 1702418704.005588552: src/main/tools/linux-sandbox-pid1.cc:550: wait returned pid=2, status=0x100 1702418704.005591954: src/main/tools/linux-sandbox-pid1.cc:568: child exited normally with code 1 1702418704.034940719: src/main/tools/linux-sandbox.cc:243: child exited normally with code 1 ``` </details> Inspecting the mounts and their ordering above confirms that contents in Bazel source roots and execroot should be visible: these mounts are bind mounted into the hermetic tmp location (not `/tmp` directly) before `/tmp` is pivoted to the hermetic tmp location (the final `bind mount:` in the above). --- By altering the `linux-sandbox` invocation above we can confirm that the `bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params` file is a dangling symlink, within the sandbox: ```bash /tmp/bazel-rrbutani/install/89a68939cbf63eb54205fdf943a58b15/linux-sandbox \ -W /tmp/bazel-working-directory/_main \ -t 15 \ -w /tmp/bazel-execroot/_main \ -w /tmp \ -w /dev/shm \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-execroot \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-working-directory \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remote_java_tools_linux \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/0 \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/rules_java~7.3.1~toolchains~remotejdk21_linux \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/1 \ -M /src/dev/bazel \ -m /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp/bazel-source-roots/2 \ -M /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/_hermetic_tmp \ -m /tmp \ -S /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/stats.out \ -D /dev/null \ -- ls --color -l bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ``` ```console-output lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ``` Inspecting `bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params` within this action's execroot (`/tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/`) confirms that the file is a symlink that refers to the host's execroot path rather than that of the sandbox (i.e. `/tmp/bazel-execroot/`): ```console ❯ ls /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -l lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params ❯ ls /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/ -l | head total 16 drwxr-x--- 2 rrbutani users 4096 Dec 12 14:05 libactions lrwxrwxrwx 1 rrbutani users 128 Dec 12 14:05 libactions_provider-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libactions_provider-hjar.jar lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:05 libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params lrwxrwxrwx 1 rrbutani users 141 Dec 12 14:05 libaspect_aware_attribute_mapper-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libaspect_aware_attribute_mapper-hjar.jar lrwxrwxrwx 1 rrbutani users 129 Dec 12 14:05 libaspect_collection-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libaspect_collection-hjar.jar lrwxrwxrwx 1 rrbutani users 130 Dec 12 14:05 libblaze_version_info-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libblaze_version_info-hjar.jar lrwxrwxrwx 1 rrbutani users 134 Dec 12 14:05 libbuild_setting_provider-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libbuild_setting_provider-hjar.jar drwxr-x--- 3 rrbutani users 4096 Dec 12 14:05 libconfig lrwxrwxrwx 1 rrbutani users 129 Dec 12 14:05 libconfigured_target-hjar.jar -> /tmp/bazel-execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libconfigured_target-hjar.jar ``` (note how the other files in the above are symlinks to `/tmp/bazel-execroot/`) ## Cause Poking around a bit, I think this is the relevant part of `rules_java`: https://github.com/bazelbuild/bazel/blob/379ee5fd888c8f3a83ed3751bee700287fa5d7de/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java#L486-L489 Notably `rules_cc` generated param files for link actions do not seem to have this issue (note the `/tmp/bazel-execroot` in the destinations): ```console ❯ fd . /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/ | grep params | xargs ls -l --color lrwxrwxrwx 1 rrbutani users 179 Dec 12 14:25 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3006/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/execroot/_main/bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params lrwxrwxrwx 1 rrbutani users 80 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3098/execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/daemonize-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/daemonize-2.params lrwxrwxrwx 1 rrbutani users 83 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3114/execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/liblogging.a-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/tools/liblogging.a-2.params lrwxrwxrwx 1 rrbutani users 111 Dec 12 14:27 /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3149/execroot/_main/bazel-out/k8-dbg/bin/src/main/java/net/starlark/java/eval/libcpu_profiler.so-2.params -> /tmp/bazel-execroot/_main/bazel-out/k8-dbg/bin/src/main/java/net/starlark/java/eval/libcpu_profiler.so-2.params ``` I _think_ that's because `rules_cc` generates its param files (for link actions) on its own using separate actions + files that are added as dependencies and doesn't use the `CommandLines.Builder` machinery: https://github.com/bazelbuild/bazel/blob/0aacc74776ec824cc403e5c040d97a4618c64429/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java#L950-L971 --- I am not familiar with this part of the Bazel codebase but it seems likely the problematic bit (placing host-execroot paths for the params file onto the command line) lives here: https://github.com/bazelbuild/bazel/blob/29f1db231f2a1c1197ae6b71cb60c3360e7fcd30/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java#L121-L154 And here: https://github.com/bazelbuild/bazel/blob/41ca39a38857fbb78566f40da008f087afbe22e8/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java#L348-L360 (note the use of `getPrimaryOutput().getExecPath()` for `paramFileBasePath`)
[ "src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java", "src/main/java/com/google/devtools/build/lib/sandbox/BUILD", "src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java", "src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java...
[ "src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java", "src/main/java/com/google/devtools/build/lib/sandbox/BUILD", "src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java", "src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java...
[ "src/test/java/com/google/devtools/build/lib/sandbox/BUILD", "src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java", "src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java", "src/test/shell/bazel/bazel_sandboxing_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java index 1afcd70e2b533b..be99bbd147220b 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FileArtifactValue.java @@ -169,11 +169,19 @@ protected boolean couldBeModifiedByMetadata(FileArtifactValue lastKnown) { /** * Optional materialization path. * - * <p>If present, this artifact is a copy of another artifact. It is still tracked as a - * non-symlink by Bazel, but materialized in the local filesystem as a symlink to the original - * artifact, whose contents live at this location. This is used by {@link - * com.google.devtools.build.lib.remote.AbstractActionInputPrefetcher} to implement zero-cost - * copies of remotely stored artifacts. + * <p>If present, this artifact is a copy of another artifact whose contents live at this path. + * This can happen when it is declared as a file and not as an unresolved symlink but the action + * that creates it materializes it in the filesystem as a symlink to another output artifact. This + * information is useful in two situations: + * + * <ol> + * <li>When the symlink target is a remotely stored artifact, we can avoid downloading it + * multiple times when building without the bytes (see AbstractActionInputPrefetcher). + * <li>When the symlink target is inaccessible from the sandboxed environment an action runs + * under, we can rewrite it accordingly (see SandboxHelpers). + * </ol> + * + * @see com.google.devtools.build.lib.skyframe.TreeArtifactValue#getMaterializationExecPath(). */ public Optional<PathFragment> getMaterializationExecPath() { return Optional.empty(); @@ -214,6 +222,12 @@ public static FileArtifactValue createForSourceArtifact( xattrProvider); } + public static FileArtifactValue createForResolvedSymlink( + PathFragment realPath, FileArtifactValue metadata, @Nullable byte[] digest) { + return new ResolvedSymlinkFileArtifactValue( + realPath, digest, metadata.getContentsProxy(), metadata.getSize()); + } + public static FileArtifactValue createFromInjectedDigest( FileArtifactValue metadata, @Nullable byte[] digest) { return createForNormalFile(digest, metadata.getContentsProxy(), metadata.getSize()); @@ -439,7 +453,25 @@ public String toString() { } } - private static final class RegularFileArtifactValue extends FileArtifactValue { + private static final class ResolvedSymlinkFileArtifactValue extends RegularFileArtifactValue { + private final PathFragment realPath; + + private ResolvedSymlinkFileArtifactValue( + PathFragment realPath, + @Nullable byte[] digest, + @Nullable FileContentsProxy proxy, + long size) { + super(digest, proxy, size); + this.realPath = realPath; + } + + @Override + public Optional<PathFragment> getMaterializationExecPath() { + return Optional.of(realPath); + } + } + + private static class RegularFileArtifactValue extends FileArtifactValue { private final byte[] digest; @Nullable private final FileContentsProxy proxy; private final long size; @@ -462,7 +494,8 @@ public boolean equals(Object o) { RegularFileArtifactValue that = (RegularFileArtifactValue) o; return Arrays.equals(digest, that.digest) && Objects.equals(proxy, that.proxy) - && size == that.size; + && size == that.size + && Objects.equals(getMaterializationExecPath(), that.getMaterializationExecPath()); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/BUILD b/src/main/java/com/google/devtools/build/lib/sandbox/BUILD index 87ac37c3644eb0..6d49080690bf08 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/BUILD +++ b/src/main/java/com/google/devtools/build/lib/sandbox/BUILD @@ -17,6 +17,7 @@ java_library( deps = [ "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", + "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", "//src/main/java/com/google/devtools/build/lib/analysis:test/test_configuration", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/vfs", diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java index fad5cfa108b11e..2bf50dffa528d2 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java @@ -228,6 +228,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java index 3dacaeaa05ee9a..971b05cd11b99b 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java @@ -226,6 +226,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index 2d593e7a28003e..9c623357e66dae 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -281,6 +281,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, withinSandboxExecRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java index 2f7608dcc8b857..c9b1509ca06107 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java @@ -100,6 +100,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs inputs = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java index fb72d591e0781e..dfc18bda2c839a 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java @@ -20,6 +20,7 @@ import static com.google.devtools.build.lib.vfs.Dirent.Type.SYMLINK; import com.google.auto.value.AutoValue; +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -29,6 +30,8 @@ import com.google.common.flogger.GoogleLogger; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.FileArtifactValue; +import com.google.devtools.build.lib.actions.InputMetadataProvider; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.UserExecException; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; @@ -444,6 +447,29 @@ private static RootedPath processFilesetSymlink( symlink.getPathString())); } + private static RootedPath processResolvedSymlink( + Root absoluteRoot, + PathFragment execRootRelativeSymlinkTarget, + Root execRootWithinSandbox, + PathFragment execRootFragment, + ImmutableList<Root> packageRoots, + Function<Root, Root> sourceRooWithinSandbox) { + PathFragment symlinkTarget = execRootFragment.getRelative(execRootRelativeSymlinkTarget); + for (Root packageRoot : packageRoots) { + if (packageRoot.contains(symlinkTarget)) { + return RootedPath.toRootedPath( + sourceRooWithinSandbox.apply(packageRoot), packageRoot.relativize(symlinkTarget)); + } + } + + if (symlinkTarget.startsWith(execRootFragment)) { + return RootedPath.toRootedPath( + execRootWithinSandbox, symlinkTarget.relativeTo(execRootFragment)); + } + + return RootedPath.toRootedPath(absoluteRoot, symlinkTarget); + } + /** * Returns the inputs of a Spawn as a map of PathFragments relative to an execRoot to paths in the * host filesystem where the input files can be found. @@ -458,6 +484,7 @@ private static RootedPath processFilesetSymlink( */ public SandboxInputs processInputFiles( Map<PathFragment, ActionInput> inputMap, + InputMetadataProvider inputMetadataProvider, Path execRootPath, Path withinSandboxExecRootPath, ImmutableList<Root> packageRoots, @@ -468,12 +495,24 @@ public SandboxInputs processInputFiles( withinSandboxExecRootPath.equals(execRootPath) ? withinSandboxExecRoot : Root.fromPath(execRootPath); + Root absoluteRoot = Root.absoluteRoot(execRootPath.getFileSystem()); Map<PathFragment, RootedPath> inputFiles = new TreeMap<>(); Map<PathFragment, PathFragment> inputSymlinks = new TreeMap<>(); Map<VirtualActionInput, byte[]> virtualInputs = new HashMap<>(); Map<Root, Root> sourceRootToSandboxSourceRoot = new TreeMap<>(); + Function<Root, Root> sourceRootWithinSandbox = + r -> { + if (!sourceRootToSandboxSourceRoot.containsKey(r)) { + int next = sourceRootToSandboxSourceRoot.size(); + sourceRootToSandboxSourceRoot.put( + r, Root.fromPath(sandboxSourceRoots.getRelative(Integer.toString(next)))); + } + + return sourceRootToSandboxSourceRoot.get(r); + }; + for (Map.Entry<PathFragment, ActionInput> e : inputMap.entrySet()) { if (Thread.interrupted()) { throw new InterruptedException(); @@ -503,23 +542,63 @@ public SandboxInputs processInputFiles( if (actionInput instanceof EmptyActionInput) { inputPath = null; + } else if (actionInput instanceof VirtualActionInput) { + inputPath = RootedPath.toRootedPath(withinSandboxExecRoot, actionInput.getExecPath()); } else if (actionInput instanceof Artifact) { Artifact inputArtifact = (Artifact) actionInput; - if (inputArtifact.isSourceArtifact() && sandboxSourceRoots != null) { - Root sourceRoot = inputArtifact.getRoot().getRoot(); - if (!sourceRootToSandboxSourceRoot.containsKey(sourceRoot)) { - int next = sourceRootToSandboxSourceRoot.size(); - sourceRootToSandboxSourceRoot.put( - sourceRoot, - Root.fromPath(sandboxSourceRoots.getRelative(Integer.toString(next)))); - } - - inputPath = - RootedPath.toRootedPath( - sourceRootToSandboxSourceRoot.get(sourceRoot), - inputArtifact.getRootRelativePath()); - } else { + if (sandboxSourceRoots == null) { inputPath = RootedPath.toRootedPath(withinSandboxExecRoot, inputArtifact.getExecPath()); + } else { + if (inputArtifact.isSourceArtifact()) { + Root sourceRoot = inputArtifact.getRoot().getRoot(); + inputPath = + RootedPath.toRootedPath( + sourceRootWithinSandbox.apply(sourceRoot), + inputArtifact.getRootRelativePath()); + } else { + PathFragment materializationExecPath = null; + if (inputArtifact.isChildOfDeclaredDirectory()) { + FileArtifactValue parentMetadata = + inputMetadataProvider.getInputMetadata(inputArtifact.getParent()); + if (parentMetadata.getMaterializationExecPath().isPresent()) { + materializationExecPath = + parentMetadata + .getMaterializationExecPath() + .get() + .getRelative(inputArtifact.getParentRelativePath()); + } + } else if (!inputArtifact.isTreeArtifact()) { + // Normally, one would not see tree artifacts here because they have already been + // expanded by the time the code gets here. However, there is one very special case: + // when an action has an archived tree artifact on its output and is executed on the + // local branch of the dynamic execution strategy, the tree artifact is zipped up + // in a little extra spawn, which has direct tree artifact on its inputs. Sadly, + // it's not easy to fix this because there isn't an easy way to inject this new + // tree artifact into the artifact expander being used. + // + // The best would be to not rely on spawn strategies for executing that little + // command: it's entirely under the control of Bazel so we can guarantee that it + // does not cause mischief. + FileArtifactValue metadata = inputMetadataProvider.getInputMetadata(actionInput); + if (metadata.getMaterializationExecPath().isPresent()) { + materializationExecPath = metadata.getMaterializationExecPath().get(); + } + } + + if (materializationExecPath != null) { + inputPath = + processResolvedSymlink( + absoluteRoot, + materializationExecPath, + withinSandboxExecRoot, + execRootPath.asFragment(), + packageRoots, + sourceRootWithinSandbox); + } else { + inputPath = + RootedPath.toRootedPath(withinSandboxExecRoot, inputArtifact.getExecPath()); + } + } } } else { PathFragment execPath = actionInput.getExecPath(); @@ -544,6 +623,7 @@ public SandboxInputs processInputFiles( return new SandboxInputs(inputFiles, virtualInputs, inputSymlinks, sandboxRootToSourceRoot); } + /** The file and directory outputs of a sandboxed spawn. */ @AutoValue public abstract static class SandboxOutputs { diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java index c7996e38582fa1..505e2417850161 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/WindowsSandboxedSpawnRunner.java @@ -76,6 +76,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context SandboxInputs readablePaths = helpers.processInputFiles( context.getInputMapping(PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java index a1b1a77d3d0cbb..1bc2f4c7c0ac6a 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStore.java @@ -264,7 +264,15 @@ private TreeArtifactValue constructTreeArtifactValueFromFilesystem(SpecialArtifa Path treeDir = artifactPathResolver.toPath(parent); boolean chmod = executionMode.get(); - FileStatus stat = treeDir.statIfFound(Symlinks.FOLLOW); + FileStatus lstat = treeDir.statIfFound(Symlinks.NOFOLLOW); + FileStatus stat; + if (lstat == null) { + stat = null; + } else if (!lstat.isSymbolicLink()) { + stat = lstat; + } else { + stat = treeDir.statIfFound(Symlinks.FOLLOW); + } // Make sure the tree artifact root exists and is a regular directory. Note that this is how the // action is initialized, so this should hold unless the action itself has deleted the root. @@ -332,12 +340,18 @@ private TreeArtifactValue constructTreeArtifactValueFromFilesystem(SpecialArtifa } // Same rationale as for constructFileArtifactValue. - if (anyRemote.get() && treeDir.isSymbolicLink() && stat instanceof FileStatusWithMetadata) { - FileArtifactValue metadata = ((FileStatusWithMetadata) stat).getMetadata(); - tree.setMaterializationExecPath( - metadata - .getMaterializationExecPath() - .orElse(treeDir.resolveSymbolicLinks().asFragment().relativeTo(execRoot))); + if (lstat.isSymbolicLink()) { + PathFragment materializationExecPath = null; + if (stat instanceof FileStatusWithMetadata) { + materializationExecPath = + ((FileStatusWithMetadata) stat).getMetadata().getMaterializationExecPath().orElse(null); + } + + if (materializationExecPath == null) { + materializationExecPath = treeDir.resolveSymbolicLinks().asFragment().relativeTo(execRoot); + } + + tree.setMaterializationExecPath(materializationExecPath); } return tree.build(); @@ -509,7 +523,13 @@ private FileArtifactValue constructFileArtifactValue( return value; } - if (type.isFile() && fileDigest != null) { + boolean isResolvedSymlink = + statAndValue.statNoFollow() != null + && statAndValue.statNoFollow().isSymbolicLink() + && statAndValue.realPath() != null + && !value.isRemote(); + + if (type.isFile() && !isResolvedSymlink && fileDigest != null) { // The digest is in the file value and that is all that is needed for this file's metadata. return value; } @@ -525,22 +545,30 @@ private FileArtifactValue constructFileArtifactValue( artifactPathResolver.toPath(artifact).getLastModifiedTime()); } - if (injectedDigest == null && type.isFile()) { + byte[] actualDigest = fileDigest != null ? fileDigest : injectedDigest; + + if (actualDigest == null && type.isFile()) { // We don't have an injected digest and there is no digest in the file value (which attempts a // fast digest). Manually compute the digest instead. - Path path = statAndValue.pathNoFollow(); - if (statAndValue.statNoFollow() != null - && statAndValue.statNoFollow().isSymbolicLink() - && statAndValue.realPath() != null) { - // If the file is a symlink, we compute the digest using the target path so that it's - // possible to hit the digest cache - we probably already computed the digest for the - // target during previous action execution. - path = statAndValue.realPath(); - } - injectedDigest = DigestUtils.manuallyComputeDigest(path, value.getSize()); + // If the file is a symlink, we compute the digest using the target path so that it's + // possible to hit the digest cache - we probably already computed the digest for the + // target during previous action execution. + Path pathToDigest = isResolvedSymlink ? statAndValue.realPath() : statAndValue.pathNoFollow(); + actualDigest = DigestUtils.manuallyComputeDigest(pathToDigest, value.getSize()); } - return FileArtifactValue.createFromInjectedDigest(value, injectedDigest); + + if (!isResolvedSymlink) { + return FileArtifactValue.createFromInjectedDigest(value, actualDigest); + } + + PathFragment realPathAsFragment = statAndValue.realPath().asFragment(); + PathFragment execRootRelativeRealPath = + realPathAsFragment.startsWith(execRoot) + ? realPathAsFragment.relativeTo(execRoot) + : realPathAsFragment; + return FileArtifactValue.createForResolvedSymlink( + execRootRelativeRealPath, value, actualDigest); } /** diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java index 6718b7e709a561..c21eb8e6bdc6b2 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnRunner.java @@ -188,6 +188,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) helpers.processInputFiles( context.getInputMapping( PathFragment.EMPTY_FRAGMENT, /* willAccessRepeatedly= */ true), + context.getInputMetadataProvider(), execRoot, execRoot, packageRoots,
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/BUILD b/src/test/java/com/google/devtools/build/lib/sandbox/BUILD index 74873ef72d3311..671997db568c43 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/BUILD +++ b/src/test/java/com/google/devtools/build/lib/sandbox/BUILD @@ -59,12 +59,14 @@ java_test( deps = [ "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", + "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", "//src/main/java/com/google/devtools/build/lib/exec:bin_tools", "//src/main/java/com/google/devtools/build/lib/exec:tree_deleter", "//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers", "//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_options", "//src/main/java/com/google/devtools/build/lib/sandbox:sandboxed_spawns", "//src/main/java/com/google/devtools/build/lib/sandbox:tree_deleter", + "//src/main/java/com/google/devtools/build/lib/skyframe:tree_artifact_value", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java b/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java index 8df844739de17e..78fe5c244ee282 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java +++ b/src/test/java/com/google/devtools/build/lib/sandbox/SandboxHelpersTest.java @@ -24,17 +24,23 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.ActionInput; +import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; +import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.actions.ArtifactRoot; import com.google.devtools.build.lib.actions.CommandLines.ParamFileActionInput; +import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType; import com.google.devtools.build.lib.actions.PathMapper; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.cache.VirtualActionInput; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.exec.BinTools; +import com.google.devtools.build.lib.exec.util.FakeActionInputFileCache; import com.google.devtools.build.lib.exec.util.SpawnBuilder; import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxInputs; import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxOutputs; +import com.google.devtools.build.lib.skyframe.TreeArtifactValue; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.TestUtils; import com.google.devtools.build.lib.vfs.DigestHashFunction; @@ -68,6 +74,7 @@ /** Tests for {@link SandboxHelpers}. */ @RunWith(JUnit4.class) public class SandboxHelpersTest { + private static final byte[] FAKE_DIGEST = new byte[] {1}; private final Scratch scratch = new Scratch(); private Path execRootPath; @@ -94,6 +101,79 @@ private RootedPath execRootedPath(String execPath) { return RootedPath.toRootedPath(execRoot, PathFragment.create(execPath)); } + @Test + public void processInputFiles_resolvesMaterializationPath_fileArtifact() throws Exception { + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(execRootPath, ArtifactRoot.RootType.Output, "outputs"); + Path sandboxSourceRoot = scratch.dir("/faketmp/sandbox-source-roots"); + + Artifact input = ActionsTestUtil.createArtifact(outputRoot, "a/a"); + FileArtifactValue symlinkTargetMetadata = + FileArtifactValue.createForNormalFile(FAKE_DIGEST, null, 0L); + FileArtifactValue inputMetadata = + FileArtifactValue.createForResolvedSymlink( + PathFragment.create("b/b"), symlinkTargetMetadata, FAKE_DIGEST); + + FakeActionInputFileCache inputMetadataProvider = new FakeActionInputFileCache(); + inputMetadataProvider.put(input, inputMetadata); + + SandboxHelpers sandboxHelpers = new SandboxHelpers(); + SandboxInputs inputs = + sandboxHelpers.processInputFiles( + inputMap(input), + inputMetadataProvider, + execRootPath, + execRootPath, + ImmutableList.of(), + sandboxSourceRoot); + + assertThat(inputs.getFiles()) + .containsEntry( + input.getExecPath(), RootedPath.toRootedPath(execRoot, PathFragment.create("b/b"))); + } + + @Test + public void processInputFiles_resolvesMaterializationPath_treeArtifact() throws Exception { + ArtifactRoot outputRoot = + ArtifactRoot.asDerivedRoot(execRootPath, ArtifactRoot.RootType.Output, "outputs"); + Path sandboxSourceRoot = scratch.dir("/faketmp/sandbox-source-roots"); + SpecialArtifact parent = + ActionsTestUtil.createTreeArtifactWithGeneratingAction( + outputRoot, "bin/config/other_dir/subdir"); + + TreeFileArtifact childA = TreeFileArtifact.createTreeOutput(parent, "a/a"); + TreeFileArtifact childB = TreeFileArtifact.createTreeOutput(parent, "b/b"); + FileArtifactValue childMetadata = FileArtifactValue.createForNormalFile(FAKE_DIGEST, null, 0L); + TreeArtifactValue parentMetadata = + TreeArtifactValue.newBuilder(parent) + .putChild(childA, childMetadata) + .putChild(childB, childMetadata) + .setMaterializationExecPath(PathFragment.create("materialized")) + .build(); + + FakeActionInputFileCache inputMetadataProvider = new FakeActionInputFileCache(); + inputMetadataProvider.put(parent, parentMetadata.getMetadata()); + + SandboxHelpers sandboxHelpers = new SandboxHelpers(); + SandboxInputs inputs = + sandboxHelpers.processInputFiles( + inputMap(childA, childB), + inputMetadataProvider, + execRootPath, + execRootPath, + ImmutableList.of(), + sandboxSourceRoot); + + assertThat(inputs.getFiles()) + .containsEntry( + childA.getExecPath(), + RootedPath.toRootedPath(execRoot, PathFragment.create("materialized/a/a"))); + assertThat(inputs.getFiles()) + .containsEntry( + childB.getExecPath(), + RootedPath.toRootedPath(execRoot, PathFragment.create("materialized/b/b"))); + } + @Test public void processInputFiles_materializesParamFile() throws Exception { SandboxHelpers sandboxHelpers = new SandboxHelpers(); @@ -106,7 +186,12 @@ public void processInputFiles_materializesParamFile() throws Exception { SandboxInputs inputs = sandboxHelpers.processInputFiles( - inputMap(paramFile), execRootPath, execRootPath, ImmutableList.of(), null); + inputMap(paramFile), + new FakeActionInputFileCache(), + execRootPath, + execRootPath, + ImmutableList.of(), + null); assertThat(inputs.getFiles()) .containsExactly(PathFragment.create("paramFile"), execRootedPath("paramFile")); @@ -127,7 +212,12 @@ public void processInputFiles_materializesBinToolsFile() throws Exception { SandboxInputs inputs = sandboxHelpers.processInputFiles( - inputMap(tool), execRootPath, execRootPath, ImmutableList.of(), null); + inputMap(tool), + new FakeActionInputFileCache(), + execRootPath, + execRootPath, + ImmutableList.of(), + null); assertThat(inputs.getFiles()) .containsExactly(PathFragment.create("_bin/say_hello"), execRootedPath("_bin/say_hello")); @@ -173,7 +263,12 @@ protected void setExecutable(PathFragment path, boolean executable) throws IOExc try { var unused = sandboxHelpers.processInputFiles( - inputMap(input), customExecRoot, customExecRoot, ImmutableList.of(), null); + inputMap(input), + new FakeActionInputFileCache(), + customExecRoot, + customExecRoot, + ImmutableList.of(), + null); finishProcessingSemaphore.release(); } catch (IOException | InterruptedException e) { throw new IllegalArgumentException(e); @@ -181,7 +276,12 @@ protected void setExecutable(PathFragment path, boolean executable) throws IOExc }); var unused = sandboxHelpers.processInputFiles( - inputMap(input), customExecRoot, customExecRoot, ImmutableList.of(), null); + inputMap(input), + new FakeActionInputFileCache(), + customExecRoot, + customExecRoot, + ImmutableList.of(), + null); finishProcessingSemaphore.release(); future.get(); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java index 430e809fb50f31..afcf8281bb36b8 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ActionOutputMetadataStoreTest.java @@ -82,10 +82,6 @@ private enum TreeComposition { FULLY_LOCAL, FULLY_REMOTE, MIXED; - - boolean isPartiallyRemote() { - return this == FULLY_REMOTE || this == MIXED; - } } private final Map<Path, Integer> chmodCalls = Maps.newConcurrentMap(); @@ -422,11 +418,10 @@ public void fileArtifactMaterializedAsSymlink( .getPath(outputArtifact.getPath().getPathString()) .createSymbolicLink(targetArtifact.getPath().asFragment()); - PathFragment expectedMaterializationExecPath = null; - if (location == FileLocation.REMOTE) { - expectedMaterializationExecPath = - preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); - } + PathFragment expectedMaterializationExecPath = + location == FileLocation.REMOTE && preexistingPath != null + ? preexistingPath + : targetArtifact.getExecPath(); assertThat(store.getOutputMetadata(outputArtifact)) .isEqualTo(createFileMetadataForSymlinkTest(location, expectedMaterializationExecPath)); @@ -436,7 +431,12 @@ private FileArtifactValue createFileMetadataForSymlinkTest( FileLocation location, @Nullable PathFragment materializationExecPath) { switch (location) { case LOCAL: - return FileArtifactValue.createForNormalFile(new byte[] {1, 2, 3}, /* proxy= */ null, 10); + FileArtifactValue target = + FileArtifactValue.createForNormalFile(new byte[] {1, 2, 3}, /* proxy= */ null, 10); + return materializationExecPath == null + ? target + : FileArtifactValue.createForResolvedSymlink( + materializationExecPath, target, target.getDigest()); case REMOTE: return RemoteFileArtifactValue.create( new byte[] {1, 2, 3}, 10, 1, -1, materializationExecPath); @@ -481,11 +481,8 @@ public void treeArtifactMaterializedAsSymlink( .getPath(outputArtifact.getPath().getPathString()) .createSymbolicLink(targetArtifact.getPath().asFragment()); - PathFragment expectedMaterializationExecPath = null; - if (composition.isPartiallyRemote()) { - expectedMaterializationExecPath = - preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); - } + PathFragment expectedMaterializationExecPath = + preexistingPath != null ? preexistingPath : targetArtifact.getExecPath(); assertThat(store.getTreeArtifactValue(outputArtifact)) .isEqualTo( @@ -814,7 +811,7 @@ public void fileArtifactValueForSymlink_readFromCache() throws Exception { var symlinkMetadata = store.getOutputMetadata(symlink); - assertThat(symlinkMetadata).isEqualTo(targetMetadata); + assertThat(symlinkMetadata.getDigest()).isEqualTo(targetMetadata.getDigest()); assertThat(DigestUtils.getCacheStats().hitCount()).isEqualTo(1); } } diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 3e65184291777a..86fa7ad1807cd4 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -334,6 +334,95 @@ EOF assert_contains GOOD bazel-bin/pkg/gen.txt } +function test_symlink_with_output_base_under_tmp() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + mkdir -p pkg + cat > pkg/BUILD <<'EOF' +load(":r.bzl", "symlink_rule") + +genrule(name="r1", srcs=[], outs=[":r1"], cmd="echo CONTENT > $@") +symlink_rule(name="r2", input=":r1") +genrule(name="r3", srcs=[":r2"], outs=[":r3"], cmd="cp $< $@") +EOF + + cat > pkg/r.bzl <<'EOF' +def _symlink_impl(ctx): + output = ctx.actions.declare_file(ctx.label.name) + ctx.actions.symlink(output = output, target_file = ctx.file.input) + return [DefaultInfo(files = depset([output]))] + +symlink_rule = rule( + implementation = _symlink_impl, + attrs = {"input": attr.label(allow_single_file=True)}) +EOF + + local tmp_output_base=$(mktemp -d "/tmp/bazel_output_base.XXXXXXXX") + trap "chmod -R u+w $tmp_output_base && rm -fr $tmp_output_base" EXIT + + bazel --output_base="$tmp_output_base" build //pkg:r3 + assert_contains CONTENT bazel-bin/pkg/r3 + bazel --output_base="$tmp_output_base" shutdown +} + +function test_symlink_to_directory_with_output_base_under_tmp() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + mkdir -p pkg + cat > pkg/BUILD <<'EOF' +load(":r.bzl", "symlink_rule", "tree_rule") + +tree_rule(name="t1") +symlink_rule(name="t2", input=":t1") +genrule(name="t3", srcs=[":t2"], outs=[":t3"], cmd=";\n".join( + ["cat $(location :t2)/{a/a,b/b} > $@"])) +EOF + + cat > pkg/r.bzl <<'EOF' +def _symlink_impl(ctx): + output = ctx.actions.declare_directory(ctx.label.name) + ctx.actions.symlink(output = output, target_file = ctx.file.input) + return [DefaultInfo(files = depset([output]))] + +symlink_rule = rule( + implementation = _symlink_impl, + attrs = {"input": attr.label(allow_single_file=True)}) + +def _tree_impl(ctx): + output = ctx.actions.declare_directory(ctx.label.name) + ctx.actions.run_shell( + outputs = [output], + command = "export TREE=%s && mkdir $TREE/a $TREE/b && echo -n A > $TREE/a/a && echo -n B > $TREE/b/b" % output.path) + return [DefaultInfo(files = depset([output]))] + +tree_rule = rule( + implementation = _tree_impl, + attrs = {}) + +EOF + + local tmp_output_base=$(mktemp -d "/tmp/bazel_output_base.XXXXXXXX") + trap "chmod -R u+w $tmp_output_base && rm -fr $tmp_output_base" EXIT + + bazel --output_base="$tmp_output_base" build //pkg:t3 + assert_contains AB bazel-bin/pkg/t3 + bazel --output_base="$tmp_output_base" shutdown +} + # The test shouldn't fail if the environment doesn't support running it. check_sandbox_allowed || exit 0
train
test
2024-01-05T18:59:07
2023-12-12T23:12:52Z
rrbutani
test
bazelbuild/bazel/20527_20772
bazelbuild/bazel
bazelbuild/bazel/20527
bazelbuild/bazel/20772
[ "keyword_pr_to_issue" ]
eb517905bac62fd1d98b371e4828f4fb9450d4c5
cc4881e07e723da1b8a230161f53f259067cff91
[ "CC @lberki \r\n\r\nA simple workaround would be to just disable the hermetic `/tmp` in this case, similar to what we do for tmpfs paths. What do you think of this?\r\n\r\n```java\r\ndiff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/b...
[]
2024-01-06T00:02:52Z
[ "type: bug", "team-Local-Exec" ]
Bazel 7: `--sandbox_add_mount_pair` under `/tmp` fails
### Description of the bug: With Bazel 7, but neither Bazel 6.4.0 nor `--noincompatible_sandbox_hermetic_tmp`, builds with `--sandbox_add_mount_pair` referencing a path under `/tmp` fail since `/tmp` has been remounted before the manually specified mount pair is applied. ### Which category does this issue belong to? Local Execution ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ```shell touch WORKSPACE cat > .bazelrc <<'EOF' build --sandbox_add_mount_pair=/tmp/some/path:/etc EOF cat > BUILD <<'EOF' genrule( name = "gen", outs = ["data.txt"], cmd = "ls /etc > $@", ) EOF ``` Then: ``` $ mkdir -p /tmp/some/path $ bazel clean --expunge && bazel shutdown && bazel build //:gen ... src/main/tools/linux-sandbox-pid1.cc:305: "mount(/tmp/some/path, /etc, nullptr, MS_BIND | MS_REC, nullptr)": No such file or directory Target //:gen failed to build ... # bazel clean --expunge && bazel shutdown && bazel build //:gen --noincompatible_sandbox_hermetic_tmp ... INFO: Build completed successfully, 2 total actions ``` ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? 7.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java" ]
[ "src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java" ]
[ "src/test/shell/bazel/bazel_sandboxing_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java index ac9c5ae72fcc13..da68a8c50c03b8 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.sandbox; +import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.devtools.build.lib.sandbox.LinuxSandboxCommandLineBuilder.NetworkNamespace.NETNS_WITH_LOOPBACK; import static com.google.devtools.build.lib.sandbox.LinuxSandboxCommandLineBuilder.NetworkNamespace.NO_NETNS; @@ -21,7 +22,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import com.google.common.io.ByteStreams; import com.google.devtools.build.lib.actions.ActionInput; import com.google.devtools.build.lib.actions.ExecException; @@ -63,6 +63,7 @@ import java.util.Optional; import java.util.SortedMap; import java.util.Set; +import java.util.TreeMap; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; @@ -316,7 +317,8 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context .addExecutionInfo(spawn.getExecutionInfo()) .setWritableFilesAndDirectories(writableDirs) .setTmpfsDirectories(ImmutableSet.copyOf(getSandboxOptions().sandboxTmpfsPath)) - .setBindMounts(getBindMounts(blazeDirs, inputs, sandboxExecRootBase, sandboxTmp)) + .setBindMounts( + prepareAndGetBindMounts(blazeDirs, inputs, sandboxExecRootBase, sandboxTmp)) .setUseFakeHostname(getSandboxOptions().sandboxFakeHostname) .setEnablePseudoterminal(getSandboxOptions().sandboxExplicitPseudoterminal) .setCreateNetworkNamespace(createNetworkNamespace ? NETNS_WITH_LOOPBACK : NO_NETNS) @@ -422,50 +424,73 @@ protected ImmutableSet<Path> getWritableDirs( .collect(toImmutableSet()); } - private ImmutableList<BindMount> getBindMounts( + private ImmutableList<BindMount> prepareAndGetBindMounts( BlazeDirectories blazeDirs, SandboxInputs inputs, Path sandboxExecRootBase, @Nullable Path sandboxTmp) - throws UserExecException { - Path tmpPath = fileSystem.getPath("/tmp"); - final SortedMap<Path, Path> bindMounts = Maps.newTreeMap(); + throws UserExecException, IOException { + Path tmpPath = fileSystem.getPath(SLASH_TMP); + final SortedMap<Path, Path> userBindMounts = new TreeMap<>(); SandboxHelpers.mountAdditionalPaths( - getSandboxOptions().sandboxAdditionalMounts, sandboxExecRootBase, bindMounts); + getSandboxOptions().sandboxAdditionalMounts, sandboxExecRootBase, userBindMounts); for (Path inaccessiblePath : getInaccessiblePaths()) { if (inaccessiblePath.isDirectory(Symlinks.NOFOLLOW)) { - bindMounts.put(inaccessiblePath, inaccessibleHelperDir); + userBindMounts.put(inaccessiblePath, inaccessibleHelperDir); } else { - bindMounts.put(inaccessiblePath, inaccessibleHelperFile); + userBindMounts.put(inaccessiblePath, inaccessibleHelperFile); } } - LinuxSandboxUtil.validateBindMounts(bindMounts); - ImmutableList.Builder<BindMount> result = ImmutableList.builder(); - bindMounts.forEach((k, v) -> result.add(BindMount.of(k, v))); + LinuxSandboxUtil.validateBindMounts(userBindMounts); - if (sandboxTmp != null) { - // First mount the real exec root and the empty directory created as the working dir of the - // action under $SANDBOX/_tmp - result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_EXECROOT), blazeDirs.getExecRootBase())); - result.add( - BindMount.of(sandboxTmp.getRelative(BAZEL_WORKING_DIRECTORY), sandboxExecRootBase)); - - // Then mount the individual package roots under $SANDBOX/_tmp/bazel-source-roots - inputs - .getSourceRootBindMounts() - .forEach( - (withinSandbox, real) -> { - PathFragment sandboxTmpSourceRoot = withinSandbox.asPath().relativeTo(tmpPath); - result.add(BindMount.of(sandboxTmp.getRelative(sandboxTmpSourceRoot), real)); - }); - - // Then mount $SANDBOX/_tmp at /tmp. At this point, even if the output base (and execroot) - // and individual source roots are under /tmp, they are accessible at /tmp/bazel-* - result.add(BindMount.of(tmpPath, sandboxTmp)); + if (sandboxTmp == null) { + return userBindMounts.entrySet().stream() + .map(e -> BindMount.of(e.getKey(), e.getValue())) + .collect(toImmutableList()); } + SortedMap<Path, Path> bindMounts = new TreeMap<>(); + for (var entry : userBindMounts.entrySet()) { + Path mountPoint = entry.getKey(); + Path content = entry.getValue(); + if (mountPoint.startsWith(tmpPath)) { + // sandboxTmp should be null if /tmp is an explicit mount point since useHermeticTmp() + // returns false in that case. + if (mountPoint.equals(tmpPath)) { + throw new IOException( + "Cannot mount /tmp explicitly with hermetic /tmp. Please file a bug at" + + " https://github.com/bazelbuild/bazel/issues/new/choose."); + } + // We need to rewrite the mount point to be under the sandbox tmp directory, which will be + // mounted onto /tmp as the final mount. + mountPoint = sandboxTmp.getRelative(mountPoint.relativeTo(tmpPath)); + mountPoint.createDirectoryAndParents(); + } + bindMounts.put(mountPoint, content); + } + + ImmutableList.Builder<BindMount> result = ImmutableList.builder(); + bindMounts.forEach((k, v) -> result.add(BindMount.of(k, v))); + + // First mount the real exec root and the empty directory created as the working dir of the + // action under $SANDBOX/_tmp + result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_EXECROOT), blazeDirs.getExecRootBase())); + result.add(BindMount.of(sandboxTmp.getRelative(BAZEL_WORKING_DIRECTORY), sandboxExecRootBase)); + + // Then mount the individual package roots under $SANDBOX/_tmp/bazel-source-roots + inputs + .getSourceRootBindMounts() + .forEach( + (withinSandbox, real) -> { + PathFragment sandboxTmpSourceRoot = withinSandbox.asPath().relativeTo(tmpPath); + result.add(BindMount.of(sandboxTmp.getRelative(sandboxTmpSourceRoot), real)); + }); + + // Then mount $SANDBOX/_tmp at /tmp. At this point, even if the output base (and execroot) and + // individual source roots are under /tmp, they are accessible at /tmp/bazel-* + result.add(BindMount.of(tmpPath, sandboxTmp)); return result.build(); }
diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 86fa7ad1807cd4..ec7655ac36d53b 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -316,21 +316,84 @@ function test_add_mount_pair_tmp_source() { sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + local mounted=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") + trap "rm -fr $mounted" EXIT + echo GOOD > "$mounted/data.txt" + mkdir -p pkg - cat > pkg/BUILD <<'EOF' + cat > pkg/BUILD <<EOF +genrule( + name = "gen", + outs = ["gen.txt"], + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${mounted}/data.txt" ] && cp /etc/data.txt \$@""", +) +EOF + + # This assumes the existence of /etc on the host system + bazel build --sandbox_add_mount_pair="$mounted:/etc" //pkg:gen || fail "build failed" + assert_contains GOOD bazel-bin/pkg/gen.txt +} + +function test_add_mount_pair_tmp_target() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + + local source_dir=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") + trap "rm -fr $source_dir" EXIT + echo BAD > "$source_dir/data.txt" + + mkdir -p pkg + cat > pkg/BUILD <<EOF genrule( name = "gen", outs = ["gen.txt"], - cmd = "cp /etc/data.txt $@", + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${source_dir}/data.txt" ] && ls "$source_dir" > \$@""", ) EOF + + # This assumes the existence of /etc on the host system + bazel build --sandbox_add_mount_pair="/etc:$source_dir" //pkg:gen || fail "build failed" + assert_contains passwd bazel-bin/pkg/gen.txt +} + +function test_add_mount_pair_tmp_target_and_source() { + if [[ "$PLATFORM" == "darwin" ]]; then + # Tests Linux-specific functionality + return 0 + fi + + create_workspace_with_default_repos WORKSPACE + + sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc + local mounted=$(mktemp -d "/tmp/bazel_mounted.XXXXXXXX") trap "rm -fr $mounted" EXIT echo GOOD > "$mounted/data.txt" - # This assumes the existence of /etc on the host system - bazel build --sandbox_add_mount_pair="$mounted:/etc" //pkg:gen || fail "build failed" + local tmp_file=$(mktemp "/tmp/bazel_tmp.XXXXXXXX") + trap "rm $tmp_file" EXIT + echo BAD > "$tmp_file" + + mkdir -p pkg + cat > pkg/BUILD <<EOF +genrule( + name = "gen", + outs = ["gen.txt"], + # Verify that /tmp is still hermetic. + cmd = """[ ! -e "${tmp_file}" ] && cp "$mounted/data.txt" \$@""", +) +EOF + + bazel build --sandbox_add_mount_pair="$mounted" //pkg:gen || fail "build failed" assert_contains GOOD bazel-bin/pkg/gen.txt }
val
test
2024-01-11T19:09:19
2023-12-13T17:26:37Z
fmeum
test
bazelbuild/bazel/20722_20840
bazelbuild/bazel
bazelbuild/bazel/20722
bazelbuild/bazel/20840
[ "keyword_pr_to_issue" ]
cac8d12cb3df6edb7f2a8c362011b64d87b99681
ce993c49aeb16b9d64f76fd408ef0b5fa2e8bf63
[ "@bazel-io fork 7.0.1", "@Wyverald @meteorcloudy This, combined with https://github.com/bazelbuild/bazel/commit/f4be0b2e7b5539502661033bcf6f47722aaa7e47#diff-ef4da5cc2da76cded220009a0dcc95373700d704629a1a2e9ebe84a9be076854, actually breaks `jvm_maven_import_external` and `http_jar` when `rules_java` is updated, o...
[]
2024-01-10T15:22:22Z
[ "type: bug", "P2", "team-ExternalDeps" ]
Repository rules aren't refetched when their repo mappings change
### Description of the bug: This is similar to https://github.com/bazelbuild/bazel/issues/20721, but 1) about repository rules rather than module extensions and 2) not a regression in 7.0.0. A repository rule isn't refetched when its repo mapping changes, which can result in `Label(...)` calls made in the implementation function to return stale results when canonical repo names change, e.g. during `bazel_dep` version bumps. ### Which category does this issue belong to? External Dependency ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ```starlark # MODULE.bazel bazel_dep(name = "rules_go", version = "0.40.0") ext = use_extension("//:ext.bzl", "ext") ext.tag(label_str = "@rules_go//go") use_repo(ext, "repo") # BUILD load("@repo//:defs.bzl", "LABEL") print(LABEL) # ext.bzl def _repo_impl(ctx): ctx.file("WORKSPACE") ctx.file("BUILD") ctx.file("defs.bzl", "LABEL = Label({})".format(repr(str(Label(ctx.attr.label_str))))) _repo = repository_rule( implementation=_repo_impl, attrs={"label_str": attr.string(mandatory=True)}, ) _tag = tag_class( attrs={"label_str": attr.string(mandatory=True)}, ) def _ext_impl(ctx): for module in ctx.modules: for tag in module.tags.tag: _repo(name = "repo", label_str = tag.label_str) ext = module_extension( implementation=_ext_impl, tag_classes={"tag": _tag}, ) ``` ```shell $ bazel build //... --lockfile_mode=off DEBUG: /home/fhenneke/tmp/repo-mapping-lock/BUILD:2:6: @@rules_go~0.40.0//go:go $ buildozer 'set version 0.41.0' MODULE.bazel:rules_go $ bazel build //... --lockfile_mode=off <no output since the old warning has already been omitted and hasn't changed> $ bazel shutdown $ bazel build //... --lockfile_mode=off DEBUG: /home/fhenneke/tmp/repo-mapping-lock/BUILD:2:6: @@rules_go~0.40.0//go:go ``` ### Which operating system are you running Bazel on? _No response_ ### What is the output of `bazel info release`? 7.0.0 and HEAD ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl" ]
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 3646c7e15bfa9c..bb33d6df320b03 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2158,7 +2158,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "rjB9TSLGt3ZwbECWtF/HMgfqMsfEnDLK6fGIe65ZyfE=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2177,9 +2177,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "rjB9TSLGt3ZwbECWtF/HMgfqMsfEnDLK6fGIe65ZyfE=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "10b96bd3c1eb194b0efe3a13fd06f2051abf36efb33414ad92048883ba471c7f", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "5218e8c896592023f884990b7a34f9276e3ce488e753eaaa8bc6057a1aca653c", "@@//:MODULE.bazel": "63625ac7809ba5bc83e0814e16f223ac28a98df884897ddd5bfbd69fd4e3ddbf" }, "envVariables": {}, @@ -2428,7 +2428,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "rjB9TSLGt3ZwbECWtF/HMgfqMsfEnDLK6fGIe65ZyfE=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2478,7 +2478,7 @@ }, "//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", + "bzlTransitiveDigest": "4x/FXzwoadac6uV9ItZ4eGOyCculGHHrKUhLFNWo3lA=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2505,7 +2505,7 @@ }, "//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", + "bzlTransitiveDigest": "y48q5zUu2oMiYv7yUyi7rFB0wt14eqiF/RQcWT6vP7I=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl index 81fc3f96dc77ab..23ed7dc05aa214 100644 --- a/tools/build_defs/repo/http.bzl +++ b/tools/build_defs/repo/http.bzl @@ -198,8 +198,6 @@ def _http_file_impl(ctx): return _update_integrity_attr(ctx, _http_file_attrs, download_info) _HTTP_JAR_BUILD = """\ -load("{rules_java_defs}", "java_import") - package(default_visibility = ["//visibility:public"]) java_import( @@ -232,7 +230,6 @@ def _http_jar_impl(ctx): ctx.file("WORKSPACE", "workspace(name = \"{name}\")".format(name = ctx.name)) ctx.file("jar/BUILD", _HTTP_JAR_BUILD.format( file_name = downloaded_file_name, - rules_java_defs = str(Label("@rules_java//java:defs.bzl")), )) return _update_integrity_attr(ctx, _http_jar_attrs, download_info) diff --git a/tools/build_defs/repo/jvm.bzl b/tools/build_defs/repo/jvm.bzl index c7e87d2f4a97bd..0c4c88b31b9ffe 100644 --- a/tools/build_defs/repo/jvm.bzl +++ b/tools/build_defs/repo/jvm.bzl @@ -282,11 +282,6 @@ def jvm_maven_import_external( srcjar_urls = kwargs.pop("srcjar_urls", None) rule_name = kwargs.pop("rule_name", "java_import") - rules_java_defs = str(Label("@rules_java//java:defs.bzl")) - rule_load = kwargs.pop( - "rule_load", - 'load("{}", "java_import")'.format(rules_java_defs), - ) if fetch_sources: src_coordinates = struct( @@ -309,7 +304,6 @@ def jvm_maven_import_external( srcjar_urls = srcjar_urls, canonical_id = artifact, rule_name = rule_name, - rule_load = rule_load, tags = tags, **kwargs )
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 80fcbbd46be616..86ee343f5e44ff 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -641,12 +641,13 @@ "name": "apple_support~1.5.0~apple_cc_configure_extension~local_config_apple_cc_toolchains" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", + "bzlTransitiveDigest": "4x/FXzwoadac6uV9ItZ4eGOyCculGHHrKUhLFNWo3lA=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -668,7 +669,8 @@ "url": "https://maven.google.com/com/android/tools/r8/8.1.56/r8-8.1.56.jar" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { @@ -691,7 +693,8 @@ "name": "bazel_tools~cc_configure_extension~local_config_cc_toolchains" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": { @@ -709,7 +712,8 @@ "remote_xcode": "" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { @@ -725,12 +729,13 @@ "name": "bazel_tools~sh_configure_extension~local_config_sh" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", + "bzlTransitiveDigest": "y48q5zUu2oMiYv7yUyi7rFB0wt14eqiF/RQcWT6vP7I=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -745,12 +750,13 @@ ] } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@rules_java~7.1.0//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "iUIRqCK7tkhvcDJCAfPPqSd06IHG0a8HQD0xeQyVAqw=", + "bzlTransitiveDigest": "D02GmifxnV/IhYgspsJMDZ/aE8HxAjXgek5gi6FSto4=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1285,12 +1291,13 @@ "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\n" } } - } + }, + "recordedRepoMappingEntries": [] } }, "@@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { "general": { - "bzlTransitiveDigest": "rTru6D/C8vlaQDk4HOKyx4U/l6PCnj3Aq/gLraAqHgQ=", + "bzlTransitiveDigest": "07IRaHKuUT2vn32xPW6gc6vmBsFK1VdVBMWxgn0SE6k=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1360,7 +1367,8 @@ "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:defs.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\"**/*.py\", \"**/* *\", \"BUILD\", \"WORKSPACE\"]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" } } - } + }, + "recordedRepoMappingEntries": [] } } }
train
test
2024-01-10T14:14:32
2024-01-03T11:20:24Z
fmeum
test
bazelbuild/bazel/19674_20856
bazelbuild/bazel
bazelbuild/bazel/19674
bazelbuild/bazel/20856
[ "keyword_pr_to_issue" ]
eb517905bac62fd1d98b371e4828f4fb9450d4c5
1c00f90318b9aa58ce8dd997d9735954c035b864
[ "This is how Kleaf works around the issue right now (by defining multiple repositories):\r\n\r\nhttps://cs.android.com/android/kernel/superproject/+/common-android-mainline:build/kernel/kleaf/download_repo.bzl;l=356;drc=93375eb99ad216911bca8366cd8b70dd3d00def8\r\n\r\nThis feature request blocks DDKv2 development ([...
[]
2024-01-11T19:10:31Z
[ "type: feature request", "P2", "team-ExternalDeps", "team-Core", "help wanted" ]
Request API in repository_ctx to download multiple files simultaneously
### Description of the feature request: tl;dr: Request an API that is similar to repository_ctx.download, but download multiple files simultaneously. ### Which category does this issue belong to? Core, External Dependency ### What underlying problem are you trying to solve with this feature? Example to reproduce the issue: my_repo_rule.bzl ``` def _impl(repository_ctx): repository_ctx.download( url = "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb", output = "chrome.deb", ) repository_ctx.download( url = "https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm", output = "chrome.rpm", ) repository_ctx.file("WORKSPACE", "") repository_ctx.file("BUILD", """exports_files(glob(["**"]))""") my_repo_rule = repository_rule( implementation = _impl, ) ``` WORKSPACE ``` load(":my_repo_rule.bzl", "my_repo_rule") my_repo_rule( name = "my_ext_repo", ) ``` BUILD ``` # empty file ``` Then run ``` bazel fetch @my_ext_repo//... ``` You can see that the two files are downloaded in serial, not in parallel. To workaround this issue, one could define two repositories. For example: my_repo_rule.bzl ``` def _impl(repository_ctx): repository_ctx.download( url = repository_ctx.attr.url, output = "myfile", ) repository_ctx.file("WORKSPACE", "") repository_ctx.file("BUILD", """exports_files(glob(["**"]))""") my_repo_rule = repository_rule( implementation = _impl, attrs = {"url": attr.string()} ) ``` WORKSPACE ``` load(":my_repo_rule.bzl", "my_repo_rule") my_repo_rule( name = "chrome_deb", url = "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" ) my_repo_rule( name = "chrome_rpm", url = "https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm" ) ``` However, when there are a lot of files, this approach requires creating a lot of repositories. The benefit of downloading in parallel is: - If there are a lot of small files to download, the time savings are big, because most of the time spent on setting up the connection is parallelized. If there are a few big files to download, the time savings are small. - I could also do something like the following with good parallelization (pseudocode): ``` def _impl(repository_ctx): repository_ctx.download(<metadata file>) metadata = repository_ctx.read(<metadata file>) repository_ctx.download_multiple(metadata.urls) ``` Without the API to download multiple files, the above can only be done in WORKSPACE only. ``` # WORKSPACE load(":download.bzl", "download_metadata", "download") download_metadata(name = "metadata") load("@metadata//:metadata.bzl", "metadata") [ download(name = elem.name, url = elem.url) for elem in meatadata ] ``` I can't hide all these in a single macro because the load statements interleave with the repository definitions. ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? release 6.3.2 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? https://bazel.build/rules/lib/builtins/repository_ctx#download ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java", "src/main/java/com/google/devtools/bui...
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java", "src/main/java/com/google/devtools/bui...
[ "src/test/shell/bazel/external_integration_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD index 69cee4b2f4a084..f3ed273ba387a1 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/BUILD @@ -23,6 +23,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/clock", "//src/main/java/com/google/devtools/build/lib/concurrent", "//src/main/java/com/google/devtools/build/lib/events", + "//src/main/java/com/google/devtools/build/lib/profiler", "//src/main/java/com/google/devtools/build/lib/remote/util", "//src/main/java/com/google/devtools/build/lib/util", "//src/main/java/com/google/devtools/build/lib/util:os", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java index 02656d8221f3e8..43853fdfdd6701 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java @@ -20,9 +20,11 @@ import com.google.auth.Credentials; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.devtools.build.lib.authandtls.StaticCredentials; import com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache; import com.google.devtools.build.lib.bazel.repository.cache.RepositoryCache.KeyType; @@ -30,6 +32,8 @@ import com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriter.RewrittenURL; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.ExtendedEventHandler; +import com.google.devtools.build.lib.profiler.Profiler; +import com.google.devtools.build.lib.profiler.SilentCloseable; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; @@ -42,6 +46,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import javax.annotation.Nullable; /** @@ -51,6 +59,16 @@ * to disk. */ public class DownloadManager { + private static final ExecutorService DOWNLOAD_EXECUTOR = + Executors.newFixedThreadPool( + // There is also GrpcRemoteDownloader so if we set the thread pool to the same size as + // the allowed number of HTTP downloads, it might unnecessarily block. No, this is not a + // very + // principled approach; ideally, we'd grow the thread pool as needed with some generous + // upper + // limit. + 2 * HttpDownloader.MAX_PARALLEL_DOWNLOADS, + new ThreadFactoryBuilder().setNameFormat("download-manager-%d").build()); private final RepositoryCache repositoryCache; private List<Path> distdir = ImmutableList.of(); @@ -96,6 +114,69 @@ public void setCredentialFactory(CredentialFactory credentialFactory) { this.credentialFactory = credentialFactory; } + public Future<Path> startDownload( + List<URL> originalUrls, + Map<URI, Map<String, List<String>>> authHeaders, + Optional<Checksum> checksum, + String canonicalId, + Optional<String> type, + Path output, + ExtendedEventHandler eventHandler, + Map<String, String> clientEnv, + String context) { + return DOWNLOAD_EXECUTOR.submit( + () -> { + try (SilentCloseable c = Profiler.instance().profile("fetching: " + context)) { + return downloadInExecutor( + originalUrls, + authHeaders, + checksum, + canonicalId, + type, + output, + eventHandler, + clientEnv, + context); + } + }); + } + + public Path finalizeDownload(Future<Path> download) throws IOException, InterruptedException { + try { + return download.get(); + } catch (ExecutionException e) { + Throwables.throwIfInstanceOf(e.getCause(), IOException.class); + Throwables.throwIfInstanceOf(e.getCause(), InterruptedException.class); + Throwables.throwIfUnchecked(e.getCause()); + throw new IllegalStateException(e); + } + } + + public Path download( + List<URL> originalUrls, + Map<URI, Map<String, List<String>>> authHeaders, + Optional<Checksum> checksum, + String canonicalId, + Optional<String> type, + Path output, + ExtendedEventHandler eventHandler, + Map<String, String> clientEnv, + String context) + throws IOException, InterruptedException { + Future<Path> future = + startDownload( + originalUrls, + authHeaders, + checksum, + canonicalId, + type, + output, + eventHandler, + clientEnv, + context); + return finalizeDownload(future); + } + /** * Downloads file to disk and returns path. * @@ -114,7 +195,7 @@ public void setCredentialFactory(CredentialFactory credentialFactory) { * @throws IOException if download was attempted and ended up failing * @throws InterruptedException if this thread is being cast into oblivion */ - public Path download( + private Path downloadInExecutor( List<URL> originalUrls, Map<URI, Map<String, List<String>>> authHeaders, Optional<Checksum> checksum, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java index 1cc14c1dd183c8..3e9e0f150a6ac8 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java @@ -47,7 +47,8 @@ * file to disk. */ public class HttpDownloader implements Downloader { - private static final int MAX_PARALLEL_DOWNLOADS = 8; + static final int MAX_PARALLEL_DOWNLOADS = 8; + private static final Semaphore SEMAPHORE = new Semaphore(MAX_PARALLEL_DOWNLOADS, true); private static final Clock CLOCK = new JavaClock(); private static final Sleeper SLEEPER = new JavaSleeper(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java index f34fb44603f63d..1374306b6be39c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Maps; +import com.google.common.util.concurrent.Futures; import com.google.devtools.build.lib.actions.FileValue; import com.google.devtools.build.lib.bazel.debug.WorkspaceRuleEvent; import com.google.devtools.build.lib.bazel.repository.DecompressorDescriptor; @@ -34,6 +35,8 @@ import com.google.devtools.build.lib.bazel.repository.downloader.DownloadManager; import com.google.devtools.build.lib.bazel.repository.downloader.HttpUtils; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.events.Event; +import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.events.ExtendedEventHandler.FetchProgress; import com.google.devtools.build.lib.packages.StarlarkInfo; import com.google.devtools.build.lib.packages.StructImpl; @@ -77,12 +80,16 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import javax.annotation.Nullable; import net.starlark.java.annot.Param; import net.starlark.java.annot.ParamType; import net.starlark.java.annot.StarlarkMethod; import net.starlark.java.eval.Dict; import net.starlark.java.eval.EvalException; +import net.starlark.java.eval.Printer; import net.starlark.java.eval.Sequence; import net.starlark.java.eval.Starlark; import net.starlark.java.eval.StarlarkInt; @@ -93,6 +100,31 @@ /** A common base class for Starlark "ctx" objects related to external dependencies. */ public abstract class StarlarkBaseExternalContext implements StarlarkValue { + + /** + * An asynchronous task run as part of fetching the repository. + * + * <p>The main property of such tasks is that they should under no circumstances keep running + * after fetching the repository is finished, whether successfully or not. To this end, the {@link + * #cancel()} method must stop all such work. + */ + private interface AsyncTask { + /** Returns a user-friendly description of the task. */ + String getDescription(); + + /** Returns where the task was started from. */ + Location getLocation(); + + /** + * Cancels the task, if not done yet. Returns false if the task was still in progress. + * + * <p>No means of error reporting is provided. Any errors should be reported by other means. The + * only possible error reported as a consequence of calling this method is one that tells the + * user that they didn't wait for an async task they should have waited for. + */ + boolean cancel(); + } + /** Max. number of command line args added as a profiler description. */ private static final int MAX_PROFILE_ARGS_LEN = 80; @@ -106,6 +138,7 @@ public abstract class StarlarkBaseExternalContext implements StarlarkValue { protected final StarlarkSemantics starlarkSemantics; private final HashMap<Label, String> accumulatedFileDigests = new HashMap<>(); private final RepositoryRemoteExecutor remoteExecutor; + private final List<AsyncTask> asyncTasks; protected StarlarkBaseExternalContext( Path workingDirectory, @@ -125,6 +158,31 @@ protected StarlarkBaseExternalContext( this.processWrapper = processWrapper; this.starlarkSemantics = starlarkSemantics; this.remoteExecutor = remoteExecutor; + this.asyncTasks = new ArrayList<>(); + } + + public boolean ensureNoPendingAsyncTasks(EventHandler eventHandler, boolean forSuccessfulFetch) { + boolean hadPendingItems = false; + for (AsyncTask task : asyncTasks) { + if (!task.cancel()) { + hadPendingItems = true; + if (forSuccessfulFetch) { + eventHandler.handle( + Event.error( + task.getLocation(), + "Work pending after repository rule finished execution: " + + task.getDescription())); + } + } + } + + return hadPendingItems; + } + + // There is no unregister(). We don't have that many futures in each repository and it just + // introduces the failure mode of erroneously unregistering async work that's not done. + protected void registerAsyncTask(AsyncTask task) { + asyncTasks.add(task); } /** A string that can be used to identify this context object. Used for logging purposes. */ @@ -363,6 +421,101 @@ private StructImpl calculateDownloadResult(Optional<Checksum> checksum, Path dow return StarlarkInfo.create(StructProvider.STRUCT, out.buildOrThrow(), Location.BUILTIN); } + private class PendingDownload implements StarlarkValue, AsyncTask { + private final boolean executable; + private final boolean allowFail; + private final StarlarkPath outputPath; + private final Optional<Checksum> checksum; + private final RepositoryFunctionException checksumValidation; + private final Future<Path> future; + private final Location location; + + private PendingDownload( + boolean executable, + boolean allowFail, + StarlarkPath outputPath, + Optional<Checksum> checksum, + RepositoryFunctionException checksumValidation, + Future<Path> future, + Location location) { + this.executable = executable; + this.allowFail = allowFail; + this.outputPath = outputPath; + this.checksum = checksum; + this.checksumValidation = checksumValidation; + this.future = future; + this.location = location; + } + + @Override + public String getDescription() { + return String.format("downloading to '%s'", outputPath); + } + + @Override + public Location getLocation() { + return location; + } + + @Override + public boolean cancel() { + if (!future.cancel(true)) { + return true; + } + + try { + future.get(); + return false; + } catch (InterruptedException | ExecutionException | CancellationException e) { + // Ignore. The only thing we care about is that there is no async work in progress after + // this point. Any error reporting should have been done before. + return false; + } + } + + @StarlarkMethod( + name = "wait", + doc = + "Blocks until the completion of the download and returns or throws as blocking " + + " download() call would") + public StructImpl await() throws InterruptedException, RepositoryFunctionException { + return completeDownload(this); + } + + @Override + public void repr(Printer printer) { + printer.append(String.format("<pending download to '%s'>", outputPath)); + } + } + + private StructImpl completeDownload(PendingDownload pendingDownload) + throws RepositoryFunctionException, InterruptedException { + Path downloadedPath; + try { + downloadedPath = downloadManager.finalizeDownload(pendingDownload.future); + if (pendingDownload.executable) { + pendingDownload.outputPath.getPath().setExecutable(true); + } + } catch (IOException e) { + if (pendingDownload.allowFail) { + return StarlarkInfo.create( + StructProvider.STRUCT, ImmutableMap.of("success", false), Location.BUILTIN); + } else { + throw new RepositoryFunctionException(e, Transience.TRANSIENT); + } + } catch (InvalidPathException e) { + throw new RepositoryFunctionException( + Starlark.errorf( + "Could not create output path %s: %s", pendingDownload.outputPath, e.getMessage()), + Transience.PERSISTENT); + } + if (pendingDownload.checksumValidation != null) { + throw pendingDownload.checksumValidation; + } + + return calculateDownloadResult(pendingDownload.checksum, downloadedPath); + } + @StarlarkMethod( name = "download", doc = @@ -435,8 +588,18 @@ private StructImpl calculateDownloadResult(Optional<Checksum> checksum, Path dow + " risk to omit the checksum as remote files can change. At best omitting this" + " field will make your build non-hermetic. It is optional to make development" + " easier but should be set before shipping."), + @Param( + name = "block", + defaultValue = "True", + named = true, + positional = false, + doc = + "If set to false, the call returns immediately and instead of the regular return" + + " value, it returns a token with one single method, wait(), which blocks" + + " until the download is finished and returns the usual return value or" + + " throws as usual.") }) - public StructImpl download( + public Object download( Object url, Object output, String sha256, @@ -445,17 +608,20 @@ public StructImpl download( String canonicalId, Dict<?, ?> authUnchecked, // <String, Dict> expected String integrity, + Boolean block, StarlarkThread thread) throws RepositoryFunctionException, EvalException, InterruptedException { + PendingDownload download = null; ImmutableMap<URI, Map<String, List<String>>> authHeaders = getAuthHeaders(getAuthContents(authUnchecked, "auth")); ImmutableList<URL> urls = getUrls( url, - /*ensureNonEmpty=*/ !allowFail, - /*checksumGiven=*/ !Strings.isNullOrEmpty(sha256) || !Strings.isNullOrEmpty(integrity)); - Optional<Checksum> checksum; + /* ensureNonEmpty= */ !allowFail, + /* checksumGiven= */ !Strings.isNullOrEmpty(sha256) + || !Strings.isNullOrEmpty(integrity)); + Optional<Checksum> checksum = null; RepositoryFunctionException checksumValidation = null; try { checksum = validateChecksum(sha256, integrity, urls); @@ -475,13 +641,24 @@ public StructImpl download( getIdentifyingStringForLogging(), thread.getCallerLocation()); env.getListener().post(w); - Path downloadedPath; - try (SilentCloseable c = - Profiler.instance().profile("fetching: " + getIdentifyingStringForLogging())) { + + try { checkInOutputDirectory("write", outputPath); makeDirectories(outputPath.getPath()); - downloadedPath = - downloadManager.download( + } catch (IOException e) { + download = + new PendingDownload( + executable, + allowFail, + outputPath, + checksum, + checksumValidation, + Futures.immediateFailedFuture(e), + thread.getCallerLocation()); + } + if (download == null) { + Future<Path> downloadFuture = + downloadManager.startDownload( urls, authHeaders, checksum, @@ -491,26 +668,22 @@ public StructImpl download( env.getListener(), envVariables, getIdentifyingStringForLogging()); - if (executable) { - outputPath.getPath().setExecutable(true); - } - } catch (IOException e) { - if (allowFail) { - return StarlarkInfo.create( - StructProvider.STRUCT, ImmutableMap.of("success", false), Location.BUILTIN); - } else { - throw new RepositoryFunctionException(e, Transience.TRANSIENT); - } - } catch (InvalidPathException e) { - throw new RepositoryFunctionException( - Starlark.errorf("Could not create output path %s: %s", outputPath, e.getMessage()), - Transience.PERSISTENT); + download = + new PendingDownload( + executable, + allowFail, + outputPath, + checksum, + checksumValidation, + downloadFuture, + thread.getCallerLocation()); + registerAsyncTask(download); } - if (checksumValidation != null) { - throw checksumValidation; + if (!block) { + return download; + } else { + return completeDownload(download); } - - return calculateDownloadResult(checksum, downloadedPath); } @StarlarkMethod( @@ -669,17 +842,15 @@ public StructImpl downloadAndExtract( Path downloadedPath; Path downloadDirectory; - try (SilentCloseable c = - Profiler.instance().profile("fetching: " + getIdentifyingStringForLogging())) { - + try { // Download to temp directory inside the outputDirectory and delete it after extraction java.nio.file.Path tempDirectory = Files.createTempDirectory(Paths.get(outputPath.toString()), "temp"); downloadDirectory = workingDirectory.getFileSystem().getPath(tempDirectory.toFile().getAbsolutePath()); - downloadedPath = - downloadManager.download( + Future<Path> pendingDownload = + downloadManager.startDownload( urls, authHeaders, checksum, @@ -689,6 +860,7 @@ public StructImpl downloadAndExtract( env.getListener(), envVariables, getIdentifyingStringForLogging()); + downloadedPath = downloadManager.finalizeDownload(pendingDownload); } catch (IOException e) { env.getListener().post(w); if (allowFail) { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java index b3aabda85f2157..db616741fbdbbc 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java @@ -282,6 +282,7 @@ private RepositoryDirectoryValue.Builder fetchInternal( // it possible to return null and not block but it doesn't seem to be easy with Starlark // structure as it is. Object result; + boolean fetchSuccessful = false; try (SilentCloseable c = Profiler.instance() .profile(ProfilerTask.STARLARK_REPOSITORY_FN, () -> rule.getLabel().toString())) { @@ -291,7 +292,19 @@ private RepositoryDirectoryValue.Builder fetchInternal( function, /*args=*/ ImmutableList.of(starlarkRepositoryContext), /*kwargs=*/ ImmutableMap.of()); + fetchSuccessful = true; + } finally { + if (starlarkRepositoryContext.ensureNoPendingAsyncTasks( + env.getListener(), fetchSuccessful)) { + if (fetchSuccessful) { + throw new RepositoryFunctionException( + new EvalException( + "Pending asynchronous work after repository rule finished running"), + Transience.PERSISTENT); + } + } } + RepositoryResolvedEvent resolved = new RepositoryResolvedEvent( rule, starlarkRepositoryContext.getAttr(), outputDirectory, result);
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index 83223138173ed7..e378a7074ccc4b 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -49,6 +49,9 @@ EOF tear_down() { shutdown_server + if [ -d "${TEST_TMPDIR}/server_dir" ]; then + rm -fr "${TEST_TMPDIR}/server_dir" + fi } function zip_up() { @@ -410,6 +413,188 @@ EOF expect_log "404 Not Found" } +function test_deferred_download_unwaited() { + cat >> $(create_workspace_with_default_repos WORKSPACE) <<'EOF' +load("hang.bzl", "hang") + +hang(name="hang") +EOF + + cat > hang.bzl <<'EOF' +def _hang_impl(rctx): + hangs = rctx.download( + # This URL will definitely not work, but that's OK -- we don't need a + # successful request for this test + url = "https://127.0.0.1:0/does_not_exist", + output = "does_not_exist", + block = False) + +hang = repository_rule(implementation = _hang_impl) +EOF + + touch BUILD + bazel query @hang//:all >& $TEST_log && fail "Bazel unexpectedly succeeded" + expect_log "Pending asynchronous work" +} + +function test_deferred_download_two_parallel_downloads() { + local server_dir="${TEST_TMPDIR}/server_dir" + local gate_socket="${server_dir}/gate_socket" + local served_apple="APPLE" + local served_banana="BANANA" + local apple_sha256=$(echo "${served_apple}" | sha256sum | cut -f1 -d' ') + local banana_sha256=$(echo "${served_banana}" | sha256sum | cut -f1 -d' ') + + mkdir -p "${server_dir}" + + mkfifo "${server_dir}/apple" || fail "cannot mkfifo" + mkfifo "${server_dir}/banana" || fail "cannot mkfifo" + mkfifo $gate_socket || fail "cannot mkfifo" + + startup_server "${server_dir}" + + cat >> $(create_workspace_with_default_repos WORKSPACE) <<'EOF' +load("defer.bzl", "defer") + +defer(name="defer") +EOF + + cat > defer.bzl <<EOF +def _defer_impl(rctx): + requests = [ + ["apple", "${apple_sha256}"], + ["banana", "${banana_sha256}"] + ] + pending = [ + rctx.download( + url = "http://127.0.0.1:${fileserver_port}/" + name, + sha256 = sha256, + output = name, + block = False) + for name, sha256 in requests] + + # Tell the rest of the test to unblock the HTTP server + rctx.execute(["/bin/sh", "-c", "echo ok > ${server_dir}/gate_socket"]) + + # Wait until the requess are done + [p.wait() for p in pending] + + rctx.file("WORKSPACE", "") + rctx.file("BUILD", "filegroup(name='f', srcs=glob(['**']))") + +defer = repository_rule(implementation = _defer_impl) +EOF + + touch BUILD + + # Start Bazel + bazel query @defer//:all >& $TEST_log & + local bazel_pid=$! + + # Wait until the .download() calls return + cat "${server_dir}/gate_socket" + + # Tell the test server the strings it should serve. In parallel because the + # test server apparently cannot serve two HTTP requests in parallel, so if we + # wait for request A to be completely served while unblocking request B, it is + # possible that the test server wants to serve request B first, which is a + # deadlock. + echo "${served_apple}" > "${server_dir}/apple" & + local apple_pid=$! + echo "${served_banana}" > "${server_dir}/banana" & + local banana_pid=$! + wait $apple_pid + wait $banana_pid + + # Wait until Bazel returns + wait "${bazel_pid}" || fail "Bazel failed" + expect_log "@defer//:f" +} + +function test_deferred_download_error() { + cat >> $(create_workspace_with_default_repos WORKSPACE) <<'EOF' +load("defer.bzl", "defer") + +defer(name="defer") +EOF + + cat > defer.bzl <<EOF +def _defer_impl(rctx): + deferred = rctx.download( + url = "https://127.0.0.1:0/doesnotexist", + output = "deferred", + block = False) + + deferred.wait() + print("survived wait") + rctx.file("WORKSPACE", "") + rctx.file("BUILD", "filegroup(name='f', srcs=glob(['**']))") + +defer = repository_rule(implementation = _defer_impl) +EOF + + touch BUILD + + # Start Bazel + bazel query @defer//:all >& $TEST_log && fail "Bazel unexpectedly succeeded" + expect_log "Error downloading.*doesnotexist" + expect_not_log "survived wait" +} + +function test_deferred_download_smoke() { + local server_dir="${TEST_TMPDIR}/server_dir" + local served_socket="${server_dir}/served_socket" + local gate_socket="${server_dir}/gate_socket" + local served_string="DEFERRED" + local served_sha256=$(echo "${served_string}" | sha256sum | cut -f1 -d' ') + + mkdir -p "${server_dir}" + + mkfifo $served_socket || fail "cannot mkfifo" + mkfifo $gate_socket || fail "cannot mkfifo" + + startup_server "${server_dir}" + + cat >> $(create_workspace_with_default_repos WORKSPACE) <<'EOF' +load("defer.bzl", "defer") + +defer(name="defer") +EOF + + cat > defer.bzl <<EOF +def _defer_impl(rctx): + deferred = rctx.download( + url = "http://127.0.0.1:${fileserver_port}/served_socket", + sha256 = "${served_sha256}", + output = "deferred", + block = False) + + # Tell the rest of the test to unblock the HTTP server + rctx.execute(["/bin/sh", "-c", "echo ok > ${server_dir}/gate_socket"]) + deferred.wait() + rctx.file("WORKSPACE", "") + rctx.file("BUILD", "filegroup(name='f', srcs=glob(['**']))") + +defer = repository_rule(implementation = _defer_impl) +EOF + + touch BUILD + + # Start Bazel + bazel query @defer//:all-targets >& $TEST_log & + local bazel_pid=$! + + # Wait until the .download() call returns + cat "${server_dir}/gate_socket" + + # Tell the test server the string it should serve + echo "${served_string}" > "${server_dir}/served_socket" + + # Wait until Bazel returns + wait "${bazel_pid}" || fail "Bazel failed" + expect_log "@defer//:deferred" +} + # Tests downloading a file and using it as a dependency. function test_http_download() { local test_file=$TEST_TMPDIR/toto
train
test
2024-01-11T19:09:19
2023-09-28T22:45:34Z
jacky8hyf
test
bazelbuild/bazel/20834_20901
bazelbuild/bazel
bazelbuild/bazel/20834
bazelbuild/bazel/20901
[ "keyword_pr_to_issue" ]
39b99542922154ef6521ae31d3d299e1e4720c95
a42bea763370d482a7a192f51e9c83e94340ef9b
[ "@bazel-io fork 7.0.1", "@fmeum Are you looking into a fix? This seems to be the only blocker for 7.0.1", "@meteorcloudy Yes, the speculative fix is https://github.com/bazelbuild/bazel/pull/20833. Unfortunately the reporter is unable to test this and it's also very challenging to cover in integration tests.", ...
[]
2024-01-15T14:13:20Z
[ "type: bug", "team-Rules-CPP", "untriaged" ]
After upgrading to bazel 7.0.0 gcc fails with: --push-state: unknown option
### Description of the bug: After upgrading to bazel 7.0.0 the builds in our internal CIs that have an old gcc compiler are failing with: ``` (08:11:06) ERROR: /home/build/.cache/native_bazel_output_base/external/io_grpc_grpc_java/compiler/BUILD.bazel:5:10: Linking external/io_grpc_grpc_java/compiler/grpc_java_plugin [for tool] failed: (Exit 1): gcc failed: error executing CppLink command (from target @@io_grpc_grpc_java//compiler:grpc_java_plugin) (cd /home/build/.cache/native_bazel_output_base/sandbox/processwrapper-sandbox/7179/execroot/core && \ exec env - \ PATH=/bin:/usr/bin:/usr/local/bin \ PWD=/proc/self/cwd \ ZERO_AR_DATE=1 \ /usr/bin/gcc @bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/io_grpc_grpc_java/compiler/grpc_java_plugin-2.params) # Configuration: 922915957e448184486ff0fb7f0ba0ee9f92dfb993e46799f9d5193882b93aa1 # Execution platform: @@local_config_platform//:host ``` seems that the check for is_push_state_supported in https://github.com/bazelbuild/bazel/commit/2482322fedb463e0bbecd29c5e8e6d0f087ed884 is not working well ### Which category does this issue belong to? C++/Objective-C Rules ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. _No response_ ### Which operating system are you running Bazel on? MacOS and Linux ### What is the output of `bazel info release`? release 7.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. https://github.com/bazelbuild/bazel/commit/2482322fedb463e0bbecd29c5e8e6d0f087ed884 ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index bb33d6df320b03..fc9d8b7e034b70 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2179,7 +2179,7 @@ "general": { "bzlTransitiveDigest": "rjB9TSLGt3ZwbECWtF/HMgfqMsfEnDLK6fGIe65ZyfE=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "5218e8c896592023f884990b7a34f9276e3ce488e753eaaa8bc6057a1aca653c", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "4e2a1386686aae6d7be071ef615438178fdb93104b5b84cf8a372b6a944b27cd", "@@//:MODULE.bazel": "63625ac7809ba5bc83e0814e16f223ac28a98df884897ddd5bfbd69fd4e3ddbf" }, "envVariables": {}, diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 6d6e7171edc98b..5e7b3b79f427c9 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -161,10 +161,9 @@ def _is_compiler_option_supported(repository_ctx, cc, option): ]) return result.stderr.find(option) == -1 -def _is_linker_option_supported(repository_ctx, cc, option, pattern): +def _is_linker_option_supported(repository_ctx, cc, force_linker_flags, option, pattern): """Checks that `option` is supported by the C linker. Doesn't %-escape the option.""" - result = repository_ctx.execute([ - cc, + result = repository_ctx.execute([cc] + force_linker_flags + [ option, "-o", "/dev/null", @@ -213,9 +212,9 @@ def _add_compiler_option_if_supported(repository_ctx, cc, option): """Returns `[option]` if supported, `[]` otherwise. Doesn't %-escape the option.""" return [option] if _is_compiler_option_supported(repository_ctx, cc, option) else [] -def _add_linker_option_if_supported(repository_ctx, cc, option, pattern): +def _add_linker_option_if_supported(repository_ctx, cc, force_linker_flags, option, pattern): """Returns `[option]` if supported, `[]` otherwise. Doesn't %-escape the option.""" - return [option] if _is_linker_option_supported(repository_ctx, cc, option, pattern) else [] + return [option] if _is_linker_option_supported(repository_ctx, cc, force_linker_flags, option, pattern) else [] def _get_no_canonical_prefixes_opt(repository_ctx, cc): # If the compiler sometimes rewrites paths in the .d files without symlinks @@ -420,16 +419,40 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): False, ), ":") + gold_or_lld_linker_path = ( + _find_linker_path(repository_ctx, cc, "lld", is_clang) or + _find_linker_path(repository_ctx, cc, "gold", is_clang) + ) + cc_path = repository_ctx.path(cc) + if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"): + # cc is outside the repository, set -B + bin_search_flags = ["-B" + escape_string(str(cc_path.dirname))] + else: + # cc is inside the repository, don't set -B. + bin_search_flags = [] + if not gold_or_lld_linker_path: + ld_path = repository_ctx.path(tool_paths["ld"]) + if ld_path.dirname != cc_path.dirname: + bin_search_flags.append("-B" + str(ld_path.dirname)) + force_linker_flags = [] + if gold_or_lld_linker_path: + force_linker_flags.append("-fuse-ld=" + gold_or_lld_linker_path) + + # TODO: It's unclear why these flags aren't added on macOS. + if bin_search_flags and not darwin: + force_linker_flags.extend(bin_search_flags) use_libcpp = darwin or bsd is_as_needed_supported = _is_linker_option_supported( repository_ctx, cc, + force_linker_flags, "-Wl,-no-as-needed", "-no-as-needed", ) is_push_state_supported = _is_linker_option_supported( repository_ctx, cc, + force_linker_flags, "-Wl,--push-state", "--push-state", ) @@ -463,21 +486,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): bazel_linklibs, False, ), ":") - gold_or_lld_linker_path = ( - _find_linker_path(repository_ctx, cc, "lld", is_clang) or - _find_linker_path(repository_ctx, cc, "gold", is_clang) - ) - cc_path = repository_ctx.path(cc) - if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"): - # cc is outside the repository, set -B - bin_search_flags = ["-B" + escape_string(str(cc_path.dirname))] - else: - # cc is inside the repository, don't set -B. - bin_search_flags = [] - if not gold_or_lld_linker_path: - ld_path = repository_ctx.path(tool_paths["ld"]) - if ld_path.dirname != cc_path.dirname: - bin_search_flags.append("-B" + str(ld_path.dirname)) coverage_compile_flags, coverage_link_flags = _coverage_flags(repository_ctx, darwin) print_resource_dir_supported = _is_compiler_option_supported( repository_ctx, @@ -610,19 +618,18 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): ), "%{cxx_flags}": get_starlark_list(cxx_opts + _escaped_cplus_include_paths(repository_ctx)), "%{conly_flags}": get_starlark_list(conly_opts), - "%{link_flags}": get_starlark_list(( - ["-fuse-ld=" + gold_or_lld_linker_path] if gold_or_lld_linker_path else [] - ) + ( + "%{link_flags}": get_starlark_list(force_linker_flags + ( ["-Wl,-no-as-needed"] if is_as_needed_supported else [] ) + _add_linker_option_if_supported( repository_ctx, cc, + force_linker_flags, "-Wl,-z,relro,-z,now", "-z", ) + ( [ "-headerpad_max_install_names", - ] if darwin else bin_search_flags + [ + ] if darwin else [ # Gold linker only? Can we enable this by default? # "-Wl,--warn-execstack", # "-Wl,--detect-odr-violations" @@ -664,6 +671,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): ["-Wl,-dead_strip"] if darwin else _add_linker_option_if_supported( repository_ctx, cc, + force_linker_flags, "-Wl,--gc-sections", "-gc-sections", ),
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 86ee343f5e44ff..aa7908c026fe7d 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -642,7 +642,13 @@ } } }, - "recordedRepoMappingEntries": [] + "recordedRepoMappingEntries": [ + [ + "apple_support~1.5.0", + "bazel_tools", + "bazel_tools" + ] + ] } }, "@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { @@ -675,7 +681,7 @@ }, "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { "general": { - "bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=", + "bzlTransitiveDigest": "mcsWHq3xORJexV5/4eCvNOLxFOQKV6eli3fkr+tEaqE=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -694,7 +700,13 @@ } } }, - "recordedRepoMappingEntries": [] + "recordedRepoMappingEntries": [ + [ + "bazel_tools", + "bazel_tools", + "bazel_tools" + ] + ] } }, "@@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": { @@ -1292,7 +1304,18 @@ } } }, - "recordedRepoMappingEntries": [] + "recordedRepoMappingEntries": [ + [ + "rules_java~7.1.0", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_java~7.1.0", + "remote_java_tools", + "rules_java~7.1.0~toolchains~remote_java_tools" + ] + ] } }, "@@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { @@ -1368,7 +1391,18 @@ } } }, - "recordedRepoMappingEntries": [] + "recordedRepoMappingEntries": [ + [ + "rules_python~0.4.0", + "bazel_tools", + "bazel_tools" + ], + [ + "rules_python~0.4.0", + "rules_python", + "rules_python~0.4.0" + ] + ] } } }
val
test
2024-01-15T17:03:07
2024-01-10T10:17:50Z
rsalvador
test
bazelbuild/bazel/13709_20915
bazelbuild/bazel
bazelbuild/bazel/13709
bazelbuild/bazel/20915
[ "keyword_pr_to_issue" ]
debe29beea0bd254fa137d76920b17b170461448
1821a88927d27f64cd4d9cd719d2899383e2f066
[ "It doesn't out of the box, but it can be made to with a bit of boiler-plate:\r\n\r\n```starlark\r\nload(\r\n \"@bazel_tools//tools/build_defs/repo:utils.bzl\",\r\n \"read_netrc\",\r\n \"use_netrc\",\r\n)\r\nload(\"@bazel_skylib//lib:versions.bzl\", \"versions\")\r\n\r\ndef _use_netrc(netrc, urls, patterns...
[]
2024-01-17T01:13:02Z
[ "type: bug", "P2", "team-ExternalDeps" ]
repository_ctx.download doesn't use netrc
### Description of the problem / feature request: It seems that `repository_ctx.download(url)` doesn't handle netrc auth (while `http_archive`/`http_file` can use it, also wget can fetch same url). Rule in question is `jvm_maven_import_external` https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/repo/jvm.bzl#L109 ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. Don't have repro yet, will try to add later ### What operating system are you running Bazel on? NixOS ### What's the output of `bazel info release`? release 4.1.0- (@non-git) ### If `bazel info release` returns "development version" or "(@non-git)", tell us how you built Bazel. nixpkgs
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl", "tools/build_defs/repo/utils.bzl" ]
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl", "tools/build_defs/repo/utils.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index ea3bea3221fa12..514a2dc2f37123 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2159,7 +2159,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2178,9 +2178,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "10b96bd3c1eb194b0efe3a13fd06f2051abf36efb33414ad92048883ba471c7f", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "cf51741dfa229ffdcb85071df1c72fbf76ee282235033e2e1a2f39b3aa716a54", "@@//:MODULE.bazel": "1ce286c2e04a814940dcb741cddee8772a3d8b97d22e12ee12e116dac57f1cd3" }, "envVariables": {}, @@ -2429,7 +2429,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "PjK+f/kxkhda9tRFlKVdGfNszPoXs7CDXZUi+ZGWGYU=", + "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2479,7 +2479,7 @@ }, "//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", + "bzlTransitiveDigest": "kyYmVfXVvQ/eqU6zuZ6/NCQC72VLGyxJvwX/5Kzw3E8=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2506,7 +2506,7 @@ }, "//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", + "bzlTransitiveDigest": "dSavvzz4Z4n0JlBCZevqTBn9fRwlL29Y3/kjd1rvGAQ=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl index 81fc3f96dc77ab..de88e6e48e588a 100644 --- a/tools/build_defs/repo/http.bzl +++ b/tools/build_defs/repo/http.bzl @@ -45,11 +45,9 @@ load( ) load( ":utils.bzl", + "get_auth", "patch", - "read_netrc", - "read_user_netrc", "update_attrs", - "use_netrc", "workspace_and_buildfile", ) @@ -119,16 +117,6 @@ Authorization: Bearer RANDOM-TOKEN </pre> """ -def _get_auth(ctx, urls): - """Given the list of URLs obtain the correct auth dict.""" - if ctx.attr.netrc: - netrc = read_netrc(ctx, ctx.attr.netrc) - elif "NETRC" in ctx.os.environ: - netrc = read_netrc(ctx, ctx.os.environ["NETRC"]) - else: - netrc = read_user_netrc(ctx) - return use_netrc(netrc, urls, ctx.attr.auth_patterns) - def _update_integrity_attr(ctx, attrs, download_info): # We don't need to override the integrity attribute if sha256 is already specified. integrity_override = {} if ctx.attr.sha256 else {"integrity": download_info.integrity} @@ -140,7 +128,7 @@ def _http_archive_impl(ctx): fail("Only one of build_file and build_file_content can be provided.") all_urls = _get_all_urls(ctx) - auth = _get_auth(ctx, all_urls) + auth = get_auth(ctx, all_urls) download_info = ctx.download_and_extract( all_urls, @@ -182,7 +170,7 @@ def _http_file_impl(ctx): if download_path in forbidden_files or not str(download_path).startswith(str(repo_root)): fail("'%s' cannot be used as downloaded_file_path in http_file" % ctx.attr.downloaded_file_path) all_urls = _get_all_urls(ctx) - auth = _get_auth(ctx, all_urls) + auth = get_auth(ctx, all_urls) download_info = ctx.download( all_urls, "file/" + downloaded_file_path, @@ -219,7 +207,7 @@ filegroup( def _http_jar_impl(ctx): """Implementation of the http_jar rule.""" all_urls = _get_all_urls(ctx) - auth = _get_auth(ctx, all_urls) + auth = get_auth(ctx, all_urls) downloaded_file_name = ctx.attr.downloaded_file_name download_info = ctx.download( all_urls, diff --git a/tools/build_defs/repo/jvm.bzl b/tools/build_defs/repo/jvm.bzl index c7e87d2f4a97bd..a3ea79e17e5386 100644 --- a/tools/build_defs/repo/jvm.bzl +++ b/tools/build_defs/repo/jvm.bzl @@ -44,6 +44,10 @@ load( "DEFAULT_CANONICAL_ID_ENV", "get_default_canonical_id", ) +load( + ":utils.bzl", + "get_auth", +) _HEADER = "# DO NOT EDIT: generated by jvm_import_external()" @@ -124,6 +128,7 @@ def _jvm_import_external(repository_ctx): path, sha, canonical_id = repository_ctx.attr.canonical_id or get_default_canonical_id(repository_ctx, urls), + auth = get_auth(repository_ctx, urls), ) if srcurls and _should_fetch_sources_in_current_env(repository_ctx): repository_ctx.download( @@ -131,6 +136,7 @@ def _jvm_import_external(repository_ctx): srcpath, srcsha, canonical_id = repository_ctx.attr.canonical_id, + auth = get_auth(repository_ctx, srcurls), ) repository_ctx.file("BUILD", "\n".join(lines)) repository_ctx.file("%s/BUILD" % extension, "\n".join([ diff --git a/tools/build_defs/repo/utils.bzl b/tools/build_defs/repo/utils.bzl index cda04c237ca7b5..dabb75332cbb1f 100644 --- a/tools/build_defs/repo/utils.bzl +++ b/tools/build_defs/repo/utils.bzl @@ -420,3 +420,27 @@ def read_user_netrc(ctx): if not ctx.path(netrcfile).exists: return {} return read_netrc(ctx, netrcfile) + +def get_auth(ctx, urls): + """Utility function to obtain the correct auth dict for a list of urls from .netrc file. + + Support optional netrc and auth_patterns attributes if available. + + Args: + ctx: The repository context of the repository rule calling this utility + function. + urls: the list of urls to read + + Returns: + the auth dict which can be passed to repository_ctx.download + """ + if hasattr(ctx.attr, "netrc") and ctx.attr.netrc: + netrc = read_netrc(ctx, ctx.attr.netrc) + elif "NETRC" in ctx.os.environ: + netrc = read_netrc(ctx, ctx.os.environ["NETRC"]) + else: + netrc = read_user_netrc(ctx) + auth_patterns = {} + if hasattr(ctx.attr, "auth_patterns") and ctx.attr.auth_patterns: + auth_patterns = ctx.attr.auth_patterns + return use_netrc(netrc, urls, auth_patterns)
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 80fcbbd46be616..709394de9f7ee9 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -646,7 +646,7 @@ }, "@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "iz3RFYDcsjupaT10sdSPAhA44WL3eDYkTEnYThllj1w=", + "bzlTransitiveDigest": "kyYmVfXVvQ/eqU6zuZ6/NCQC72VLGyxJvwX/5Kzw3E8=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -730,7 +730,7 @@ }, "@@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "cizrA62cv8WUgb0cCmx5B6PRijtr/I4TAWxg/4caNGU=", + "bzlTransitiveDigest": "dSavvzz4Z4n0JlBCZevqTBn9fRwlL29Y3/kjd1rvGAQ=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -750,7 +750,7 @@ }, "@@rules_java~7.1.0//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "iUIRqCK7tkhvcDJCAfPPqSd06IHG0a8HQD0xeQyVAqw=", + "bzlTransitiveDigest": "8Iziusp18/KdkV+5SEUfQVW9SZzGjlEhlnyCj67JB60=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1290,7 +1290,7 @@ }, "@@rules_python~0.4.0//bzlmod:extensions.bzl%pip_install": { "general": { - "bzlTransitiveDigest": "rTru6D/C8vlaQDk4HOKyx4U/l6PCnj3Aq/gLraAqHgQ=", + "bzlTransitiveDigest": "HXTU3kpE37wW2sY8kraZBNNdfwttv4GVV9n6rlJf2NE=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
test
test
2024-01-16T17:32:13
2021-07-19T09:37:38Z
dmivankov
test
bazelbuild/bazel/20722_20917
bazelbuild/bazel
bazelbuild/bazel/20722
bazelbuild/bazel/20917
[ "keyword_pr_to_issue" ]
86a5f6b66dac4001c88fa00f938e0b482aede4a7
572f5eab573765ed2bdc86887a933c07f5f049d9
[ "@bazel-io fork 7.0.1", "@Wyverald @meteorcloudy This, combined with https://github.com/bazelbuild/bazel/commit/f4be0b2e7b5539502661033bcf6f47722aaa7e47#diff-ef4da5cc2da76cded220009a0dcc95373700d704629a1a2e9ebe84a9be076854, actually breaks `jvm_maven_import_external` and `http_jar` when `rules_java` is updated, o...
[]
2024-01-17T03:36:34Z
[ "type: bug", "P2", "team-ExternalDeps" ]
Repository rules aren't refetched when their repo mappings change
### Description of the bug: This is similar to https://github.com/bazelbuild/bazel/issues/20721, but 1) about repository rules rather than module extensions and 2) not a regression in 7.0.0. A repository rule isn't refetched when its repo mapping changes, which can result in `Label(...)` calls made in the implementation function to return stale results when canonical repo names change, e.g. during `bazel_dep` version bumps. ### Which category does this issue belong to? External Dependency ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ```starlark # MODULE.bazel bazel_dep(name = "rules_go", version = "0.40.0") ext = use_extension("//:ext.bzl", "ext") ext.tag(label_str = "@rules_go//go") use_repo(ext, "repo") # BUILD load("@repo//:defs.bzl", "LABEL") print(LABEL) # ext.bzl def _repo_impl(ctx): ctx.file("WORKSPACE") ctx.file("BUILD") ctx.file("defs.bzl", "LABEL = Label({})".format(repr(str(Label(ctx.attr.label_str))))) _repo = repository_rule( implementation=_repo_impl, attrs={"label_str": attr.string(mandatory=True)}, ) _tag = tag_class( attrs={"label_str": attr.string(mandatory=True)}, ) def _ext_impl(ctx): for module in ctx.modules: for tag in module.tags.tag: _repo(name = "repo", label_str = tag.label_str) ext = module_extension( implementation=_ext_impl, tag_classes={"tag": _tag}, ) ``` ```shell $ bazel build //... --lockfile_mode=off DEBUG: /home/fhenneke/tmp/repo-mapping-lock/BUILD:2:6: @@rules_go~0.40.0//go:go $ buildozer 'set version 0.41.0' MODULE.bazel:rules_go $ bazel build //... --lockfile_mode=off <no output since the old warning has already been omitted and hasn't changed> $ bazel shutdown $ bazel build //... --lockfile_mode=off DEBUG: /home/fhenneke/tmp/repo-mapping-lock/BUILD:2:6: @@rules_go~0.40.0//go:go ``` ### Which operating system are you running Bazel on? _No response_ ### What is the output of `bazel info release`? 7.0.0 and HEAD ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl" ]
[ "MODULE.bazel.lock", "tools/build_defs/repo/http.bzl", "tools/build_defs/repo/jvm.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 0af79c54f807e9..985f3b8cb8a5aa 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2159,7 +2159,7 @@ "moduleExtensions": { "//:extensions.bzl%bazel_android_deps": { "general": { - "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", + "bzlTransitiveDigest": "OaXuahb8Ga1zYeFJL4rrJjYmP9XovLouv9Tp+aqzEX0=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2178,9 +2178,9 @@ }, "//:extensions.bzl%bazel_build_deps": { "general": { - "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", + "bzlTransitiveDigest": "OaXuahb8Ga1zYeFJL4rrJjYmP9XovLouv9Tp+aqzEX0=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "552de48b3e70c27129fc02c79840365699609807f51793d0dc1590a62958de30", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "a35aced942408a91b1d681edb1049ebf55c7ddad7f382d6a45d44953510f4d96", "@@//:MODULE.bazel": "1ce286c2e04a814940dcb741cddee8772a3d8b97d22e12ee12e116dac57f1cd3" }, "envVariables": {}, @@ -2435,7 +2435,7 @@ }, "//:extensions.bzl%bazel_test_deps": { "general": { - "bzlTransitiveDigest": "QhQuQNBvy9io+azl8gYOlszhd84XltqOUhc6WXnInFY=", + "bzlTransitiveDigest": "OaXuahb8Ga1zYeFJL4rrJjYmP9XovLouv9Tp+aqzEX0=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2485,7 +2485,7 @@ }, "//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "kyYmVfXVvQ/eqU6zuZ6/NCQC72VLGyxJvwX/5Kzw3E8=", + "bzlTransitiveDigest": "S0n86BFe4SJ3lRaZiRA5D46oH52UO2hP1T50t/zldOw=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2512,7 +2512,7 @@ }, "//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "dSavvzz4Z4n0JlBCZevqTBn9fRwlL29Y3/kjd1rvGAQ=", + "bzlTransitiveDigest": "l5mcjH2gWmbmIycx97bzI2stD0Q0M5gpDc0aLOHKIm8=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl index de88e6e48e588a..71bb6a3d6cc255 100644 --- a/tools/build_defs/repo/http.bzl +++ b/tools/build_defs/repo/http.bzl @@ -186,8 +186,6 @@ def _http_file_impl(ctx): return _update_integrity_attr(ctx, _http_file_attrs, download_info) _HTTP_JAR_BUILD = """\ -load("{rules_java_defs}", "java_import") - package(default_visibility = ["//visibility:public"]) java_import( @@ -220,7 +218,6 @@ def _http_jar_impl(ctx): ctx.file("WORKSPACE", "workspace(name = \"{name}\")".format(name = ctx.name)) ctx.file("jar/BUILD", _HTTP_JAR_BUILD.format( file_name = downloaded_file_name, - rules_java_defs = str(Label("@rules_java//java:defs.bzl")), )) return _update_integrity_attr(ctx, _http_jar_attrs, download_info) diff --git a/tools/build_defs/repo/jvm.bzl b/tools/build_defs/repo/jvm.bzl index a3ea79e17e5386..5584ee11398a32 100644 --- a/tools/build_defs/repo/jvm.bzl +++ b/tools/build_defs/repo/jvm.bzl @@ -288,11 +288,6 @@ def jvm_maven_import_external( srcjar_urls = kwargs.pop("srcjar_urls", None) rule_name = kwargs.pop("rule_name", "java_import") - rules_java_defs = str(Label("@rules_java//java:defs.bzl")) - rule_load = kwargs.pop( - "rule_load", - 'load("{}", "java_import")'.format(rules_java_defs), - ) if fetch_sources: src_coordinates = struct( @@ -315,7 +310,6 @@ def jvm_maven_import_external( srcjar_urls = srcjar_urls, canonical_id = artifact, rule_name = rule_name, - rule_load = rule_load, tags = tags, **kwargs )
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 94ab8ba71d5969..6887b750690452 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -989,7 +989,7 @@ }, "@@bazel_tools//tools/android:android_extensions.bzl%remote_android_tools_extensions": { "general": { - "bzlTransitiveDigest": "kyYmVfXVvQ/eqU6zuZ6/NCQC72VLGyxJvwX/5Kzw3E8=", + "bzlTransitiveDigest": "S0n86BFe4SJ3lRaZiRA5D46oH52UO2hP1T50t/zldOw=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1073,7 +1073,7 @@ }, "@@bazel_tools//tools/test:extensions.bzl%remote_coverage_tools_extension": { "general": { - "bzlTransitiveDigest": "dSavvzz4Z4n0JlBCZevqTBn9fRwlL29Y3/kjd1rvGAQ=", + "bzlTransitiveDigest": "l5mcjH2gWmbmIycx97bzI2stD0Q0M5gpDc0aLOHKIm8=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1093,7 +1093,7 @@ }, "@@rules_java~7.1.0//java:extensions.bzl%toolchains": { "general": { - "bzlTransitiveDigest": "8Iziusp18/KdkV+5SEUfQVW9SZzGjlEhlnyCj67JB60=", + "bzlTransitiveDigest": "04zUmtTZlr1dV4uomFuJ3vSbBSlCcm5xmKcp/Fy7bGw=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -1633,7 +1633,7 @@ }, "@@rules_jvm_external~4.4.2//:extensions.bzl%maven": { "general": { - "bzlTransitiveDigest": "8bCMg1PvrC5kIZolTwRMdMG2stFYPJph2VrNUkWxiBw=", + "bzlTransitiveDigest": "v8HssW6WP6B8s0BwuAMJuQCz6cQ9jlhOfx4dKBtPYB4=", "accumulatedFileDigests": { "@@rules_jvm_external~4.4.2//:rules_jvm_external_deps_install.json": "10442a5ae27d9ff4c2003e5ab71643bf0d8b48dcf968b4173fa274c3232a8c06" }, @@ -2720,7 +2720,7 @@ }, "@@rules_jvm_external~4.4.2//:non-module-deps.bzl%non_module_deps": { "general": { - "bzlTransitiveDigest": "ianytwKVaqmOgfIRGRP4Ra/4fOv9bVx66S9abA454wc=", + "bzlTransitiveDigest": "DqBh3ObkOvjDFKv8VTy6J2qr7hXsJm9/sES7bha7ftA=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2740,7 +2740,7 @@ }, "@@rules_python~0.22.0//python/extensions:python.bzl%python": { "general": { - "bzlTransitiveDigest": "5984r65oTDrHlsC2EzVYYzZuSysKJJHzbkPtXZaZq9Q=", + "bzlTransitiveDigest": "31xtOi5rmBJ3jSHeziLzV7KKKgCc6tMnRUZ1BQLBeao=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": { @@ -2757,7 +2757,7 @@ }, "@@rules_python~0.22.0//python/extensions/private:internal_deps.bzl%internal_deps": { "general": { - "bzlTransitiveDigest": "BnJzAP4gt64l11dxPIXHUAtc4AYnunQFksKopy7uynE=", + "bzlTransitiveDigest": "fUb5iKCtPgjhclraX+//BnJ+LOcG6I6+O9UUxT+gZ50=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
val
test
2024-01-17T15:48:42
2024-01-03T11:20:24Z
fmeum
test
bazelbuild/bazel/17829_20979
bazelbuild/bazel
bazelbuild/bazel/17829
bazelbuild/bazel/20979
[ "keyword_pr_to_issue" ]
269c70bb63bce060ff2daac7dee1ff5e124eab58
8edf5e5f67ced417dca578bd9635acf415d21cce
[ "cc @Wyverald ", "Note, we'll need to add a workaround in rules_oci for now, however it uses a requires using another tool during the repository rule, making it require a fake toolchain resolution and also the download it makes is not cached anywhere.", "@meteorcloudy Do you see any potential issues with allowi...
[]
2024-01-22T21:14:09Z
[ "type: feature request", "P3", "team-ExternalDeps" ]
Allow arbitrary headers to sent with Bazel Downloader
### Description of the feature request: Currently, bazel sets some headers when sending an HTTP request to fetch artifacts over the internet. While this works well for most cases, it doesn't work at all when the remote server requires some HTTP headers to be set to special values. For instance, currently bazel sets all the `Accept` header to `text/html, image/gif, image/jpeg, */*` in outgoing HTTP requests. In my case, its `Accept` header that needs to be set to `application/vnd.oci.image.manifest.v1+json` so that docker registry sees no problem responding when the image has oci manifest types. See: https://github.com/bazelbuild/bazel/issues/16659#issuecomment-1470347164 Related to #16682 ### What underlying problem are you trying to solve with this feature? _No response_ ### Which operating system are you running Bazel on? darwin/arm64 ### What is the output of `bazel info release`? _No response_ ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java", "src/main/java/com/goo...
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java", "src/main/java/com/goo...
[ "src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloaderTest.java", "src/test/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloaderTest.java", "src/test/shell/bazel/remote_helpers.sh", "src/test/shell/bazel/starlark_repository_test.sh", "src/test/shell/baze...
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java index 249cc22c7c0d19..3b06fec38ce2ee 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DelegatingDownloader.java @@ -47,6 +47,7 @@ public void setDelegate(@Nullable Downloader delegate) { @Override public void download( List<URL> urls, + Map<String, List<String>> headers, Credentials credentials, Optional<Checksum> checksum, String canonicalId, @@ -60,6 +61,14 @@ public void download( downloader = delegate; } downloader.download( - urls, credentials, checksum, canonicalId, destination, eventHandler, clientEnv, type); + urls, + headers, + credentials, + checksum, + canonicalId, + destination, + eventHandler, + clientEnv, + type); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java index 43853fdfdd6701..a56ce634c24307 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadManager.java @@ -116,6 +116,7 @@ public void setCredentialFactory(CredentialFactory credentialFactory) { public Future<Path> startDownload( List<URL> originalUrls, + Map<String, List<String>> headers, Map<URI, Map<String, List<String>>> authHeaders, Optional<Checksum> checksum, String canonicalId, @@ -129,6 +130,7 @@ public Future<Path> startDownload( try (SilentCloseable c = Profiler.instance().profile("fetching: " + context)) { return downloadInExecutor( originalUrls, + headers, authHeaders, checksum, canonicalId, @@ -154,6 +156,7 @@ public Path finalizeDownload(Future<Path> download) throws IOException, Interrup public Path download( List<URL> originalUrls, + Map<String, List<String>> headers, Map<URI, Map<String, List<String>>> authHeaders, Optional<Checksum> checksum, String canonicalId, @@ -166,6 +169,7 @@ public Path download( Future<Path> future = startDownload( originalUrls, + headers, authHeaders, checksum, canonicalId, @@ -197,6 +201,7 @@ public Path download( */ private Path downloadInExecutor( List<URL> originalUrls, + Map<String, List<String>> headers, Map<URI, Map<String, List<String>>> authHeaders, Optional<Checksum> checksum, String canonicalId, @@ -339,6 +344,7 @@ private Path downloadInExecutor( try { downloader.download( rewrittenUrls, + headers, credentialFactory.create(rewrittenAuthHeaders), checksum, canonicalId, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java index 1e8fc932b43b08..79a0076a3f56e1 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/Downloader.java @@ -42,6 +42,7 @@ public interface Downloader { */ void download( List<URL> urls, + Map<String, List<String>> headers, Credentials credentials, Optional<Checksum> checksum, String canonicalId, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java index 1d5ba9b08a435c..b82587b5a91a0c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java @@ -75,7 +75,7 @@ final class HttpConnectorMultiplexer { } public HttpStream connect(URL url, Optional<Checksum> checksum) throws IOException { - return connect(url, checksum, StaticCredentials.EMPTY, Optional.empty()); + return connect(url, checksum, ImmutableMap.of(), StaticCredentials.EMPTY, Optional.empty()); } /** @@ -96,14 +96,23 @@ public HttpStream connect(URL url, Optional<Checksum> checksum) throws IOExcepti * @throws IllegalArgumentException if {@code urls} is empty or has an unsupported protocol */ public HttpStream connect( - URL url, Optional<Checksum> checksum, Credentials credentials, Optional<String> type) + URL url, + Optional<Checksum> checksum, + Map<String, List<String>> headers, + Credentials credentials, + Optional<String> type) throws IOException { Preconditions.checkArgument(HttpUtils.isUrlSupportedByDownloader(url)); if (Thread.interrupted()) { throw new InterruptedIOException(); } + ImmutableMap.Builder<String, List<String>> baseHeaders = new ImmutableMap.Builder<>(); + baseHeaders.putAll(headers); + // REQUEST_HEADERS should not be overridable by user provided headers + baseHeaders.putAll(REQUEST_HEADERS); + Function<URL, ImmutableMap<String, List<String>>> headerFunction = - getHeaderFunction(REQUEST_HEADERS, credentials); + getHeaderFunction(baseHeaders.buildKeepingLast(), credentials); URLConnection connection = connector.connect(url, headerFunction); return httpStreamFactory.create( connection, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java index 3e9e0f150a6ac8..35e0ea2ebb8577 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloader.java @@ -16,6 +16,7 @@ import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.io.ByteStreams; import com.google.devtools.build.lib.buildeventstream.FetchEvent; @@ -75,6 +76,7 @@ public void setMaxRetryTimeout(Duration maxRetryTimeout) { @Override public void download( List<URL> urls, + Map<String, List<String>> headers, Credentials credentials, Optional<Checksum> checksum, String canonicalId, @@ -94,7 +96,7 @@ public void download( for (URL url : urls) { SEMAPHORE.acquire(); - try (HttpStream payload = multiplexer.connect(url, checksum, credentials, type); + try (HttpStream payload = multiplexer.connect(url, checksum, headers, credentials, type); OutputStream out = destination.getOutputStream()) { try { ByteStreams.copy(payload, out); @@ -153,7 +155,8 @@ public byte[] downloadAndReadOneUrl( ByteArrayOutputStream out = new ByteArrayOutputStream(); SEMAPHORE.acquire(); try (HttpStream payload = - multiplexer.connect(url, Optional.empty(), credentials, Optional.empty())) { + multiplexer.connect( + url, Optional.empty(), ImmutableMap.of(), credentials, Optional.empty())) { ByteStreams.copy(payload, out); } catch (SocketTimeoutException e) { // SocketTimeoutExceptions are InterruptedIOExceptions; however they do not signify diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java index 50c5554c772e6f..30e9f4f34d411c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java @@ -291,6 +291,32 @@ private static ImmutableMap<URI, Map<String, List<String>>> getAuthHeaders( return res; } + private static ImmutableMap<String, List<String>> getHeaderContents(Dict<?, ?> x, String what) + throws EvalException { + Dict<String, Object> headersUnchecked = + (Dict<String, Object>) Dict.cast(x, String.class, Object.class, what); + ImmutableMap.Builder<String, List<String>> headers = new ImmutableMap.Builder<>(); + + for (Map.Entry<String, Object> entry : headersUnchecked.entrySet()) { + ImmutableList<String> headerValue; + Object valueUnchecked = entry.getValue(); + if (valueUnchecked instanceof Sequence) { + headerValue = + Sequence.cast(valueUnchecked, String.class, "header values").getImmutableList(); + } else if (valueUnchecked instanceof String) { + headerValue = ImmutableList.of(valueUnchecked.toString()); + } else { + throw new EvalException( + String.format( + "%s argument must be a dict whose keys are string and whose values are either" + + " string or sequence of string", + what)); + } + headers.put(entry.getKey(), headerValue); + } + return headers.buildOrThrow(); + } + private static ImmutableList<String> checkAllUrls(Iterable<?> urlList) throws EvalException { ImmutableList.Builder<String> result = ImmutableList.builder(); @@ -587,6 +613,11 @@ private StructImpl completeDownload(PendingDownload pendingDownload) defaultValue = "{}", named = true, doc = "An optional dict specifying authentication information for some of the URLs."), + @Param( + name = "headers", + defaultValue = "{}", + named = true, + doc = "An optional dict specifying http headers for all URLs."), @Param( name = "integrity", defaultValue = "''", @@ -617,6 +648,7 @@ public Object download( Boolean allowFail, String canonicalId, Dict<?, ?> authUnchecked, // <String, Dict> expected + Dict<?, ?> headersUnchecked, // <String, List<String> | String> expected String integrity, Boolean block, StarlarkThread thread) @@ -625,6 +657,8 @@ public Object download( ImmutableMap<URI, Map<String, List<String>>> authHeaders = getAuthHeaders(getAuthContents(authUnchecked, "auth")); + ImmutableMap<String, List<String>> headers = getHeaderContents(headersUnchecked, "headers"); + ImmutableList<URL> urls = getUrls( url, @@ -670,6 +704,7 @@ public Object download( Future<Path> downloadFuture = downloadManager.startDownload( urls, + headers, authHeaders, checksum, canonicalId, @@ -778,6 +813,11 @@ public Object download( defaultValue = "{}", named = true, doc = "An optional dict specifying authentication information for some of the URLs."), + @Param( + name = "headers", + defaultValue = "{}", + named = true, + doc = "An optional dict specifying http headers for all URLs."), @Param( name = "integrity", defaultValue = "''", @@ -809,13 +849,16 @@ public StructImpl downloadAndExtract( String stripPrefix, Boolean allowFail, String canonicalId, - Dict<?, ?> auth, // <String, Dict> expected + Dict<?, ?> authUnchecked, // <String, Dict> expected + Dict<?, ?> headersUnchecked, // <String, List<String> | String> expected String integrity, Dict<?, ?> renameFiles, // <String, String> expected StarlarkThread thread) throws RepositoryFunctionException, InterruptedException, EvalException { ImmutableMap<URI, Map<String, List<String>>> authHeaders = - getAuthHeaders(getAuthContents(auth, "auth")); + getAuthHeaders(getAuthContents(authUnchecked, "auth")); + + ImmutableMap<String, List<String>> headers = getHeaderContents(headersUnchecked, "headers"); ImmutableList<URL> urls = getUrls( @@ -862,6 +905,7 @@ public StructImpl downloadAndExtract( Future<Path> pendingDownload = downloadManager.startDownload( urls, + headers, authHeaders, checksum, canonicalId, diff --git a/src/main/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloader.java b/src/main/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloader.java index 29466a5e9d9407..ddc011ef99432d 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloader.java +++ b/src/main/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloader.java @@ -110,6 +110,7 @@ public void close() { @Override public void download( List<URL> urls, + Map<String, List<String>> headers, Credentials credentials, Optional<Checksum> checksum, String canonicalId, @@ -154,7 +155,15 @@ public void download( eventHandler.handle( Event.warn("Remote Cache: " + Utils.grpcAwareErrorMessage(e, verboseFailures))); fallbackDownloader.download( - urls, credentials, checksum, canonicalId, destination, eventHandler, clientEnv, type); + urls, + headers, + credentials, + checksum, + canonicalId, + destination, + eventHandler, + clientEnv, + type); } }
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloaderTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloaderTest.java index 2451af6027aabf..0e59d412abb975 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpDownloaderTest.java @@ -117,6 +117,7 @@ public void downloadFrom1UrlOk() throws IOException, InterruptedException { Collections.singletonList( new URL(String.format("http://localhost:%d/foo", server.getLocalPort()))), Collections.emptyMap(), + Collections.emptyMap(), Optional.empty(), "testCanonicalId", Optional.empty(), @@ -181,6 +182,7 @@ public void downloadFrom2UrlsFirstOk() throws IOException, InterruptedException downloadManager.download( urls, Collections.emptyMap(), + Collections.emptyMap(), Optional.empty(), "testCanonicalId", Optional.empty(), @@ -248,6 +250,7 @@ public void downloadFrom2UrlsFirstSocketTimeoutOnBodyReadSecondOk() downloadManager.download( urls, Collections.emptyMap(), + Collections.emptyMap(), Optional.empty(), "testCanonicalId", Optional.empty(), @@ -317,6 +320,7 @@ public void downloadFrom2UrlsBothSocketTimeoutDuringBodyRead() downloadManager.download( urls, Collections.emptyMap(), + Collections.emptyMap(), Optional.empty(), "testCanonicalId", Optional.empty(), @@ -371,6 +375,7 @@ public void downloadOneUrl_ok() throws IOException, InterruptedException { httpDownloader.download( Collections.singletonList( new URL(String.format("http://localhost:%d/foo", server.getLocalPort()))), + Collections.emptyMap(), StaticCredentials.EMPTY, Optional.empty(), "testCanonicalId", @@ -410,6 +415,7 @@ public void downloadOneUrl_notFound() throws IOException, InterruptedException { httpDownloader.download( Collections.singletonList( new URL(String.format("http://localhost:%d/foo", server.getLocalPort()))), + Collections.emptyMap(), StaticCredentials.EMPTY, Optional.empty(), "testCanonicalId", @@ -470,6 +476,7 @@ public void downloadTwoUrls_firstNotFoundAndSecondOk() throws IOException, Inter Path destination = fs.getPath(workingDir.newFile().getAbsolutePath()); httpDownloader.download( urls, + Collections.emptyMap(), StaticCredentials.EMPTY, Optional.empty(), "testCanonicalId", @@ -564,13 +571,14 @@ public void download_contentLengthMismatch_propagateErrorIfNotRetry() throws Exc throw new ContentLengthMismatchException(0, data.length); }) .when(downloader) - .download(any(), any(), any(), any(), any(), any(), any(), any()); + .download(any(), any(), any(), any(), any(), any(), any(), any(), any()); assertThrows( ContentLengthMismatchException.class, () -> downloadManager.download( ImmutableList.of(new URL("http://localhost")), + Collections.emptyMap(), ImmutableMap.of(), Optional.empty(), "testCanonicalId", @@ -597,7 +605,7 @@ public void download_contentLengthMismatch_retries() throws Exception { if (times.getAndIncrement() < 3) { throw new ContentLengthMismatchException(0, data.length); } - Path output = invocationOnMock.getArgument(4, Path.class); + Path output = invocationOnMock.getArgument(5, Path.class); try (OutputStream outputStream = output.getOutputStream()) { ByteStreams.copy(new ByteArrayInputStream(data), outputStream); } @@ -605,12 +613,13 @@ public void download_contentLengthMismatch_retries() throws Exception { return null; }) .when(downloader) - .download(any(), any(), any(), any(), any(), any(), any(), any()); + .download(any(), any(), any(), any(), any(), any(), any(), any(), any()); Path result = downloadManager.download( ImmutableList.of(new URL("http://localhost")), ImmutableMap.of(), + ImmutableMap.of(), Optional.empty(), "testCanonicalId", Optional.empty(), diff --git a/src/test/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloaderTest.java b/src/test/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloaderTest.java index ced0fe561c830a..f881d862800e83 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/downloader/GrpcRemoteDownloaderTest.java @@ -178,6 +178,7 @@ private static byte[] downloadBlob( final Path destination = scratch.resolve("output file path"); downloader.download( urls, + ImmutableMap.of(), StaticCredentials.EMPTY, checksum, canonicalId, @@ -240,13 +241,13 @@ public void fetchBlob( invocation -> { List<URL> urls = invocation.getArgument(0); if (urls.equals(ImmutableList.of(new URL("http://example.com/content.txt")))) { - Path output = invocation.getArgument(4); + Path output = invocation.getArgument(5); FileSystemUtils.writeContent(output, content); } return null; }) .when(fallbackDownloader) - .download(any(), any(), any(), any(), any(), any(), any(), any()); + .download(any(), any(), any(), any(), any(), any(), any(), any(), any()); final GrpcRemoteDownloader downloader = newDownloader(cacheClient, fallbackDownloader); final byte[] downloaded = diff --git a/src/test/shell/bazel/remote_helpers.sh b/src/test/shell/bazel/remote_helpers.sh index 6a66398d3eabd9..e8181d210ff7db 100755 --- a/src/test/shell/bazel/remote_helpers.sh +++ b/src/test/shell/bazel/remote_helpers.sh @@ -179,6 +179,28 @@ function serve_timeout() { cd - } +# Serves a HTTP 200 Ok response with headers dumped into the file +# Args: +# $1: required; path to the file +# $2: optional; path to the file where headers will be written to. +function serve_file_header_dump() { + file_name=served_file.$$ + cat $1 > "${TEST_TMPDIR}/$file_name" + nc_log="${TEST_TMPDIR}/nc.log" + rm -f $nc_log + touch $nc_log + cd "${TEST_TMPDIR}" + port_file=server-port.$$ + rm -f $port_file + python3 $python_server always $file_name --dump_headers ${2:-"headers.json"} > $port_file & + nc_pid=$! + while ! grep started $port_file; do sleep 1; done + nc_port=$(head -n 1 $port_file) + fileserver_port=$nc_port + wait_for_server_startup + cd - +} + # Waits for the SimpleHTTPServer to actually start up before the test is run. # Otherwise the entire test can run before the server starts listening for # connections, which causes flakes. diff --git a/src/test/shell/bazel/starlark_repository_test.sh b/src/test/shell/bazel/starlark_repository_test.sh index dc45b9e2be0f54..d5008c47cd5dd4 100755 --- a/src/test/shell/bazel/starlark_repository_test.sh +++ b/src/test/shell/bazel/starlark_repository_test.sh @@ -2354,8 +2354,8 @@ genrule( cmd = "cp $< $@", ) EOF - - bazel build --repository_disable_download //:it || fail "Failed to build" + # for some reason --repository_disable_download fails with bzlmod trying to download @platforms. + bazel build --repository_disable_download --noenable_bzlmod //:it || fail "Failed to build" } function test_no_restarts_fetching_with_worker_thread() { @@ -2408,6 +2408,181 @@ EOF || fail "Expected build to succeed" } + +function test_cred_helper_overrides_starlark_headers() { + if "$is_windows"; then + # Skip on Windows: credential helper is a Python script. + return + fi + + setup_credential_helper + + filename="cred_helper_starlark.txt" + echo $filename > $filename + sha256="$(sha256sum $filename | head -c 64)" + serve_file_header_dump $filename credhelper_headers.json + + setup_starlark_repository + + cat > test.bzl <<EOF +def _impl(repository_ctx): + repository_ctx.file("BUILD") + repository_ctx.download( + url = "http://127.0.0.1:$nc_port/$filename", + output = "test.txt", + sha256 = "$sha256", + headers = { + "Authorization": ["should be overidden"], + "X-Custom-Token": ["foo"] + } + ) + +repo = repository_rule(implementation=_impl) +EOF + + + bazel build --credential_helper="${TEST_TMPDIR}/credhelper" @foo//:all || fail "expected bazel to succeed" + + headers="${TEST_TMPDIR}/credhelper_headers.json" + assert_contains '"Authorization": "Bearer TOKEN"' "$headers" + assert_contains '"X-Custom-Token": "foo"' "$headers" + assert_not_contains "should be overidden" "$headers" +} + +function test_netrc_overrides_starlark_headers() { + filename="netrc_headers.txt" + echo $filename > $filename + sha256="$(sha256sum $filename | head -c 64)" + serve_file_header_dump $filename netrc_headers.json + + setup_starlark_repository + + cat > .netrc <<EOF +machine 127.0.0.1 +login foo +password bar +EOF + + cat > test.bzl <<EOF +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_netrc", "use_netrc") + +def _impl(repository_ctx): + url = "http://127.0.0.1:$nc_port/$filename" + netrc = read_netrc(repository_ctx, repository_ctx.attr.netrc) + auth = use_netrc(netrc, [url], {}) + repository_ctx.file("BUILD") + repository_ctx.download( + url = url, + output = "$filename", + sha256 = "$sha256", + headers = { + "Authorization": ["should be overidden"], + "X-Custom-Token": ["foo"] + }, + auth = auth + ) + +repo = repository_rule(implementation=_impl, attrs = {"netrc": attr.label(default = ":.netrc")}) +EOF + + + bazel build @foo//:all || fail "expected bazel to succeed" + + headers="${TEST_TMPDIR}/netrc_headers.json" + assert_contains '"Authorization": "Basic Zm9vOmJhcg=="' "$headers" + assert_contains '"X-Custom-Token": "foo"' "$headers" + assert_not_contains "should be overidden" "$headers" +} + + +function test_starlark_headers_override_default_headers() { + + filename="default_headers.txt" + echo $filename > $filename + sha256="$(sha256sum $filename | head -c 64)" + serve_file_header_dump $filename default_headers.json + + setup_starlark_repository + + cat > test.bzl <<EOF +def _impl(repository_ctx): + repository_ctx.file("BUILD") + repository_ctx.download( + url = "http://127.0.0.1:$nc_port/$filename", + output = "$filename", + sha256 = "$sha256", + headers = { + "Accept": ["application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json"], + } + ) + +repo = repository_rule(implementation=_impl) +EOF + + bazel build @foo//:all || fail "expected bazel to succeed" + + headers="${TEST_TMPDIR}/default_headers.json" + assert_contains '"Accept": "application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json"' "$headers" + assert_not_contains '"Accept": "text/html, image/gif, image/jpeg, */*"' "$headers" +} + +function test_invalid_starlark_headers() { + + filename="invalid_headers.txt" + echo $filename > $filename + sha256="$(sha256sum $filename | head -c 64)" + serve_file_header_dump $filename invalid_headers.json + + setup_starlark_repository + + cat > test.bzl <<EOF +def _impl(repository_ctx): + repository_ctx.file("BUILD") + repository_ctx.download( + url = "http://127.0.0.1:$nc_port/$filename", + output = "$filename", + sha256 = "$sha256", + headers = { + "Accept": 1, + } + ) + +repo = repository_rule(implementation=_impl) +EOF + + bazel build @foo//:all >& $TEST_log && fail "expected bazel to fail" || : + expect_log "headers argument must be a dict whose keys are string and whose values are either string or sequence of string" +} + +function test_string_starlark_headers() { + + filename="string_headers.txt" + echo $filename > $filename + sha256="$(sha256sum $filename | head -c 64)" + serve_file_header_dump $filename string_headers.json + + setup_starlark_repository + + cat > test.bzl <<EOF +def _impl(repository_ctx): + repository_ctx.file("BUILD") + repository_ctx.download( + url = "http://127.0.0.1:$nc_port/$filename", + output = "$filename", + sha256 = "$sha256", + headers = { + "Accept": "application/text", + } + ) + +repo = repository_rule(implementation=_impl) +EOF + + bazel build @foo//:all || fail "expected bazel to succeed" + headers="${TEST_TMPDIR}/string_headers.json" + assert_contains '"Accept": "application/text"' "$headers" +} + function test_repo_boundary_files() { create_new_workspace cat > MODULE.bazel <<EOF diff --git a/src/test/shell/bazel/testing_server.py b/src/test/shell/bazel/testing_server.py index 00c714792d2d95..e4255b46687394 100644 --- a/src/test/shell/bazel/testing_server.py +++ b/src/test/shell/bazel/testing_server.py @@ -17,6 +17,8 @@ # pylint: disable=g-import-not-at-top,g-importing-member import argparse import base64 +import json + try: from http.server import BaseHTTPRequestHandler except ImportError: @@ -44,11 +46,13 @@ class Handler(BaseHTTPRequestHandler): auth = False not_found = False simulate_timeout = False + dump_headers = None filename = None redirect = None valid_headers = [ b'Basic ' + base64.b64encode('foo:bar'.encode('ascii')), b'Bearer TOKEN' ] + unstable_headers = ['Host', 'User-Agent'] def do_HEAD(self): # pylint: disable=invalid-name self.send_response(200) @@ -67,6 +71,13 @@ def do_GET(self): # pylint: disable=invalid-name # fail without this being set. self.client_address = 'localhost' + if self.dump_headers: + headers = filter( + lambda hv: hv[0] not in self.unstable_headers, self.headers.items() + ) + with open(self.dump_headers, 'w') as f: + f.write(json.dumps(dict(headers))) + if self.simulate_timeout: while True: time.sleep(1) @@ -110,6 +121,8 @@ def serve_file(self): def main(argv): parser = argparse.ArgumentParser() parser.add_argument('--unix_socket', action='store') + parser.add_argument('--dump_headers', action='store') + parser.add_argument('mode', type=str, nargs='?') parser.add_argument('target', type=str, nargs='?') args = parser.parse_args(argv) @@ -128,6 +141,8 @@ def main(argv): if args.target: Handler.filename = args.target + Handler.dump_headers = args.dump_headers + httpd = None if args.unix_socket: httpd = UnixStreamServer(args.unix_socket, Handler)
test
test
2024-01-19T17:35:40
2023-03-20T17:41:12Z
thesayyn
test
bazelbuild/bazel/20834_20990
bazelbuild/bazel
bazelbuild/bazel/20834
bazelbuild/bazel/20990
[ "keyword_pr_to_issue" ]
269c70bb63bce060ff2daac7dee1ff5e124eab58
0aa0f602091a1d66bd18984aca66d87ff8867831
[ "@bazel-io fork 7.0.1", "@fmeum Are you looking into a fix? This seems to be the only blocker for 7.0.1", "@meteorcloudy Yes, the speculative fix is https://github.com/bazelbuild/bazel/pull/20833. Unfortunately the reporter is unable to test this and it's also very challenging to cover in integration tests.", ...
[]
2024-01-22T23:08:06Z
[ "type: bug", "team-Rules-CPP", "untriaged" ]
After upgrading to bazel 7.0.0 gcc fails with: --push-state: unknown option
### Description of the bug: After upgrading to bazel 7.0.0 the builds in our internal CIs that have an old gcc compiler are failing with: ``` (08:11:06) ERROR: /home/build/.cache/native_bazel_output_base/external/io_grpc_grpc_java/compiler/BUILD.bazel:5:10: Linking external/io_grpc_grpc_java/compiler/grpc_java_plugin [for tool] failed: (Exit 1): gcc failed: error executing CppLink command (from target @@io_grpc_grpc_java//compiler:grpc_java_plugin) (cd /home/build/.cache/native_bazel_output_base/sandbox/processwrapper-sandbox/7179/execroot/core && \ exec env - \ PATH=/bin:/usr/bin:/usr/local/bin \ PWD=/proc/self/cwd \ ZERO_AR_DATE=1 \ /usr/bin/gcc @bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/io_grpc_grpc_java/compiler/grpc_java_plugin-2.params) # Configuration: 922915957e448184486ff0fb7f0ba0ee9f92dfb993e46799f9d5193882b93aa1 # Execution platform: @@local_config_platform//:host ``` seems that the check for is_push_state_supported in https://github.com/bazelbuild/bazel/commit/2482322fedb463e0bbecd29c5e8e6d0f087ed884 is not working well ### Which category does this issue belong to? C++/Objective-C Rules ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. _No response_ ### Which operating system are you running Bazel on? MacOS and Linux ### What is the output of `bazel info release`? release 7.0.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced. https://github.com/bazelbuild/bazel/commit/2482322fedb463e0bbecd29c5e8e6d0f087ed884 ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 985f3b8cb8a5aa..badb20420084f0 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2180,7 +2180,7 @@ "general": { "bzlTransitiveDigest": "OaXuahb8Ga1zYeFJL4rrJjYmP9XovLouv9Tp+aqzEX0=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "a35aced942408a91b1d681edb1049ebf55c7ddad7f382d6a45d44953510f4d96", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "a76d8c53ac208e3b6335eefa542a24b2e1a70fcfccb5d79fd80cea2cc2947ab4", "@@//:MODULE.bazel": "1ce286c2e04a814940dcb741cddee8772a3d8b97d22e12ee12e116dac57f1cd3" }, "envVariables": {}, diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 6d6e7171edc98b..5e7b3b79f427c9 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -161,10 +161,9 @@ def _is_compiler_option_supported(repository_ctx, cc, option): ]) return result.stderr.find(option) == -1 -def _is_linker_option_supported(repository_ctx, cc, option, pattern): +def _is_linker_option_supported(repository_ctx, cc, force_linker_flags, option, pattern): """Checks that `option` is supported by the C linker. Doesn't %-escape the option.""" - result = repository_ctx.execute([ - cc, + result = repository_ctx.execute([cc] + force_linker_flags + [ option, "-o", "/dev/null", @@ -213,9 +212,9 @@ def _add_compiler_option_if_supported(repository_ctx, cc, option): """Returns `[option]` if supported, `[]` otherwise. Doesn't %-escape the option.""" return [option] if _is_compiler_option_supported(repository_ctx, cc, option) else [] -def _add_linker_option_if_supported(repository_ctx, cc, option, pattern): +def _add_linker_option_if_supported(repository_ctx, cc, force_linker_flags, option, pattern): """Returns `[option]` if supported, `[]` otherwise. Doesn't %-escape the option.""" - return [option] if _is_linker_option_supported(repository_ctx, cc, option, pattern) else [] + return [option] if _is_linker_option_supported(repository_ctx, cc, force_linker_flags, option, pattern) else [] def _get_no_canonical_prefixes_opt(repository_ctx, cc): # If the compiler sometimes rewrites paths in the .d files without symlinks @@ -420,16 +419,40 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): False, ), ":") + gold_or_lld_linker_path = ( + _find_linker_path(repository_ctx, cc, "lld", is_clang) or + _find_linker_path(repository_ctx, cc, "gold", is_clang) + ) + cc_path = repository_ctx.path(cc) + if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"): + # cc is outside the repository, set -B + bin_search_flags = ["-B" + escape_string(str(cc_path.dirname))] + else: + # cc is inside the repository, don't set -B. + bin_search_flags = [] + if not gold_or_lld_linker_path: + ld_path = repository_ctx.path(tool_paths["ld"]) + if ld_path.dirname != cc_path.dirname: + bin_search_flags.append("-B" + str(ld_path.dirname)) + force_linker_flags = [] + if gold_or_lld_linker_path: + force_linker_flags.append("-fuse-ld=" + gold_or_lld_linker_path) + + # TODO: It's unclear why these flags aren't added on macOS. + if bin_search_flags and not darwin: + force_linker_flags.extend(bin_search_flags) use_libcpp = darwin or bsd is_as_needed_supported = _is_linker_option_supported( repository_ctx, cc, + force_linker_flags, "-Wl,-no-as-needed", "-no-as-needed", ) is_push_state_supported = _is_linker_option_supported( repository_ctx, cc, + force_linker_flags, "-Wl,--push-state", "--push-state", ) @@ -463,21 +486,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): bazel_linklibs, False, ), ":") - gold_or_lld_linker_path = ( - _find_linker_path(repository_ctx, cc, "lld", is_clang) or - _find_linker_path(repository_ctx, cc, "gold", is_clang) - ) - cc_path = repository_ctx.path(cc) - if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"): - # cc is outside the repository, set -B - bin_search_flags = ["-B" + escape_string(str(cc_path.dirname))] - else: - # cc is inside the repository, don't set -B. - bin_search_flags = [] - if not gold_or_lld_linker_path: - ld_path = repository_ctx.path(tool_paths["ld"]) - if ld_path.dirname != cc_path.dirname: - bin_search_flags.append("-B" + str(ld_path.dirname)) coverage_compile_flags, coverage_link_flags = _coverage_flags(repository_ctx, darwin) print_resource_dir_supported = _is_compiler_option_supported( repository_ctx, @@ -610,19 +618,18 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): ), "%{cxx_flags}": get_starlark_list(cxx_opts + _escaped_cplus_include_paths(repository_ctx)), "%{conly_flags}": get_starlark_list(conly_opts), - "%{link_flags}": get_starlark_list(( - ["-fuse-ld=" + gold_or_lld_linker_path] if gold_or_lld_linker_path else [] - ) + ( + "%{link_flags}": get_starlark_list(force_linker_flags + ( ["-Wl,-no-as-needed"] if is_as_needed_supported else [] ) + _add_linker_option_if_supported( repository_ctx, cc, + force_linker_flags, "-Wl,-z,relro,-z,now", "-z", ) + ( [ "-headerpad_max_install_names", - ] if darwin else bin_search_flags + [ + ] if darwin else [ # Gold linker only? Can we enable this by default? # "-Wl,--warn-execstack", # "-Wl,--detect-odr-violations" @@ -664,6 +671,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools): ["-Wl,-dead_strip"] if darwin else _add_linker_option_if_supported( repository_ctx, cc, + force_linker_flags, "-Wl,--gc-sections", "-gc-sections", ),
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 6887b750690452..b7493f2c371bf4 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -1016,7 +1016,7 @@ }, "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { "general": { - "bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=", + "bzlTransitiveDigest": "mcsWHq3xORJexV5/4eCvNOLxFOQKV6eli3fkr+tEaqE=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
train
test
2024-01-19T17:35:40
2024-01-10T10:17:50Z
rsalvador
test
bazelbuild/bazel/20631_21023
bazelbuild/bazel
bazelbuild/bazel/20631
bazelbuild/bazel/21023
[ "keyword_pr_to_issue" ]
c6c7693bbcc8558074281eabf5ef40128a216c57
5202a05d182f2881972791af19a8d236c01d57ad
[ "I started working on this in the past in https://github.com/bazelbuild/bazel/pull/18990, but noticed a problems with my implementation: All repositories generated by a module extension share the same repository mapping containing all these repos. If stored naively, this results in memory usage that is quadratic in...
[]
2024-01-25T05:41:52Z
[ "type: feature request", "P1", "team-ExternalDeps" ]
Support querying repo mappings
### Description of the feature request: Add a way of querying for repo mappings, for usage in external tools (such as language servers). The repo mapping is necessary for these tools to resolve labels to files on disk, since the files live under the canonical repo name. ### Which category does this issue belong to? External Dependency ### What underlying problem are you trying to solve with this feature? Facebook have a [starlark parser & lsp](https://github.com/facebookexperimental/starlark-rust) which works pretty great with Bazel. However, it doesn't support bzlmod because it assumes the repo name of a label is the canonical name, i.e. it looks up `@foo` in `$(bazel info output_base)/external/foo`. According to @fmeum, this is needed for intellij too. ### Which operating system are you running Bazel on? _No response_ ### What is the output of `bazel info release`? _No response_ ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? Slack discussion: https://bazelbuild.slack.com/archives/C014RARENH0/p1703107424515999
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java", "src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD", "src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java", "src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java", "src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD", "src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java", "src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt" ]
[ "src/test/py/bazel/bzlmod/mod_command_test.py" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java index ab45297ae423fc..bac6b42d6b9c48 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/modcommand/ModOptions.java @@ -172,7 +172,8 @@ public enum ModSubcommand { PATH(true), EXPLAIN(true), SHOW_REPO(false), - SHOW_EXTENSION(false); + SHOW_EXTENSION(false), + DUMP_REPO_MAPPING(false); /** Whether this subcommand produces a graph output. */ private final boolean isGraph; diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD index d4bd139ed31e78..2ce21351e194f2 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/BUILD @@ -65,6 +65,7 @@ java_library( "//src/main/java/com/google/devtools/common/options", "//src/main/java/net/starlark/java/eval", "//src/main/protobuf:failure_details_java_proto", + "//third_party:gson", "//third_party:guava", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java index 77c0be124615c8..ec6d9d3caa8158 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/ModCommand.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.bazel.commands; +import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableMap.toImmutableMap; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModOptions.Charset.UTF8; @@ -44,6 +45,7 @@ import com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModOptions.ModSubcommandConverter; import com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg; import com.google.devtools.build.lib.bazel.bzlmod.modcommand.ModuleArg.ModuleArgConverter; +import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.RepositoryMapping; import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.events.Event; @@ -57,6 +59,7 @@ import com.google.devtools.build.lib.server.FailureDetails; import com.google.devtools.build.lib.server.FailureDetails.FailureDetail; import com.google.devtools.build.lib.server.FailureDetails.ModCommand.Code; +import com.google.devtools.build.lib.skyframe.RepositoryMappingValue; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; import com.google.devtools.build.lib.util.AbruptExitException; import com.google.devtools.build.lib.util.DetailedExitCode; @@ -70,11 +73,17 @@ import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.OptionsParsingResult; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import java.io.OutputStreamWriter; +import java.io.Writer; import java.util.List; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; +import java.util.stream.IntStream; /** Queries the Bzlmod external dependency graph. */ @Command( @@ -125,8 +134,51 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti } private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingResult options) { + ModOptions modOptions = options.getOptions(ModOptions.class); + Preconditions.checkArgument(modOptions != null); + + if (options.getResidue().isEmpty()) { + String errorMessage = + String.format( + "No subcommand specified, choose one of : %s.", ModSubcommand.printValues()); + return reportAndCreateFailureResult(env, errorMessage, Code.MOD_COMMAND_UNKNOWN); + } + + // The first element in the residue must be the subcommand, and then comes a list of arguments. + String subcommandStr = options.getResidue().get(0); + ModSubcommand subcommand; + try { + subcommand = new ModSubcommandConverter().convert(subcommandStr); + } catch (OptionsParsingException e) { + String errorMessage = + String.format("Invalid subcommand, choose one from : %s.", ModSubcommand.printValues()); + return reportAndCreateFailureResult(env, errorMessage, Code.MOD_COMMAND_UNKNOWN); + } + List<String> args = options.getResidue().subList(1, options.getResidue().size()); + + ImmutableList.Builder<RepositoryMappingValue.Key> repositoryMappingKeysBuilder = + ImmutableList.builder(); + if (subcommand.equals(ModSubcommand.DUMP_REPO_MAPPING)) { + if (args.isEmpty()) { + // Make this case an error so that we are free to add a mode that emits all mappings in a + // single JSON object later. + return reportAndCreateFailureResult( + env, "No repository name(s) specified", Code.INVALID_ARGUMENTS); + } + for (String arg : args) { + try { + repositoryMappingKeysBuilder.add(RepositoryMappingValue.key(RepositoryName.create(arg))); + } catch (LabelSyntaxException e) { + return reportAndCreateFailureResult(env, e.getMessage(), Code.INVALID_ARGUMENTS); + } + } + } + ImmutableList<RepositoryMappingValue.Key> repoMappingKeys = + repositoryMappingKeysBuilder.build(); + BazelDepGraphValue depGraphValue; BazelModuleInspectorValue moduleInspector; + ImmutableList<RepositoryMappingValue> repoMappingValues; SkyframeExecutor skyframeExecutor = env.getSkyframeExecutor(); LoadingPhaseThreadsOption threadsOption = options.getOptions(LoadingPhaseThreadsOption.class); @@ -140,10 +192,14 @@ private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingRe try { env.syncPackageLoading(options); + ImmutableSet.Builder<SkyKey> keys = ImmutableSet.builder(); + if (subcommand.equals(ModSubcommand.DUMP_REPO_MAPPING)) { + keys.addAll(repoMappingKeys); + } else { + keys.add(BazelDepGraphValue.KEY, BazelModuleInspectorValue.KEY); + } EvaluationResult<SkyValue> evaluationResult = - skyframeExecutor.prepareAndGet( - ImmutableSet.of(BazelDepGraphValue.KEY, BazelModuleInspectorValue.KEY), - evaluationContext); + skyframeExecutor.prepareAndGet(keys.build(), evaluationContext); if (evaluationResult.hasError()) { Exception e = evaluationResult.getError().getException(); @@ -159,6 +215,11 @@ private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingRe moduleInspector = (BazelModuleInspectorValue) evaluationResult.get(BazelModuleInspectorValue.KEY); + repoMappingValues = + repoMappingKeys.stream() + .map(evaluationResult::get) + .map(RepositoryMappingValue.class::cast) + .collect(toImmutableList()); } catch (InterruptedException e) { String errorMessage = "mod command interrupted: " + e.getMessage(); env.getReporter().handle(Event.error(errorMessage)); @@ -169,27 +230,29 @@ private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingRe return BlazeCommandResult.detailedExitCode(e.getDetailedExitCode()); } - ModOptions modOptions = options.getOptions(ModOptions.class); - Preconditions.checkArgument(modOptions != null); - - if (options.getResidue().isEmpty()) { - String errorMessage = - String.format( - "No subcommand specified, choose one of : %s.", ModSubcommand.printValues()); - return reportAndCreateFailureResult(env, errorMessage, Code.MOD_COMMAND_UNKNOWN); - } - - // The first element in the residue must be the subcommand, and then comes a list of arguments. - String subcommandStr = options.getResidue().get(0); - ModSubcommand subcommand; - try { - subcommand = new ModSubcommandConverter().convert(subcommandStr); - } catch (OptionsParsingException e) { - String errorMessage = - String.format("Invalid subcommand, choose one from : %s.", ModSubcommand.printValues()); - return reportAndCreateFailureResult(env, errorMessage, Code.MOD_COMMAND_UNKNOWN); + if (subcommand.equals(ModSubcommand.DUMP_REPO_MAPPING)) { + String missingRepos = + IntStream.range(0, repoMappingKeys.size()) + .filter(i -> repoMappingValues.get(i) == RepositoryMappingValue.NOT_FOUND_VALUE) + .mapToObj(repoMappingKeys::get) + .map(RepositoryMappingValue.Key::repoName) + .map(RepositoryName::getName) + .collect(joining(", ")); + if (!missingRepos.isEmpty()) { + return reportAndCreateFailureResult( + env, "Repositories not found: " + missingRepos, Code.INVALID_ARGUMENTS); + } + try { + dumpRepoMappings( + repoMappingValues, + new OutputStreamWriter( + env.getReporter().getOutErr().getOutputStream(), + modOptions.charset == UTF8 ? UTF_8 : US_ASCII)); + } catch (IOException e) { + throw new IllegalStateException(e); + } + return BlazeCommandResult.success(); } - List<String> args = options.getResidue().subList(1, options.getResidue().size()); // Extract and check the --base_module argument first to use it when parsing the other args. // Can only be a TargetModule or a repoName relative to the ROOT. @@ -453,6 +516,8 @@ private BlazeCommandResult execInternal(CommandEnvironment env, OptionsParsingRe case SHOW_EXTENSION: modExecutor.showExtension(argsAsExtensions, usageKeys); break; + default: + throw new IllegalStateException("Unexpected subcommand: " + subcommand); } return BlazeCommandResult.success(); @@ -510,4 +575,21 @@ private static BlazeCommandResult createFailureResult(String message, Code detai .setMessage(message) .build())); } + + public static void dumpRepoMappings(List<RepositoryMappingValue> repoMappings, Writer writer) + throws IOException { + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + for (RepositoryMappingValue repoMapping : repoMappings) { + JsonWriter jsonWriter = gson.newJsonWriter(writer); + jsonWriter.beginObject(); + for (Entry<String, RepositoryName> entry : + repoMapping.getRepositoryMapping().entries().entrySet()) { + jsonWriter.name(entry.getKey()); + jsonWriter.value(entry.getValue().getName()); + } + jsonWriter.endObject(); + writer.write('\n'); + } + writer.flush(); + } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt b/src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt index 01d576972cf61d..8cdc0fdc1aa1ab 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/mod.txt @@ -12,6 +12,7 @@ The command will display the external dependency graph or parts thereof, structu - explain <module>...: Prints all the places where the module is (or was) requested as a direct dependency, along with the reason why the respective final version was selected. It will display a pruned version of the `all_paths <module>...` command which only contains the direct deps of the root, the <module(s)> leaves, along with their dependants (can be modified with --depth). - show_repo <module>...: Prints the rule that generated the specified repos (i.e. http_archive()). The arguments may refer to extension-generated repos. - show_extension <extension>...: Prints information about the given extension(s). Usages can be filtered down to only those from modules in --extension_usage. + - dump_repo_mapping <canonical_repo_name>...: Prints the mappings from apparent repo names to canonical repo names for the given repos in NDJSON format. The order of entries within each JSON object is unspecified. This command is intended for use by tools such as IDEs and Starlark language servers. <module> arguments must be one of the following: @@ -25,4 +26,6 @@ The command will display the external dependency graph or parts thereof, structu <extension> arguments must be of the form <module><label_to_bzl_file>%<extension_name>. For example, both rules_java//java:extensions.bzl%toolchains and @rules_java//java:extensions.bzl%toolchains are valid specifications of extensions. +<canonical_repo_name> arguments are canonical repo names without any leading @ characters. The canonical repo name of the root module repository is the empty string. + %{options} \ No newline at end of file
diff --git a/src/test/py/bazel/bzlmod/mod_command_test.py b/src/test/py/bazel/bzlmod/mod_command_test.py index d17264ed2f7923..74172b0c765e7d 100644 --- a/src/test/py/bazel/bzlmod/mod_command_test.py +++ b/src/test/py/bazel/bzlmod/mod_command_test.py @@ -14,6 +14,7 @@ # limitations under the License. """Tests the mod command.""" +import json import os import tempfile from absl.testing import absltest @@ -454,6 +455,72 @@ def testShowRepoThrowsUnusedModule(self): stderr, ) + def testDumpRepoMapping(self): + _, stdout, _ = self.RunBazel( + [ + 'mod', + 'dump_repo_mapping', + '', + 'foo~2.0', + ], + ) + root_mapping, foo_mapping = [json.loads(l) for l in stdout] + + self.assertContainsSubset( + { + 'my_project': '', + 'foo1': 'foo~1.0', + 'foo2': 'foo~2.0', + 'myrepo2': 'ext2~1.0~ext~repo1', + 'bazel_tools': 'bazel_tools', + }.items(), + root_mapping.items(), + ) + + self.assertContainsSubset( + { + 'foo': 'foo~2.0', + 'ext_mod': 'ext~1.0', + 'my_repo3': 'ext~1.0~ext~repo3', + 'bazel_tools': 'bazel_tools', + }.items(), + foo_mapping.items(), + ) + + def testDumpRepoMappingThrowsNoRepos(self): + _, _, stderr = self.RunBazel( + ['mod', 'dump_repo_mapping'], + allow_failure=True, + ) + self.assertIn( + "ERROR: No repository name(s) specified. Type 'bazel help mod' for" + ' syntax and help.', + stderr, + ) + + def testDumpRepoMappingThrowsInvalidRepoName(self): + _, _, stderr = self.RunBazel( + ['mod', 'dump_repo_mapping', '{}'], + allow_failure=True, + ) + self.assertIn( + "ERROR: invalid repository name '{}': repo names may contain only A-Z," + " a-z, 0-9, '-', '_', '.' and '~' and must not start with '~'. Type" + " 'bazel help mod' for syntax and help.", + stderr, + ) + + def testDumpRepoMappingThrowsUnknownRepoName(self): + _, _, stderr = self.RunBazel( + ['mod', 'dump_repo_mapping', 'does_not_exist'], + allow_failure=True, + ) + self.assertIn( + "ERROR: Repositories not found: does_not_exist. Type 'bazel help mod'" + ' for syntax and help.', + stderr, + ) + if __name__ == '__main__': absltest.main()
train
test
2024-01-26T00:31:44
2023-12-20T23:59:38Z
cameron-martin
test
bazelbuild/bazel/17794_21224
bazelbuild/bazel
bazelbuild/bazel/17794
bazelbuild/bazel/21224
[ "keyword_pr_to_issue" ]
89f23acb86c4fa540d1d5d04f0c32305a6b75f7c
8632aaf71ac5480e66ce36658050651eb2f1450b
[ "I simply didn't consider this case when I submitted https://github.com/bazelbuild/bazel/commit/ef3f05852b3bf542903f091184da96b96354a13d. Happy to (pre-)review a PR.", "A fix for this issue has been included in [Bazel 7.1.0 RC1](https://releases.bazel.build/7.1.0/rc1/index.html). Please test out the release candi...
[ "This should not be changed." ]
2024-02-06T20:06:17Z
[ "type: bug", "P3", "team-Rules-CPP" ]
@bazel_tools//tools/cpp:compiler:gcc detection does not handle `gcc-10`
### Description of the bug: Bazel's detection of GCC only works if the compiler executable name is exactly "gcc": https://github.com/bazelbuild/bazel/blob/f06d00b8060b3b50f5dbc4a03b957c269ef62670/tools/cpp/unix_cc_configure.bzl#L273 Consequently, it fails to detect common variations like `gcc-10` as GCC. ### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. CC=gcc-10 bazel ... ### Which operating system are you running Bazel on? Linux ### What is the output of `bazel info release`? release 6.1.0 ### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel. _No response_ ### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ? _No response_ ### Have you found anything relevant by searching the web? _No response_ ### Any other information, logs, or outputs that you want to share? _No response_
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "MODULE.bazel.lock", "tools/cpp/unix_cc_configure.bzl" ]
[ "src/test/tools/bzlmod/MODULE.bazel.lock" ]
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 00927dd2728418..b290989d4724ac 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -2293,7 +2293,7 @@ "general": { "bzlTransitiveDigest": "TaEUQXsOyJBUS1hp5pqPajfzBJlceug58PemF8nCEa8=", "accumulatedFileDigests": { - "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "0398b2a48c58023e0736fcb5b0937f39a3a95b4ed34941f482deb898ca3d21e1", + "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "c61fe9fb628aaae087bfa754fc5d1f7a7d19b0d5debaf9bf84eb37fc1a365e71", "@@//:MODULE.bazel": "f0f6c040c50ad1d3555157b29dea32260bdaf5cc7205dfc346d4b1b6b008baca" }, "envVariables": {}, diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 5e7b3b79f427c9..ca8c1ba8ff7763 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -272,7 +272,8 @@ def _is_clang(repository_ctx, cc): def _is_gcc(repository_ctx, cc): # GCC's version output uses the basename of argv[0] as the program name: # https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=158461167951c1b9540322fb19be6a89d6da07fc;hb=HEAD#l8728 - return repository_ctx.execute([cc, "--version"]).stdout.startswith("gcc ") + cc_stdout = repository_ctx.execute([cc, "--version"]).stdout + return cc_stdout.startswith("gcc ") or cc_stdout.startswith("gcc-") def _get_compiler_name(repository_ctx, cc): if _is_clang(repository_ctx, cc):
diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock index 7b3d08135fdfed..58783496a694af 100644 --- a/src/test/tools/bzlmod/MODULE.bazel.lock +++ b/src/test/tools/bzlmod/MODULE.bazel.lock @@ -1002,7 +1002,7 @@ }, "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { "general": { - "bzlTransitiveDigest": "mcsWHq3xORJexV5/4eCvNOLxFOQKV6eli3fkr+tEaqE=", + "bzlTransitiveDigest": "PHpT2yqMGms2U4L3E/aZ+WcQalmZWm+ILdP3yiLsDhA=", "accumulatedFileDigests": {}, "envVariables": {}, "generatedRepoSpecs": {
train
test
2024-02-06T17:35:39
2023-03-15T21:44:13Z
jbms
test
bazelbuild/bazel/14_48
bazelbuild/bazel
bazelbuild/bazel/14
bazelbuild/bazel/48
[ "timestamp(timedelta=66336.0, similarity=0.8547909199217864)" ]
03bad4619075aa77876698c55827aa54e7426ea9
5e28c4e2882a98e5afb0b7b3c1c33c1001699909
[ "Thanks, should all be fixed.\n" ]
[]
2015-03-25T05:57:33Z
[]
typos in readme
A emphasis on automated testing -> An emphasis on automated testing "Find more background about Bazel in our FAQ" -- needs a period after FAQ. "The test environment is described the test encyclopedia." -- described _in_ the test encyclopedia?
[ "README.md" ]
[ "README.md" ]
[]
diff --git a/README.md b/README.md index a84d7b1b67a686..4bec7211edf027 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,17 @@ Find more background about Bazel in our [FAQ](docs/FAQ.md) ## Getting Started - * How to [install Bazel](//bazel.io/docs/install.html) - * How to [get started using Bazel](//bazel.io/docs/getting-started.html) - * The Bazel command line is documented in the [user manual](//bazel.io/docs/bazel-user-manual.html) - * The rule reference documentation is in the [build encyclopedia](//bazel.io/docs/build-encyclopedia.html) - * How to [use the query command](//bazel.io/docs/query.html) - * How to [extend Bazel](//bazel.io/docs/skylark/index.html) - * The test environment is described in the [test encyclopedia](//bazel.io/docs/test-encyclopedia.html) + * How to [install Bazel](http://bazel.io/docs/install.html) + * How to [get started using Bazel](http://bazel.io/docs/getting-started.html) + * The Bazel command line is documented in the [user manual](http://bazel.io/docs/bazel-user-manual.html) + * The rule reference documentation is in the [build encyclopedia](http://bazel.io/docs/build-encyclopedia.html) + * How to [use the query command](http://bazel.io/docs/query.html) + * How to [extend Bazel](http://bazel.io/docs/skylark/index.html) + * The test environment is described in the [test encyclopedia](http://bazel.io/docs/test-encyclopedia.html) * About the Bazel project: - * How to [contribute to Bazel](//bazel.io/docs/contributing.html) - * Our [governance plan](//bazel.io/docs/governance.html) - * Future plans are in the [roadmap](//bazel.io/docs/roadmap.html) - * For each feature, which level of [support](//bazel.io/docs/support.html) to expect. + * How to [contribute to Bazel](http://bazel.io/docs/contributing.html) + * Our [governance plan](http://bazel.io/docs/governance.html) + * Future plans are in the [roadmap](http://bazel.io/docs/roadmap.html) + * For each feature, which level of [support](http://bazel.io/docs/support.html) to expect.
null
train
train
2015-03-24T18:17:20
2015-03-24T15:53:43Z
jason-sachs
test
bazelbuild/bazel/142_143
bazelbuild/bazel
bazelbuild/bazel/142
bazelbuild/bazel/143
[ "timestamp(timedelta=407.0, similarity=0.9395480498605061)" ]
ee85e55ca03e945f7babb9a1c619a6a7bbfc1d51
39f5fa31ea918628dc315c6a1bfa51d8c60d1018
[ "Nice catch. Can you submit your patch with a github pull request?\n", "OK, I sent a pull request. I haven't done that before, so let me know if anything is fishy.\n", "https://github.com/google/bazel/commit/e93638335955ff8d7e948f2d385319e458ee0ca4\n" ]
[]
2015-04-19T18:29:45Z
[]
./compile.sh fails with macports
Following the instructions at http://bazel.io/docs/install.html for a Mac using macports, I get: <pre> $ ./compile.sh cp: /include/archive.h: No such file or directory cp: /include/archive_entry.h: No such file or directory </pre> This seems to fix the problem: <pre> $ git diff ./compile.sh diff --git a/compile.sh b/compile.sh index c4ff9bf..3a9231a 100755 --- a/compile.sh +++ b/compile.sh @@ -99,7 +99,8 @@ EOF elif [[ -e $macports_header ]]; then # For use with Macports. - archive_dir=$(dirname $(dirname $macports_header)) rm -f fromhost/*.[ah] + archive_dir=$(dirname $(dirname $macports_header)) + rm -f fromhost/*.[ah] touch fromhost/empty.c cp "${archive_dir}"/include/{archive.h,archive_entry.h} fromhost/ cp "${archive_dir}"/lib/{libarchive,liblzo2,liblzma,libcharset,libbz2,libxml2,libz,libiconv}.a \ </pre>
[ "compile.sh" ]
[ "compile.sh" ]
[]
diff --git a/compile.sh b/compile.sh index c4ff9bf3944aa0..3a9231ac06b55e 100755 --- a/compile.sh +++ b/compile.sh @@ -99,7 +99,8 @@ EOF elif [[ -e $macports_header ]]; then # For use with Macports. - archive_dir=$(dirname $(dirname $macports_header)) rm -f fromhost/*.[ah] + archive_dir=$(dirname $(dirname $macports_header)) + rm -f fromhost/*.[ah] touch fromhost/empty.c cp "${archive_dir}"/include/{archive.h,archive_entry.h} fromhost/ cp "${archive_dir}"/lib/{libarchive,liblzo2,liblzma,libcharset,libbz2,libxml2,libz,libiconv}.a \
null
train
train
2015-04-19T11:29:46
2015-04-19T02:23:12Z
allenporter
test
bazelbuild/bazel/308_3571
bazelbuild/bazel
bazelbuild/bazel/308
bazelbuild/bazel/3571
[ "timestamp(timedelta=87.0, similarity=0.8616929189821002)" ]
c69dbf8ed4893066d0474f87c0a8ddae00e4ee58
15821573093277590de0debda4f2aa2363c33866
[ "As mentioned on https://groups.google.com/d/msg/bazel-discuss/25X8NKHv4H8/pS2so6AjJAAJ, downloading the javadoc jar would also be nice.\n", "+1\n", "+1\n", "+1\n", "+1\n", "+1\n", "Why is this P4 priority issue? Quoting Gerrit Code Review priority descriptions: [1], that apparently common for all Googl...
[]
2017-08-16T14:07:04Z
[ "type: feature request" ]
maven_jar should also pull source jars
most maven jars have a parallel -src.jar available. This is very useful in an IDE as eclipse lets you tie a src-jar to a precompiled-jar. In mvn that is usually: mvn eclipse:eclipse -DdownloadSources=true I would suggest that this should be the default option in bazel, or at least configurable in the maven_jar(..., downloadSrcs = 1)
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java", "src/main/java/com/google/devtools/build/lib/ba...
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java", "src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java", "src/main/java/com/google/devtools/build/lib/ba...
[ "src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java index 40c7b7c297c506..b1d02132cd8f1c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java @@ -31,17 +31,21 @@ public class DecompressorDescriptor { private final String targetKind; private final String targetName; private final Path archivePath; + private final Optional<Path> archiveSourcesPath; private final Path repositoryPath; private final Optional<String> prefix; private final boolean executable; private final Decompressor decompressor; private DecompressorDescriptor( - String targetKind, String targetName, Path archivePath, Path repositoryPath, + String targetKind, String targetName, Path archivePath, + @Nullable Path archiveSourcesPath, + Path repositoryPath, @Nullable String prefix, boolean executable, Decompressor decompressor) { this.targetKind = targetKind; this.targetName = targetName; this.archivePath = archivePath; + this.archiveSourcesPath = Optional.fromNullable(archiveSourcesPath); this.repositoryPath = repositoryPath; this.prefix = Optional.fromNullable(prefix); this.executable = executable; @@ -60,6 +64,10 @@ public Path archivePath() { return archivePath; } + public Optional<Path> archiveSourcesPath() { + return archiveSourcesPath; + } + public Path repositoryPath() { return repositoryPath; } @@ -113,6 +121,7 @@ public static class Builder { private String targetKind; private String targetName; private Path archivePath; + private Path archiveSourcesPath; private Path repositoryPath; private String prefix; private boolean executable; @@ -126,7 +135,7 @@ public DecompressorDescriptor build() throws RepositoryFunctionException { decompressor = DecompressorValue.getDecompressor(archivePath); } return new DecompressorDescriptor( - targetKind, targetName, archivePath, repositoryPath, prefix, executable, decompressor); + targetKind, targetName, archivePath, archiveSourcesPath, repositoryPath, prefix, executable, decompressor); } public Builder setTargetKind(String targetKind) { @@ -144,6 +153,11 @@ public Builder setArchivePath(Path archivePath) { return this; } + public Builder setArchiveSourcesPath(Path archiveSourcesPath) { + this.archiveSourcesPath = archiveSourcesPath; + return this; + } + public Builder setRepositoryPath(Path repositoryPath) { this.repositoryPath = repositoryPath; return this; diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java index 9031d4ba54b30c..c2cb2355cd9f4b 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/FileDecompressor.java @@ -15,7 +15,9 @@ package com.google.devtools.build.lib.bazel.repository; import com.google.common.base.Joiner; +import com.google.common.base.Optional; import com.google.devtools.build.lib.bazel.repository.DecompressorValue.Decompressor; +import com.google.devtools.build.lib.vfs.Path; /** * Creates a repository for a random file. @@ -32,7 +34,7 @@ protected String getPackageName() { } @Override - protected String createBuildFile(String baseName) { + protected String createBuildFile(String baseName, Optional<Path> sourcesJar) { return Joiner.on("\n") .join( "filegroup(", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java index 703c4a32dd72ae..6825d8083d6aa3 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/JarDecompressor.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.bazel.repository; import com.google.common.base.Joiner; +import com.google.common.base.Optional; import com.google.devtools.build.lib.bazel.repository.DecompressorValue.Decompressor; import com.google.devtools.build.lib.rules.repository.RepositoryFunction; import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException; @@ -60,6 +61,12 @@ public Path decompress(DecompressorDescriptor descriptor) throws RepositoryFunct if (!jarSymlink.exists()) { jarSymlink.createSymbolicLink(descriptor.archivePath()); } + if (descriptor.archiveSourcesPath().isPresent()) { + Path sourcesSymlink = jarDirectory.getRelative(descriptor.archiveSourcesPath().get().getBaseName()); + if (!sourcesSymlink.exists()) { + sourcesSymlink.createSymbolicLink(descriptor.archiveSourcesPath().get()); + } + } // external/some-name/repository/jar/BUILD.bazel defines the //jar target. Path buildFile = jarDirectory.getRelative("BUILD.bazel"); FileSystemUtils.writeLinesAs( @@ -69,7 +76,7 @@ public Path decompress(DecompressorDescriptor descriptor) throws RepositoryFunct + descriptor.targetKind() + " rule " + descriptor.targetName(), - createBuildFile(baseName)); + createBuildFile(baseName, descriptor.archiveSourcesPath())); if (descriptor.executable()) { descriptor.archivePath().chmod(0755); } @@ -84,13 +91,21 @@ protected String getPackageName() { return "jar"; } - protected String createBuildFile(String baseName) { - return Joiner.on("\n") + protected String createBuildFile(String baseName, Optional<Path> srcJar) { + String buildFileText = Joiner.on("\n") .join( "java_import(", " name = 'jar',", - " jars = ['" + baseName + "'],", - " visibility = ['//visibility:public']", + " jars = ['" + baseName + "'],"); + + if (srcJar.isPresent()) { + buildFileText += "\n srcjar = ':sources',"; + } + + buildFileText += Joiner.on("\n") + .join( + "", + " visibility = ['//visibility:public'],", ")", "", "filegroup(", @@ -98,5 +113,17 @@ protected String createBuildFile(String baseName) { " srcs = ['" + baseName + "'],", " visibility = ['//visibility:public']", ")"); + + if (srcJar.isPresent()) { + return buildFileText + Joiner.on("\n").join("", + "", + "filegroup(", + " name = 'sources',", + " srcs = ['" + srcJar.get().getBaseName() + "'],", + " visibility = ['//visibility:public']", + ")"); + } else { + return buildFileText; + } } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenDownloader.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenDownloader.java index 264173ef8f59a4..855b328bc5d6c4 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenDownloader.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenDownloader.java @@ -43,8 +43,8 @@ import org.eclipse.aether.resolution.ArtifactResult; /** - * Downloader for JAR files from Maven repositories. - * TODO(jingwen): standardize interface between this and HttpDownloader + * Downloader for JAR files from Maven repositories. TODO(jingwen): standardize interface between + * this and HttpDownloader */ public class MavenDownloader extends HttpDownloader { @@ -79,22 +79,36 @@ public Path download(String name, WorkspaceAttributeMapper mapper, Path outputDi this.name = name; this.outputDirectory = outputDirectory; + Artifact artifact = createArtifact(mapper); + String sha1 = getSha1(mapper, "sha1"); + return downloadArtifact(sha1, outputDirectory, artifact, serverValue); + } + + /** + * Download the sources for the Maven artifact to the output directory. Returns the path to the + * jar. + */ + public Path downloadSources(String name, WorkspaceAttributeMapper mapper, Path outputDirectory, + MavenServerValue serverValue) + throws IOException, EvalException { + this.name = name; + this.outputDirectory = outputDirectory; + + Artifact artifact = createArtifact(mapper); + Artifact sourcesArtifact = + new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), "sources", + artifact.getExtension(), artifact.getVersion()); + String sha1 = getSha1(mapper, "sources_sha1"); + + return downloadArtifact(sha1, outputDirectory, sourcesArtifact, serverValue); + } + + private Path downloadArtifact(String sha1, Path outputDirectory, Artifact artifact, + MavenServerValue serverValue) throws EvalException, IOException { + String url = serverValue.getUrl(); Server server = serverValue.getServer(); - Artifact artifact; - String artifactId = mapper.get("artifact", Type.STRING); - String sha1 = mapper.isAttributeValueExplicitlySpecified("sha1") - ? mapper.get("sha1", Type.STRING) : null; - if (sha1 != null && !KeyType.SHA1.isValid(sha1)) { - throw new IOException("Invalid SHA-1 for maven_jar " + name + ": '" + sha1 + "'"); - } - try { - artifact = new DefaultArtifact(artifactId); - } catch (IllegalArgumentException e) { - throw new IOException(e.getMessage()); - } - boolean isCaching = repositoryCache.isEnabled() && KeyType.SHA1.isValid(sha1); if (isCaching) { @@ -137,6 +151,29 @@ public Path download(String name, WorkspaceAttributeMapper mapper, Path outputDi return downloadPath; } + private String getSha1(WorkspaceAttributeMapper mapper, String attrName) + throws EvalException, IOException { + String sha1 = mapper.isAttributeValueExplicitlySpecified(attrName) + ? mapper.get(attrName, Type.STRING) : null; + if (sha1 != null && !KeyType.SHA1.isValid(sha1)) { + throw new IOException( + "Invalid SHA-1 attr " + attrName + " for maven_jar " + name + ": '" + sha1 + "'"); + } + return sha1; + } + + private Artifact createArtifact(WorkspaceAttributeMapper mapper) + throws EvalException, IOException { + Artifact artifact; + String artifactId = mapper.get("artifact", Type.STRING); + try { + artifact = new DefaultArtifact(artifactId); + } catch (IllegalArgumentException e) { + throw new IOException(e.getMessage()); + } + return artifact; + } + private Path getDownloadDestination(Artifact artifact) { String groupIdPath = artifact.getGroupId().replace('.', '/'); String artifactId = artifact.getArtifactId(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java index 907227e959aa4a..87cdbf7069e5e1 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/MavenJarFunction.java @@ -120,16 +120,40 @@ private RepositoryDirectoryValue.Builder createOutputTree(Rule rule, Path output throw new RepositoryFunctionException(e, Transience.TRANSIENT); } + Path repositorySourcesJar = null; + if (shouldAttachSources(rule)) { + try { + repositorySourcesJar = + mavenDownloader.downloadSources(name, WorkspaceAttributeMapper.of(rule), + outputDirectory, serverValue); + } catch (IOException e) { + throw new RepositoryFunctionException(e, Transience.TRANSIENT); + } catch (EvalException e) { + throw new RepositoryFunctionException(e, Transience.TRANSIENT); + } + } + // Add a WORKSPACE file & BUILD file to the Maven jar. Path result = DecompressorValue.decompress(DecompressorDescriptor.builder() .setDecompressor(JarDecompressor.INSTANCE) .setTargetKind(MavenJarRule.NAME) .setTargetName(name) .setArchivePath(repositoryJar) + .setArchiveSourcesPath(repositorySourcesJar) .setRepositoryPath(outputDirectory).build()); return RepositoryDirectoryValue.builder().setPath(result); } + private boolean shouldAttachSources(Rule rule) throws RepositoryFunctionException { + WorkspaceAttributeMapper mapper = WorkspaceAttributeMapper.of(rule); + try { + return mapper.isAttributeValueExplicitlySpecified("attach_sources") + && mapper.get("attach_sources", Type.BOOLEAN) == Boolean.TRUE; + } catch (EvalException e) { + throw new RepositoryFunctionException(e, Transience.PERSISTENT); + } + } + /** * @see RepositoryFunction#getRule(RepositoryName, String, Environment) */ diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/MavenJarRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/MavenJarRule.java index 63c0e95b0d91a8..2880982b9d2a38 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/MavenJarRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/MavenJarRule.java @@ -65,6 +65,22 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) { should be set before shipping.</p> <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("sha1", Type.STRING)) + /* <!-- #BLAZE_RULE(maven_jar).ATTRIBUTE(attach_sources) --> + Set this to make Bazel also pull down the sources jar from the Maven repository. + + <p>The sources jar will be located in the same package as the main jar with the label + :sources</p> + <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ + .add(attr("attach_sources", Type.BOOLEAN)) + /* <!-- #BLAZE_RULE(maven_jar).ATTRIBUTE(sources_sha1) --> + A SHA-1 hash of the desired sources jar. + + <p>If the downloaded jar does not match this hash, Bazel will error out. <em>It is a + security risk to omit the SHA-1 as remote files can change.</em> At best omitting this + field will make your build non-hermetic. It is optional to make development easier but + should be set before shipping.</p> + <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ + .add(attr("sources_sha1", Type.STRING)) .setWorkspaceOnly() .build(); }
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java index 37cfa8daa33f41..f3bafaeb8e79ef 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/repository/JarDecompressorTest.java @@ -32,13 +32,17 @@ */ @RunWith(JUnit4.class) public class JarDecompressorTest { + private static final String FOO_JAR = "/foo.jar"; + private static final String BUILD_FILE = "BUILD.bazel"; + private static final String FOO_SOURCES_JAR = "/foo-sources.jar"; private DecompressorDescriptor.Builder descriptorBuilder; + private Scratch fs; @Before public void setUpFs() throws Exception { - Scratch fs = new Scratch(); + fs = new Scratch(); Path dir = fs.dir("/whatever/external/tester"); - Path jar = fs.file("/foo.jar", "I'm a jar"); + Path jar = fs.file(FOO_JAR, "I'm a jar"); FileSystemUtils.createDirectoryAndParents(dir); descriptorBuilder = DecompressorDescriptor.builder() .setDecompressor(JarDecompressor.INSTANCE) @@ -53,7 +57,9 @@ public void testTargets() throws Exception { Path outputDir = DecompressorValue.decompress(descriptorBuilder.build()); assertThat(outputDir.exists()).isTrue(); String buildContent = - new String(FileSystemUtils.readContentAsLatin1(outputDir.getRelative("jar/BUILD.bazel"))); + new String(FileSystemUtils.readContentAsLatin1(jarDirectoryFile(BUILD_FILE, outputDir))); + assertThat(jarDirectoryFile(FOO_JAR, outputDir).exists()).isTrue(); + assertThat(jarDirectoryFile(FOO_SOURCES_JAR, outputDir).exists()).isFalse(); assertThat(buildContent).contains("java_import"); assertThat(buildContent).contains("filegroup"); } @@ -66,4 +72,25 @@ public void testWorkspaceGen() throws Exception { FileSystemUtils.readContentAsLatin1(outputDir.getRelative("WORKSPACE"))); assertThat(workspaceContent).contains("workspace(name = \"tester\")"); } + + @Test + public void testTargetsWithSources() throws Exception { + Path sourceJar = fs.file(FOO_SOURCES_JAR, "I'm a sources jar"); + descriptorBuilder.setArchiveSourcesPath(sourceJar); + + Path outputDir = DecompressorValue.decompress(descriptorBuilder.build()); + assertThat(outputDir.exists()).isTrue(); + assertThat(jarDirectoryFile(sourceJar.getBaseName(), outputDir).exists()).isTrue(); + assertThat(jarDirectoryFile(FOO_JAR, outputDir).exists()).isTrue(); + + String buildContent = + new String(FileSystemUtils.readContentAsLatin1(jarDirectoryFile(BUILD_FILE, outputDir))); + assertThat(buildContent).contains("java_import"); + assertThat(buildContent).contains("srcjar"); + assertThat(buildContent).contains("filegroup"); + } + + private Path jarDirectoryFile(String baseName, Path outputPath) { + return outputPath.getRelative("jar/" + baseName); + } }
train
train
2017-08-16T11:06:42
2015-07-15T11:41:27Z
pmbethe09
test
bazelbuild/bazel/457_459
bazelbuild/bazel
bazelbuild/bazel/457
bazelbuild/bazel/459
[ "timestamp(timedelta=158.0, similarity=0.918334548218563)" ]
71973e629ef11bdc619a3c9b10809fa1482995e8
a79cd42972b46d0d70a0fe3ab6bd57ad728b90e6
[ "I'm sorry to dig up this issue from the history but I'm trying to introduce [jvm_flags](https://bazel.build/versions/master/docs/be/java.html#java_binary.jvm_flags) to rules_scala and I could use a bit of understanding about the motivation of this issue.\r\nThis change added the ability to configure the `scalac` o...
[]
2015-09-16T15:39:35Z
[]
Add support for scalac and jvm_flags in scala.bzl
It would be nice to be able to pass these through, as one can for `java_library` and `java_binary`.
[ "tools/build_defs/scala/scala.bzl" ]
[ "tools/build_defs/scala/scala.bzl" ]
[]
diff --git a/tools/build_defs/scala/scala.bzl b/tools/build_defs/scala/scala.bzl index 222573db8f68da..9618592f688ee2 100644 --- a/tools/build_defs/scala/scala.bzl +++ b/tools/build_defs/scala/scala.bzl @@ -25,13 +25,15 @@ def _compile(ctx, jars): cmd = """ set -e mkdir -p {out}_tmp -{scalac} -classpath "{jars}" $@ -d {out}_tmp +{scalac} {scala_opts} {jvm_flags} -classpath "{jars}" $@ -d {out}_tmp # Make jar file deterministic by setting the timestamp of files touch -t 198001010000 $(find .) jar cmf {manifest} {out} -C {out}_tmp . """ cmd = cmd.format( scalac=_scalac_path, + scala_opts = " ".join(ctx.attr.scalacopts), + jvm_flags = " ".join(["-J" + flag for flag in ctx.attr.jvm_flags]), out=ctx.outputs.jar.path, manifest=ctx.outputs.manifest.path, jars=":".join([j.path for j in jars])) @@ -119,6 +121,8 @@ scala_library = rule( non_empty=True), "deps": attr.label_list(), "data": attr.label_list(allow_files=True, cfg=DATA_CFG), + "scalacopts": attr.string_list(), + "jvm_flags": attr.string_list(), }, outputs={ "jar": "%{name}_deploy.jar", @@ -135,6 +139,8 @@ scala_binary = rule( non_empty=True), "deps": attr.label_list(), "data": attr.label_list(allow_files=True, cfg=DATA_CFG), + "scalacopts":attr.string_list(), + "jvm_flags": attr.string_list(), }, outputs={ "jar": "%{name}_deploy.jar",
null
val
train
2015-09-16T17:16:40
2015-09-16T03:47:26Z
JackSullivan
test
bazelbuild/bazel/503_657
bazelbuild/bazel
bazelbuild/bazel/503
bazelbuild/bazel/657
[ "timestamp(timedelta=2377.0, similarity=0.8508197549457626)" ]
fbd8333bbe73c03242d69815d6dceee333662f90
58839864110aafe363028f0ebdad458e0672e148
[ "you could create a scala_test that expands into java_test that imports the jar generated by scala_binary?\n", "Added this issue as b/25141720.\n" ]
[ "are these needed? It would be nice to default to discovering all the suites in the jar and running them. That seems like the preferred way to go. If you don't want to run a suite, it should be in its own target, and just not test that target.\n\nOr at least, that's my view.\n", "I think it is better to download ...
2015-11-29T15:15:41Z
[ "type: feature request", "P3" ]
Executing scala tests
Any existing workaround to use `java_test` for executing scala tests (similar to https://github.com/bazelbuild/bazel/issues/443), or is there a different approach to substitute the lack of `scala_test` for now? Scala test classes usually use `org.junit.runner.RunWith` and a custom `JUnitRunner` to execute (like this one for [specs2](https://github.com/etorreborre/specs2/blob/master/junit/src/main/scala/org/specs2/runner/JUnitRunner.scala)). Simple example: ``` scala package com.example import org.junit.runner.RunWith import org.specs2.mutable.Specification import org.specs2.runner.JUnitRunner @RunWith(classOf[JUnitRunner]) class HelloWorldTest extends Specification { "HelloWorld" should { "have the correct message" in { HelloWorld.message must_== "Hello world!" } } } ```
[ "WORKSPACE", "tools/build_defs/scala/README.md", "tools/build_defs/scala/scala.bzl" ]
[ "WORKSPACE", "tools/build_defs/scala/README.md", "tools/build_defs/scala/scala.bzl" ]
[ "tools/build_defs/scala/test/BUILD", "tools/build_defs/scala/test/HelloLib.scala", "tools/build_defs/scala/test/HelloLibTest.scala" ]
diff --git a/WORKSPACE b/WORKSPACE index ebe5700f2f086a..1cb41a8e00ac6c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -52,3 +52,11 @@ new_http_archive( url = "http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz", build_file = "tools/build_defs/scala/scala.BUILD", ) + +# only used for the scala test rule +http_file( + name = "scalatest", + url = "https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.11/2.2.6/scalatest_2.11-2.2.6.jar", + sha256 = "f198967436a5e7a69cfd182902adcfbcb9f2e41b349e1a5c8881a2407f615962", +) + diff --git a/tools/build_defs/scala/README.md b/tools/build_defs/scala/README.md index c2db3040358563..06d96a7db8cd41 100644 --- a/tools/build_defs/scala/README.md +++ b/tools/build_defs/scala/README.md @@ -5,17 +5,16 @@ <ul> <li><a href="#scala_library">scala_library/scala_macro_library</a></li> <li><a href="#scala_binary">scala_binary</a></li> + <li><a href="#scala_test">scala_test</a></li> </ul> </div> ## Overview This rule is used for building [Scala][scala] projects with Bazel. There are -currently three rules, `scala_library`, `scala_macro_library` and -`scala_binary`. More features will be added in the future, e.g. `scala_test`. +currently four rules, `scala_library`, `scala_macro_library`, `scala_binary` and `scala_test`. -In order to use this build rule, you must add the following to your WORKSPACE -file: +In order to use `scala_library`, `scala_macro_library`, and `scala_binary`, you must add the following to your WORKSPACE file: ```python new_http_archive( name = "scala", @@ -26,6 +25,15 @@ new_http_archive( ) ``` +In addition, in order to use `scala_test`, you must add the following to your WORKSPACE file: +```python +http_file( + name = "scalatest", + url = "https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.11/2.2.6/scalatest_2.11-2.2.6.jar", + sha256 = "f198967436a5e7a69cfd182902adcfbcb9f2e41b349e1a5c8881a2407f615962", +) +``` + [scala]: http://www.scala-lang.org/ <a name="scala_library"></a> @@ -234,3 +242,15 @@ A `scala_binary` requires a `main_class` attribute. </tr> </tbody> </table> + +<a name="scala_test"></a> +## scala_test + +```python +scala_test(name, srcs, suites, deps, data, main_class, resources, scalacopts, jvm_flags) +``` + +`scala_test` generates a Scala executable which runs unit test suites written using the `scalatest` library. It may depend on `scala_library`, `scala_macro_library` and `java_library` rules. + +A `scala_test` requires a `suites` attribute, specifying the fully qualified (canonical) names of the test suites to run. In a future version, we might investigate lifting this requirement. + diff --git a/tools/build_defs/scala/scala.bzl b/tools/build_defs/scala/scala.bzl index 488d526cbddf64..10ac1aec2257ea 100644 --- a/tools/build_defs/scala/scala.bzl +++ b/tools/build_defs/scala/scala.bzl @@ -85,9 +85,10 @@ def _write_manifest(ctx): def _write_launcher(ctx, jars): content = """#!/bin/bash cd $0.runfiles -java -cp {cp} {name} "$@" +{java} -cp {cp} {name} "$@" """ content = content.format( + java=ctx.file._java.path, name=ctx.attr.main_class, deploy_jar=ctx.outputs.jar.path, cp=":".join([j.short_path for j in jars])) @@ -95,6 +96,27 @@ java -cp {cp} {name} "$@" output=ctx.outputs.executable, content=content) +def _args_for_suites(suites): + args = ["-o"] + for suite in suites: + args.extend(["-s", suite]) + return args + +def _write_test_launcher(ctx, jars): + content = """#!/bin/bash +cd $0.runfiles +{java} -cp {cp} {name} {args} "$@" +""" + content = content.format( + java=ctx.file._java.path, + name=ctx.attr.main_class, + args=' '.join(_args_for_suites(ctx.attr.suites)), + deploy_jar=ctx.outputs.jar.path, + cp=":".join([j.short_path for j in jars])) + ctx.file_action( + output=ctx.outputs.executable, + content=content) + def _collect_comp_run_jars(ctx): compile_jars = set() runtime_jars = set() @@ -140,43 +162,60 @@ def _scala_macro_library_impl(ctx): interface_jar_files=cjars, runfiles=runfiles) -def _scala_binary_impl(ctx): - (cjars, rjars) = _collect_comp_run_jars(ctx) +# Common code shared by all scala binary implementations. +def _scala_binary_common(ctx, cjars, rjars): _write_manifest(ctx) _compile(ctx, cjars, False) - rjars += [ctx.outputs.jar, ctx.file._scalalib] - _write_launcher(ctx, rjars) - runfiles = ctx.runfiles( - files = list(rjars) + [ctx.outputs.executable], + files = list(rjars) + [ctx.outputs.executable] + [ctx.file._java] + ctx.files._jdk, collect_data = True) return struct( files=set([ctx.outputs.executable]), runfiles=runfiles) +def _scala_binary_impl(ctx): + (cjars, rjars) = _collect_comp_run_jars(ctx) + cjars += [ctx.file._scalareflect] + rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect] + _write_launcher(ctx, rjars) + return _scala_binary_common(ctx, cjars, rjars) + +def _scala_test_impl(ctx): + (cjars, rjars) = _collect_comp_run_jars(ctx) + cjars += [ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml] + rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml] + _write_test_launcher(ctx, rjars) + return _scala_binary_common(ctx, cjars, rjars) + _implicit_deps = { "_ijar": attr.label(executable=True, default=Label("//tools/defaults:ijar"), single_file=True, allow_files=True), "_scalac": attr.label(executable=True, default=Label("@scala//:bin/scalac"), single_file=True, allow_files=True), "_scalalib": attr.label(default=Label("@scala//:lib/scala-library.jar"), single_file=True, allow_files=True), + "_scalaxml": attr.label(default=Label("@scala//:lib/scala-xml_2.11-1.0.4.jar"), single_file=True, allow_files=True), "_scalasdk": attr.label(default=Label("@scala//:sdk"), allow_files=True), + "_scalareflect": attr.label(default=Label("@scala//:lib/scala-reflect.jar"), single_file=True, allow_files=True), "_jar": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:jar"), single_file=True, allow_files=True), "_jdk": attr.label(default=Label("//tools/defaults:jdk"), allow_files=True), } +# Common attributes reused across multiple rules. +_common_attrs = { + "srcs": attr.label_list( + allow_files=_scala_filetype, + non_empty=True), + "deps": attr.label_list(), + "data": attr.label_list(allow_files=True, cfg=DATA_CFG), + "resources": attr.label_list(allow_files=True), + "scalacopts":attr.string_list(), + "jvm_flags": attr.string_list(), +} + scala_library = rule( implementation=_scala_library_impl, attrs={ "main_class": attr.string(), - "srcs": attr.label_list( - allow_files=_scala_filetype, - non_empty=True), - "deps": attr.label_list(), - "data": attr.label_list(allow_files=True, cfg=DATA_CFG), - "resources": attr.label_list(allow_files=True), - "scalacopts": attr.string_list(), - "jvm_flags": attr.string_list(), - } + _implicit_deps, + } + _implicit_deps + _common_attrs, outputs={ "jar": "%{name}_deploy.jar", "ijar": "%{name}_ijar.jar", @@ -188,16 +227,8 @@ scala_macro_library = rule( implementation=_scala_macro_library_impl, attrs={ "main_class": attr.string(), - "srcs": attr.label_list( - allow_files=_scala_filetype, - non_empty=True), - "deps": attr.label_list(), - "data": attr.label_list(allow_files=True, cfg=DATA_CFG), - "resources": attr.label_list(allow_files=True), - "scalacopts": attr.string_list(), - "jvm_flags": attr.string_list(), "_scala-reflect": attr.label(default=Label("@scala//:lib/scala-reflect.jar"), single_file=True, allow_files=True), - } + _implicit_deps, + } + _implicit_deps + _common_attrs, outputs={ "jar": "%{name}_deploy.jar", "manifest": "%{name}_MANIFEST.MF", @@ -208,18 +239,27 @@ scala_binary = rule( implementation=_scala_binary_impl, attrs={ "main_class": attr.string(mandatory=True), - "srcs": attr.label_list( - allow_files=_scala_filetype, - non_empty=True), - "deps": attr.label_list(), - "data": attr.label_list(allow_files=True, cfg=DATA_CFG), - "resources": attr.label_list(allow_files=True), - "scalacopts":attr.string_list(), - "jvm_flags": attr.string_list(), - } + _implicit_deps, + "_java": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:java"), single_file=True, allow_files=True), + } + _implicit_deps + _common_attrs, + outputs={ + "jar": "%{name}_deploy.jar", + "manifest": "%{name}_MANIFEST.MF", + }, + executable=True, +) + +scala_test = rule( + implementation=_scala_test_impl, + attrs={ + "main_class": attr.string(default="org.scalatest.tools.Runner"), + "suites": attr.string_list(), + "_scalatest": attr.label(executable=True, default=Label("@scalatest//file"), single_file=True, allow_files=True), + "_java": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:java"), single_file=True, allow_files=True), + } + _implicit_deps + _common_attrs, outputs={ "jar": "%{name}_deploy.jar", "manifest": "%{name}_MANIFEST.MF", }, executable=True, + test=True, )
diff --git a/tools/build_defs/scala/test/BUILD b/tools/build_defs/scala/test/BUILD index 9c2e71db8637dc..f516a10c21ea11 100644 --- a/tools/build_defs/scala/test/BUILD +++ b/tools/build_defs/scala/test/BUILD @@ -1,4 +1,4 @@ -load("/tools/build_defs/scala/scala", "scala_binary", "scala_library") +load("/tools/build_defs/scala/scala", "scala_binary", "scala_library", "scala_test") # The examples below show how to combine Scala and Java rules. # ScalaBinary is the Scala equivalent of JavaBinary. @@ -33,6 +33,16 @@ scala_library( ], ) +scala_test( + name = "HelloLibTest", + srcs = ["HelloLibTest.scala"], + suites = ["scala.test.ScalaSuite", "scala.test.JavaSuite"], + size = "medium", # Not a macro, can pass test-specific attributes. + deps = [ + ":HelloLib", + ], +) + scala_library( name = "OtherLib", srcs = ["OtherLib.scala"], diff --git a/tools/build_defs/scala/test/HelloLib.scala b/tools/build_defs/scala/test/HelloLib.scala index 88db4546acc66a..a1fef111da6b4b 100644 --- a/tools/build_defs/scala/test/HelloLib.scala +++ b/tools/build_defs/scala/test/HelloLib.scala @@ -2,7 +2,15 @@ package scala.test object HelloLib { def printMessage(arg: String) { - println(arg + " " + OtherLib.getMessage()) - println(arg + " " + OtherJavaLib.getMessage()) + println(getOtherLibMessage(arg)) + println(getOtherJavaLibMessage(arg)) + } + + def getOtherLibMessage(arg: String) : String = { + arg + " " + OtherLib.getMessage() + } + + def getOtherJavaLibMessage(arg: String) : String = { + arg + " " + OtherJavaLib.getMessage() } } diff --git a/tools/build_defs/scala/test/HelloLibTest.scala b/tools/build_defs/scala/test/HelloLibTest.scala new file mode 100644 index 00000000000000..7f5cb5f9b76df4 --- /dev/null +++ b/tools/build_defs/scala/test/HelloLibTest.scala @@ -0,0 +1,16 @@ +package scala.test + +import org.scalatest._ + +class ScalaSuite extends FlatSpec { + "HelloLib" should "call scala" in { + assert(HelloLib.getOtherLibMessage("hello").equals("hello scala!")) + } +} + +class JavaSuite extends FlatSpec { + "HelloLib" should "call java" in { + assert(HelloLib.getOtherJavaLibMessage("hello").equals("hello java!")) + } +} +
train
train
2016-01-29T16:36:41
2015-10-12T14:42:37Z
orrsella
test
bazelbuild/bazel/579_6923
bazelbuild/bazel
bazelbuild/bazel/579
bazelbuild/bazel/6923
[ "timestamp(timedelta=1.0, similarity=0.8929275300915026)" ]
0ecb86d80e878d5b68c4344092a68a878f54194f
cfd112f8bc51dfba29fcbf5ced20b0c091b57922
[ "To sort of reiterate a comment I made on bazel-discuss (possibly redundant, as I'm not sure what \"add versioning\" means), it would be helpful if:\r\n\r\n- The docs prominently display the Bazel version to which they apply.\r\n- Docs for multiple versions, including `master` are readily available (e.g. see Python...
[ "What are these hashes?\r\nHow do we update them?", "why do we need `exit` at the end?\r\n\r\nIf it's because of the trap, can you instead put the `mv` here?\r\nOr put the `sed` only when the condition is true?", "Add comment that it must be in sync with the config file?", "good idea. fixed.", "added instru...
2018-12-14T00:43:02Z
[ "type: documentation (cleanup)", "P2", "team-Bazel" ]
Versioning for Bazel docs
The docs on bazel.io are synced with `master`, and updates are pushed when new commits are pushed to `master`. As a result, the docs are often ahead of the latest release. We should also add versioning for the Bazel docs for releases. This is also something that @damienmg brought up in a separate thread offline. The documentation should also note which version they are for.
[ "WORKSPACE", "site/BUILD", "site/_config.yml", "site/_layouts/documentation.html", "site/_sass/sidebar.scss", "site/jekyll-tree.sh" ]
[ "WORKSPACE", "scripts/docs/doc_versions.bzl", "scripts/docs/generate_versioned_docs.sh", "site/BUILD", "site/_config.yml", "site/_layouts/documentation.html", "site/_sass/sidebar.scss", "site/jekyll-tree.sh" ]
[]
diff --git a/WORKSPACE b/WORKSPACE index ef6fb686911873..907c1bb7de423b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -278,3 +278,11 @@ distdir_tar( "jdk10-server-release-1804.tar.xz" : ["https://mirror.bazel.build/openjdk.linaro.org/releases/jdk10-server-release-1804.tar.xz"], }, ) + +load("//scripts/docs:doc_versions.bzl", "DOC_VERSIONS") + +[http_file( + name = "jekyll_tree_%s" % DOC_VERSION["version"].replace(".", "_"), + sha256 = DOC_VERSION["sha256"], + urls = ["https://mirror.bazel.build/bazel_versioned_docs/jekyll-tree-%s.tar" % DOC_VERSION["version"]], +) for DOC_VERSION in DOC_VERSIONS] diff --git a/scripts/docs/doc_versions.bzl b/scripts/docs/doc_versions.bzl new file mode 100644 index 00000000000000..6ce903f37efb9f --- /dev/null +++ b/scripts/docs/doc_versions.bzl @@ -0,0 +1,34 @@ +# To get the checksum of the versioned documentation tree tarball, run the +# following command with the selected Bazel version: +# +# $ curl -s https://mirror.bazel.build/bazel_versioned_docs/jekyll-tree-0.20.0.tar | sha256sum | cut -d" " -f1 +# bb79a63810bf1b0aa1f89bd3bbbeb4a547a30ab9af70c9be656cc6866f4b015b +# +# This list must be kept in sync with `doc_versions` variable in //site:_config.yml + +DOC_VERSIONS = [ + { + "version": "0.20.0", + "sha256": "bb79a63810bf1b0aa1f89bd3bbbeb4a547a30ab9af70c9be656cc6866f4b015b", + }, + { + "version": "0.19.2", + "sha256": "3c2d9f21ec2fd1c0b8a310f6eb6043027c838810cdfc2457d4346a0e5cdcaa7a", + }, + { + "version": "0.19.1", + "sha256": "ec892c59ba18bb8de1f9ae2bde937db144e45f28d6d1c32a2cee847ee81b134d", + }, + { + "version": "0.18.1", + "sha256": "98b77f48e37a50fc6f83100bf53f661e10732bb3ddbc226e02d0225cb7a9a7d8", + }, + { + "version": "0.17.2", + "sha256": "13b35dd309a0d52f0a2518a1193f42729c75255f5fae40cea68e4d4224bfaa2e", + }, + { + "version": "0.17.1", + "sha256": "02256ddd20eeaf70cf8fcfe9b2cdddd7be87aedd5848d549474fb0358e0031d3", + }, +] diff --git a/scripts/docs/generate_versioned_docs.sh b/scripts/docs/generate_versioned_docs.sh new file mode 100755 index 00000000000000..8be787aa246800 --- /dev/null +++ b/scripts/docs/generate_versioned_docs.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Generate a versioned documentation tree. +# +# Run this script from a git checkout of a release tag. This script will infer +# the tag and create the documentation tree with the correct tag injected into +# the static pages, archive the tree, and copy it to Google Cloud Storage. +# +# This only needs to be done once per release. This script is non-destructive. +# +# TODO(jingwen): Automate this into the release pipeline. + +set -eu + +function log_info() { + echo "[Info]" $@ +} + +readonly SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# Unless we're in a tag (e.g. 0.20.0), set DOC_VERSION to master. +readonly DOC_VERSION=$(git describe --tags --exact-match 2>/dev/null || echo "NOT_A_RELEASE") + +if [[ $DOC_VERSION == "NOT_A_RELEASE" ]] +then + log_info "You are currently in the branch: `git rev-parse --abbrev-ref HEAD`" + log_info "Please run this script from a git checkout of a release tag, e.g. git checkout 0.20.0" + log_info "See the valid list of tags with 'git tag'" + exit 1 +fi + +function cleanup() { + mv $SCRIPT_DIR/../../site/_config.yml{.bak,} +} + +read -p "You're going to generate the docs for $DOC_VERSION. Continue? <y/n> " prompt +if [[ $prompt =~ [yY](es)* ]] +then + # Modify the "version" Jekyll variable so all links in anchor tags are generated + # with the injected version. + sed -i.bak "s/master/$DOC_VERSION/" $SCRIPT_DIR/../../site/_config.yml + trap cleanup EXIT + + bazel build //site:jekyll-tree --action_env=DOC_VERSION=$DOC_VERSION + + # -n: no-clobber; prevent overwriting existing archives to be non-destructive. + # There should be no need to delete existing archives once it's uploaded. But + # should there be such a need, please file an issue. + # + # -a public-read: set the default ACL for uploaded archives to public-read for Bazel to download it. + gsutil cp -n -a public-read $SCRIPT_DIR/../../bazel-genfiles/site/jekyll-tree.tar gs://bazel-mirror/bazel_versioned_docs/jekyll-tree-$DOC_VERSION.tar + + log_info "Done." + log_info "Now, please add \"$DOC_VERSION\" to the doc_versions list in <workspace>/site/_config.yml." + log_info "Please also add \"$DOC_VERSION\" to <workspace>/scripts/docs/doc_versions.bzl." +fi diff --git a/site/BUILD b/site/BUILD index 370ef7e085fd68..782c5994eda2e7 100644 --- a/site/BUILD +++ b/site/BUILD @@ -1,5 +1,6 @@ load("//tools/build_defs/pkg:pkg.bzl", "pkg_tar") load("//scripts/docs:jekyll.bzl", "jekyll_build") +load("//scripts/docs:doc_versions.bzl", "DOC_VERSIONS") exports_files( [ @@ -125,6 +126,7 @@ tar cf $$origdir/$@ * tools = ["//scripts/docs:generate_dot_graphs"], ) +# Generate the documentation tree in the current git worktree genrule( name = "jekyll-tree", srcs = [ @@ -148,6 +150,9 @@ genrule( jekyll_build( name = "site", - srcs = [":jekyll-tree"], + srcs = [ + "@jekyll_tree_%s//file" % DOC_VERSION["version"].replace(".", "_") + for DOC_VERSION in DOC_VERSIONS + ] + [":jekyll-tree"], # jekyll-tree *must* come last to be the default. bucket = "docs.bazel.build", ) diff --git a/site/_config.yml b/site/_config.yml index a57a92b4b6816e..00f82998f49c69 100644 --- a/site/_config.yml +++ b/site/_config.yml @@ -12,6 +12,16 @@ gems: [jekyll-paginate] version: "master" +# This must be kept in sync with //site/script/docs:versions.bzl +doc_versions: + - master + - 0.20.0 + - 0.19.2 + - 0.19.1 + - 0.18.1 + - 0.17.2 + - 0.17.1 + main_site_url: https://www.bazel.build docs_site_url: "/" blog_site_url: https://blog.bazel.build diff --git a/site/_layouts/documentation.html b/site/_layouts/documentation.html index 10f3b669432bd5..0ac8e3440f2cb7 100644 --- a/site/_layouts/documentation.html +++ b/site/_layouts/documentation.html @@ -22,16 +22,31 @@ <h1>Documentation</h1> aria-controls="sidebar-nav"> <i class="glyphicon glyphicon-menu-hamburger"></i> Navigation </a> + <nav class="sidebar collapse" id="sidebar-nav"> - <h3>Home</h3> + <!-- /versions/master/foo/bar -> ["master", "foo", "bar"] --> + <!-- /versions/0.12.3/baz.md -> ["0.12.3", "baz.md"] --> + {% assign versioned_url_parts = page.url | split: '/' | shift | shift %} + {% assign current_version = versioned_url_parts.first %} + <select onchange="location.href=this.value"> + <option value="" selected disabled hidden>Version: {{ current_version }}</option> + {% for doc_version in site.doc_versions %} + <!-- reconstruct absolute url for the current page for each doc version --> + <option value="/{{ versioned_url_parts | shift | unshift: doc_version | unshift: 'versions' | join: '/' }}"> + {{ doc_version }} + </option> + {% endfor %} + </select> + + <h3>Home</h3> <ul class="sidebar-nav"> - <li><a href="/versions/{{ site.version }}/bazel-overview.html">Bazel Overview</a></li> - <li><a href="/versions/{{ site.version }}/bazel-vision.html">Bazel Vision</a></li> - <li><a href="/versions/{{ site.version }}/getting-started.html">Getting Started</a></li> - <li><a href="/versions/{{ site.version }}/skylark/backward-compatibility.html">Backward Compatibility</a></li> + <li><a href="/versions/{{ current_version }}/bazel-overview.html">Bazel Overview</a></li> + <li><a href="/versions/{{ current_version }}/bazel-vision.html">Bazel Vision</a></li> + <li><a href="/versions/{{ current_version }}/getting-started.html">Getting Started</a></li> + <li><a href="/versions/{{ current_version }}/skylark/backward-compatibility.html">Backward Compatibility</a></li> </ul> - <h3>Using Bazel</h3> + <h3>Using Bazel</h3> <ul class="sidebar-nav"> <li> @@ -41,14 +56,14 @@ <h3>Using Bazel</h3> Installing Bazel<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="installing-menu"> - <li><a href="/versions/{{ site.version }}/install.html">Installation Overview</a></li> - <li><a href="/versions/{{ site.version }}/install-ubuntu.html">Installing on Ubuntu</a></li> - <li><a href="/versions/{{ site.version }}/install-redhat.html">Installing on Fedora/CentOS</a></li> - <li><a href="/versions/{{ site.version }}/install-os-x.html">Installing on macOS</a></li> - <li><a href="/versions/{{ site.version }}/install-windows.html">Installing on Windows</a></li> - <li><a href="/versions/{{ site.version }}/install-compile-source.html">Compiling from Source</a></li> - <li><a href="/versions/{{ site.version }}/completion.html">Command-Line Completion</a></li> - <li><a href="/versions/{{ site.version }}/ide.html">Integrating with IDEs</a></li> + <li><a href="/versions/{{ current_version }}/install.html">Installation Overview</a></li> + <li><a href="/versions/{{ current_version }}/install-ubuntu.html">Installing on Ubuntu</a></li> + <li><a href="/versions/{{ current_version }}/install-redhat.html">Installing on Fedora/CentOS</a></li> + <li><a href="/versions/{{ current_version }}/install-os-x.html">Installing on macOS</a></li> + <li><a href="/versions/{{ current_version }}/install-windows.html">Installing on Windows</a></li> + <li><a href="/versions/{{ current_version }}/install-compile-source.html">Compiling from Source</a></li> + <li><a href="/versions/{{ current_version }}/completion.html">Command-Line Completion</a></li> + <li><a href="/versions/{{ current_version }}/ide.html">Integrating with IDEs</a></li> </ul> </li> @@ -59,18 +74,18 @@ <h3>Using Bazel</h3> Tutorials<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="tutorials-menu"> - <li><a href="/versions/{{ site.version }}/tutorial/java.html">Building a Java Project</a></li> - <li><a href="/versions/{{ site.version }}/tutorial/cpp.html">Building a C++ Project</a></li> - <li><a href="/versions/{{ site.version }}/tutorial/android-app.html">Building an Android App</a></li> - <li><a href="/versions/{{ site.version }}/tutorial/ios-app.html">Building an iOS App</a></li> - <li><a href="/versions/{{ site.version }}/skylark/tutorial-sharing-variables.html">Sharing Variables</a></li> - <li><a href="/versions/{{ site.version }}/skylark/tutorial-creating-a-macro.html">Creating a Macro</a></li> + <li><a href="/versions/{{ current_version }}/tutorial/java.html">Building a Java Project</a></li> + <li><a href="/versions/{{ current_version }}/tutorial/cpp.html">Building a C++ Project</a></li> + <li><a href="/versions/{{ current_version }}/tutorial/android-app.html">Building an Android App</a></li> + <li><a href="/versions/{{ current_version }}/tutorial/ios-app.html">Building an iOS App</a></li> + <li><a href="/versions/{{ current_version }}/skylark/tutorial-sharing-variables.html">Sharing Variables</a></li> + <li><a href="/versions/{{ current_version }}/skylark/tutorial-creating-a-macro.html">Creating a Macro</a></li> </ul> </li> - <li><a href="/versions/{{ site.version }}/build-ref.html">Bazel Concepts</a></li> - <li><a href="/versions/{{ site.version }}/guide.html">User's Guide</a></li> - <li><a href="/versions/{{ site.version }}/external.html">External Dependencies</a></li> + <li><a href="/versions/{{ current_version }}/build-ref.html">Bazel Concepts</a></li> + <li><a href="/versions/{{ current_version }}/guide.html">User's Guide</a></li> + <li><a href="/versions/{{ current_version }}/external.html">External Dependencies</a></li> <li> <a class="sidebar-nav-heading" data-toggle="collapse" @@ -79,15 +94,15 @@ <h3>Using Bazel</h3> Queries<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="query-menu"> - <li><a href="/versions/{{ site.version }}/query-how-to.html">Bazel query</a></li> - <li><a href="/versions/{{ site.version }}/cquery.html">Bazel cquery</a></li> - <li><a href="/versions/{{ site.version }}/user-manual.html#aquery">Bazel aquery</a></li> - <li><a href="/versions/{{ site.version }}/query.html">Query Language</a></li> + <li><a href="/versions/{{ current_version }}/query-how-to.html">Bazel query</a></li> + <li><a href="/versions/{{ current_version }}/cquery.html">Bazel cquery</a></li> + <li><a href="/versions/{{ current_version }}/user-manual.html#aquery">Bazel aquery</a></li> + <li><a href="/versions/{{ current_version }}/query.html">Query Language</a></li> </ul> </li> - <li><a href="/versions/{{ site.version }}/configurable-attributes.html">Configurable Attributes</a></li> - <li><a href="/versions/{{ site.version }}/best-practices.html">Best Practices</a></li> + <li><a href="/versions/{{ current_version }}/configurable-attributes.html">Configurable Attributes</a></li> + <li><a href="/versions/{{ current_version }}/best-practices.html">Best Practices</a></li> <li> <a class="sidebar-nav-heading" data-toggle="collapse" href="#remote-execution-menu" aria-expanded="false" @@ -95,8 +110,8 @@ <h3>Using Bazel</h3> Remote Execution<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="remote-execution-menu"> - <li><a href="/versions/{{ site.version }}/remote-execution.html">Remote Execution Overview</a></li> - <li><a href="/versions/{{ site.version }}/remote-execution-rules.html">Guidelines for Remote Execution</a></li> + <li><a href="/versions/{{ current_version }}/remote-execution.html">Remote Execution Overview</a></li> + <li><a href="/versions/{{ current_version }}/remote-execution-rules.html">Guidelines for Remote Execution</a></li> <li> <a class="sidebar-nav-heading" data-toggle="collapse" href="#troubleshoot-remote-execution-menu" aria-expanded="false" @@ -104,12 +119,12 @@ <h3>Using Bazel</h3> Troubleshooting Remote Execution<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="troubleshoot-remote-execution-menu"> - <li><a href="/versions/{{ site.version }}/remote-execution-sandbox.html">Troubleshooting Remote Execution with Bazel Sandbox</a></li> - <li><a href="/versions/{{ site.version }}/workspace-log.html">Finding non-hermetic behavior in WORKSPACE rules</a></li> - <li><a href="/versions/{{ site.version }}/remote-execution-caching-debug.html">Debugging Remote Cache Hit Rate</a></li> + <li><a href="/versions/{{ current_version }}/remote-execution-sandbox.html">Troubleshooting Remote Execution with Bazel Sandbox</a></li> + <li><a href="/versions/{{ current_version }}/workspace-log.html">Finding non-hermetic behavior in WORKSPACE rules</a></li> + <li><a href="/versions/{{ current_version }}/remote-execution-caching-debug.html">Debugging Remote Cache Hit Rate</a></li> </ul> </li> - <li><a href="/versions/{{ site.version }}/remote-execution-ci.html">Configuring Bazel CI for Remote Execution Rule Testing</a></li> + <li><a href="/versions/{{ current_version }}/remote-execution-ci.html">Configuring Bazel CI for Remote Execution Rule Testing</a></li> </ul> </li> @@ -120,15 +135,15 @@ <h3>Using Bazel</h3> Remote Caching<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="remote-caching-menu"> - <li><a href="/versions/{{ site.version }}/remote-caching.html">Remote Caching Overview</a></li> - <li><a href="/versions/{{ site.version }}/remote-caching-debug.html">Debugging Remote Cache Hit Rate for Local Execution</a></li> + <li><a href="/versions/{{ current_version }}/remote-caching.html">Remote Caching Overview</a></li> + <li><a href="/versions/{{ current_version }}/remote-caching-debug.html">Debugging Remote Cache Hit Rate for Local Execution</a></li> </ul> </li> </ul> <h3>Rules</h3> <ul class="sidebar-nav"> - <li><a href="/versions/{{ site.version }}/be/overview.html">Build Encyclopedia</a></li> + <li><a href="/versions/{{ current_version }}/be/overview.html">Build Encyclopedia</a></li> <li> <a class="sidebar-nav-heading" data-toggle="collapse" @@ -137,10 +152,10 @@ <h3>Rules</h3> Android<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="android-menu"> - <li><a href="/versions/{{ site.version }}/bazel-and-android.html">Android Resources</a></li> - <li><a href="/versions/{{ site.version }}/mobile-install.html">Using mobile-install</a></li> - <li><a href="/versions/{{ site.version }}/android-instrumentation-test.html">Android Instrumentation Tests</a></li> - <li><a href="/versions/{{ site.version }}/android-ndk.html">Android NDK</a></li> + <li><a href="/versions/{{ current_version }}/bazel-and-android.html">Android Resources</a></li> + <li><a href="/versions/{{ current_version }}/mobile-install.html">Using mobile-install</a></li> + <li><a href="/versions/{{ current_version }}/android-instrumentation-test.html">Android Instrumentation Tests</a></li> + <li><a href="/versions/{{ current_version }}/android-ndk.html">Android NDK</a></li> <li><a href="https://plugins.jetbrains.com/plugin/9185-bazel">Android Studio Plugin</a></li> </ul> </li> @@ -152,9 +167,9 @@ <h3>Rules</h3> Apple<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="apple-menu"> - <li><a href="/versions/{{ site.version }}/bazel-and-apple.html">Apple Resources</a></li> - <li><a href="/versions/{{ site.version }}/migrate-xcode.html">Migrating from Xcode</a></li> - <li><a href="/versions/{{ site.version }}/migrate-cocoapods.html">Converting CocoaPods</a></li> + <li><a href="/versions/{{ current_version }}/bazel-and-apple.html">Apple Resources</a></li> + <li><a href="/versions/{{ current_version }}/migrate-xcode.html">Migrating from Xcode</a></li> + <li><a href="/versions/{{ current_version }}/migrate-cocoapods.html">Converting CocoaPods</a></li> </ul> </li> @@ -165,10 +180,10 @@ <h3>Rules</h3> C++<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="cpp-menu"> - <li><a href="/versions/{{ site.version }}/bazel-and-cpp.html">C++ Resources</a></li> - <li><a href="/versions/{{ site.version }}/cpp-use-cases.html">C++ Use Cases</a></li> - <li><a href="/versions/{{ site.version }}/crosstool-reference.html">Understanding CROSSTOOL</a></li> - <li><a href="/versions/{{ site.version }}/tutorial/crosstool.html">Tutorial: CROSSTOOL</a></li> + <li><a href="/versions/{{ current_version }}/bazel-and-cpp.html">C++ Resources</a></li> + <li><a href="/versions/{{ current_version }}/cpp-use-cases.html">C++ Use Cases</a></li> + <li><a href="/versions/{{ current_version }}/crosstool-reference.html">Understanding CROSSTOOL</a></li> + <li><a href="/versions/{{ current_version }}/tutorial/crosstool.html">Tutorial: CROSSTOOL</a></li> </ul> </li> @@ -179,9 +194,9 @@ <h3>Rules</h3> Java<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="java-menu"> - <li><a href="/versions/{{ site.version }}/bazel-and-java.html">Java Resources</a></li> - <li><a href="/versions/{{ site.version }}/migrate-maven.html">Migrating from Maven</a></li> - <li><a href="/versions/{{ site.version }}/generate-workspace.html">Converting Maven Dependencies</a></li> + <li><a href="/versions/{{ current_version }}/bazel-and-java.html">Java Resources</a></li> + <li><a href="/versions/{{ current_version }}/migrate-maven.html">Migrating from Maven</a></li> + <li><a href="/versions/{{ current_version }}/generate-workspace.html">Converting Maven Dependencies</a></li> </ul> </li> @@ -192,8 +207,8 @@ <h3>Rules</h3> JavaScript<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="javascript-menu"> - <li><a href="/versions/{{ site.version }}/bazel-and-javascript.html">JavaScript Resources</a></li> - <li><a href="/versions/{{ site.version }}/build-javascript.html">Building JavaScript</a></li> + <li><a href="/versions/{{ current_version }}/bazel-and-javascript.html">JavaScript Resources</a></li> + <li><a href="/versions/{{ current_version }}/build-javascript.html">Building JavaScript</a></li> </ul> </li> @@ -201,19 +216,19 @@ <h3>Rules</h3> <h3>Reference</h3> <ul class="sidebar-nav"> - <li><a href="/versions/{{ site.version }}/user-manual.html">Commands and Options</a></li> - <li><a href="/versions/{{ site.version }}/skylark/build-style.html">BUILD Style Guide</a></li> - <li><a href="/versions/{{ site.version }}/command-line-reference.html">Command Line Reference</a></li> - <li><a href="/versions/{{ site.version }}/test-encyclopedia.html">Writing Tests</a></li> - <li><a href="/versions/{{ site.version }}/build-event-protocol.html">Build Event Protocol</a></li> - <li><a href="/versions/{{ site.version }}/output_directories.html">Output Directory Layout</a></li> - <li><a href="/versions/{{ site.version }}/platforms.html">Platforms</a></li> - <li><a href="/versions/{{ site.version }}/toolchains.html">Toolchains</a></li> + <li><a href="/versions/{{ current_version }}/user-manual.html">Commands and Options</a></li> + <li><a href="/versions/{{ current_version }}/skylark/build-style.html">BUILD Style Guide</a></li> + <li><a href="/versions/{{ current_version }}/command-line-reference.html">Command Line Reference</a></li> + <li><a href="/versions/{{ current_version }}/test-encyclopedia.html">Writing Tests</a></li> + <li><a href="/versions/{{ current_version }}/build-event-protocol.html">Build Event Protocol</a></li> + <li><a href="/versions/{{ current_version }}/output_directories.html">Output Directory Layout</a></li> + <li><a href="/versions/{{ current_version }}/platforms.html">Platforms</a></li> + <li><a href="/versions/{{ current_version }}/toolchains.html">Toolchains</a></li> </ul> <h3>Extending Bazel</h3> <ul class="sidebar-nav"> - <li><a href="/versions/{{ site.version }}/skylark/concepts.html">Extension Overview</a></li> + <li><a href="/versions/{{ current_version }}/skylark/concepts.html">Extension Overview</a></li> <li> <a class="sidebar-nav-heading" data-toggle="collapse" @@ -222,12 +237,12 @@ <h3>Extending Bazel</h3> Concepts<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="starlark-concepts"> - <li><a href="/versions/{{ site.version }}/skylark/macros.html">Macros</a></li> - <li><a href="/versions/{{ site.version }}/skylark/rules.html">Rules</a></li> - <li><a href="/versions/{{ site.version }}/skylark/depsets.html">Depsets</a></li> - <li><a href="/versions/{{ site.version }}/skylark/aspects.html">Aspects</a></li> - <li><a href="/versions/{{ site.version }}/skylark/repository_rules.html">Repository Rules</a></li> - <li><a href="/versions/{{ site.version }}/skylark/faq.html">FAQ</a></li> + <li><a href="/versions/{{ current_version }}/skylark/macros.html">Macros</a></li> + <li><a href="/versions/{{ current_version }}/skylark/rules.html">Rules</a></li> + <li><a href="/versions/{{ current_version }}/skylark/depsets.html">Depsets</a></li> + <li><a href="/versions/{{ current_version }}/skylark/aspects.html">Aspects</a></li> + <li><a href="/versions/{{ current_version }}/skylark/repository_rules.html">Repository Rules</a></li> + <li><a href="/versions/{{ current_version }}/skylark/faq.html">FAQ</a></li> </ul> </li> @@ -238,18 +253,18 @@ <h3>Extending Bazel</h3> Best Practices<span class="caret"></span> </a> <ul class="collapse sidebar-nav sidebar-submenu" id="starlark-practices"> - <li><a href="/versions/{{ site.version }}/skylark/bzl-style.html">.bzl Style Guide</a></li> - <li><a href="/versions/{{ site.version }}/skylark/testing.html">Testing</a></li> + <li><a href="/versions/{{ current_version }}/skylark/bzl-style.html">.bzl Style Guide</a></li> + <li><a href="/versions/{{ current_version }}/skylark/testing.html">Testing</a></li> <li><a href="https://skydoc.bazel.build" target="_blank">Documenting Rules</a></li> - <li><a href="/versions/{{ site.version }}/skylark/skylint.html">Linter</a></li> - <li><a href="/versions/{{ site.version }}/skylark/performance.html">Optimizing Performance</a></li> - <li><a href="/versions/{{ site.version }}/skylark/deploying.html">Deploying Rules</a></li> + <li><a href="/versions/{{ current_version }}/skylark/skylint.html">Linter</a></li> + <li><a href="/versions/{{ current_version }}/skylark/performance.html">Optimizing Performance</a></li> + <li><a href="/versions/{{ current_version }}/skylark/deploying.html">Deploying Rules</a></li> </ul> </li> <li><a href="https://github.com/bazelbuild/examples/tree/master/rules">Examples</a></li> - <li><a href="/versions/{{ site.version }}/skylark/lib/skylark-overview.html">API Reference</a></li> - <li><a href="/versions/{{ site.version }}/skylark/language.html">Starlark Language</a></li> + <li><a href="/versions/{{ current_version }}/skylark/lib/skylark-overview.html">API Reference</a></li> + <li><a href="/versions/{{ current_version }}/skylark/language.html">Starlark Language</a></li> </ul> </nav> </div> diff --git a/site/_sass/sidebar.scss b/site/_sass/sidebar.scss index 19879374bdc0bf..e2f5ae2056f284 100644 --- a/site/_sass/sidebar.scss +++ b/site/_sass/sidebar.scss @@ -50,6 +50,13 @@ $sidebar-hover-border-color: #66bb6a; padding-left: 10px; } } + + select { + padding: 3px 4px; + border: 2px solid $sidebar-border-color; + border-radius: 3px; + overflow: hidden; + } } @media (min-width: 992px) { diff --git a/site/jekyll-tree.sh b/site/jekyll-tree.sh index fd767ca7eff3d5..1c2f2ab60452be 100755 --- a/site/jekyll-tree.sh +++ b/site/jekyll-tree.sh @@ -40,10 +40,7 @@ readonly TMP=$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXX") readonly OUT_DIR="$TMP/out" trap "rm -rf ${TMP}" EXIT -# TODO: Create a variant of this script for cutting versions of documentation -# for Bazel releases. For that case, consider extracting the Git branch or tag -# name to be used as the versioned directory name. -readonly VERSION="master" +readonly VERSION="${DOC_VERSION:-master}" readonly VERSION_DIR="$OUT_DIR/versions/$VERSION" # Unpacks the base Jekyll tree, Build Encyclopedia, Skylark Library, and
null
train
train
2018-12-14T00:00:34
2015-11-09T09:40:18Z
davidzchen
test
bazelbuild/bazel/748_755
bazelbuild/bazel
bazelbuild/bazel/748
bazelbuild/bazel/755
[ "timestamp(timedelta=35552.0, similarity=0.8496915557676555)" ]
27bdc238e5855a25e54f1e7300beebb2f17bcab7
1ba03979389df1ee158886fa88375eee0a92310b
[ "Quick update on the situation: After cold starting Bazel multiple times (due to rebooting the OS) it seems the problem has disappeared entirely. However, let me leave the bug open for now.\n", "Hit ctrl-\\ while bazel is \"stuck\" and you'll get a thread dump.\nPosting that here may help us diagnose the problem....
[ "Why this change? The include path is relative to the root of the workspace.\n", "Have you tested this? The `:hello-world` target is in the `//examples/cpp` package. There is no `:hello-world` target in the root BUILD file.\n\nIf you want to build `:hello-world` from inside the `examples/cpp` directory, then the ...
2016-01-06T08:56:37Z
[]
Bazel getting stuck while building
I've been having trouble building things with Bazel lately. The issue manifests itself with Bazel appearing to be stuck (with no CPU load) at essentially random build steps (including the loading and analysis phase). This happens both when I attempt to build targets from my own repository, as well as in the bootstrap step in the Bazel installation; I've also tried with releases 0.1.0 and 0.1.2 with no success this far. For example, when running `./compile.sh` from HEAD just now I get stuck with the following (aborted after several minutes without any progress): ``` sh [mnett@singularity ~/Development/bazel] (master) Sat Jan 02 22:40:25 $ ./compile.sh INFO: You can skip this first step by providing a path to the bazel binary as second argument: INFO: ./compile.sh build /path/to/bazel 🍃 Building Bazel from scratch............ 🍃 Building Bazel with Bazel. .Extracting Bazel installation... Sending SIGTERM to previous Bazel server (pid=26879)... done. ....... INFO: Found 1 target... [2 / 45] Writing file src/main/java/com/google/devtools/build/lib/libbazel-main.jar-2.params ``` If I interpret the output of `strace` (see below), this seems to be a deadlock. ``` sh [mnett@singularity ~] Sat Jan 02 22:40:58 $ sudo strace -p 26879 [sudo] password for mnett: Process 26879 attached futex(0x7f059b3319d0, FUTEX_WAIT, 26880, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=30672, si_uid=1000} --- futex(0x7f059a5028c0, FUTEX_WAKE_PRIVATE, 1) = 1 rt_sigreturn() = 202 futex(0x7f059b3319d0, FUTEX_WAIT, 26880, NULL <unfinished ...> +++ exited with 143 +++ [mnett@singularity ~] Sat Jan 02 22:45:38 $ sudo strace -p 30715 Process 30715 attached futex(0x7f50b497b9d0, FUTEX_WAIT, 30716, NULL ``` The step at which the deadlock happens seems arbitrary and repeatedly running a build command eventually succeeds. Anyway, I didn't find any issues that seem to be related to this, and at this point I'm unsure of how to further debug the problem. Do you have any suggestions?
[ "examples/cpp/README.md", "examples/cpp/hello-lib.cc", "examples/cpp/hello-world.cc" ]
[ "examples/cpp/README.md", "examples/cpp/hello-lib.cc", "examples/cpp/hello-world.cc" ]
[]
diff --git a/examples/cpp/README.md b/examples/cpp/README.md index fba714321c6797..6191d9d919a55a 100644 --- a/examples/cpp/README.md +++ b/examples/cpp/README.md @@ -2,3 +2,9 @@ C++ Examples ============ These examples demonstrate building C++ binaries, libraries, and tests. + +To starting build , change to this directory. +``` +cd examples/cpp/ +bazel build //:hello-world +``` diff --git a/examples/cpp/hello-lib.cc b/examples/cpp/hello-lib.cc index bceb2683d54ef1..8c31185815c955 100644 --- a/examples/cpp/hello-lib.cc +++ b/examples/cpp/hello-lib.cc @@ -1,4 +1,4 @@ -#include "examples/cpp/hello-lib.h" +#include "hello-lib.h" #include <iostream> diff --git a/examples/cpp/hello-world.cc b/examples/cpp/hello-world.cc index be435c3256ff5b..1e2317ab46eedf 100644 --- a/examples/cpp/hello-world.cc +++ b/examples/cpp/hello-world.cc @@ -1,4 +1,4 @@ -#include "examples/cpp/hello-lib.h" +#include "hello-lib.h" #include <string>
null
train
train
2016-01-04T13:59:10
2016-01-02T13:54:12Z
mnett
test
bazelbuild/bazel/1087_1120
bazelbuild/bazel
bazelbuild/bazel/1087
bazelbuild/bazel/1120
[ "timestamp(timedelta=109140.0, similarity=0.8482036932530586)" ]
62d1e72bac93d1cb240630c1ff9777b994712216
1ffae44c9a0394eedbdb9318799c502def1df00b
[ "Thanks for the report! We recently moved all of these rules to their own repos (e.g., https://github.com/bazelbuild/rule_appengine), and I think we're still updating how their documentation is generated.\n" ]
[]
2016-04-05T20:28:14Z
[ "type: documentation (cleanup)" ]
Missing docs pages / broken links
I was reading through the Docs on http://bazel.io/docs/install.html and there are some broken links on the Skylark Rules section of the side menu. These links return 404: - Java AppEngine - http://bazel.io/docs/be/appengine.html - C# - http://bazel.io/docs/be/dotnet.html - D - http://bazel.io/docs/be/d.html - Groovy - http://bazel.io/docs/be/groovy.html - Go - http://bazel.io/docs/be/go.html - Sass - http://bazel.io/docs/be/sass.html This link returns a page with a redirect link, and that link returns 404: - Scala - http://bazel.io/docs/be/scala.html Apologies if this is the wrong repo to report this, but I couldn't find a better one in the bazelbuild org.
[ "src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm" ]
[ "src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm" ]
[]
diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm index 0aa490835df6be..671b5a691deefe 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/be-nav.vm @@ -34,7 +34,7 @@ <li><a href="${bazelbuildGithub}/rules_go" target="_blank">Go</a></li> <li><a href="${bazelbuildGithub}/rules_jsonnet" target="_blank">Jsonnet</a></li> <li><a href="${path}/pkg.html">Packaging</a></li> - <li><a href="${bazelbuildGithub}/rules_rust target="_blank"">Rust</a></li> + <li><a href="${bazelbuildGithub}/rules_rust" target="_blank"">Rust</a></li> <li><a href="${bazelbuildGithub}/rules_sass" target="_blank">Sass</a></li> <li><a href="${bazelbuildGithub}/rules_scala" target="_blank">Scala</a></li> </ul>
null
test
train
2016-04-05T16:09:15
2016-03-25T15:34:46Z
aj-michael
test
bazelbuild/bazel/1332_4368
bazelbuild/bazel
bazelbuild/bazel/1332
bazelbuild/bazel/4368
[ "timestamp(timedelta=112365.0, similarity=0.8625023770678207)" ]
192583d5fbf49f43bc7646e5750647362dfaecfe
0d145eaea90edb0b74d73fa80b7450b1a6fd7bb7
[ "@aehlig this is done, right?", "It was addressed in https://github.com/bazelbuild/bazel/pull/4368 in the skylark rules only (not the built-in)." ]
[ "I know you didn't start it, but I would have preferred email adresses in the rfc2606-reserved domains for fictional characters. (This also applies to other parts of that change.)\r\n ", "I shall enter a new PR to fix those (since it will be a big diff but mostly noise). Thanks!" ]
2017-12-30T01:45:31Z
[ "type: feature request", "P4" ]
new_git_repository doesn't have a strip_prefix option
[ "tools/build_defs/repo/git.bzl" ]
[ "tools/build_defs/repo/git.bzl" ]
[ "src/test/shell/bazel/skylark_git_repository_test.sh", "src/test/shell/bazel/testdata/pluto.git_log", "src/test/shell/bazel/testdata/refetch.git_log" ]
diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl index 2375b21f71f886..0f735528d6d2d5 100644 --- a/tools/build_defs/repo/git.bzl +++ b/tools/build_defs/repo/git.bzl @@ -15,7 +15,8 @@ def _clone_or_update(ctx): if (ctx.attr.verbose): - print('git.bzl: Cloning or updating repository %s' % ctx.name) + print('git.bzl: Cloning or updating repository %s using strip_prefix of [%s]' % + (ctx.name, ctx.attr.strip_prefix if ctx.attr.strip_prefix else 'None')) if ((not ctx.attr.tag and not ctx.attr.commit) or (ctx.attr.tag and ctx.attr.commit)): fail('Exactly one of commit and tag must be provided') @@ -23,12 +24,15 @@ def _clone_or_update(ctx): ref = ctx.attr.commit else: ref = 'tags/' + ctx.attr.tag + dir=str(ctx.path('.')) + if ctx.attr.strip_prefix: + dir = dir + "-tmp" st = ctx.execute(['bash', '-c', """ set -ex ( cd {working_dir} && - if ! ( cd '{dir}' && git rev-parse --git-dir ) >/dev/null 2>&1; then - rm -rf '{dir}' + if ! ( cd '{dir_link}' && git rev-parse --git-dir ) >/dev/null 2>&1; then + rm -rf '{dir}' '{dir_link}' git clone '{remote}' '{dir}' fi cd '{dir}' @@ -36,12 +40,21 @@ set -ex git clean -xdf ) """.format( working_dir=ctx.path('.').dirname, - dir=ctx.path('.'), + dir_link=ctx.path('.'), + dir=dir, remote=ctx.attr.remote, ref=ref, )]) + if st.return_code: fail('error cloning %s:\n%s' % (ctx.name, st.stderr)) + + if ctx.attr.strip_prefix: + dest_link="{}/{}".format(dir, ctx.attr.strip_prefix) + if not ctx.path(dest_link).exists: + fail("strip_prefix at {} does not exist in repo".format(ctx.attr.strip_prefix)) + + ctx.symlink(dest_link, ctx.path('.')) if ctx.attr.init_submodules: st = ctx.execute(['bash', '-c', """ set -ex @@ -75,6 +88,7 @@ _common_attrs = { 'tag': attr.string(default=''), 'init_submodules': attr.bool(default=False), 'verbose': attr.bool(default=False), + 'strip_prefix': attr.string(default='') } @@ -107,6 +121,8 @@ Args: init_submodules: Whether to clone submodules in the repository. remote: The URI of the remote Git repository. + + strip_prefix: A directory prefix to strip from the extracted files. """ git_repository = repository_rule( @@ -124,4 +140,6 @@ Args: init_submodules: Whether to clone submodules in the repository. remote: The URI of the remote Git repository. + + strip_prefix: A directory prefix to strip from the extracted files. """
diff --git a/src/test/shell/bazel/skylark_git_repository_test.sh b/src/test/shell/bazel/skylark_git_repository_test.sh index 1c7231f8efe2a0..2e683bf5dd2279 100755 --- a/src/test/shell/bazel/skylark_git_repository_test.sh +++ b/src/test/shell/bazel/skylark_git_repository_test.sh @@ -58,7 +58,16 @@ function set_up() { # BUILD # info # -# Then, set up workspace with the following files: +# Followed by a test at 2-subdir which contains the following files to test +# the strip_prefix functionality: +# +# pluto/ +# pluto/ +# WORKSPACE +# BUILD +# info +# +# In each case, set up workspace with the following files: # # $WORKSPACE_DIR/ # WORKSPACE @@ -67,11 +76,12 @@ function set_up() { # planet_info.sh # # //planets has a dependency on a target in the pluto Git repository. -function test_git_repository() { +function do_git_repository_test() { local pluto_repo_dir=$TEST_TMPDIR/repos/pluto - # Commit 85b8224 corresponds to tag 1-build. See testdata/pluto.git_log. - local commit_hash="b87de93" - + # Commit corresponds to tag 1-build. See testdata/pluto.git_log. + local commit_hash="$1" + local strip_prefix="" + [ $# -eq 2 ] && strip_prefix="strip_prefix=\"$2\"," # Create a workspace that clones the repository at the first commit. cd $WORKSPACE_DIR cat > WORKSPACE <<EOF @@ -80,6 +90,7 @@ git_repository( name = "pluto", remote = "$pluto_repo_dir", commit = "$commit_hash", + $strip_prefix ) EOF mkdir -p planets @@ -102,12 +113,30 @@ EOF expect_log "Pluto is a dwarf planet" } +function test_git_repository() { + do_git_repository_test "b87de93" +} + +function test_git_repository_strip_prefix() { + # This commit has the files in a subdirectory named 'pluto' + # so we strip_prefix and the build should still work. + do_git_repository_test "ceab34f" "pluto" +} + function test_new_git_repository_with_build_file() { - do_new_git_repository_test "build_file" + do_new_git_repository_test "0-initial" "build_file" +} + +function test_new_git_repository_with_build_file_strip_prefix() { + do_new_git_repository_test "3-subdir-bare" "build_file" "pluto" } function test_new_git_repository_with_build_file_content() { - do_new_git_repository_test "build_file_content" + do_new_git_repository_test "0-initial" "build_file_content" +} + +function test_new_git_repository_with_build_file_content_strip_prefix() { + do_new_git_repository_test "3-subdir-bare" "build_file_content" "pluto" } # Test cloning a Git repository using the new_git_repository rule. @@ -118,6 +147,12 @@ function test_new_git_repository_with_build_file_content() { # pluto/ # info # +# Then it uses the pluto Git repository at tag 3-subdir-bare, which contains the +# following files: +# pluto/ +# pluto/ +# info +# # Set up workspace with the following files: # # $WORKSPACE_DIR/ @@ -131,18 +166,21 @@ function test_new_git_repository_with_build_file_content() { # repository. function do_new_git_repository_test() { local pluto_repo_dir=$TEST_TMPDIR/repos/pluto + local strip_prefix="" + [ $# -eq 3 ] && strip_prefix="strip_prefix=\"$3\"," # Create a workspace that clones the repository at the first commit. cd $WORKSPACE_DIR - if [ "$1" == "build_file" ] ; then + if [ "$2" == "build_file" ] ; then cat > WORKSPACE <<EOF load('@bazel_tools//tools/build_defs/repo:git.bzl', 'new_git_repository') new_git_repository( name = "pluto", remote = "$pluto_repo_dir", - tag = "0-initial", + tag = "$1", build_file = "//:pluto.BUILD", + $strip_prefix ) EOF @@ -162,7 +200,8 @@ load('@bazel_tools//tools/build_defs/repo:git.bzl', 'new_git_repository') new_git_repository( name = "pluto", remote = "$pluto_repo_dir", - tag = "0-initial", + tag = "$1", + $strip_prefix build_file_content = """ filegroup( name = "pluto", @@ -189,8 +228,12 @@ EOF chmod +x planets/planet_info.sh bazel run //planets:planet-info >& $TEST_log \ - || echo "Expected build/run to succeed" - expect_log "Pluto is a planet" + || echo "Expected build/run to succeed" + if [ "$1" == "0-initial" ]; then + expect_log "Pluto is a planet" + else + expect_log "Pluto is a dwarf planet" + fi } # Test cloning a Git repository that has a submodule using the @@ -316,6 +359,26 @@ EOF assert_contains "GIT 2" bazel-genfiles/external/g/go } +function test_git_repository_not_refetched_on_server_restart_strip_prefix() { + local repo_dir=$TEST_TMPDIR/repos/refetch + # Change the strip_prefix which should cause a new checkout + cat > WORKSPACE <<EOF +load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') +git_repository(name='g', remote='$repo_dir', commit='b0a2ada', verbose=True) +EOF + bazel --batch build @g//gdir:g >& $TEST_log || fail "Build failed" + expect_log "Cloning" + assert_contains "GIT 2" bazel-genfiles/external/g/gdir/go + + cat > WORKSPACE <<EOF +load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') +git_repository(name='g', remote='$repo_dir', commit='b0a2ada', verbose=True, strip_prefix="gdir") +EOF + bazel --batch build @g//:g >& $TEST_log || fail "Build failed" + expect_log "Cloning" + assert_contains "GIT 2" bazel-genfiles/external/g/go +} + function test_git_repository_refetched_when_commit_changes() { local repo_dir=$TEST_TMPDIR/repos/refetch @@ -366,6 +429,17 @@ EOF assert_contains "GIT 1" bazel-genfiles/external/g/go bazel build @g//:g >& $TEST_log || fail "Build failed" assert_contains "GIT 2" bazel-genfiles/external/g/go + + cat > WORKSPACE <<EOF +load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') +git_repository(name='g', remote='$repo_dir', commit='b0a2ada', strip_prefix="gdir") +EOF + + bazel build --nofetch @g//:g >& $TEST_log || fail "Build failed" + expect_log "External repository 'g' is not up-to-date" + bazel build @g//:g >& $TEST_log || fail "Build failed" + assert_contains "GIT 2" bazel-genfiles/external/g/go + } # Helper function for setting up the workspace as follows @@ -403,7 +477,7 @@ EOF # info function test_git_repository_both_commit_tag_error() { setup_error_test - local pluto_repo_dir=$TEST_TMPDIR/pluto + local pluto_repo_dir=$TEST_TMPDIR/repos/pluto # Commit 85b8224 corresponds to tag 1-build. See testdata/pluto.git_log. local commit_hash="b87de93" @@ -434,7 +508,7 @@ EOF # info function test_git_repository_no_commit_tag_error() { setup_error_test - local pluto_repo_dir=$TEST_TMPDIR/pluto + local pluto_repo_dir=$TEST_TMPDIR/repos/pluto cd $WORKSPACE_DIR cat > WORKSPACE <<EOF @@ -450,4 +524,26 @@ EOF expect_log "Exactly one of commit and tag must be provided" } +# Verifies that if a non-existent subdirectory is supplied, then strip_prefix +# throws an error. +function test_invalid_strip_prefix_error() { + setup_error_test + local pluto_repo_dir=$TEST_TMPDIR/repos/pluto + + cd $WORKSPACE_DIR + cat > WORKSPACE <<EOF +load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') +git_repository( + name = "pluto", + remote = "$pluto_repo_dir", + tag = "1-build", + strip_prefix = "dir_does_not_exist" +) +EOF + + bazel fetch //planets:planet-info >& $TEST_log \ + || echo "Expect run to fail." + expect_log "strip_prefix at dir_does_not_exist does not exist in repo" +} + run_suite "skylark git_repository tests" diff --git a/src/test/shell/bazel/testdata/pluto.git_log b/src/test/shell/bazel/testdata/pluto.git_log index fb98d77cb060b1..28a31640032322 100644 --- a/src/test/shell/bazel/testdata/pluto.git_log +++ b/src/test/shell/bazel/testdata/pluto.git_log @@ -1,4 +1,40 @@ -commit b87de9346bb1a4a3d4d2ab1a567b07c5d11a486a (HEAD -> master, tag: 1-build) +commit a367b7e7f8f362697a079b7d23935bd079058af8 (HEAD -> master, tag: 3-subdir-bare) +Author: John Doe <john@foo.com> +Date: Fri Dec 29 20:33:35 2017 -0500 + + Remove BUILD and WORKSPACE files + +diff --git a/WORKSPACE b/WORKSPACE +deleted file mode 100644 +index e69de29..0000000 +diff --git a/pluto/BUILD b/pluto/BUILD +deleted file mode 100644 +index 874e03f..0000000 +--- a/pluto/BUILD ++++ /dev/null +@@ -1,5 +0,0 @@ +-filegroup( +- name = "pluto", +- srcs = ["info"], +- visibility = ["//visibility:public"], +-) + +commit ceab34fb9b4b9370d52dd5153074089a51bfb50e (tag: 2-subdir) +Author: John Doe <john@foo.com> +Date: Wed Dec 27 20:54:31 2017 +0000 + + Move pluto files into pluto subdirectory + +diff --git a/BUILD b/pluto/BUILD +similarity index 100% +rename from BUILD +rename to pluto/BUILD +diff --git a/info b/pluto/info +similarity index 100% +rename from info +rename to pluto/info + +commit b87de9346bb1a4a3d4d2ab1a567b07c5d11a486a (tag: 1-build) Author: John Doe <john@foo.com> Date: Thu Jul 16 04:50:53 2015 -0700 diff --git a/src/test/shell/bazel/testdata/refetch.git_log b/src/test/shell/bazel/testdata/refetch.git_log index 1d42f6979b1960..e0ef8294bc0fa3 100644 --- a/src/test/shell/bazel/testdata/refetch.git_log +++ b/src/test/shell/bazel/testdata/refetch.git_log @@ -1,4 +1,15 @@ -commit 62777acc140a240a3ec8fa1adecaa6bc9e25ccdd (HEAD -> master) +commit b0a2adafea74d36e0374a119eab6623dbe5ba418 (HEAD -> master) +Author: John Doe <john@foo.com> +Date: Fri Dec 29 18:36:06 2017 -0500 + + Move BUILD into a subdirectory + +diff --git a/BUILD b/gdir/BUILD +similarity index 100% +rename from BUILD +rename to gdir/BUILD + +commit 62777acc140a240a3ec8fa1adecaa6bc9e25ccdd Author: John Doe <john@foo.com> Date: Wed Nov 25 13:20:07 2015 +0100
train
train
2017-12-28T22:31:01
2016-06-02T19:23:29Z
kchodorow
test
bazelbuild/bazel/1345_1354
bazelbuild/bazel
bazelbuild/bazel/1345
bazelbuild/bazel/1354
[ "timestamp(timedelta=444.0, similarity=0.8789615018699354)" ]
aeee3b8e4cccc95fa7932fe45abbc6279bfb72d0
fc8a89e316e190282b4fbc43175f70d421d26aed
[ "The default value of `use_testrunner` is 1 and default behavior is to use `BazelTestRunner`, if a user needs to use this property, he would set `use_testrunner = 0` to use `GoogleTestRunner`.\n\nMaybe we should make it more clear. ;)\n", "Sorry, what I said above was totally wrong. The GoogleTestRunner doesn't e...
[]
2016-06-08T09:11:36Z
[ "type: documentation (cleanup)", "P3" ]
Documentation- java_test use_testrunner mistake
Hi, I think the documentation of the java_test use_testrunner property is mistaken. It talks about `com.google.testing.junit.runner.GoogleTestRunner` while I think that was superseded by `BazelTestRunner` which is also mentioned which adds to the confusion. I think the first mention should also change to `BazelTestRunner`. Hope I'm not talking gibberish.
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java index cf195562209cf9..fc40911439b36f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java @@ -290,7 +290,7 @@ generated by the wrapper script includes the name of the main class followed by .add(attr("jvm_flags", STRING_LIST)) /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(use_testrunner) --> Use the - <code>com.google.testing.junit.runner.GoogleTestRunner</code> class as the + <code>com.google.testing.junit.runner.BazelTestRunner</code> class as the main entry point for a Java program. You can use this to override the default
null
test
train
2016-06-08T10:51:46
2016-06-07T12:39:47Z
ittaiz
test
bazelbuild/bazel/1523_1524
bazelbuild/bazel
bazelbuild/bazel/1523
bazelbuild/bazel/1524
[ "timestamp(timedelta=2132.0, similarity=0.8414718166154534)" ]
9bde9d09a83cdca2dc884d322ab50f7542c062cf
70e6b5556f2223e736b54a8271548daf6efb6afe
[ "Isn't this fixed already?", "Andreas's fix is still pending: https://github.com/bazelbuild/bazel/pull/1524", "Is merged.", "Thank you!" ]
[]
2016-07-14T11:22:08Z
[ "type: feature request" ]
Skylark operator list * int missing
Currently it is not supported to write `[foo] * 5`. Message is: ``` unsupported operand type(s) for *: 'list' and 'int'. ```
[ "src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java", "src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java" ]
[ "src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java", "src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java" ]
[ "src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java index ed0e55f569ac0f..973260fefb1f8f 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java @@ -144,7 +144,7 @@ Object doEval(Environment env) throws EvalException, InterruptedException { return minus(lval, rval, getLocation()); case MULT: - return mult(lval, rval, getLocation()); + return mult(lval, rval, env, getLocation()); case DIVIDE: return divide(lval, rval, getLocation()); @@ -374,7 +374,7 @@ public static Object minus(Object lval, Object rval, Location location) throws E * * <p>Publicly accessible for reflection and compiled Skylark code. */ - public static Object mult(Object lval, Object rval, Location location) throws EvalException { + public static Object mult(Object lval, Object rval, Environment env, Location location) throws EvalException { Integer number = null; Object otherFactor = null; @@ -392,8 +392,10 @@ public static Object mult(Object lval, Object rval, Location location) throws Ev } else if (otherFactor instanceof String) { // Similar to Python, a factor < 1 leads to an empty string. return Strings.repeat((String) otherFactor, Math.max(0, number.intValue())); + } else if (otherFactor instanceof MutableList) { + // Similar to Python, a factor < 1 leads to an empty string. + return MutableList.duplicate((MutableList) otherFactor, Math.max(0, number.intValue()), env); } - // TODO(skylark-team): implement int * list } throw typeException(lval, rval, Operator.MULT, location); } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java index 1221aa67cc8e66..b6f17e9f4e907b 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java @@ -407,6 +407,33 @@ public static <E> MutableList<E> concat( left.getGlobListOrContentsUnsafe(), right.getGlobListOrContentsUnsafe()), env); } + /** + * Duplicates MutableList n times + * @param list the list to duplicate + * @param times the count of times to duplicate + * @param env the Environment in which to create a new list + * @return a new MutableList + */ + public static <E> MutableList<E> duplicate( + final MutableList<? extends E> list, + final int times, + final Environment env) { + final int concatCount = times - 1; + if (list.getGlobList() == null) { + Iterable<? extends E> iterable = list; + for (int i = concatCount; i > 0; --i) { + iterable = Iterables.concat(iterable, iterable); + } + return new MutableList(iterable, env); + } + + List<?> globs = list.getGlobListOrContentsUnsafe(); + for (int i = concatCount; i > 0; --i) { + globs = GlobList.concat(globs, globs); + } + return new MutableList(globs, env); + } + /** * Adds one element at the end of the MutableList. * @param element the element to add
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java index 9bdaa150e7b39c..21a4cc2d3bb06a 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java @@ -537,6 +537,19 @@ public void testListConcatenation() throws Exception { "(1, 2) + [3, 4]"); } + @Test + public void testListMultiply() throws Exception { + newTest() + .testStatement("[1, 2] * 2", MutableList.of(env, 1, 2, 1, 2)) + .testStatement("[ ] * 10", MutableList.EMPTY) + .testStatement("[1, 2] * 0", MutableList.EMPTY) + .testStatement("[1, 2] * -4", MutableList.EMPTY) + .testStatement(" 2 * [1, 2]", MutableList.of(env, 1, 2, 1, 2)) + .testStatement("10 * []", MutableList.EMPTY) + .testStatement(" 0 * [1, 2]", MutableList.EMPTY) + .testStatement("-4 * [1, 2]", MutableList.EMPTY); + } + @SuppressWarnings("unchecked") @Test public void testSelectorListConcatenation() throws Exception {
train
train
2016-12-09T16:53:09
2016-07-14T10:14:18Z
abergmeier-dsfishlabs
test
bazelbuild/bazel/1644_1645
bazelbuild/bazel
bazelbuild/bazel/1644
bazelbuild/bazel/1645
[ "timestamp(timedelta=0.0, similarity=0.9419610559888507)" ]
fd843fe97e5e088ec422e5a294d71040e80b4cbd
c260b9c15570b061f84f2efee79b7a0f6be87ac6
[]
[ "replace to www.bazel.io?\n" ]
2016-08-15T08:51:11Z
[ "type: documentation (cleanup)", "P2" ]
http://bazel.io should redirect to https://bazel.io
https://bazel.io is now live, but http://bazel.io does not redirect to the https site.
[ ".gitignore", "site/_includes/head.html" ]
[ ".gitignore", "site/_includes/head.html" ]
[]
diff --git a/.gitignore b/.gitignore index e6d98586835c48..d5396a246de715 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ /bazel-testlogs /bazel.iml /output/ +/.sass-cache/ +/production/ diff --git a/site/_includes/head.html b/site/_includes/head.html index 57bad5c9ee0246..7bd812a48032ec 100644 --- a/site/_includes/head.html +++ b/site/_includes/head.html @@ -8,7 +8,11 @@ var current_url = window.location.href; var bad_url = new RegExp("^https?://bazelbuild.github.io/bazel/"); if (bad_url.test(current_url)) { - window.location.replace(current_url.replace(bad_url, "http://bazel.io/")); + window.location.replace(current_url.replace(bad_url, "https://www.bazel.io/")); + } + var http_url = new RegExp("^http://(www\.)?bazel.io/"); + if (http_url.test(current_url)) { + window.location.replace(current_url.replace(http_url, "https://www.bazel.io/")); } </script>
null
test
train
2016-08-22T18:42:12
2016-08-15T07:59:10Z
davidzchen
test
bazelbuild/bazel/1673_3991
bazelbuild/bazel
bazelbuild/bazel/1673
bazelbuild/bazel/3991
[ "timestamp(timedelta=0.0, similarity=0.8777530327961319)" ]
b87a41f3a69873b40b4211b348a497afca9ef316
446c08773c5e7691a60b6f3d13b11e67a91266c0
[]
[]
2017-10-30T21:12:21Z
[]
prelude ignored in remote repos
see: https://github.com/johnynek/bazel-deps/issues/13 this tool (johnynek/bazel-deps) puts the scala rules in the prelude: https://github.com/johnynek/bazel-deps/blob/master/tools/build_rules/prelude_bazel but another repo that does not do this and uses the above as an external repo gets: ``` $ bazel run @com_github_johnynek_bazel_deps//src/scala/com/github/johnynek/bazel_deps:parseproject .. WARNING: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/WORKSPACE:1: Workspace name in /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/WORKSPACE (@com_github_pgr0ss_bazel_deps) does not match the name given in the repository's definition (@com_github_johnynek_bazel_deps); this will cause a build error in future versions. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:1:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:5:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:9:1: name 'scala_repl' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:12:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:27:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:35:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:42:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:52:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:67:1: name 'scala_binary' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:81:1: name 'scala_library' is not defined. ERROR: /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD:93:1: name 'scala_library' is not defined. ERROR: no such target '@com_github_johnynek_bazel_deps//src/scala/com/github/johnynek/bazel_deps:parseproject': target 'parseproject' not declared in package 'src/scala/com/github/johnynek/bazel_deps' defined by /private/var/tmp/_bazel_David/aca004537b75fd97c67330379e89470b/external/com_github_johnynek_bazel_deps/src/scala/com/github/johnynek/bazel_deps/BUILD. INFO: Elapsed time: 0.715s ERROR: Build failed. Not running target. ``` It seems to me preludes in remote repos should be in effect for the targets in those repos.
[ "src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java" ]
[ "src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java" ]
[ "src/test/shell/integration/BUILD", "src/test/shell/integration/prelude_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java index f873feac503b83..7ecd70606981f7 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java @@ -541,7 +541,13 @@ public SkyValue compute(SkyKey key, Environment env) throws PackageFunctionExcep return null; } - SkyKey astLookupKey = ASTFileLookupValue.key(preludeLabel); + // Load the prelude from the same repository as the package being loaded. Can't use + // Label.resolveRepositoryRelative because preludeLabel is in the main repository, not the + // default one, so it is resolved to itself. + Label pkgPreludeLabel = Label.createUnvalidated( + PackageIdentifier.create(packageId.getRepository(), preludeLabel.getPackageFragment()), + preludeLabel.getName()); + SkyKey astLookupKey = ASTFileLookupValue.key(pkgPreludeLabel); ASTFileLookupValue astLookupValue = null; try { astLookupValue = (ASTFileLookupValue) env.getValueOrThrow(astLookupKey,
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD index 1d9b55d76c1bd3..0547a794fd1fe8 100644 --- a/src/test/shell/integration/BUILD +++ b/src/test/shell/integration/BUILD @@ -302,6 +302,13 @@ cc_binary( malloc = "//base:system_malloc", ) +sh_test( + name = "prelude_test", + size = "medium", + srcs = ["prelude_test.sh"], + data = [":test-deps"], +) + ######################################################################## # Test suites. diff --git a/src/test/shell/integration/prelude_test.sh b/src/test/shell/integration/prelude_test.sh new file mode 100755 index 00000000000000..de4e1e49c48161 --- /dev/null +++ b/src/test/shell/integration/prelude_test.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# +# Copyright 2015 The Bazel Authors. All rights reserved. +# +# 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. +# +# An end-to-end test of the behavior of tools/build_rules/prelude_bazel. + +# Load the test setup defined in the parent directory +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${CURRENT_DIR}/../integration_test_setup.sh" \ + || { echo "integration_test_setup.sh not found!" >&2; exit 1; } + +#### SETUP ############################################################# + +set -e + +#### TESTS ############################################################# + +function test_prelude() { + touch WORKSPACE + + mkdir -p tools/build_rules + touch tools/build_rules/BUILD + + cat > tools/build_rules/prelude_bazel << EOF +PRELUDE_VAR = 'from test_prelude' +EOF + + cat > BUILD << EOF +genrule( + name = 'gr', + srcs = [], + outs = ['gr.out'], + cmd = 'echo "%s" > \$(location gr.out)' % PRELUDE_VAR, +) +EOF + + bazel build :gr >&$TEST_log 2>&1 || fail "build failed" + + output=$(cat bazel-genfiles/gr.out) + check_eq "from test_prelude" "$output" "unexpected output in gr.out" +} + +function test_prelude_external_repository() { + cat > WORKSPACE << EOF +local_repository( + name = "imported_workspace", + path = "$PWD/imported_workspace", +) +EOF + + mkdir -p tools/build_rules + touch tools/build_rules/BUILD + + cat > tools/build_rules/prelude_bazel << EOF +PRELUDE_VAR = 'from test_prelude_external_repository, outer workspace' +EOF + + cat > BUILD << EOF +genrule( + name = 'gr', + srcs = [], + outs = ['gr.out'], + cmd = 'echo "outer %s" > \$(location gr.out)' % PRELUDE_VAR, +) +EOF + + mkdir -p imported_workspace + touch imported_workspace/WORKSPACE + + mkdir -p imported_workspace/tools/build_rules + touch imported_workspace/tools/build_rules/BUILD + + cat > imported_workspace/tools/build_rules/prelude_bazel << EOF +PRELUDE_VAR = 'from test_prelude_external_repository, inner workspace' +EOF + + cat > imported_workspace/BUILD << EOF +genrule( + name = 'gr_inner', + srcs = [], + outs = ['gr_inner.out'], + cmd = 'echo "inner %s" > \$(location gr_inner.out)' % PRELUDE_VAR, +) +EOF + + bazel build :gr @imported_workspace//:gr_inner >&$TEST_log 2>&1 || fail "build failed" + + output=$(cat bazel-genfiles/gr.out) + check_eq "outer from test_prelude_external_repository, outer workspace" "$output" "unexpected output in gr.out" + + output=$(cat bazel-genfiles/external/imported_workspace/gr_inner.out) + check_eq "inner from test_prelude_external_repository, inner workspace" "$output" "unexpected output in gr_inner.out" +} + +run_suite "prelude"
train
train
2017-11-29T16:49:19
2016-08-22T18:20:57Z
johnynek
test
bazelbuild/bazel/2032_2046
bazelbuild/bazel
bazelbuild/bazel/2032
bazelbuild/bazel/2046
[ "timestamp(timedelta=0.0, similarity=0.8691097587201603)" ]
fa407e52920a9c187befc94cc13014c19dd6219d
e24e84a6184933bf54f308f9a8c5e1ac0842cbf1
[ "@petemounce @laszlocsomor \n", "Woah woah woah, regex find and replace in powershell? What have I let myself in for. Are different drives really necessary? :p\n\nYeah, sure. I'll get that done.\n", "Help us Obi-Wan, you're the only PS expert! :)\n", "Done.\n" ]
[ "I think you don't need to match $2 if you're outputting it unaltered.\n", "That's true. I like this pattern more since it's more explicit, but I don't feel strongly.\n", "ok\n" ]
2016-11-05T19:23:06Z
[ "P3", "platform: windows" ]
Windows, chocolatey: support drive letters other than C: in chocolatey package.
At least in `chocolateyinstall.ps1`, line 53, and maybe other places
[ "scripts/packages/chocolatey/tools/chocolateyinstall.ps1" ]
[ "scripts/packages/chocolatey/tools/chocolateyinstall.ps1" ]
[]
diff --git a/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 b/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 index 9afd433d8ef29e..fbd3cc32b0c653 100644 --- a/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 +++ b/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 @@ -2,13 +2,14 @@ $ErrorActionPreference = 'Stop'; # stop on all errors $packageName = 'bazel' $toolsDir = Split-Path -parent $MyInvocation.MyCommand.Definition -$p = ((gc "$toolsDir\params.json") -join "`n") | convertfrom-json +$json = gc "$toolsDir\params.json" +$p = (($json) -join "`n") | convertfrom-json $packageDir = Split-Path -parent $toolsDir $binRoot = (Get-ToolsLocation) -replace "\\", "/" write-host "Read params from json" -write-host $p +write-host (convertto-json $p) Install-ChocolateyZipPackage -PackageName "$packageName" ` -Url "$($p.package.uri)" ` @@ -50,7 +51,7 @@ if ($packageParameters) } Install-ChocolateyPath -PathToInstall "$msys2Path\usr\bin" -PathType "Machine" -$addToMsysPath = ($packageDir -replace 'c:\\','/c/') -replace '\\','/' +$addToMsysPath = ($packageDir -replace '^([a-zA-Z]):\\(.*)','/$1/$2') -replace '\\','/' write-host @" bazel installed to $packageDir
null
train
train
2016-11-04T17:06:07
2016-11-03T11:00:00Z
dslomov
test
bazelbuild/bazel/2054_4852
bazelbuild/bazel
bazelbuild/bazel/2054
bazelbuild/bazel/4852
[ "timestamp(timedelta=0.0, similarity=0.852035181509092)" ]
e2df6e2ade9279dc2a1adfbcaaf16116f201ad07
6a179ab88fe6c4388ad4397d3ccbca07ca5ab80d
[ "this (in combination with #1752) sounds valuable since it lowers the entry costs of an organization. People can check out and best practices are laid out in the shared bazelrc ", "+1" ]
[ "Please add an `OS.getCurrent()` check around this `if`, and only replace \"~\" on Linux/macOS.", "here too", "(`OS` in the same Java package)", "AFAIK, `user.home` should be resolved just fine on Windows and recent JDK versions: [1]. On Windows, on Java 8, we have:\r\n\r\n```java\r\npublic class Test {\r\n ...
2018-03-14T21:36:07Z
[ "type: feature request", "P3", "category: misc > misc" ]
Allow options to use ~ or $HOME
It would be nice for users to be able to specify user-specific paths. We'd probably have to add support for both client & server path parsing. See https://github.com/bazelbuild/bazel/issues/1752#issuecomment-258642717 for context.
[ "src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java" ]
[ "src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java" ]
[ "src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java index c94863ed86d01a..029d08c8c10ba9 100644 --- a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java +++ b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.util; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Converter; @@ -103,7 +104,11 @@ public static class PathFragmentConverter @Override public PathFragment convert(String input) { - return PathFragment.create(input); + String path = Preconditions.checkNotNull(input); + if (!path.isEmpty() && path.startsWith("~/")) { + path = path.replace("~", System.getProperty("user.home")); + } + return PathFragment.create(path); } @Override @@ -123,6 +128,9 @@ public List<PathFragment> convert(String input) { List<PathFragment> list = new ArrayList<>(); for (String piece : input.split(":")) { if (!piece.isEmpty()) { + if (piece.startsWith("~/")) { + piece = piece.replace("~", System.getProperty("user.home")); + } list.add(PathFragment.create(piece)); } }
diff --git a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java index ddf8dadda93f9e..2d7d2f75f93ff8 100644 --- a/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java +++ b/src/test/java/com/google/devtools/build/lib/util/OptionsUtilsTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.fail; import com.google.common.collect.Lists; +import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentConverter; import com.google.devtools.build.lib.util.OptionsUtils.PathFragmentListConverter; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Option; @@ -166,6 +167,10 @@ private List<PathFragment> convert(String input) throws Exception { return new PathFragmentListConverter().convert(input); } + private PathFragment convertOne(String input) throws Exception { + return new PathFragmentConverter().convert(input); + } + @Test public void emptyStringYieldsEmptyList() throws Exception { assertThat(convert("")).isEqualTo(list()); @@ -183,12 +188,23 @@ public void converterSkipsEmptyStrings() throws Exception { @Test public void multiplePaths() throws Exception { - assertThat(convert("foo:/bar/baz:.:/tmp/bang")) + assertThat(convert("~/foo:foo:/bar/baz:.:/tmp/bang")) .containsExactly( - fragment("foo"), fragment("/bar/baz"), fragment("."), fragment("/tmp/bang")) + fragment(System.getProperty("user.home") + "/foo"), + fragment("foo"), + fragment("/bar/baz"), + fragment("."), + fragment("/tmp/bang")) .inOrder(); } + @Test + public void singlePath() throws Exception { + assertThat(convertOne("foo")).isEqualTo(fragment("foo")); + assertThat(convertOne("foo/bar/baz")).isEqualTo(fragment("foo/bar/baz")); + assertThat(convertOne("~/foo")).isEqualTo(fragment(System.getProperty("user.home") + "/foo")); + } + @Test public void valueisUnmodifiable() throws Exception { try {
val
train
2018-03-19T22:32:41
2016-11-07T19:50:00Z
kchodorow
test
bazelbuild/bazel/2121_6801
bazelbuild/bazel
bazelbuild/bazel/2121
bazelbuild/bazel/6801
[ "timestamp(timedelta=166854.0, similarity=0.8431258311203514)" ]
d0cdf9fef159fa502830718e4cdcd385aed8569e
77c4c92395fe507f284cf42da3a2722e1c6c9f50
[ "Hi Shahms,\r\n\r\nThank you for the report, I'll try to improve the clang support in cc_configure.bzl when I'll have spare cycles. If in the meantime you feel like it, feel free to tackle it yourself, cc_configure.bzl is not too complicated. If not, no worries, I will get to it eventually :)\r\nCheers", "Piggyba...
[]
2018-11-29T11:25:49Z
[ "type: feature request", "P3", "team-Rules-CPP" ]
cc_configure rules do not work with Clang on Linux
### Description of the problem / feature request / question: The cc_autoconf repository rule does not work with Clang on Linux, but rather spits out a number of warnings: clang: warning: -Wl,-z,-relro,-z,now: 'linker' input unused and the error: clang: error: unsupported option '-pass-exit-codes' I suspect there are further issues, but these are just the first encountered. Additionally, it would be nice if the repository rule itself allowed a bit more flexibility. I know they are experimental, but it would be nice if there was a middle ground between "entirely automatic" and "entirely manual" when configuring the C compiler to use. Some nice-to-haves: Compiler name (used by _find_cc). In our case, GCC doesn't work and we need Clang. `cxx_flags`: In particular, specifying the required version of C++ via `-std=c++11`, etc. ### If possible, provide a minimal example to reproduce the problem: CC=/usr/bin/clang bazel build //any:cc_rule ### Environment info * Operating System: Linux * Bazel version (output of `bazel info release`): release 0.4.0 (But still present in HEAD)
[ "tools/cpp/windows_cc_configure.bzl" ]
[ "tools/cpp/windows_cc_configure.bzl" ]
[]
diff --git a/tools/cpp/windows_cc_configure.bzl b/tools/cpp/windows_cc_configure.bzl index 54a3a8c4b4b5a3..2c0952769adbb0 100644 --- a/tools/cpp/windows_cc_configure.bzl +++ b/tools/cpp/windows_cc_configure.bzl @@ -341,6 +341,14 @@ def _use_clang_cl(repository_ctx): """Returns True if USE_CLANG_CL is set to 1.""" return repository_ctx.os.environ.get("USE_CLANG_CL", default = "0") == "1" +def _get_clang_version(repository_ctx, clang_cl): + result = repository_ctx.execute([clang_cl, "-v"]) + if result.return_code != 0: + auto_configure_fail("Failed to get clang version by running \"%s -v\"" % clang_cl) + # Stderr should look like "clang version X.X.X ..." + return result.stderr.strip().split(" ")[2] + + def configure_windows_toolchain(repository_ctx): """Configure C++ toolchain on Windows.""" paths = resolve_labels(repository_ctx, [ @@ -427,7 +435,11 @@ def configure_windows_toolchain(repository_ctx): "Please install Clang via http://releases.llvm.org/download.html\n") cl_path = find_llvm_tool(repository_ctx, llvm_path, "clang-cl.exe") link_path = find_llvm_tool(repository_ctx, llvm_path, "lld-link.exe") + if not link_path: + link_path = find_msvc_tool(repository_ctx, vc_path, "link.exe") lib_path = find_llvm_tool(repository_ctx, llvm_path, "llvm-lib.exe") + if not lib_path: + lib_path = find_msvc_tool(repository_ctx, vc_path, "lib.exe") else: cl_path = find_msvc_tool(repository_ctx, vc_path, "cl.exe") link_path = find_msvc_tool(repository_ctx, vc_path, "link.exe") @@ -440,8 +452,12 @@ def configure_windows_toolchain(repository_ctx): if path: escaped_cxx_include_directories.append("cxx_builtin_include_directory: \"%s\"" % path) if llvm_path: - clang_include_path = (llvm_path + "\\lib\\clang").replace("\\", "\\\\") + clang_version = _get_clang_version(repository_ctx, cl_path) + clang_dir = llvm_path + "\\lib\\clang\\" + clang_version + clang_include_path = (clang_dir + "\\include").replace("\\", "\\\\") escaped_cxx_include_directories.append("cxx_builtin_include_directory: \"%s\"" % clang_include_path) + clang_lib_path = (clang_dir + "\\lib\\windows").replace("\\", "\\\\") + escaped_lib_paths = escaped_lib_paths + ";" + clang_lib_path support_debug_fastlink = _is_support_debug_fastlink(repository_ctx, link_path)
null
test
train
2018-11-29T11:35:13
2016-11-22T17:44:17Z
shahms
test
bazelbuild/bazel/2398_2410
bazelbuild/bazel
bazelbuild/bazel/2398
bazelbuild/bazel/2410
[ "timestamp(timedelta=0.0, similarity=0.8828373293694733)" ]
ce7c4deda60a307bba5f0c9421738e2a375cf44e
3292ada3de88b32c2fc9c23a6420ee5ac5d6dc6b
[]
[]
2017-01-24T16:24:17Z
[ "type: documentation (cleanup)" ]
Users page is duplicated between website and wiki
https://github.com/bazelbuild/bazel/wiki/Bazel-Users is a fork of https://bazel.build/users.html Which means there are 2 places where we show a list of Bazel users. [There can be only one](https://www.youtube.com/watch?v=sqcLjcSloXs). Based on advice from the Chromium team, we agreed that a wiki reduces the friction such user contributions. The wiki should thus be the only place where we have an extensive and user-contributed list of Bazel users. In the future, we will work on a users testimonials page, which will be curated by the maintainers of https://bazel.build and that will also link to the Bazel users wiki page What we need to do in the short term: * [x] merge the latest contributions to https://github.com/bazelbuild/bazel/blob/master/site/users.md into https://github.com/bazelbuild/bazel/wiki/Bazel-Users * [ ] make the "Who's using Bazel" link of the site left nav link to https://github.com/bazelbuild/bazel/wiki/Bazel-Users
[ "site/_layouts/contribute.html", "site/index.html", "site/users.md" ]
[ "site/_layouts/contribute.html", "site/index.html" ]
[]
diff --git a/site/_layouts/contribute.html b/site/_layouts/contribute.html index 8dea8901a40be1..46d7519e04b0df 100644 --- a/site/_layouts/contribute.html +++ b/site/_layouts/contribute.html @@ -25,7 +25,7 @@ <h1>Contribute!</h1> <nav class="sidebar collapse" id="sidebar-nav"> <ul class="sidebar-nav"> <li><a href="/contributing.html">Contributing to Bazel</a></li> - <li><a href="/users.html">Who's Using Bazel</a></li> + <li><a href="https://github.com/bazelbuild/bazel/wiki/Bazel-Users">Who's Using Bazel</a></li> <li><a href="/roadmap.html">Roadmap</a></li> <li><a href="/governance.html">Governance</a></li> </ul> diff --git a/site/index.html b/site/index.html index 6d6e25c4952b94..4d98e0543bd36a 100644 --- a/site/index.html +++ b/site/index.html @@ -158,7 +158,7 @@ <h1>About Bazel</h1> <a href="governance.html">Governance Plan</a><br /> <a href="roadmap.html">Roadmap</a><br /> <a href="docs/support.html">Support</a><br /> - <a href="users.html">Who's using Bazel</a> + <a href="https://github.com/bazelbuild/bazel/wiki/Bazel-Users">Who's using Bazel</a> </p> </div> </div> diff --git a/site/users.md b/site/users.md deleted file mode 100644 index d0244b40beba57..00000000000000 --- a/site/users.md +++ /dev/null @@ -1,150 +0,0 @@ ---- -layout: contribute -title: Bazel Users ---- - -# Corporate users of Bazel - -## [Ascend.io](https://ascend.io) - -Ascend is a Palo Alto startup that offers solutions for large data sets -analysis. Their motto is _Big data is hard. We make it easy_. - -## [Beeswax](https://www.beeswax.com/) (_in their own words_) - -"_Beeswax is a New York based startup that provides real time bidding as -service. Bazel powers their Jenkins based continuous integration and deployment -framework. Beeswax loves Bazel because it is blazingly fast, correct and well -supported across many languages and platforms._" - -## [Braintree](https://www.braintreepayments.com) - -Braintree, a PayPal subsidiary, develops payment solutions for websites and -applications. They use Bazel for parts of their internal build and Paul Gross -even posted a [nice piece about how their switch to -Bazel went](https://www.pgrs.net/2015/09/01/migrating-from-gradle-to-bazel/). - -## [Databricks](https://databricks.com) - -Databricks provides cloud-based integrated workspaces based on Apache Spark™. - -## [Interaxon](https://www.choosemuse.com/) - -InteraXon is a thought-controlled computing firm that creates hardware and -software platforms to convert brainwaves into digital signals. - -## [Improbable.io](https://improbable.io/) - -Improbable.io develops SpatialOS, a distributed operating system that enables -creating huge simulations inhabited by millions of complex entities. - -## [Makani](https://www.google.com/makani) - -Makani, now a Google subsidiary, develops energy kites and uses -Bazel to build their software (including their embedded C++ software). - -## [Peloton Technology](http://www.peloton-tech.com) - -Peloton Technology is an automated vehicle technology company that tackles -truck accidents and fuel use. They use Bazel to _enable reliable builds for -automotive safety systems_. - -## [Stripe](https://stripe.com) - -Stripe provides mobile payment solutions. They are the main maintainers of the -[Bazel Scala rules](https://github.com/bazelbuild/rules_scala). - -# Open-source projects using Bazel - -If you'd like your project listed here, please -[let us know](mailto:kchodorow@google.com?subject=My project uses Bazel)! - -## [CallBuilder](https://github.com/google/CallBuilder) - -A Java code generator that allows you to create a builder by writing one -function. - -## [Copybara](https://github.com/google/copybara) - -Copybara is a tool for transforming and moving code between repositories. - -## [Deepmind Lab](https://github.com/deepmind/lab) - -A customisable 3D platform for agent-based AI research. - -## [Error Prone](https://github.com/google/error-prone) - -Catches common Java mistakes as compile-time errors. (Migration to Bazel is -in progress.) - -## [FFruit](https://gitlab.com/perezd/ffruit/) - -FFruit is a free & open source Android application to the popular service -[Falling Fruit](https://fallingfruit.org). - -## [Gerrit Code Review](https://gerritcodereview.com) - -Gerrit is a code review and project management tool for Git based projects. - -## [Gitiles](https://gerrit.googlesource.com/gitiles/) - -Gitiles is a simple repository browser for Git repositories, built on JGit. - -## [GRPC](http://www.grpc.io) - -A language-and-platform-neutral remote procedure call system. (Bazel is a -supported, although not primary, build system.) - -## [Gulava](http://www.github.com/google/gulava/) - -A Java code generator that lets you write Prolog-style predicates and use them -seamlessly from normal Java code. - -## [Heron](http://twitter.github.io/heron/) - -Heron is a realtime, distributed, fault-tolerant stream processing engine -from Twitter. - -## [Jsonnet](http://google.github.io/jsonnet/doc/) - -An elegant, formally-specified config generation language for JSON. (Bazel is a -supported build system.) - -## [Kythe](https://github.com/google/kythe) - -An ecosystem for building tools that work with code. - -## [Nomulus](https://github.com/google/nomulus) - -Top-level domain name registry service on Google App Engine. - -## [PetitParser for Java](https://github.com/petitparser/java-petitparser) - -Grammars for programming languages are traditionally specified statically. They -are hard to compose and reuse due to ambiguities that inevitably arise. -PetitParser combines ideas from scannnerless parsing, parser combinators, -parsing expression grammars and packrat parsers to model grammars and parsers -as objects that can be reconfigured dynamically. - -## [TensorFlow](http://tensorflow.org) - -An open source software library for machine intelligence. - -## [Trunk](https://github.com/mzhaom/trunk) - -A collection of C++/Java opensource projects with BUILD files so they -can be built with Bazel with out of box support for protobuf and -grpc (maybe thrift). - -## [Turbo Santa](https://github.com/turbo-santa/turbo-santa-common) - -A platform-independent GameBoy emulator. - -## [Wycheproof](https://github.com/google/wycheproof) - -Project Wycheproof tests crypto libraries against known attacks. - -## [XIOSim](https://github.com/s-kanev/XIOSim) - -XIOSim is a detailed user-mode microarchitectural simulator for the x86 architecture. -
null
train
train
2017-01-24T17:20:54
2017-01-23T13:49:02Z
steren
test
bazelbuild/bazel/2438_2439
bazelbuild/bazel
bazelbuild/bazel/2438
bazelbuild/bazel/2439
[ "timestamp(timedelta=0.0, similarity=0.912943864111191)" ]
930fa9b24cb7b1e516f92a200d9087fd3ba561e5
bed2d816360879ae40dfce93a7bb5771dcdf9a99
[]
[ "s/install/installed/\r\n\r\nAlso, `bazel version` instead of `$ bazel` (don't include the $ for inline snippets).", "s/install/installed/\r\n\r\nAlso, `bazel version` instead of `$ bazel` (don't include the $ for inline snippets).", "This seems like useful info to have.", "fixed", "fixed\r\n", "fixed" ]
2017-01-27T09:56:37Z
[ "type: documentation (cleanup)", "P2" ]
Homebrew install steps are missing Java install
I followed https://bazel.build/versions/master/docs/install.html#mac-os-x and when I type `brew install bazel` I am told that Java 1.8+ is required. Following Java install steps at https://bazel.build/versions/master/docs/install.html#1-install-jdk-8-2 works
[ "site/versions/master/docs/install.md" ]
[ "site/versions/master/docs/install.md" ]
[]
diff --git a/site/versions/master/docs/install.md b/site/versions/master/docs/install.md index 0a6f9e5b0cbfaf..a7faca3cc6c56a 100644 --- a/site/versions/master/docs/install.md +++ b/site/versions/master/docs/install.md @@ -136,25 +136,31 @@ You can also add this command to your `~/.bashrc` file. Install Bazel on Mac OS X using one of the following methods: - * [Using Homebrew](#install-on-mac-os-x-homebrew) - * [Using binary installer](#install-with-installer-mac-os-x) + * [Install using Homebrew](#install-on-mac-os-x-homebrew) + * [Install with installer](#install-with-installer-mac-os-x) * [Compiling Bazel from source](#compiling-from-source) -### <a name="install-on-mac-os-x-homebrew"></a>Using Homebrew +### <a name="install-on-mac-os-x-homebrew"></a>Install using Homebrew -#### 1. Install Homebrew on Mac OS X (one time setup) +#### 1. Install JDK 8 + +JDK 8 can be downloaded from +[Oracle's JDK Page](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). +Look for "Mac OS X x64" under "Java SE Development Kit". This will download a +DMG image with an install wizard. + +#### 2. Install Homebrew on Mac OS X (one time setup) `$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` -#### 2. Install Bazel Homebrew Package +#### 3. Install Bazel Homebrew Package `$ brew install bazel` -Once installed, you can upgrade to newer version of Bazel with: - -`$ brew upgrade bazel` +You are all set. You can confirm Bazel is installed successfully by running `bazel version`. +You can later upgrade to newer version of Bazel with `brew upgrade bazel`. ### <a name="install-with-installer-mac-os-x"></a>Install with installer @@ -216,6 +222,7 @@ $ export PATH="$PATH:$HOME/bin" You can also add this command to your `~/.bashrc` file. +You are all set. You can confirm Bazel is installed successfully by running `bazel version`. ## <a name="windows"></a>Windows
null
train
train
2017-01-27T00:05:39
2017-01-27T09:48:03Z
steren
test
bazelbuild/bazel/2571_3316
bazelbuild/bazel
bazelbuild/bazel/2571
bazelbuild/bazel/3316
[ "timestamp(timedelta=0.0, similarity=0.9664825861331298)" ]
259c9e8014ad960985c0ed99db2a879cdd2ac301
4adeaf9053686cbcd924d4d9298a4751f36f4cc3
[ "@philwo can you take a look at this?", "I would like to take this issue up.. ", "@philwo, @iirina any progress on this yet?", "@aljabrr I don't think anyone of us is working on it. Please feel free to send a patch via Gerrit. :)\r\n\r\nThe help string for that option is here:\r\n\r\nhttps://github.com/bazelb...
[ "Not only for tests, I would change this to:\r\n\r\n'standalone' means run all of them locally without any kind of sandboxing", "This is also wrong by now, it should read:\r\n\r\n'sandboxed' means to run them in a sandboxed environment with limited privileges (details depend on platform support)", "Thanks for t...
2017-07-03T09:57:10Z
[ "type: feature request", "type: documentation (cleanup)", "P4", "category: sandboxing", "good first issue" ]
Document --spawn_strategy=standalone for test
### Description of the problem / feature request / question: `--spawn_strategy=standalone` actually disables sandboxing for tests. This is IMO not clear since the option is documented under _BuildOptions_. Make it clear that it also applies for testing.
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java index 512b5c0f3b1c8f..cc72ec77ed19db 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelStrategyModule.java @@ -43,8 +43,8 @@ public static class BazelExecutionOptions extends OptionsBase { effectTags = {OptionEffectTag.UNKNOWN}, help = "Specify how spawn actions are executed by default." - + "'standalone' means run all of them locally." - + "'sandboxed' means run them in namespaces based sandbox (available only on Linux)" + + "'standalone' means run all of them locally without any kind of sandboxing." + + "'sandboxed' means to run them in a sandboxed environment with limited privileges (details depend on platform support)" ) public String spawnStrategy;
null
train
train
2017-07-03T09:06:52
2017-02-22T16:50:06Z
abergmeier-dsfishlabs
test
bazelbuild/bazel/2958_2959
bazelbuild/bazel
bazelbuild/bazel/2958
bazelbuild/bazel/2959
[ "timestamp(timedelta=1.0, similarity=0.9331296354628537)" ]
8e006399c42830855da11898db6707ac9f759762
460ee6fab073865bd36d55daf8073dd5d6bbaaba
[ "You mean that having a ~/.bazelrc is no longer mandatory so the installer\nshouldn't try to create one?\nOn Sat, 6 May 2017 at 10:29 Philipp Wollermann <notifications@github.com>\nwrote:\n\n> The Bazel installer currently moves ~/.bazelrc to ~/.bazelrc.bak and\n> creates an empty file instead, which is rather anno...
[]
2017-05-06T07:35:54Z
[ "P2" ]
Bazel installer should not overwrite ~/.bazelrc
The Bazel installer currently moves ~/.bazelrc to ~/.bazelrc.bak and creates an empty file instead, which is rather annoying. We should change the installer to not touch the file.
[ "scripts/packages/template_bin.sh" ]
[ "scripts/packages/template_bin.sh" ]
[]
diff --git a/scripts/packages/template_bin.sh b/scripts/packages/template_bin.sh index c35b2463d64388..906a3871d3bcea 100755 --- a/scripts/packages/template_bin.sh +++ b/scripts/packages/template_bin.sh @@ -41,25 +41,20 @@ usage() { echo " --prefix=/some/path set the prefix path (default=/usr/local)." >&2 echo " --bin= set the binary folder path (default=%prefix%/bin)." >&2 echo " --base= set the base install path (default=%prefix%/lib/bazel)." >&2 - echo " --bazelrc= set the path to bazelrc (default=/etc/bazel.bazelrc)." >&2 echo " --user configure for user install, expands to:" >&2 - echo ' --bin=$HOME/bin --base=$HOME/.bazel --bazelrc=$HOME/.bazelrc' >&2 + echo ' --bin=$HOME/bin --base=$HOME/.bazel' >&2 exit 1 } prefix="/usr/local" bin="%prefix%/bin" base="%prefix%/lib/bazel" -bazelrc="/etc/bazel.bazelrc" for opt in "${@}"; do case $opt in --prefix=*) prefix="$(echo "$opt" | cut -d '=' -f 2-)" ;; - --bazelrc=*) - bazelrc="$(echo "$opt" | cut -d '=' -f 2-)" - ;; --bin=*) bin="$(echo "$opt" | cut -d '=' -f 2-)" ;; @@ -69,7 +64,6 @@ for opt in "${@}"; do --user) bin="$HOME/bin" base="$HOME/.bazel" - bazelrc="$HOME/.bazelrc" ;; *) usage @@ -79,7 +73,6 @@ done bin="${bin//%prefix%/${prefix}}" base="${base//%prefix%/${prefix}}" -bazelrc="${bazelrc//%prefix%/${prefix}}" test_write() { local file="$1" @@ -133,7 +126,6 @@ fi # Test for write access test_write "${bin}" test_write "${base}" -test_write "${bazelrc}" # Do the actual installation echo -n "Uncompressing." @@ -159,17 +151,7 @@ echo -n . ln -s "${base}/bin/bazel" "${bin}/bazel" echo -n . -if [ -f "${bazelrc}" ]; then - echo - echo "${bazelrc} already exists, moving it to ${bazelrc}.bak." - mv "${bazelrc}" "${bazelrc}.bak" -fi - -# Not necessary, but this way it matches the Debian package. -touch "${bazelrc}" -if [ "${UID}" -eq 0 ]; then - chmod 0644 "${bazelrc}" -else +if [ "${UID}" -ne 0 ]; then # Uncompress the bazel base install for faster startup time "${bin}/bazel" help >/dev/null fi
null
train
train
2017-05-05T23:20:14
2017-05-06T07:29:40Z
philwo
test
bazelbuild/bazel/2988_5905
bazelbuild/bazel
bazelbuild/bazel/2988
bazelbuild/bazel/5905
[ "timestamp(timedelta=0.0, similarity=0.8717960914532032)" ]
2d3adfb93c023f9752f00d4bf3440ee9869f64f2
421dfcaa179644d84966ec0bd88a05bd30c0da35
[ "any updates on this?", "No updates yet -- we'll be chatting about this over the next few business days to prioritize.", "Is there a hint so that we could fix it and perhaps submit a PR ?", "We're not likely to get to this ourselves; we deemed this low priority internally.\r\nIf you'd like to go ahead and cre...
[]
2018-08-16T00:36:58Z
[ "under investigation", "category: rules > ObjC / iOS / J2ObjC" ]
Feature Request: Objc Library Module Name
I'd like the ability to control the module name created by the objc_library rule. For more details refer to https://github.com/bazelbuild/rules_apple/issues/51.
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java", "src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java", "src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java", "src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRu...
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java", "src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java", "src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java", "src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRu...
[ "src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java index 602089b691fb3f..37cc3ee659013d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java @@ -49,10 +49,10 @@ public final class CppModuleMapAction extends AbstractFileWriteAction { // C++ module map of the current target private final CppModuleMap cppModuleMap; - + /** * If set, the paths in the module map are relative to the current working directory instead - * of relative to the module map file's location. + * of relative to the module map file's location. */ private final boolean moduleMapHomeIsCwd; @@ -217,7 +217,7 @@ private void appendHeader(Appendable content, String visibilitySpecifier, } content.append("\n"); } - + private boolean shouldCompileHeader(PathFragment path) { return compiledModule && !CppFileTypes.CPP_TEXTUAL_INCLUDE.matches(path); } @@ -258,6 +258,9 @@ protected void computeKey(ActionKeyContext actionKeyContext, Fingerprint fp) { fp.addBoolean(externDependencies); } + @VisibleForTesting + public CppModuleMap getCppModuleMap() { return cppModuleMap; } + @VisibleForTesting public Collection<Artifact> getPublicHeaders() { return publicHeaders; @@ -267,7 +270,7 @@ public Collection<Artifact> getPublicHeaders() { public Collection<Artifact> getPrivateHeaders() { return privateHeaders; } - + @VisibleForTesting public ImmutableList<PathFragment> getAdditionalExportedHeaders() { return additionalExportedHeaders; diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 5ef84aba9b088c..a1d423a946f4bb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -604,6 +604,10 @@ static final class ExtraCompileArgs extends IterableWrapper<String> { static final String FILE_IN_SRCS_AND_NON_ARC_SRCS_ERROR_FORMAT = "File '%s' is present in both srcs and non_arc_srcs which is forbidden."; + @VisibleForTesting + static final String BOTH_MODULE_NAME_AND_MODULE_MAP_SPECIFIED = + "Specifying both module_name and module_map is invalid, please remove one of them."; + static final ImmutableList<String> DEFAULT_COMPILER_FLAGS = ImmutableList.of("-DOS_IOS"); static final ImmutableList<String> DEFAULT_LINKER_FLAGS = ImmutableList.of("-ObjC"); @@ -936,6 +940,12 @@ CompilationSupport validateAttributes() throws RuleErrorException { } } + if (ruleContext.attributes().isAttributeValueExplicitlySpecified("module_name") + && ruleContext.attributes().isAttributeValueExplicitlySpecified("module_map")) { + ruleContext.attributeError( + "module_name", BOTH_MODULE_NAME_AND_MODULE_MAP_SPECIFIED); + } + ruleContext.assertNoErrors(); return this; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java index 90b46950371306..7c79a11c35bd1c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IntermediateArtifacts.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.rules.cpp.CppModuleMap.UmbrellaHeaderStrategy; +import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; @@ -370,15 +371,20 @@ public Artifact linkmap(String arch) { * {@link CppModuleMap} that provides the clang module map for this target. */ public CppModuleMap moduleMap() { - String moduleName = - ruleContext - .getLabel() - .toString() - .replace("//", "") - .replace("@", "") - .replace("-", "_") - .replace("/", "_") - .replace(":", "_"); + String moduleName; + if (ruleContext.attributes().isAttributeValueExplicitlySpecified("module_name")) { + moduleName = ruleContext.attributes().get("module_name", Type.STRING); + } else { + moduleName = + ruleContext + .getLabel() + .toString() + .replace("//", "") + .replace("@", "") + .replace("-", "_") + .replace("/", "_") + .replace(":", "_"); + } Optional<Artifact> customModuleMap = CompilationSupport.getCustomModuleMap(ruleContext); if (customModuleMap.isPresent()) { return new CppModuleMap(customModuleMap.get(), moduleName); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index c17fa0692650b3..2270b281768d31 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -684,6 +684,11 @@ Enables clang module support (via -fmodules). provided module map to the compiler. <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/ .add(attr("module_map", LABEL).allowedFileTypes(FileType.of(".modulemap"))) + /* <!-- #BLAZE_RULE($objc_compiling_rule).ATTRIBUTE(module_name) --> + Sets the module name for this target. By default the module name is the target path with + all special symbols replaced by _, e.g. //foo/baz:bar can be imported as foo_baz_bar. + <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/ + .add(attr("module_name", STRING)) /* Provides the label for header_scanner tool that is used to scan inclusions for ObjC sources and provide a list of required headers via a .header_list file.
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java index 16aee317cbf29a..a4a45892fca126 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseArtifactNames; import static com.google.devtools.build.lib.rules.objc.CompilationSupport.ABSOLUTE_INCLUDES_PATH_FORMAT; +import static com.google.devtools.build.lib.rules.objc.CompilationSupport.BOTH_MODULE_NAME_AND_MODULE_MAP_SPECIFIED; import static com.google.devtools.build.lib.rules.objc.CompilationSupport.FILE_IN_SRCS_AND_HDRS_WARNING_FORMAT; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.ASSET_CATALOG; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE; @@ -52,6 +53,7 @@ import com.google.devtools.build.lib.rules.apple.ApplePlatform; import com.google.devtools.build.lib.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.cpp.CppCompileAction; +import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction; import com.google.devtools.build.lib.rules.cpp.LinkerInput; import com.google.devtools.build.lib.rules.objc.ObjcProvider.Key; @@ -587,6 +589,15 @@ public void testObjcCopts_argumentOrdering() throws Exception { assertThat(args).containsAllOf("-fobjc-arc", "-foo", "-bar").inOrder(); } + @Test + public void testBothModuleNameAndModuleMapGivesError() throws Exception { + checkError( + "x", + "x", + BOTH_MODULE_NAME_AND_MODULE_MAP_SPECIFIED, + "objc_library( name = 'x', module_name = 'x', module_map = 'x.modulemap' )"); + } + @Test public void testCompilationActionsWithModuleMapsEnabled() throws Exception { useConfiguration( @@ -676,6 +687,22 @@ public void testCompilationActionsWithBitcode_simulator() throws Exception { assertThat(compileActionA.getArguments()).doesNotContain("-fembed-bitcode-marker"); } + @Test + public void testModuleNameAttributeChangesName() throws Exception { + RULE_TYPE.scratchTarget( + scratch, + "module_name", + "'foo'"); + + ConfiguredTarget configuredTarget = getConfiguredTarget("//x:x"); + Artifact moduleMap = getGenfilesArtifact("x.modulemaps/module.modulemap", configuredTarget); + + CppModuleMapAction genMap = (CppModuleMapAction) getGeneratingAction(moduleMap); + + CppModuleMap cppModuleMap = genMap.getCppModuleMap(); + assertThat(cppModuleMap.getName()).isEqualTo("foo"); + } + @Test public void testModuleMapActionFiltersHeaders() throws Exception { RULE_TYPE.scratchTarget( @@ -692,6 +719,10 @@ public void testModuleMapActionFiltersHeaders() throws Exception { assertThat(Artifact.toRootRelativePaths(genMap.getPrivateHeaders())).isEmpty(); assertThat(Artifact.toRootRelativePaths(genMap.getPublicHeaders())).containsExactly("x/a.h"); + + // now check the generated name + CppModuleMap cppModuleMap = genMap.getCppModuleMap(); + assertThat(cppModuleMap.getName()).isEqualTo("x_x"); } @Test
train
train
2018-08-22T17:58:03
2017-05-11T08:14:43Z
lswith
test
bazelbuild/bazel/3000_3002
bazelbuild/bazel
bazelbuild/bazel/3000
bazelbuild/bazel/3002
[ "timestamp(timedelta=0.0, similarity=0.894002445849351)" ]
b44c9f7dd969a1f61eb45627100d0f78943e3d31
97e42376d065bec2fb3eb9afa640de0af1ad6810
[ "I'm actually not sure why it doesn't pick this up automatically, but it seems to only be looking for crosstools in `@local_config_cc`, which doesn't contain a ppc crosstool (?). You have to give the `--crosstool_top=//tools/cpp:default-toolchain` argument to make it look at //tools/cpp, which _does_ contain a ppc...
[ "nit: add missing space after the comma." ]
2017-05-12T17:03:11Z
[ "type: bug", "P2", "platform: other" ]
Compile Bazel on Power8
Hi! I am trying to compile Bazel from source on a Power 8 machine. Here's the error I get when launching "bash compile.sh" 🍃 Building Bazel from scratch....... 🍃 Building Bazel with Bazel. ERROR: No toolchain found for cpu 'ppc'. Valid cpus are: [ piii, armeabi-v7a, x64_windows_msvc, x64_windows_msys, s390x, ios_x86_64, ]. INFO: Elapsed time: 2.181s ERROR: Could not build Bazel The output from uname -a: 4.7.4-200.fc24.ppc64 #1 SMP Thu Sep 22 17:40:37 UTC 2016 ppc64 ppc64 ppc64 GNU/Linux Do you have any idea of why I get this error? Thank you
[ "tools/cpp/CROSSTOOL", "tools/cpp/cc_configure.bzl" ]
[ "tools/cpp/CROSSTOOL", "tools/cpp/cc_configure.bzl" ]
[]
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL index bb22006090ab08..d70a6dcb604908 100644 --- a/tools/cpp/CROSSTOOL +++ b/tools/cpp/CROSSTOOL @@ -44,6 +44,11 @@ default_toolchain { toolchain_identifier: "local_linux" } +default_toolchain { + cpu: "ppc64" + toolchain_identifier: "local_linux" +} + default_toolchain { cpu: "ios_x86_64" toolchain_identifier: "ios_x86_64" diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index 4f93195d26b999..ae87934b68ce49 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -161,7 +161,7 @@ def _get_cpu_value(repository_ctx): return "x64_windows" # Use uname to figure out whether we are on x86_32 or x86_64 result = repository_ctx.execute(["uname", "-m"]) - if result.stdout.strip() in ["power", "ppc64le", "ppc"]: + if result.stdout.strip() in ["power", "ppc64le", "ppc", "ppc64"]: return "ppc" if result.stdout.strip() in ["arm", "armv7l", "aarch64"]: return "arm"
null
train
train
2017-05-12T17:14:15
2017-05-12T14:16:31Z
davideleoni90
test
bazelbuild/bazel/3102_3697
bazelbuild/bazel
bazelbuild/bazel/3102
bazelbuild/bazel/3697
[ "timestamp(timedelta=0.0, similarity=0.9105872551600119)" ]
312578105fdf73ce56eed1de06ab2950cfbea0f5
dbf57a8530e3fd5845ffcfab2c648307848127b0
[ "Thanks for the bug report! Unfortunately we have no capacity to fix it now, so I'm marking it P4 to indicate that we need external help to fix it. Would you be interested in fixing it?" ]
[ "Why not use Locale.US here. That seems to more clearly document the purpose. Also, might want to add a comment on why we provide a locale here.", "Maybe the test should reset the locale before it returns?" ]
2017-09-07T11:07:30Z
[ "type: feature request", "P4", "category: misc > misc", "good first issue" ]
HtmlChart is uncolored
### Description of the problem / feature request / question: Legend and Chart are completely white. ![bildschirmfoto 2017-06-02 um 11 51 27](https://cloud.githubusercontent.com/assets/28805183/26720825/e64d9e32-4789-11e7-929a-f32b1a79a39c.png) ### Environment info * Operating System: MacOSX * Bazel version: release 0.4.5-homebrew ### Reason css color values `background-color:rgba(102,153,204,1,000000)` are not valid . This should be a result of german decimal separator ','. ### Solution force '.' as decimal separator.
[ "src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java" ]
[ "src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java" ]
[ "src/test/java/com/google/devtools/build/lib/profiler/ProfilerChartTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java index 4649326b312772..170334df66dc35 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/chart/HtmlChartVisitor.java @@ -16,6 +16,7 @@ import java.io.PrintStream; import java.util.List; +import java.util.Locale; /** * {@link ChartVisitor} that builds HTML from the visited chart and prints it @@ -313,13 +314,14 @@ private void anchor(String name) { /** * Formats the given {@link Color} to a css style color string. */ - private String formatColor(Color color) { + public static String formatColor(Color color) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); int a = color.getAlpha(); - return String.format("rgba(%d,%d,%d,%f)", r, g, b, (a / 255.0)); + // US Locale is used to ensure a dot as decimal separator + return String.format(Locale.US, "rgba(%d,%d,%d,%f)", r, g, b, (a / 255.0)); } /**
diff --git a/src/test/java/com/google/devtools/build/lib/profiler/ProfilerChartTest.java b/src/test/java/com/google/devtools/build/lib/profiler/ProfilerChartTest.java index 0551881064fdea..b8f94567fb14a7 100644 --- a/src/test/java/com/google/devtools/build/lib/profiler/ProfilerChartTest.java +++ b/src/test/java/com/google/devtools/build/lib/profiler/ProfilerChartTest.java @@ -29,12 +29,16 @@ import com.google.devtools.build.lib.profiler.chart.ChartVisitor; import com.google.devtools.build.lib.profiler.chart.Color; import com.google.devtools.build.lib.profiler.chart.DetailedChartCreator; +import com.google.devtools.build.lib.profiler.chart.HtmlChartVisitor; import com.google.devtools.build.lib.testutil.FoundationTestCase; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.Suite; import com.google.devtools.build.lib.testutil.TestSpec; import com.google.devtools.build.lib.vfs.Path; + import java.util.List; +import java.util.Locale; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -230,6 +234,18 @@ public void testVisitor() throws Exception { assertThat(visitor.lineCount).isEqualTo(0); } + @Test + public void testHtmlChartVisitorFormatColor() { + Locale defaultLocale = Locale.getDefault(); + + Locale.setDefault(Locale.GERMANY); + String black = HtmlChartVisitor.formatColor(Color.GRAY); + String[] grayComponents = black.split(","); + assertThat(grayComponents.length).isEqualTo(4); + + Locale.setDefault(defaultLocale); + } + private ProfileInfo createProfileInfo(Runnable runnable, int noOfRows) throws Exception { Scratch scratch = new Scratch(); Path cacheDir = scratch.dir("/tmp");
test
train
2017-09-07T11:51:25
2017-06-02T10:07:21Z
ahippler
test
bazelbuild/bazel/3131_3140
bazelbuild/bazel
bazelbuild/bazel/3131
bazelbuild/bazel/3140
[ "timestamp(timedelta=0.0, similarity=0.8405917286274984)" ]
8242c502d04332291487a19907c5ee3d7566acfd
4ceb2c0abf3db9135ebb2cdb4cc2ebfc8cf56a01
[ "You're right, that's a holdover from the internal docs, and should be removed. Would you like to send a patch to remove it?" ]
[]
2017-06-07T18:24:25Z
[ "type: documentation (cleanup)", "P2" ]
Docs describe nonexistent --local_genrule_timeout_seconds option
### Description of the problem / feature request / question: https://bazel.build/versions/master/docs/bazel-user-manual.html describes an option called `--local_genrule_timeout_seconds`, but I can't find any such option, or anything similar. Should this be removed from the docs?
[ "site/docs/bazel-user-manual.html" ]
[ "site/docs/bazel-user-manual.html" ]
[]
diff --git a/site/docs/bazel-user-manual.html b/site/docs/bazel-user-manual.html index f38f29f60e3f19..f16498cf2041f7 100644 --- a/site/docs/bazel-user-manual.html +++ b/site/docs/bazel-user-manual.html @@ -1824,9 +1824,6 @@ <h4 id='flag--genrule_strategy'><code class='flag'>--genrule_strategy <var>strat </ul> -<h4 id='flag--local_genrule_timeout_seconds'><code class='flag'>--local_genrule_timeout_seconds <var>seconds</var></code></h4> -<p>Sets a timeout value for local genrules with the given number of seconds.</p> - <h4 id='flag--jobs'><code class='flag'>--jobs <var>n</var></code> (-j)</h4> <p> This option, which takes an integer argument, specifies a limit on
null
val
train
2017-06-07T17:36:15
2017-06-06T16:08:27Z
mmorearty
test
bazelbuild/bazel/3193_3591
bazelbuild/bazel
bazelbuild/bazel/3193
bazelbuild/bazel/3591
[ "timestamp(timedelta=2790.0, similarity=0.8870933720382193)" ]
cfccdf1f6e93125d894ff40e0ccecaf20cc20ef5
4330769049823b08d6a40ab48efa70538d46bf46
[ "SHA1 is a bit outdated now, as is MD5. We should probably add support for - at least - SHA256.", "A good option might be `blake2`, which is secure and fast in software.", "SHA256 isn't exactly slow either and recent CPUs might even already have native instructions: https://en.wikipedia.org/wiki/Intel_SHA_exten...
[ "You probably meant SHA256 here", "Fixed!" ]
2017-08-21T12:27:21Z
[ "type: feature request", "P2" ]
Switch Bazel to a more secure hash by default (SHA256?)
Switch Bazel to a more secure hash by default (SHA256?).
[ "src/main/java/com/google/devtools/build/lib/remote/README.md", "src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java", "src/tools/remote_worker/BUILD", "src/tools/remote_worker/README.md" ]
[ "src/main/java/com/google/devtools/build/lib/remote/README.md", "src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java", "src/tools/remote_worker/BUILD", "src/tools/remote_worker/README.md" ]
[ "src/test/shell/bazel/remote_execution_sandboxing_test.sh", "src/test/shell/bazel/remote_execution_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/README.md b/src/main/java/com/google/devtools/build/lib/remote/README.md index e8487ec8b16db5..398ef89cb632f7 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/README.md +++ b/src/main/java/com/google/devtools/build/lib/remote/README.md @@ -26,7 +26,7 @@ For a quick setup, you can use Hazelcast's REST interface. Alternatively you can We recommend editing your `~/.bazelrc` to enable remote caching using the HTTP REST protocol. You will need to replace `http://server-address:port/cache` with the correct address for your HTTP REST server: ``` -startup --host_jvm_args=-Dbazel.DigestFunction=SHA1 +startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 build --spawn_strategy=remote build --remote_rest_cache=REPLACE_THIS:http://server-address:port/cache # Bazel currently doesn't support remote caching in combination with workers. @@ -39,7 +39,7 @@ build --strategy=Closure=remote #### Customizing The Digest Function -Bazel currently supports the following digest functions with the remote worker: SHA1, SHA256, and MD5. The digest function is passed via the `--host_jvm_args=-Dbazel.DigestFunction=###` startup option. In the example above, SHA1 is used, but you can use any one of SHA1, SHA256, and MD5, provided that your remote execution server supports it and is configured to use the same one. For example, the provided remote worker (`//src/tools/remote_worker`) is configured to use SHA1 by default in the binary build rule. You can customize it there by modifying the `jvm_flags` attribute to use, for example, `"-Dbazel.DigestFunction=SHA256"` instead. +Bazel currently supports the following digest functions with the remote worker: SHA1, SHA256, and MD5. The digest function is passed via the `--host_jvm_args=-Dbazel.DigestFunction=###` startup option. In the example above, SHA256 is used, but you can use any one of SHA1, SHA256, and MD5, provided that your remote execution server supports it and is configured to use the same one. For example, the provided remote worker (`//src/tools/remote_worker`) is configured to use SHA256 by default in the binary build rule. You can customize it there by modifying the `jvm_flags` attribute to use, for example, `"-Dbazel.DigestFunction=SHA1"` instead. ### Hazelcast with REST interface @@ -114,7 +114,7 @@ that supports both remote caching and remote execution. As of this writing, ther We recommend editing your `~/.bazelrc` to enable remote caching using the gRPC protocol. Use the following build options to use the gRPC CAS endpoint for sharing build artifacts. Change `REPLACE_THIS:address:8080` to the correct server address and port number. ``` -startup --host_jvm_args=-Dbazel.DigestFunction=SHA1 +startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 build --spawn_strategy=remote build --remote_cache=REPLACE_THIS:address:8080 # Bazel currently doesn't support remote caching in combination with workers. diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java index 13a7360532a72f..48704b97db8127 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystem.java @@ -76,7 +76,7 @@ public boolean isValidDigest(byte[] digest) { static { try { digestFunction = new HashFunction.Converter().convert( - System.getProperty("bazel.DigestFunction", "MD5")); + System.getProperty("bazel.DigestFunction", "SHA256")); } catch (OptionsParsingException e) { throw new IllegalStateException(e); } diff --git a/src/tools/remote_worker/BUILD b/src/tools/remote_worker/BUILD index ed5351d039ce8e..3190387a393d27 100644 --- a/src/tools/remote_worker/BUILD +++ b/src/tools/remote_worker/BUILD @@ -10,7 +10,7 @@ java_binary( # Enables REST for Hazelcast server for testing. "-Dhazelcast.rest.enabled=true", # Set this to the same function that you run Bazel with. - "-Dbazel.DigestFunction=SHA1", + "-Dbazel.DigestFunction=SHA256", ], main_class = "com.google.devtools.build.remote.RemoteWorker", visibility = ["//visibility:public"], diff --git a/src/tools/remote_worker/README.md b/src/tools/remote_worker/README.md index 32c912a0abdd2c..b4c213ce0ec3ea 100644 --- a/src/tools/remote_worker/README.md +++ b/src/tools/remote_worker/README.md @@ -13,7 +13,7 @@ The simplest setup is as follows: - Then you run Bazel pointing to the remote_worker instance. - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote --remote_cache=localhost:8080 \ --remote_executor=localhost:8080 src/tools/generate_workspace:all
diff --git a/src/test/shell/bazel/remote_execution_sandboxing_test.sh b/src/test/shell/bazel/remote_execution_sandboxing_test.sh index 38c1c2c04fdce4..0b1522381c3f1d 100755 --- a/src/test/shell/bazel/remote_execution_sandboxing_test.sh +++ b/src/test/shell/bazel/remote_execution_sandboxing_test.sh @@ -83,7 +83,7 @@ function tear_down() { } function test_genrule() { - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -92,7 +92,7 @@ function test_genrule() { } function test_genrule_can_write_to_path() { - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -103,7 +103,7 @@ function test_genrule_can_write_to_path() { } function test_genrule_cannot_write_to_other_path() { - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ diff --git a/src/test/shell/bazel/remote_execution_test.sh b/src/test/shell/bazel/remote_execution_test.sh index c81ce2ed528a04..b47fdaa5ef0f8b 100755 --- a/src/test/shell/bazel/remote_execution_test.sh +++ b/src/test/shell/bazel/remote_execution_test.sh @@ -83,7 +83,7 @@ EOF cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected bazel clean --expunge >& $TEST_log - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -106,7 +106,7 @@ EOF #include <iostream> int main() { std::cout << "Hello test!" << std::endl; return 0; } EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 test \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -133,7 +133,7 @@ EOF cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected bazel clean --expunge >& $TEST_log - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_cache=localhost:${worker_port} \ //a:test >& $TEST_log \ @@ -155,7 +155,7 @@ EOF #include <iostream> int main() { std::cout << "Fail me!" << std::endl; return 1; } EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 test \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -187,7 +187,7 @@ EOF cp -f bazel-genfiles/a/large_blob.txt ${TEST_TMPDIR}/large_blob_expected.txt bazel clean --expunge >& $TEST_log - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -215,7 +215,7 @@ EOF cp -f bazel-bin/a/test ${TEST_TMPDIR}/test_expected bazel clean --expunge >& $TEST_log - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_rest_cache=http://localhost:${hazelcast_port}/hazelcast/rest/maps/cache \ //a:test >& $TEST_log \ @@ -245,7 +245,7 @@ import sys if __name__ == "__main__": sys.exit(0) EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 test \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -278,7 +278,7 @@ if __name__ == "__main__": ''') sys.exit(0) EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 test \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -315,7 +315,7 @@ if __name__ == "__main__": ''') sys.exit(1) EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 test \ --spawn_strategy=remote \ --remote_executor=localhost:${worker_port} \ --remote_cache=localhost:${worker_port} \ @@ -347,7 +347,7 @@ load("//a:rule.bzl", "empty") package(default_visibility = ["//visibility:public"]) empty(name = 'test') EOF - bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 build \ + bazel --host_jvm_args=-Dbazel.DigestFunction=SHA256 build \ --spawn_strategy=remote \ --remote_cache=localhost:${worker_port} \ --test_output=errors \
train
train
2017-10-16T17:49:14
2017-06-14T14:39:10Z
ulfjack
test
bazelbuild/bazel/3256_4971
bazelbuild/bazel
bazelbuild/bazel/3256
bazelbuild/bazel/4971
[ "timestamp(timedelta=0.0, similarity=0.9268525109128359)" ]
ece8c4ede0b6d3ba9cb41a54233fd4343d14e0e7
183bfda296333e7a4806f52185029ec48d0c7767
[ "```\r\n$ bazel analyze-profile profile\r\njava.lang.NullPointerException\r\n\tat com.google.devtools.build.lib.runtime.commands.ProfileCommand.exec(ProfileCommand.java:251)\r\n\tat com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:552)\r\n\tat com.google.devto...
[ "There's no need to call new String() here. Just pass in \"<workspace>\"." ]
2018-04-06T13:05:53Z
[ "type: bug", "P1", "category: misc > misc" ]
Bazel analyze-profile crashes outside of a workspace
I think that's a recent regression.
[ "src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java" ]
[ "src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java index f39f0054b35774..b9f2fd7eb35813 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java @@ -281,11 +281,18 @@ public BlazeCommandResult exec(final CommandEnvironment env, OptionsProvider opt PhaseSummaryStatistics phaseSummaryStatistics = new PhaseSummaryStatistics(info); EnumMap<ProfilePhase, PhaseStatistics> phaseStatistics = new EnumMap<>(ProfilePhase.class); + + Path workspace = env.getWorkspace(); for (ProfilePhase phase : ProfilePhase.values()) { phaseStatistics.put( phase, new PhaseStatistics( - phase, info, env.getWorkspace().getBaseName(), opts.vfsStatsLimit > 0)); + phase, + info, + (workspace == null + ? "<workspace>" + : workspace.getBaseName()), + opts.vfsStatsLimit > 0)); } CriticalPathStatistics critPathStats = new CriticalPathStatistics(info);
null
train
train
2018-04-06T14:29:44
2017-06-23T11:17:18Z
ulfjack
test
bazelbuild/bazel/3285_3677
bazelbuild/bazel
bazelbuild/bazel/3285
bazelbuild/bazel/3677
[ "timestamp(timedelta=0.0, similarity=0.8864842583364211)" ]
663df9d96f10a2dd0fa8a85b4aac39cd2cc368fb
5b6b98fba2edf21231fc02fa52dc75021374f594
[ "+1!\nOn Wed, 28 Jun 2017 at 18:21 Kristina <notifications@github.com> wrote:\n\n> Right now we print something like:\n>\n> ** Please add the following dependencies:\n> //:C to //:A\n>\n> Now that buildozer is open sourced, it would be nice to give people a\n> one-liner to run.\n>\n> —\n> You are receiving this ...
[]
2017-09-04T07:38:33Z
[ "type: feature request", "P3" ]
Print buildozer command for "add the following deps" message
Right now we print something like: ``` ** Please add the following dependencies: //:C to //:A ``` Now that buildozer is open sourced, it would be nice to give people a one-liner to run.
[ "src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java" ]
[ "src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java" ]
[]
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java index 7d2ddb46b768c3..7167756fb9563f 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java @@ -334,7 +334,8 @@ public String get(Iterable<JarOwner> missing, String recipient, boolean useColor } return String.format( - "%s** Please add the following dependencies:%s\n %s to %s\n\n", + "%1$s ** Please add the following dependencies:%2$s \n %3$s to %4$s \n" + + "%1$s ** You can use the following buildozer command:%2$s \nbuildozer 'add deps %3$s' %4$s \n\n", useColor ? "\033[35m\033[1m" : "", useColor ? "\033[0m" : "", missingTargetsStr.toString(),
null
train
train
2017-09-01T20:08:38
2017-06-28T15:21:23Z
kchodorow
test
bazelbuild/bazel/3303_6967
bazelbuild/bazel
bazelbuild/bazel/3303
bazelbuild/bazel/6967
[ "timestamp(timedelta=169720.0, similarity=0.8471509188515058)" ]
d0e6e06be3adbf625b065b787db2053e630be5f1
86b8204af1ecfb84994e34f97e40cc9715c2c510
[ "The install docs are now versioned, and I also don't see hardcoded Bazel version numbers in the installation instructions anymore.\r\n\r\nhttps://docs.bazel.build/versions/0.20.0/install-windows.html\r\nhttps://docs.bazel.build/versions/0.20.0/install-ubuntu.html" ]
[]
2018-12-19T16:53:27Z
[ "type: feature request", "type: documentation (cleanup)" ]
Use a variable for latest Bazel version number in docs
Our install docs are often displaying the latest version number to download: http://docs.bazel.build/versions/master/install-ubuntu.html Today, this is hardcoded in the text. We should introduce a variable that is defined in one place and that we update when performing the release. https://github.com/bazelbuild/bazel/blob/master/site/_config.yml is probably the place to put this variable.
[ "scripts/docs/doc_versions.bzl", "site/_config.yml" ]
[ "scripts/docs/doc_versions.bzl", "site/_config.yml" ]
[]
diff --git a/scripts/docs/doc_versions.bzl b/scripts/docs/doc_versions.bzl index 4e4b76a5ffc52e..09f2c80aacfdd9 100644 --- a/scripts/docs/doc_versions.bzl +++ b/scripts/docs/doc_versions.bzl @@ -22,6 +22,10 @@ """This module contains the versions and hashes of Bazel's documentation tarballs.""" DOC_VERSIONS = [ + { + "version": "0.21.0", + "sha256": "23ec39c0138d358c544151e5c81586716d5d1c6124f10a742bead70516e6eb93", + }, { "version": "0.20.0", "sha256": "bb79a63810bf1b0aa1f89bd3bbbeb4a547a30ab9af70c9be656cc6866f4b015b", diff --git a/site/_config.yml b/site/_config.yml index 00f82998f49c69..9e82fe02e149d8 100644 --- a/site/_config.yml +++ b/site/_config.yml @@ -15,6 +15,7 @@ version: "master" # This must be kept in sync with //site/script/docs:versions.bzl doc_versions: - master + - 0.21.0 - 0.20.0 - 0.19.2 - 0.19.1
null
val
train
2018-12-19T17:29:59
2017-06-30T14:09:44Z
steren
test
bazelbuild/bazel/3432_6130
bazelbuild/bazel
bazelbuild/bazel/3432
bazelbuild/bazel/6130
[ "timestamp(timedelta=0.0, similarity=0.8480277078258937)" ]
5bf57be6ec4b63daa1956f38ea232a434eaf71cc
7d9fdb4f8525e68fb239fa7f04dc63180a3f2041
[ "I remember @ianthehat asked for this." ]
[ "What's the use case for defaults? Are they required for a constraint_setting or are they optional?\r\n\r\nFor example, if have `constraint_setting(name = \"macos_version\", default_constraint_value = \":osx10_11_6\")` and we build for platform `\"osx10_11_6\"`, does that risk pulling in toolchains that don't even ...
2018-09-11T17:13:23Z
[ "type: feature request", "P2" ]
Constraints should have defaults
constraint_setting() and constraint_value() should be allowed to select a default value to be used if none is specified in the platform.
[ "src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java" ]
[ "src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java" ]
[ "src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintCollectionApiTest.java", "src/test/java/com/google/devtools/build/lib/rules/platform/PlatformInfoApiTest.java", "src/test/shell/bazel/toolchain_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java index af9ac5701fef34..8f8629a1663a04 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/ConstraintCollection.java @@ -73,7 +73,12 @@ private ConstraintSettingInfo convertKey(Object key, Location loc) throws EvalEx @Nullable @Override public ConstraintValueInfo get(ConstraintSettingInfo constraint) { - return constraints.get(constraint); + if (constraints.containsKey(constraint)) { + return constraints.get(constraint); + } + + // Since this constraint isn't set, fall back to the default. + return constraint.defaultConstraintValue(); } @Override
diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintCollectionApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintCollectionApiTest.java index 5cb360d0fef9da..7a18c28dc99062 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintCollectionApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/ConstraintCollectionApiTest.java @@ -40,9 +40,11 @@ public class ConstraintCollectionApiTest extends PlatformInfoApiTest { @Test public void testConstraintSettings() throws Exception { - platformBuilder().addConstraint("s1", "value1").addConstraint("s2", "value2").build(); + constraintBuilder("//foo:s1").addConstraintValue("value1").write(); + constraintBuilder("//foo:s2").addConstraintValue("value2").write(); + platformBuilder("//foo:my_platform").addConstraint("value1").addConstraint("value2").write(); - ConstraintCollection constraintCollection = fetchConstraintCollection(); + ConstraintCollection constraintCollection = fetchConstraintCollection("//foo:my_platform"); assertThat(constraintCollection).isNotNull(); assertThat(collectLabels(constraintCollection.constraintSettings())) @@ -52,9 +54,11 @@ public void testConstraintSettings() throws Exception { @Test public void testGet() throws Exception { - platformBuilder().addConstraint("s1", "value1").addConstraint("s2", "value2").build(); + constraintBuilder("//foo:s1").addConstraintValue("value1").write(); + constraintBuilder("//foo:s2").addConstraintValue("value2").write(); + platformBuilder("//foo:my_platform").addConstraint("value1").addConstraint("value2").write(); - ConstraintCollection constraintCollection = fetchConstraintCollection(); + ConstraintCollection constraintCollection = fetchConstraintCollection("//foo:my_platform"); assertThat(constraintCollection).isNotNull(); ConstraintSettingInfo setting = @@ -66,7 +70,9 @@ public void testGet() throws Exception { @Test public void testGet_starlark() throws Exception { - platformBuilder().addConstraint("s1", "value1").addConstraint("s2", "value2").build(); + constraintBuilder("//foo:s1").addConstraintValue("value1").write(); + constraintBuilder("//foo:s2").addConstraintValue("value2").write(); + platformBuilder("//foo:my_platform").addConstraint("value1").addConstraint("value2").write(); scratch.file( "verify/verify.bzl", @@ -130,13 +136,43 @@ public void testGet_starlark() throws Exception { ConstraintSettingInfo.create(Label.parseAbsoluteUnchecked("//foo:s2"))); } + @Test + public void testGet_defaultConstraintValues() throws Exception { + constraintBuilder("//constraint/default:basic") + .defaultConstraintValue("foo") + .addConstraintValue("bar") + .write(); + constraintBuilder("//constraint/default:other").write(); + + platformBuilder("//constraint/default:plat_with_default").write(); + platformBuilder("//constraint/default:plat_without_default").addConstraint("bar").write(); + + ConstraintSettingInfo basicConstraintSetting = + fetchConstraintSettingInfo("//constraint/default:basic"); + ConstraintSettingInfo otherConstraintSetting = + fetchConstraintSettingInfo("//constraint/default:other"); + + ConstraintCollection constraintCollectionWithDefault = fetchConstraintCollection("//constraint/default:plat_with_default"); + assertThat(constraintCollectionWithDefault).isNotNull(); + assertThat(constraintCollectionWithDefault.get(basicConstraintSetting)).isNotNull(); + assertThat(constraintCollectionWithDefault.get(basicConstraintSetting).label()) + .isEqualTo(makeLabel("//constraint/default:foo")); + assertThat(constraintCollectionWithDefault.get(otherConstraintSetting)).isNull(); + + ConstraintCollection constraintCollectionWithoutDefault = fetchConstraintCollection("//constraint/default:plat_without_default"); + assertThat(constraintCollectionWithoutDefault).isNotNull(); + assertThat(constraintCollectionWithoutDefault.get(basicConstraintSetting)).isNotNull(); + assertThat(constraintCollectionWithoutDefault.get(basicConstraintSetting).label()) + .isEqualTo(makeLabel("//constraint/default:bar")); + } + private Set<Label> collectLabels(Collection<? extends ConstraintSettingInfo> settings) { return settings.stream().map(ConstraintSettingInfo::label).collect(Collectors.toSet()); } @Nullable - private ConstraintCollection fetchConstraintCollection() throws Exception { - PlatformInfo platformInfo = fetchPlatformInfo(); + private ConstraintCollection fetchConstraintCollection(String platformLabel) throws Exception { + PlatformInfo platformInfo = fetchPlatformInfo(platformLabel); if (platformInfo == null) { return null; } diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformInfoApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformInfoApiTest.java index f8c248c2d38a82..2e8b2498af8a58 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformInfoApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformInfoApiTest.java @@ -17,16 +17,16 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Multimap; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.platform.ConstraintSettingInfo; import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; -import java.util.Map; +import com.google.devtools.build.lib.cmdline.Label; +import java.util.ArrayList; +import java.util.List; import javax.annotation.Nullable; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,10 +38,11 @@ public class PlatformInfoApiTest extends BuildViewTestCase { @Test public void testPlatform() throws Exception { - platformBuilder().addConstraint("basic", "value1").build(); + constraintBuilder("//foo:basic").addConstraintValue("value1").write(); + platformBuilder("//foo:my_platform").addConstraint("value1").write(); assertNoEvents(); - PlatformInfo platformInfo = fetchPlatformInfo(); + PlatformInfo platformInfo = fetchPlatformInfo("//foo:my_platform"); assertThat(platformInfo).isNotNull(); ConstraintSettingInfo constraintSetting = ConstraintSettingInfo.create(makeLabel("//foo:basic")); @@ -53,91 +54,147 @@ public void testPlatform() throws Exception { @Test public void testPlatform_overlappingConstraintValueError() throws Exception { + List<String> lines = + new ImmutableList.Builder<String>() + .addAll( + constraintBuilder("//foo:basic") + .addConstraintValue("value1") + .addConstraintValue("value2") + .lines()) + .addAll( + platformBuilder("//foo:my_platform") + .addConstraint("value1") + .addConstraint("value2") + .lines()) + .build(); + checkError( "foo", "my_platform", "Duplicate constraint_values detected: " + "constraint_setting //foo:basic has [//foo:value1, //foo:value2]", - "constraint_setting(name = 'basic')", - "constraint_value(name = 'value1',", - " constraint_setting = ':basic',", - ")", - "constraint_value(name = 'value2',", - " constraint_setting = ':basic',", - ")", - "platform(name = 'my_platform',", - " constraint_values = [", - " ':value1',", - " ':value2',", - "])"); + lines.toArray(new String[] {})); } @Test public void testPlatform_remoteExecution() throws Exception { - platformBuilder().setRemoteExecutionProperties("foo: val1").build(); + platformBuilder("//foo:my_platform").setRemoteExecutionProperties("foo: val1").write(); assertNoEvents(); - PlatformInfo platformInfo = fetchPlatformInfo(); + PlatformInfo platformInfo = fetchPlatformInfo("//foo:my_platform"); assertThat(platformInfo).isNotNull(); assertThat(platformInfo.remoteExecutionProperties()).isEqualTo("foo: val1"); } - PlatformBuilder platformBuilder() { - return new PlatformBuilder(); + ConstraintBuilder constraintBuilder(String name) { + return new ConstraintBuilder(name); } - final class PlatformBuilder { - private final Multimap<String, String> constraints = HashMultimap.create(); - private String remoteExecutionProperties = ""; + final class ConstraintBuilder { + private final Label label; + private final List<String> constraintValues = new ArrayList<>(); + private String defaultConstraintValue = null; + + public ConstraintBuilder(String name) { + this.label = Label.parseAbsoluteUnchecked(name); + } - public PlatformBuilder addConstraint(String setting, String value) { - this.constraints.put(setting, value); + public ConstraintBuilder defaultConstraintValue(String defaultConstraintValue) { + this.defaultConstraintValue = defaultConstraintValue; + this.constraintValues.add(defaultConstraintValue); return this; } - public PlatformBuilder setRemoteExecutionProperties(String value) { - this.remoteExecutionProperties = value; + public ConstraintBuilder addConstraintValue(String constraintValue) { + this.constraintValues.add(constraintValue); return this; } - public void build() throws Exception { + public List<String> lines() { ImmutableList.Builder<String> lines = ImmutableList.builder(); - // Add the constraint settings. - for (String name : constraints.keySet()) { - lines.add("constraint_setting(name = '" + name + "')"); + // Add the constraint setting. + lines.add("constraint_setting(name = '" + label.getName() + "',"); + if (!Strings.isNullOrEmpty(defaultConstraintValue)) { + lines.add(" default_constraint_value = ':" + defaultConstraintValue + "',"); } + lines.add(")"); // Add the constraint values. - for (Map.Entry<String, String> entry : constraints.entries()) { + for (String constraintValue : constraintValues) { lines.add( "constraint_value(", - " name = '" + entry.getValue() + "',", - " constraint_setting = ':" + entry.getKey() + "',", + " name = '" + constraintValue + "',", + " constraint_setting = ':" + label.getName() + "',", ")"); } - // Add the platform. - lines.add("platform(", " name = 'my_platform',"); - if (!constraints.isEmpty()) { - lines.add(" constraint_values = ["); - for (String name : constraints.values()) { - lines.add(" ':" + name + "',"); - } - lines.add(" ],"); + return lines.build(); + } + + public void write() throws Exception { + List<String> lines = lines(); + String filename = label.getPackageFragment().getRelative("BUILD").getPathString(); + scratch.appendFile(filename, lines.toArray(new String[] {})); + } + } + + PlatformBuilder platformBuilder(String name) { + return new PlatformBuilder(name); + } + + final class PlatformBuilder { + private final Label label; + private final List<String> constraintValues = new ArrayList<>(); + private String remoteExecutionProperties = ""; + + public PlatformBuilder(String name) { + this.label = Label.parseAbsoluteUnchecked(name); + } + + public PlatformBuilder addConstraint(String value) { + this.constraintValues.add(value); + return this; + } + + public PlatformBuilder setRemoteExecutionProperties(String value) { + this.remoteExecutionProperties = value; + return this; + } + + public List<String> lines() { + ImmutableList.Builder<String> lines = ImmutableList.builder(); + + lines.add("platform(", " name = '" + label.getName() + "',"); + lines.add(" constraint_values = ["); + for (String name : constraintValues) { + lines.add(" ':" + name + "',"); } + lines.add(" ],"); if (!Strings.isNullOrEmpty(remoteExecutionProperties)) { lines.add(" remote_execution_properties = '" + remoteExecutionProperties + "',"); } lines.add(")"); - scratch.file("foo/BUILD", lines.build().toArray(new String[] {})); + return lines.build(); + } + + public void write() throws Exception { + List<String> lines = lines(); + String filename = label.getPackageFragment().getRelative("BUILD").getPathString(); + scratch.appendFile(filename, lines.toArray(new String[] {})); } } @Nullable - PlatformInfo fetchPlatformInfo() throws Exception { - ConfiguredTarget myRuleTarget = getConfiguredTarget("//foo:my_platform"); - return PlatformProviderUtils.platform(myRuleTarget); + ConstraintSettingInfo fetchConstraintSettingInfo(String label) throws Exception { + ConfiguredTarget target = getConfiguredTarget(label); + return PlatformProviderUtils.constraintSetting(target); + } + + @Nullable + PlatformInfo fetchPlatformInfo(String platformLabel) throws Exception { + ConfiguredTarget target = getConfiguredTarget(platformLabel); + return PlatformProviderUtils.platform(target); } } diff --git a/src/test/shell/bazel/toolchain_test.sh b/src/test/shell/bazel/toolchain_test.sh index 097e874641ca60..da8c639e36ca34 100755 --- a/src/test/shell/bazel/toolchain_test.sh +++ b/src/test/shell/bazel/toolchain_test.sh @@ -914,4 +914,88 @@ EOF expect_log "Selected execution platform //platforms:platform2_4" } +function test_default_constraint_values { + # Add test constraints and platforms. + mkdir -p platforms + cat >> platforms/BUILD <<EOF +package(default_visibility = ['//visibility:public']) +constraint_setting(name = 'setting1', default_constraint_value = ':value_foo') +constraint_value(name = 'value_foo', constraint_setting = ':setting1') +constraint_value(name = 'value_bar', constraint_setting = ':setting1') + +platform( + name = 'platform_default', + constraint_values = []) +platform( + name = 'platform_no_default', + constraint_values = [':value_bar']) +EOF + + # Add test toolchains using the constraints. + write_test_toolchain + cat >> BUILD <<EOF +load('//toolchain:toolchain_test_toolchain.bzl', 'test_toolchain') + +# Define the toolchains. +test_toolchain( + name = 'test_toolchain_impl_foo', + extra_str = 'foo', + visibility = ['//visibility:public']) + +test_toolchain( + name = 'test_toolchain_impl_bar', + extra_str = 'bar', + visibility = ['//visibility:public']) + +# Declare the toolchains. +toolchain( + name = 'test_toolchain_foo', + toolchain_type = '//toolchain:test_toolchain', + exec_compatible_with = [], + target_compatible_with = [ + # No constraint set, takes the default. + ], + toolchain = ':test_toolchain_impl_foo', + visibility = ['//visibility:public']) +toolchain( + name = 'test_toolchain_bar', + toolchain_type = '//toolchain:test_toolchain', + exec_compatible_with = [], + target_compatible_with = [ + # Explicitly sets a non-default value. + '//platforms:value_bar', + ], + toolchain = ':test_toolchain_impl_bar', + visibility = ['//visibility:public']) +EOF + + # Register the toolchains + cat >> WORKSPACE <<EOF +register_toolchains('//:test_toolchain_foo', '//:test_toolchain_bar') +EOF + + write_test_rule + mkdir -p demo + cat >> demo/BUILD <<EOF +load('//toolchain:rule_use_toolchain.bzl', 'use_toolchain') +# Use the toolchain. +use_toolchain( + name = 'use', + message = 'this is the rule') +EOF + + # Test some builds and verify which was used. + # This should use the default value. + bazel build \ + --platforms=//platforms:platform_default \ + //demo:use &> $TEST_log || fail "Build failed" + expect_log 'toolchain extra_str: "foo"' + + # This should use the explicit value. + bazel build \ + --platforms=//platforms:platform_no_default \ + //demo:use &> $TEST_log || fail "Build failed" + expect_log 'toolchain extra_str: "bar"' +} + run_suite "toolchain tests"
test
train
2018-09-11T17:40:38
2017-07-21T16:08:51Z
katre
test
bazelbuild/bazel/3502_6954
bazelbuild/bazel
bazelbuild/bazel/3502
bazelbuild/bazel/6954
[ "timestamp(timedelta=1.0, similarity=0.9352260033689938)" ]
0fbbb253b643b301205ee46fc015227b2fc7b6e7
df39c0b3f10db674253ce74f9c2e413ef3e97e47
[]
[]
2018-12-18T01:44:22Z
[ "type: documentation (cleanup)", "P2", "team-Bazel" ]
Link to individual flags in command line reference
We need be able to link to individual flags in the command line reference (https://docs.bazel.build/versions/master/command-line-reference.html) from elsewhere in the doc. To keep info consistent and fresh, flags should only be documented in one place, and this doc should be generated from the code's in-line doc (which is what's done in that reference topic). When flags are discussed elsewhere in the doc, should be able to deep link to the flag on that reference page.
[ "site/_sass/style.scss", "src/main/java/com/google/devtools/common/options/OptionsUsage.java" ]
[ "site/_sass/style.scss", "src/main/java/com/google/devtools/common/options/OptionsUsage.java" ]
[ "src/test/java/com/google/devtools/common/options/OptionsUsageTest.java" ]
diff --git a/site/_sass/style.scss b/site/_sass/style.scss index d2feac91d18882..6bbb8b755534d3 100644 --- a/site/_sass/style.scss +++ b/site/_sass/style.scss @@ -172,3 +172,10 @@ $md-shadow-3: rgba(0, 0, 0, .12); box-sizing: content-box !important; } } + +// Used for the Command-line Reference flag anchors. Linkifying the flag name +// causes it to turn $link-color (green), but we turn it red here to be consistent +// with the rest of the code block. +dd > code > a, dl > dt > code > a { + color: #c7254e; +} diff --git a/src/main/java/com/google/devtools/common/options/OptionsUsage.java b/src/main/java/com/google/devtools/common/options/OptionsUsage.java index 6dee0eb7acc655..cd6a48fd680584 100644 --- a/src/main/java/com/google/devtools/common/options/OptionsUsage.java +++ b/src/main/java/com/google/devtools/common/options/OptionsUsage.java @@ -200,8 +200,20 @@ static void getUsageHtml( String flagName = getFlagName(optionDefinition); String valueDescription = optionDefinition.getValueTypeHelpText(); String typeDescription = getTypeDescription(optionDefinition); - usage.append("<dt><code><a name=\"flag--").append(plainFlagName).append("\"></a>--"); - usage.append(flagName); + + usage + // Add the id of the flag to point anchor hrefs to it + .append("<dt id=\"flag--") + .append(plainFlagName) + .append("\">") + // Add the href to the id hash + .append("<code><a href=\"#flag--") + .append(plainFlagName) + .append("\">") + // Use the flag name as the link body + .append("--" + flagName) + .append("</a>"); + if (optionDefinition.usesBooleanValueSyntax() || optionDefinition.isVoidField()) { // Nothing for boolean, tristate, boolean_or_enum, or void options. } else if (!valueDescription.isEmpty()) { @@ -249,14 +261,21 @@ static void getUsageHtml( Preconditions.checkArgument(!expansion.isEmpty()); expandsMsg = new StringBuilder("Expands to:<br/>\n"); for (String exp : expansion) { - // TODO(ulfjack): We should link to the expanded flags, but unfortunately we don't + // TODO(jingwen): We link to the expanded flags here, but unfortunately we don't // currently guarantee that all flags are only printed once. A flag in an OptionBase that // is included by 2 different commands, but not inherited through a parent command, will - // be printed multiple times. + // be printed multiple times. Clicking on the flag will bring the user to its first + // definition. expandsMsg - .append("&nbsp;&nbsp;<code>") + .append("&nbsp;&nbsp;") + .append("<code><a href=\"#flag") + // Link to the '#flag--flag_name' hash. + // Some expansions are in the form of '--flag_name=value', so we drop everything from + // '=' onwards. + .append(escaper.escape(exp).split("=")[0]) + .append("\">") .append(escaper.escape(exp)) - .append("</code><br/>\n"); + .append("</a></code><br/>\n"); } } usage.append(expandsMsg.toString());
diff --git a/src/test/java/com/google/devtools/common/options/OptionsUsageTest.java b/src/test/java/com/google/devtools/common/options/OptionsUsageTest.java index 6f3550649bbe09..2520f80b31fc60 100644 --- a/src/test/java/com/google/devtools/common/options/OptionsUsageTest.java +++ b/src/test/java/com/google/devtools/common/options/OptionsUsageTest.java @@ -100,15 +100,15 @@ public void stringValue_longTerminalOutput() { public void stringValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_string")) .isEqualTo( - "<dt><code><a name=\"flag--test_string\"></a>" - + "--test_string=&lt;a string&gt</code> default: \"test string default\"</dt>\n" + "<dt id=\"flag--test_string\"><code><a href=\"#flag--test_string\">--test_string</a>" + + "=&lt;a string&gt</code> default: \"test string default\"</dt>\n" + "<dd>\n" + "a string-valued option to test simple option operations\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_string")) .isEqualTo( - "<dt><code><a name=\"flag--test_string\"></a>" - + "--test_string=&lt;a string&gt</code> default: \"test string default\"</dt>\n" + "<dt id=\"flag--test_string\"><code><a href=\"#flag--test_string\">--test_string</a>" + + "=&lt;a string&gt</code> default: \"test string default\"</dt>\n" + "<dd>\n" + "a string-valued option to test simple option operations\n" + "<br>Tags: \n" @@ -149,15 +149,17 @@ public void intValue_longTerminalOutput() { public void intValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("expanded_c")) .isEqualTo( - "<dt><code><a name=\"flag--expanded_c\"></a>" - + "--expanded_c=&lt;an integer&gt</code> default: \"12\"</dt>\n" + "<dt id=\"flag--expanded_c\"><code>" + + "<a href=\"#flag--expanded_c\">--expanded_c</a>" + + "=&lt;an integer&gt</code> default: \"12\"</dt>\n" + "<dd>\n" + "an int-value&#39;d flag used to test expansion logic\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("expanded_c")) .isEqualTo( - "<dt><code><a name=\"flag--expanded_c\"></a>" - + "--expanded_c=&lt;an integer&gt</code> default: \"12\"</dt>\n" + "<dt id=\"flag--expanded_c\"><code>" + + "<a href=\"#flag--expanded_c\">--expanded_c</a>" + + "=&lt;an integer&gt</code> default: \"12\"</dt>\n" + "<dd>\n" + "an int-value&#39;d flag used to test expansion logic\n" + "<br>Tags: \n" @@ -197,8 +199,8 @@ public void booleanValue_longTerminalOutput() { public void booleanValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("expanded_a")) .isEqualTo( - "<dt><code><a name=\"flag--expanded_a\"></a>" - + "--[no]expanded_a</code> default: \"true\"</dt>\n" + "<dt id=\"flag--expanded_a\"><code><a href=\"#flag--expanded_a\">" + + "--[no]expanded_a</a></code> default: \"true\"</dt>\n" + "<dd>\n" + "A boolean flag with unknown effect to test tagless usage text.\n" + "</dd>\n"); @@ -238,16 +240,18 @@ public void multipleValue_longTerminalOutput() { public void multipleValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_multiple_string")) .isEqualTo( - "<dt><code><a name=\"flag--test_multiple_string\"></a>" - + "--test_multiple_string=&lt;a string&gt</code> " + "<dt id=\"flag--test_multiple_string\"><code>" + + "<a href=\"#flag--test_multiple_string\">--test_multiple_string</a>" + + "=&lt;a string&gt</code> " + "multiple uses are accumulated</dt>\n" + "<dd>\n" + "a repeatable string-valued flag with its own unhelpful help text\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_multiple_string")) .isEqualTo( - "<dt><code><a name=\"flag--test_multiple_string\"></a>" - + "--test_multiple_string=&lt;a string&gt</code> " + "<dt id=\"flag--test_multiple_string\"><code>" + + "<a href=\"#flag--test_multiple_string\">--test_multiple_string</a>" + + "=&lt;a string&gt</code> " + "multiple uses are accumulated</dt>\n" + "<dd>\n" + "a repeatable string-valued flag with its own unhelpful help text\n" @@ -291,8 +295,9 @@ public void customConverterValue_longTerminalOutput() { public void customConverterValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_list_converters")) .isEqualTo( - "<dt><code><a name=\"flag--test_list_converters\"></a>" - + "--test_list_converters=&lt;a list of strings&gt</code> " + "<dt id=\"flag--test_list_converters\"><code>" + + "<a href=\"#flag--test_list_converters\">--test_list_converters</a>" + + "=&lt;a list of strings&gt</code> " + "multiple uses are accumulated</dt>\n" + "<dd>\n" + "a repeatable flag that accepts lists, but doesn&#39;t want to have lists of \n" @@ -300,8 +305,9 @@ public void customConverterValue_htmlOutput() { + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_list_converters")) .isEqualTo( - "<dt><code><a name=\"flag--test_list_converters\"></a>" - + "--test_list_converters=&lt;a list of strings&gt</code> " + "<dt id=\"flag--test_list_converters\"><code>" + + "<a href=\"#flag--test_list_converters\">--test_list_converters</a>" + + "=&lt;a list of strings&gt</code> " + "multiple uses are accumulated</dt>\n" + "<dd>\n" + "a repeatable flag that accepts lists, but doesn&#39;t want to have lists of \n" @@ -348,33 +354,33 @@ public void staticExpansionOption_longTerminalOutput() { public void staticExpansionOption_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_expansion")) .isEqualTo( - "<dt><code><a name=\"flag--test_expansion\"></a>" - + "--test_expansion</code></dt>\n" + "<dt id=\"flag--test_expansion\"><code><a href=\"#flag--test_expansion\">" + + "--test_expansion</a></code></dt>\n" + "<dd>\n" + "this expands to an alphabet soup.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--noexpanded_a</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_b=false</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_c</code><br/>\n" - + "&nbsp;&nbsp;<code>42</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n" - + "&nbsp;&nbsp;<code>bar</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--noexpanded_a\">--noexpanded_a</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_b\">--expanded_b=false</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_c\">--expanded_c</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag42\">42</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_d\">--expanded_d</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flagbar\">bar</a></code><br/>\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_expansion")) .isEqualTo( - "<dt><code><a name=\"flag--test_expansion\"></a>" - + "--test_expansion</code></dt>\n" + "<dt id=\"flag--test_expansion\"><code><a href=\"#flag--test_expansion\">" + + "--test_expansion</a></code></dt>\n" + "<dd>\n" + "this expands to an alphabet soup.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--noexpanded_a</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_b=false</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_c</code><br/>\n" - + "&nbsp;&nbsp;<code>42</code><br/>\n" - + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n" - + "&nbsp;&nbsp;<code>bar</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--noexpanded_a\">--noexpanded_a</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_b\">--expanded_b=false</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_c\">--expanded_c</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag42\">42</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_d\">--expanded_d</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flagbar\">bar</a></code><br/>\n" + "<br>Tags: \n" + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>" + "</dd>\n"); @@ -424,25 +430,27 @@ public void recursiveExpansionOption_longTerminalOutput() { public void recursiveExpansionOption_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_recursive_expansion_top_level")) .isEqualTo( - "<dt><code><a name=\"flag--test_recursive_expansion_top_level\"></a>" - + "--test_recursive_expansion_top_level</code></dt>\n" + "<dt id=\"flag--test_recursive_expansion_top_level\">" + + "<code><a href=\"#flag--test_recursive_expansion_top_level\">" + + "--test_recursive_expansion_top_level</a></code></dt>\n" + "<dd>\n" + "Lets the children do all the work.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle1</code><br/>\n" - + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle2</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_recursive_expansion_middle1\">--test_recursive_expansion_middle1</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_recursive_expansion_middle2\">--test_recursive_expansion_middle2</a></code><br/>\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_recursive_expansion_top_level")) .isEqualTo( - "<dt><code><a name=\"flag--test_recursive_expansion_top_level\"></a>" - + "--test_recursive_expansion_top_level</code></dt>\n" + "<dt id=\"flag--test_recursive_expansion_top_level\">" + + "<code><a href=\"#flag--test_recursive_expansion_top_level\">" + + "--test_recursive_expansion_top_level</a></code></dt>\n" + "<dd>\n" + "Lets the children do all the work.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle1</code><br/>\n" - + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle2</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_recursive_expansion_middle1\">--test_recursive_expansion_middle1</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_recursive_expansion_middle2\">--test_recursive_expansion_middle2</a></code><br/>\n" + "<br>Tags: \n" + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>" + "</dd>\n"); @@ -485,25 +493,25 @@ public void expansionToMultipleValue_longTerminalOutput() { public void expansionToMultipleValue_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_expansion_to_repeatable")) .isEqualTo( - "<dt><code><a name=\"flag--test_expansion_to_repeatable\"></a>" - + "--test_expansion_to_repeatable</code></dt>\n" + "<dt id=\"flag--test_expansion_to_repeatable\"><code><a href=\"#flag--test_expansion_to_repeatable\">--test_expansion_to_repeatable</a>" + + "</code></dt>\n" + "<dd>\n" + "Go forth and multiply, they said.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--test_multiple_string=expandedFirstValue</code><br/>\n" - + "&nbsp;&nbsp;<code>--test_multiple_string=expandedSecondValue</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_multiple_string\">--test_multiple_string=expandedFirstValue</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_multiple_string\">--test_multiple_string=expandedSecondValue</a></code><br/>\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_expansion_to_repeatable")) .isEqualTo( - "<dt><code><a name=\"flag--test_expansion_to_repeatable\"></a>" - + "--test_expansion_to_repeatable</code></dt>\n" + "<dt id=\"flag--test_expansion_to_repeatable\"><code><a href=\"#flag--test_expansion_to_repeatable\">--test_expansion_to_repeatable</a>" + + "</code></dt>\n" + "<dd>\n" + "Go forth and multiply, they said.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--test_multiple_string=expandedFirstValue</code><br/>\n" - + "&nbsp;&nbsp;<code>--test_multiple_string=expandedSecondValue</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_multiple_string\">--test_multiple_string=expandedFirstValue</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--test_multiple_string\">--test_multiple_string=expandedSecondValue</a></code><br/>\n" + "<br>Tags: \n" + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>" + "</dd>\n"); @@ -546,16 +554,18 @@ public void implicitRequirementOption_longTerminalOutput() { public void implicitRequirementOption_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_implicit_requirement")) .isEqualTo( - "<dt><code><a name=\"flag--test_implicit_requirement\"></a>" - + "--test_implicit_requirement=&lt;a string&gt</code> " + "<dt id=\"flag--test_implicit_requirement\"><code>" + + "<a href=\"#flag--test_implicit_requirement\">--test_implicit_requirement</a>" + + "=&lt;a string&gt</code> " + "default: \"direct implicit\"</dt>\n" + "<dd>\n" + "this option really needs that other one, isolation of purpose has failed.\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_implicit_requirement")) .isEqualTo( - "<dt><code><a name=\"flag--test_implicit_requirement\"></a>" - + "--test_implicit_requirement=&lt;a string&gt</code> " + "<dt id=\"flag--test_implicit_requirement\"><code>" + + "<a href=\"#flag--test_implicit_requirement\">--test_implicit_requirement</a>" + + "=&lt;a string&gt</code> " + "default: \"direct implicit\"</dt>\n" + "<dd>\n" + "this option really needs that other one, isolation of purpose has failed.\n" @@ -599,25 +609,27 @@ public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_longTerm public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_htmlOutput() { assertThat(getHtmlUsageWithoutTags("prefix_expansion")) .isEqualTo( - "<dt><code><a name=\"flag--prefix_expansion\"></a>" - + "--prefix_expansion</code></dt>\n" + "<dt id=\"flag--prefix_expansion\"><code>" + + "<a href=\"#flag--prefix_expansion\">--prefix_expansion</a>" + + "</code></dt>\n" + "<dd>\n" + "Expands to all options with a specific prefix.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--specialexp_bar</code><br/>\n" - + "&nbsp;&nbsp;<code>--specialexp_foo</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--specialexp_bar\">--specialexp_bar</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--specialexp_foo\">--specialexp_foo</a></code><br/>\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("prefix_expansion")) .isEqualTo( - "<dt><code><a name=\"flag--prefix_expansion\"></a>" - + "--prefix_expansion</code></dt>\n" + "<dt id=\"flag--prefix_expansion\"><code>" + + "<a href=\"#flag--prefix_expansion\">--prefix_expansion</a>" + + "</code></dt>\n" + "<dd>\n" + "Expands to all options with a specific prefix.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--specialexp_bar</code><br/>\n" - + "&nbsp;&nbsp;<code>--specialexp_foo</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--specialexp_bar\">--specialexp_bar</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--specialexp_foo\">--specialexp_foo</a></code><br/>\n" + "<br>Tags: \n" + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>" + "</dd>\n"); @@ -658,25 +670,27 @@ public void tagHeavyExpansionOption_longTerminalOutput() { public void tagHeavyExpansionOption_htmlOutput() { assertThat(getHtmlUsageWithoutTags("test_void_expansion_function")) .isEqualTo( - "<dt><code><a name=\"flag--test_void_expansion_function\"></a>" - + "--test_void_expansion_function</code></dt>\n" + "<dt id=\"flag--test_void_expansion_function\"><code>" + + "<a href=\"#flag--test_void_expansion_function\">--test_void_expansion_function</a>" + + "</code></dt>\n" + "<dd>\n" + "Listing a ton of random tags to test the usage output.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n" - + "&nbsp;&nbsp;<code>void expanded</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_d\">--expanded_d</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flagvoid expanded\">void expanded</a></code><br/>\n" + "</dd>\n"); assertThat(getHtmlUsageWithTags("test_void_expansion_function")) .isEqualTo( - "<dt><code><a name=\"flag--test_void_expansion_function\"></a>" - + "--test_void_expansion_function</code></dt>\n" + "<dt id=\"flag--test_void_expansion_function\"><code>" + + "<a href=\"#flag--test_void_expansion_function\">--test_void_expansion_function</a>" + + "</code></dt>\n" + "<dd>\n" + "Listing a ton of random tags to test the usage output.\n" + "<br/>\n" + "Expands to:<br/>\n" - + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n" - + "&nbsp;&nbsp;<code>void expanded</code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flag--expanded_d\">--expanded_d</a></code><br/>\n" + + "&nbsp;&nbsp;<code><a href=\"#flagvoid expanded\">void expanded</a></code><br/>\n" + "<br>Tags: \n" + "<a href=\"#effect_tag_ACTION_COMMAND_LINES\"><code>action_command_lines</code>" + "</a>, "
train
train
2018-12-18T02:42:35
2017-08-03T18:49:24Z
michelleirvine
test
bazelbuild/bazel/3526_3725
bazelbuild/bazel
bazelbuild/bazel/3526
bazelbuild/bazel/3725
[ "timestamp(timedelta=0.0, similarity=0.9092550907745788)" ]
117da7a947b4f497dffd6859b9769d7c8765443d
fbc41e363c741d584f85a1cbed1c55e04b6a7488
[]
[]
2017-09-11T23:29:16Z
[ "type: feature request", "P3" ]
Remove warning for multiple copts in same string
### Description of the problem / feature request / question: Consider the BUILD file below: ``` cc_binary( name = "foo", srcs = ["foo.cc"], copts = ["-framework IOKit"], linkopts = ["-framework IOKit"], ) ``` When building this binary, Bazel emits a warning: ``` WARNING: /Users/jayconrod/Code/scratch/BUILD:4:13: in copts attribute of cc_binary rule //:foo: each item in the list should contain only one option ``` Bazel performs Bourne shell tokenization and Make variable expansion on both `copts` and `linkopts`, so these options will be passed to the compiler as separate arguments. Additionally, Bazel performs label expansion on `linkopts` strings that don't start with '-'. This means that the framework above *must* be passed to `linkopts` as a single string to prevent `IOKit` from being interpreted as a label. It would be awkward to break up the string for `copts` but not for `linkopts`, but there's no other way to avoid the warning. The tokenization doesn't seem to cause problems, so I think the warning should be removed. We are seeing this warning a lot in the Go rules for generated BUILD files. Because `-framework` options in cgo code must be specified together, we don't split option strings extracted from cgo LDFLAGS directives. We would prefer to process CFLAGS directives the same way. ### Environment info * Operating System: Linux, Darwin * Bazel version (output of `bazel info release`): Observed on 0.5.1, 0.5.3.
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java" ]
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java" ]
[ "src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index 47aa40a0ecd578..0f439d39b99940 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -156,10 +156,6 @@ public ImmutableList<String> getCopts() { tokens.clear(); try { ShellUtils.tokenize(tokens, str); - if (tokens.size() > 1) { - ruleContext.attributeWarning("copts", - "each item in the list should contain only one option"); - } } catch (ShellUtils.TokenizationException e) { // ignore, the error is reported in the getAttributeCopts call }
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java index 2ff18b43797a28..5f2a3fddeb8ce3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java @@ -160,7 +160,6 @@ public void testCoptsTokenization() throws Exception { " copts = ['-Wmy-warning -frun-faster'])"); List<String> copts = getCopts("//copts:c_lib"); assertThat(copts).containsAllOf("-Wmy-warning", "-frun-faster"); - assertContainsEvent("each item in the list should contain only one option"); } @Test
train
train
2017-09-11T13:08:53
2017-08-08T21:07:47Z
jayconrod
test
bazelbuild/bazel/3590_7207
bazelbuild/bazel
bazelbuild/bazel/3590
bazelbuild/bazel/7207
[ "timestamp(timedelta=1.0, similarity=0.8960968417948798)" ]
a89c7ef616b2a9fe18afadd99690691d00b7326f
cb5696420a9bdb880b938f09e79cbaaec54c0bf9
[ "PR: https://github.com/bazelbuild/bazel/pull/7207" ]
[]
2019-01-22T00:35:03Z
[ "type: feature request", "P2" ]
Please add `repository_ctx.extract()` function
The existing `repository_ctx.download_and_extract()` will, as it says on the tin, download an archive and then extract it to the local filesystem. There's also a function `repository_ctx.download()`, which lets the user handle the extraction part themselves. This request is for a function `repository_ctx.extract()`, so that I can write custom Skylark to download an archive via a non-HTTP protocol, and then let Bazel handle extraction. Such a function is especially useful for XZ archives, which Bazel can handle natively but many OSes (e.g. MacOS) don't bundle tools for.
[ "src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto", "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/s...
[ "src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto", "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/s...
[ "src/test/shell/bazel/bazel_workspaces_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java index ae2115374f5ab0..6f62d31a6a61cb 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java @@ -107,7 +107,32 @@ public static WorkspaceRuleEvent newDownloadEvent( return new WorkspaceRuleEvent(result.build()); } - /** Creates a new WorkspaceRuleEvent for a download and excract event. */ + /** Creates a new WorkspaceRuleEvent for an extract event. */ + public static WorkspaceRuleEvent newExtractEvent( + String archive, + String output, + String stripPrefix, + String ruleLabel, + Location location) { + WorkspaceLogProtos.ExtractEvent.Builder e = + WorkspaceLogProtos.ExtractEvent.newBuilder() + .setArchive(archive) + .setOutput(output) + .setStripPrefix(stripPrefix); + + WorkspaceLogProtos.WorkspaceEvent.Builder result = + WorkspaceLogProtos.WorkspaceEvent.newBuilder(); + result = result.setExtractEvent(e.build()); + if (location != null) { + result = result.setLocation(location.print()); + } + if (ruleLabel != null) { + result = result.setRule(ruleLabel); + } + return new WorkspaceRuleEvent(result.build()); + } + + /** Creates a new WorkspaceRuleEvent for a download and extract event. */ public static WorkspaceRuleEvent newDownloadAndExtractEvent( List<URL> urls, String output, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto b/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto index 874ddc652fa44d..4248911024640e 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto +++ b/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto @@ -50,6 +50,15 @@ message DownloadEvent { bool executable = 4; } +message ExtractEvent { + // Path to the archive file + string archive = 1; + // Path to the output directory + string output = 2; + // A directory prefix to strip from extracted files. + string strip_prefix = 3; +} + message DownloadAndExtractEvent { // Url(s) to download from repeated string url = 1; @@ -120,5 +129,6 @@ message WorkspaceEvent { SymlinkEvent symlink_event = 8; TemplateEvent template_event = 9; WhichEvent which_event = 10; + ExtractEvent extract_event = 11; } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java index b4c581b3f02f20..24bde5c29b8e22 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java @@ -404,6 +404,28 @@ public StructImpl download( return StructProvider.STRUCT.createStruct(dict, null); } + @Override + public void extract( + Object archive, Object output, String stripPrefix, Location location) + throws RepositoryFunctionException, InterruptedException, EvalException { + SkylarkPath archivePath = getPath("extract()", archive); + SkylarkPath outputPath = getPath("extract()", output); + + WorkspaceRuleEvent w = + WorkspaceRuleEvent.newExtractEvent( + archive.toString(), output.toString(), stripPrefix, rule.getLabel().toString(), location); + env.getListener().post(w); + + DecompressorValue.decompress( + DecompressorDescriptor.builder() + .setTargetKind(rule.getTargetKind()) + .setTargetName(rule.getName()) + .setArchivePath(archivePath.getPath()) + .setRepositoryPath(outputPath.getPath()) + .setPrefix(stripPrefix) + .build()); + } + @Override public StructImpl downloadAndExtract( Object url, Object output, String sha256, String type, String stripPrefix, Location location) diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java index ebdcd84c136839..ad7f961810edf4 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java @@ -302,6 +302,50 @@ public StructApi download( Object url, Object output, String sha256, Boolean executable, Location location) throws RepositoryFunctionExceptionT, EvalException, InterruptedException; + @SkylarkCallable( + name = "extract", + doc = "Extract an archive to the repository directory.", + useLocation = true, + parameters = { + @Param( + name = "archive", + allowedTypes = { + @ParamType(type = String.class), + @ParamType(type = Label.class), + @ParamType(type = RepositoryPathApi.class) + }, + named = true, + doc = + "path to the archive that will be unpacked," + + " relative to the repository directory."), + @Param( + name = "output", + allowedTypes = { + @ParamType(type = String.class), + @ParamType(type = Label.class), + @ParamType(type = RepositoryPathApi.class) + }, + defaultValue = "''", + named = true, + doc = + "path to the directory where the archive will be unpacked," + + " relative to the repository directory."), + @Param( + name = "stripPrefix", + type = String.class, + defaultValue = "''", + named = true, + doc = + "a directory prefix to strip from the extracted files." + + "\nMany archives contain a top-level directory that contains all files in the" + + " archive. Instead of needing to specify this prefix over and over in the" + + " <code>build_file</code>, this field can be used to strip it from extracted" + + " files."), + }) + public void extract( + Object archive, Object output, String stripPrefix, Location location) + throws RepositoryFunctionExceptionT, InterruptedException, EvalException; + @SkylarkCallable( name = "download_and_extract", doc =
diff --git a/src/test/shell/bazel/bazel_workspaces_test.sh b/src/test/shell/bazel/bazel_workspaces_test.sh index 00b698eb48792d..8d21cfa74880a2 100755 --- a/src/test/shell/bazel/bazel_workspaces_test.sh +++ b/src/test/shell/bazel/bazel_workspaces_test.sh @@ -214,6 +214,40 @@ function test_download_multiple() { ensure_contains_exactly 'output: "out_for_list.txt"' 1 } +function test_download_then_extract() { + # Prepare HTTP server with Python + local server_dir="${TEST_TMPDIR}/server_dir" + mkdir -p "${server_dir}" + local file_prefix="${server_dir}/download_then_extract" + + pushd ${TEST_TMPDIR} + echo "This is one file" > server_dir/download_then_extract.txt + zip -r server_dir/download_then_extract.zip server_dir + file_sha256="$(sha256sum server_dir/download_then_extract.zip | head -c 64)" + popd + + # Start HTTP server with Python + startup_server "${server_dir}" + + set_workspace_command " + repository_ctx.download(\"http://localhost:${fileserver_port}/download_then_extract.zip\", \"downloaded_file.zip\", \"${file_sha256}\") + repository_ctx.extract(\"downloaded_file.zip\", \"out_dir\", \"server_dir/\")" + + build_and_process_log --exclude_rule "//external:local_config_cc" + + ensure_contains_exactly 'location: .*repos.bzl:3:3' 1 + ensure_contains_exactly 'location: .*repos.bzl:4:3' 1 + ensure_contains_atleast 'rule: "//external:repo"' 2 + ensure_contains_exactly 'download_event' 1 + ensure_contains_exactly "url: \"http://localhost:${fileserver_port}/download_then_extract.zip\"" 1 + ensure_contains_exactly 'output: "downloaded_file.zip"' 1 + ensure_contains_exactly "sha256: \"${file_sha256}\"" 1 + ensure_contains_exactly 'extract_event' 1 + ensure_contains_exactly 'archive: "downloaded_file.zip"' 1 + ensure_contains_exactly 'output: "out_dir"' 1 + ensure_contains_exactly 'strip_prefix: "server_dir/"' 1 +} + function test_download_and_extract() { # Prepare HTTP server with Python local server_dir="${TEST_TMPDIR}/server_dir"
train
train
2019-01-21T18:30:09
2017-08-20T23:10:05Z
jmillikin
test
bazelbuild/bazel/3599_3671
bazelbuild/bazel
bazelbuild/bazel/3599
bazelbuild/bazel/3671
[ "timestamp(timedelta=66037.0, similarity=1.0)" ]
c67dceca77a93646961fc4bb863826e344fda5e0
a5abafceafc81c311ad96fd685a3dc9047fc10a5
[ "`bazel info release` suffices for this, recommend it be closed.", "@werkt Sure, but it doesn't solve the problem that it's non-intuitive to people who are so used to the GNU convention of -v and --version, which in my experience is by far the most common way of allowing people to query version information in oth...
[]
2017-09-03T11:05:16Z
[ "type: feature request", "P4", "good first issue", "team-OSS" ]
Add -v, --version flag
Working out that `bazel version` is the right command is (for me at least) quite slow. It would be better to support the more common `-v` and `--version` flags. ``` > bazel -v Unknown startup option: '-v'. For more info, run 'bazel help startup_options'. > bazel --version Unknown startup option: '--version'. For more info, run 'bazel help startup_options'. > bazel help startup_options | grep version > bazel help | grep version version Prints version information for bazel. > bazel version Build label: 0.5.3 Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Fri Jul 28 08:34:59 2017 (1501230899) Build timestamp: 1501230899 Build timestamp as int: 1501230899 ``` ### Environment info * Operating System: Ubuntu 14.04 * Bazel version: 0.5.3
[ "src/main/cpp/blaze_util.cc", "src/main/cpp/option_processor.cc", "src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java" ]
[ "src/main/cpp/blaze_util.cc", "src/main/cpp/option_processor.cc", "src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java" ]
[ "src/test/cpp/option_processor_test.cc" ]
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc index fd742e2392eac9..e365ad6adc38cb 100644 --- a/src/main/cpp/blaze_util.cc +++ b/src/main/cpp/blaze_util.cc @@ -125,7 +125,8 @@ bool SearchNullaryOption(const vector<string>& args, bool IsArg(const string& arg) { return blaze_util::starts_with(arg, "-") && (arg != "--help") - && (arg != "-help") && (arg != "-h"); + && (arg != "-help") && (arg != "-h") && (arg != "--version") + && (arg != "-v"); } void LogWait(unsigned int elapsed_seconds, unsigned int wait_seconds) { diff --git a/src/main/cpp/option_processor.cc b/src/main/cpp/option_processor.cc index 158ecb99f35723..7d6c179555733a 100644 --- a/src/main/cpp/option_processor.cc +++ b/src/main/cpp/option_processor.cc @@ -471,7 +471,7 @@ std::vector<std::string> OptionProcessor::GetBlazercAndEnvCommandArgs( std::vector<std::string> OptionProcessor::GetCommandArguments() const { assert(cmd_line_ != nullptr); // When the user didn't specify a command, the server expects the command - // arguments to be empty in order to display the help message. + // arguments to be empty in order to display the help or version message. if (cmd_line_->command.empty()) { return {}; } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 4325524c9c4199..91323456665f17 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -77,6 +77,9 @@ public enum LockingMode { private static final ImmutableSet<String> ALL_HELP_OPTIONS = ImmutableSet.of("--help", "-help", "-h"); + private static final ImmutableSet<String> ALL_VERSION_OPTIONS = + ImmutableSet.of("--version", "-v"); + private final BlazeRuntime runtime; private final Object commandLock; private String currentClientDescription = null; @@ -142,6 +145,11 @@ public BlazeCommandResult exec( commandName = "help"; } + // Be gentle to users who want to find out Blaze version information. + if (ALL_VERSION_OPTIONS.contains(commandName)) { + commandName = "version"; + } + BlazeCommand command = runtime.getCommandMap().get(commandName); if (command == null) { outErr.printErrLn(String.format(
diff --git a/src/test/cpp/option_processor_test.cc b/src/test/cpp/option_processor_test.cc index b1a59efd618134..e4530744a3d0f4 100644 --- a/src/test/cpp/option_processor_test.cc +++ b/src/test/cpp/option_processor_test.cc @@ -490,6 +490,14 @@ TEST_F(OptionProcessorTest, SplitCommandLineWithBlazeVersion) { SuccessfulSplitStartupOptionsTest( {"bazel", "version"}, CommandLine("bazel", {}, "version", {})); + + SuccessfulSplitStartupOptionsTest( + {"bazel", "-v"}, + CommandLine("bazel", {}, "-v", {})); + + SuccessfulSplitStartupOptionsTest( + {"bazel", "--version"}, + CommandLine("bazel", {}, "--version", {})); } TEST_F(OptionProcessorTest, SplitCommandLineWithMultipleCommandArgs) {
train
train
2019-01-17T20:26:01
2017-08-23T09:11:09Z
drigz
test
bazelbuild/bazel/3648_3887
bazelbuild/bazel
bazelbuild/bazel/3648
bazelbuild/bazel/3887
[ "timestamp(timedelta=0.0, similarity=0.9011354485736779)" ]
f581da7375d8548ffaac61ead74cdc3519eeb5b2
5f00e01a6903e655d1ed91f43243095dc7423e23
[ "Yes, I am sure it can, will looking into this." ]
[ "We don't need --cpu=x64_windows_msvc anymore, please remove this." ]
2017-10-11T02:11:54Z
[ "type: bug", "P3", "platform: windows" ]
Action_config for 'assemble' missing from Windows crosstool
Reported on [bazel-discuss](https://groups.google.com/d/msgid/bazel-discuss/f0bcc3e2-2e19-4d30-86ab-4eb37a923e1b%40googlegroups.com). Yun, can cl.exe compile assembly?
[ "tools/cpp/CROSSTOOL.tpl", "tools/cpp/unix_cc_configure.bzl", "tools/cpp/windows_cc_configure.bzl" ]
[ "tools/cpp/CROSSTOOL.tpl", "tools/cpp/unix_cc_configure.bzl", "tools/cpp/windows_cc_configure.bzl" ]
[ "src/test/py/bazel/bazel_windows_test.py" ]
diff --git a/tools/cpp/CROSSTOOL.tpl b/tools/cpp/CROSSTOOL.tpl index af58b7ad182f2e..6b585fcaf49e41 100644 --- a/tools/cpp/CROSSTOOL.tpl +++ b/tools/cpp/CROSSTOOL.tpl @@ -132,6 +132,10 @@ toolchain { name: "ar" path: "%{msvc_lib_path}" } + tool_path { + name: "ml" + path: "%{msvc_ml_path}" + } tool_path { name: "cpp" path: "%{msvc_cl_path}" @@ -264,6 +268,26 @@ toolchain { name: 'copy_dynamic_libraries_to_binary' } + action_config { + config_name: 'assemble' + action_name: 'assemble' + tool { + tool_path: '%{msvc_ml_path}' + } + flag_set { + expand_if_all_available: 'output_object_file' + flag_group { + flag: '/Fo%{output_object_file}' + flag: '/Zi' + flag: '/c' + flag: '%{source_file}' + } + } + implies: 'nologo' + implies: 'msvc_env' + implies: 'sysroot' + } + action_config { config_name: 'c-compile' action_name: 'c-compile' @@ -453,7 +477,6 @@ toolchain { name: 'legacy_compile_flags' flag_set { expand_if_all_available: 'legacy_compile_flags' - action: 'assemble' action: 'preprocess-assemble' action: 'c-compile' action: 'c++-compile' @@ -523,6 +546,7 @@ toolchain { feature { name: 'include_paths' flag_set { + action: "assemble" action: 'preprocess-assemble' action: 'c-compile' action: 'c++-compile' @@ -547,6 +571,7 @@ toolchain { feature { name: "preprocessor_defines" flag_set { + action: "assemble" action: "preprocess-assemble" action: "c-compile" action: "c++-compile" @@ -564,7 +589,6 @@ toolchain { feature { name: 'parse_showincludes' flag_set { - action: 'assemble' action: 'preprocess-assemble' action: 'c-compile' action: 'c++-compile' @@ -933,7 +957,6 @@ toolchain { name: 'user_compile_flags' flag_set { expand_if_all_available: 'user_compile_flags' - action: 'assemble' action: 'preprocess-assemble' action: 'c-compile' action: 'c++-compile' @@ -973,7 +996,6 @@ toolchain { name: 'unfiltered_compile_flags' flag_set { expand_if_all_available: 'unfiltered_compile_flags' - action: 'assemble' action: 'preprocess-assemble' action: 'c-compile' action: 'c++-compile' diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index ed245fc943df39..aa46f5597840be 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -392,6 +392,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value): "%{msvc_env_include}": "", "%{msvc_env_lib}": "", "%{msvc_cl_path}": "", + "%{msvc_ml_path}": "", "%{msvc_link_path}": "", "%{msvc_lib_path}": "", "%{compilation_mode_content}": "", diff --git a/tools/cpp/windows_cc_configure.bzl b/tools/cpp/windows_cc_configure.bzl index a78c8a9b79f875..594e82a8ea4bb3 100644 --- a/tools/cpp/windows_cc_configure.bzl +++ b/tools/cpp/windows_cc_configure.bzl @@ -295,6 +295,7 @@ def configure_windows_toolchain(repository_ctx): escaped_tmp_dir = escape_string( get_env_var(repository_ctx, "TMP", "C:\\Windows\\Temp").replace("\\", "\\\\")) msvc_cl_path = _find_msvc_tool(repository_ctx, vc_path, "cl.exe").replace("\\", "/") + msvc_ml_path = _find_msvc_tool(repository_ctx, vc_path, "ml64.exe").replace("\\", "/") msvc_link_path = _find_msvc_tool(repository_ctx, vc_path, "link.exe").replace("\\", "/") msvc_lib_path = _find_msvc_tool(repository_ctx, vc_path, "lib.exe").replace("\\", "/") escaped_cxx_include_directories = [] @@ -346,6 +347,7 @@ def configure_windows_toolchain(repository_ctx): "%{msvc_env_include}": escaped_include_paths, "%{msvc_env_lib}": escaped_lib_paths, "%{msvc_cl_path}": msvc_cl_path, + "%{msvc_ml_path}": msvc_ml_path, "%{msvc_link_path}": msvc_link_path, "%{msvc_lib_path}": msvc_lib_path, "%{compilation_mode_content}": compilation_mode_content,
diff --git a/src/test/py/bazel/bazel_windows_test.py b/src/test/py/bazel/bazel_windows_test.py index 69ac921c56c5ed..931c240284b800 100644 --- a/src/test/py/bazel/bazel_windows_test.py +++ b/src/test/py/bazel/bazel_windows_test.py @@ -68,6 +68,50 @@ def testUseMSVCWrapperScript(self): execution_root, 'external/local_config_cc/wrapper/bin/pydir/msvc_tools.py'))) + def testWindowsCompilesAssembly(self): + self.ScratchFile('WORKSPACE') + exit_code, stdout, stderr = self.RunBazel(['info', 'bazel-bin']) + self.AssertExitCode(exit_code, 0, stderr) + bazel_bin = stdout[0] + self.ScratchFile('BUILD', [ + 'cc_binary(', + ' name="x",', + ' srcs=[' + ' "x.asm",', + ' "y.cc",', + ' ],', + ')', + ]) + self.ScratchFile('x.asm', [ + '.code', + 'PUBLIC increment', + 'increment PROC x:WORD', + ' xchg rcx,rax', + ' inc rax', + ' ret', + 'increment EndP', + 'END', + ]) + self.ScratchFile('y.cc', [ + '#include <stdio.h>', + 'extern "C" int increment(int);', + 'int main(int, char**) {' + ' int x = 5;', + ' x = increment(x);', + ' printf("%d\\n", x);', + ' return 0;', + '}', + ]) + + exit_code, _, stderr = self.RunBazel( + [ + 'build', + '//:x', + ]) + + self.AssertExitCode(exit_code, 0, stderr) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'x.exe'))) + if __name__ == '__main__': unittest.main()
train
train
2017-11-14T02:20:27
2017-08-31T08:44:58Z
hlopko
test
bazelbuild/bazel/3761_4015
bazelbuild/bazel
bazelbuild/bazel/3761
bazelbuild/bazel/4015
[ "timestamp(timedelta=0.0, similarity=0.8991682871191983)" ]
d16012774f97d8a3d0f7732e116dba8ab636a4cb
4e7a3e56ef090ae23eb1115089f558da4bab8dde
[ "Sounds like a good idea! @philwo , @aehlig : WDYT? ", "@jmillikin-stripe Considering that java8-jdk-headless doesn't exist, should we then change the dependency list from:\r\n\r\n> google-jdk | java8-jdk | java8-sdk | oracle-java8-installer\r\n\r\ninto:\r\n\r\n> google-jdk | java8-sdk-headless | oracle-java8-ins...
[]
2017-11-03T03:46:42Z
[ "type: feature request", "P3", "category: misc > misc" ]
Please let the Debian package depend on headless JDK
The official Bazel packages for Debian/Ubuntu depend on `java8-sdk`, which usually resolves to `openjdk-8-jdk`. This is the full JDK including graphical toolkits, and it's fairly bulky when working within a Docker container: ```shell $ apt-get install --no-install-recommends openjdk-8-jdk [...] Need to get 72.8 MB of archives. After this operation, 384 MB of additional disk space will be used. ``` Since Bazel doesn't have a graphical component, it would be nice if it depended on `java8-sdk-headless`, which is less than half as big: ```shell $ apt-get install --no-install-recommends openjdk-8-jdk-headless [...] Need to get 39.8 MB of archives. After this operation, 155 MB of additional disk space will be used. ```
[ "scripts/packages/debian/control" ]
[ "scripts/packages/debian/control" ]
[]
diff --git a/scripts/packages/debian/control b/scripts/packages/debian/control index 443240e5cafdec..fe428fce2eb50f 100644 --- a/scripts/packages/debian/control +++ b/scripts/packages/debian/control @@ -9,7 +9,7 @@ Package: bazel Section: contrib/devel Priority: optional Architecture: amd64 -Depends: google-jdk | java8-jdk | java8-sdk | oracle-java8-installer, g++, zlib1g-dev, bash-completion +Depends: google-jdk | java8-sdk-headless | java8-jdk | java8-sdk | oracle-java8-installer, g++, zlib1g-dev, bash-completion Description: Bazel is a tool that automates software builds and tests. Supported build tasks include running compilers and linkers to produce executable programs and libraries, and assembling deployable packages
null
train
train
2017-11-02T19:53:14
2017-09-19T00:55:55Z
jmillikin-stripe
test
bazelbuild/bazel/3766_7309
bazelbuild/bazel
bazelbuild/bazel/3766
bazelbuild/bazel/7309
[ "timestamp(timedelta=1.0, similarity=0.8473022587967347)" ]
e0864d0698bdfb350d3b9700e4e865a1516bf994
c5a9a6c0d8775d15db4a160c1adb155fe785eef8
[ "This sounds related to (though definitely not a duplicate of) #3438", "Has there been any progress on this, or prioritization? It's worse than the issue description when you consider windows compatibility, as \"cat\" isn't an external executable on that platform (it being a powershell alias to Get-Content, whic...
[ "We want 8859-1 as the default? ", "The default is set to UTF-8 in `SkylarkRepositoryContextApi`. I'm using `StandardCharsets.ISO_8859_1` to mean raw bytes, for when the user calls `ctx.read(\"somefile\", encoding=\"\")`.\r\n\r\nMy assumption is that this function will almost always be used to ingest text files ...
2019-01-31T06:14:33Z
[ "type: feature request", "P3", "team-ExternalDeps" ]
Please add a repository_ctx method for reading files by Label
A `repository_ctx` can have Label attributes that point to files in other repositories (useful for tool plumbing), but such attributes are awkward to work with because there's no direct way to read their content. The best workaround I've found is to use symlinks and run `cat` as a subprocess, which certainly deserves an entry in the [Useless Use of Cat Award](http://porkmail.org/era/unix/award.html). ```python def _some_repo_rule(ctx): ctx.symlink(ctx.attr.genrule_cmd_file, "external-genrule-cmd.sh") cat_genrule_cmd = ctx.execute(["cat", "external-genrule-cmd.sh"]) if cat_genrule_cmd.return_code != 0: fail("Failed to read genrule command %r: %s" % ( ctx.attr.genrule_cmd_file, cat_genrule_cmd.stderr)) genrule_content = cat_genrule_cmd.stdout ``` That whole mess could, ideally, be simplified down to this: ```python def _some_repo_rule(ctx): genrule_content = ctx.read_file(ctx.attr.genrule_cmd_file) ```
[ "src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto", "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/s...
[ "src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java", "src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto", "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/s...
[ "src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java", "src/test/shell/bazel/bazel_workspaces_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java index 3b9ec466777766..06759395996e8a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/debug/WorkspaceRuleEvent.java @@ -183,6 +183,26 @@ public static WorkspaceRuleEvent newFileEvent( return new WorkspaceRuleEvent(result.build()); } + /** Creates a new WorkspaceRuleEvent for a file read event. */ + public static WorkspaceRuleEvent newReadEvent( + String path, String ruleLabel, Location location) { + WorkspaceLogProtos.ReadEvent e = + WorkspaceLogProtos.ReadEvent.newBuilder() + .setPath(path) + .build(); + + WorkspaceLogProtos.WorkspaceEvent.Builder result = + WorkspaceLogProtos.WorkspaceEvent.newBuilder(); + result = result.setReadEvent(e); + if (location != null) { + result = result.setLocation(location.print()); + } + if (ruleLabel != null) { + result = result.setRule(ruleLabel); + } + return new WorkspaceRuleEvent(result.build()); + } + /** Creates a new WorkspaceRuleEvent for an os event. */ public static WorkspaceRuleEvent newOsEvent(String ruleLabel, Location location) { OsEvent e = WorkspaceLogProtos.OsEvent.getDefaultInstance(); diff --git a/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto b/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto index 4248911024640e..2ade26a4776aea 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto +++ b/src/main/java/com/google/devtools/build/lib/bazel/debug/workspace_log.proto @@ -82,6 +82,12 @@ message FileEvent { bool executable = 3; } +// Information on "read" event in repository_ctx. +message ReadEvent { + // Path to the file to read + string path = 1; +} + // Information on "os" event in repository_ctx. message OsEvent { // Takes no inputs @@ -130,5 +136,6 @@ message WorkspaceEvent { TemplateEvent template_event = 9; WhichEvent which_event = 10; ExtractEvent extract_event = 11; + ReadEvent read_event = 12; } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java index 5ab3b9bd2bbd43..9306c8294b79ed 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java @@ -180,7 +180,7 @@ public void symlink(Object from, Object to, Location location) fromPath.toString(), toPath.toString(), rule.getLabel().toString(), location); env.getListener().post(w); try { - checkInOutputDirectory(toPath); + checkInOutputDirectory("write", toPath); makeDirectories(toPath.getPath()); toPath.getPath().createSymbolicLink(fromPath.getPath()); } catch (IOException e) { @@ -192,30 +192,36 @@ public void symlink(Object from, Object to, Location location) } } - private void checkInOutputDirectory(SkylarkPath path) throws RepositoryFunctionException { + private void checkInOutputDirectory(String operation, SkylarkPath path) throws RepositoryFunctionException { if (!path.getPath().getPathString().startsWith(outputDirectory.getPathString())) { throw new RepositoryFunctionException( new EvalException( Location.fromFile(path.getPath()), - "Cannot write outside of the repository directory for path " + path), + "Cannot " + operation + " outside of the repository directory for path " + path), Transience.PERSISTENT); } } @Override - public void createFile(Object path, String content, Boolean executable, Location location) + public void createFile(Object path, String content, Boolean executable, Boolean legacyUtf8, Location location) throws RepositoryFunctionException, EvalException, InterruptedException { SkylarkPath p = getPath("file()", path); + byte[] contentBytes; + if (legacyUtf8) { + contentBytes = content.getBytes(StandardCharsets.UTF_8); + } else { + contentBytes = content.getBytes(StandardCharsets.ISO_8859_1); + } WorkspaceRuleEvent w = WorkspaceRuleEvent.newFileEvent( p.toString(), content, executable, rule.getLabel().toString(), location); env.getListener().post(w); try { - checkInOutputDirectory(p); + checkInOutputDirectory("write", p); makeDirectories(p.getPath()); p.getPath().delete(); try (OutputStream stream = p.getPath().getOutputStream()) { - stream.write(content.getBytes(StandardCharsets.UTF_8)); + stream.write(contentBytes); } if (executable) { p.getPath().setExecutable(true); @@ -245,7 +251,7 @@ public void createFileFromTemplate( location); env.getListener().post(w); try { - checkInOutputDirectory(p); + checkInOutputDirectory("write", p); makeDirectories(p.getPath()); String tpl = FileSystemUtils.readContent(t.getPath(), StandardCharsets.UTF_8); for (Map.Entry<String, String> substitution : substitutions.entrySet()) { @@ -264,6 +270,22 @@ public void createFileFromTemplate( } } + @Override + public String readFile(Object path, Location location) + throws RepositoryFunctionException, EvalException, InterruptedException { + SkylarkPath p = getPath("read()", path); + WorkspaceRuleEvent w = + WorkspaceRuleEvent.newReadEvent( + p.toString(), rule.getLabel().toString(), location); + env.getListener().post(w); + try { + checkInOutputDirectory("read", p); + return FileSystemUtils.readContent(p.getPath(), StandardCharsets.ISO_8859_1); + } catch (IOException e) { + throw new RepositoryFunctionException(e, Transience.TRANSIENT); + } + } + // Create parent directories for the given path private void makeDirectories(Path path) throws IOException { Path parent = path.getParentDirectory(); @@ -397,7 +419,7 @@ public StructImpl download( env.getListener().post(w); Path downloadedPath; try { - checkInOutputDirectory(outputPath); + checkInOutputDirectory("write", outputPath); makeDirectories(outputPath.getPath()); downloadedPath = httpDownloader.download( @@ -481,7 +503,7 @@ public StructImpl downloadAndExtract( // Download to outputDirectory and delete it after extraction SkylarkPath outputPath = getPath("download_and_extract()", output); - checkInOutputDirectory(outputPath); + checkInOutputDirectory("write", outputPath); createDirectory(outputPath.getPath()); Path downloadedPath; diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java index 41360435230840..b15808dcb789ee 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java @@ -138,8 +138,16 @@ public void symlink(Object from, Object to, Location location) type = Boolean.class, defaultValue = "True", doc = "set the executable flag on the created file, true by default."), + @Param( + name = "legacy_utf8", + named = true, + type = Boolean.class, + defaultValue = "True", + doc = + "encode file content to UTF-8, true by default. Future versions will change" + + " the default and remove this parameter."), }) - public void createFile(Object path, String content, Boolean executable, Location location) + public void createFile(Object path, String content, Boolean executable, Boolean legacyUtf8, Location location) throws RepositoryFunctionExceptionT, EvalException, InterruptedException; @SkylarkCallable( @@ -189,6 +197,23 @@ public void createFileFromTemplate( Location location) throws RepositoryFunctionExceptionT, EvalException, InterruptedException; + @SkylarkCallable( + name = "read", + doc = "Reads the content of a file on the filesystem.", + useLocation = true, + parameters = { + @Param( + name = "path", + allowedTypes = { + @ParamType(type = String.class), + @ParamType(type = Label.class), + @ParamType(type = RepositoryPathApi.class) + }, + doc = "path of the file to read from."), + }) + public String readFile(Object path, Location location) + throws RepositoryFunctionExceptionT, EvalException, InterruptedException; + @SkylarkCallable( name = "os", structField = true,
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java index 37ed659c9cd05f..dfe2512cb5f908 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java @@ -145,16 +145,16 @@ public void testWhich() throws Exception { @Test public void testFile() throws Exception { setUpContexForRule("test"); - context.createFile(context.path("foobar"), "", true, null); - context.createFile(context.path("foo/bar"), "foobar", true, null); - context.createFile(context.path("bar/foo/bar"), "", true, null); + context.createFile(context.path("foobar"), "", true, true, null); + context.createFile(context.path("foo/bar"), "foobar", true, true, null); + context.createFile(context.path("bar/foo/bar"), "", true, true, null); testOutputFile(outputDirectory.getChild("foobar"), ""); testOutputFile(outputDirectory.getRelative("foo/bar"), "foobar"); testOutputFile(outputDirectory.getRelative("bar/foo/bar"), ""); try { - context.createFile(context.path("/absolute"), "", true, null); + context.createFile(context.path("/absolute"), "", true, true, null); fail("Expected error on creating path outside of the repository directory"); } catch (RepositoryFunctionException ex) { assertThat(ex) @@ -163,7 +163,7 @@ public void testFile() throws Exception { .isEqualTo("Cannot write outside of the repository directory for path /absolute"); } try { - context.createFile(context.path("../somepath"), "", true, null); + context.createFile(context.path("../somepath"), "", true, true, null); fail("Expected error on creating path outside of the repository directory"); } catch (RepositoryFunctionException ex) { assertThat(ex) @@ -172,7 +172,7 @@ public void testFile() throws Exception { .isEqualTo("Cannot write outside of the repository directory for path /somepath"); } try { - context.createFile(context.path("foo/../../somepath"), "", true, null); + context.createFile(context.path("foo/../../somepath"), "", true, true, null); fail("Expected error on creating path outside of the repository directory"); } catch (RepositoryFunctionException ex) { assertThat(ex) @@ -182,10 +182,47 @@ public void testFile() throws Exception { } } + @Test + public void testRead() throws Exception { + setUpContexForRule("test"); + context.createFile(context.path("foo/bar"), "foobar", true, true, null); + + String content = context.readFile(context.path("foo/bar"), null); + assertThat(content).isEqualTo("foobar"); + + try { + context.readFile(context.path("/absolute"), null); + fail("Expected error on reading path outside of the repository directory"); + } catch (RepositoryFunctionException ex) { + assertThat(ex) + .hasCauseThat() + .hasMessageThat() + .isEqualTo("Cannot read outside of the repository directory for path /absolute"); + } + try { + context.readFile(context.path("../somepath"), null); + fail("Expected error on reading path outside of the repository directory"); + } catch (RepositoryFunctionException ex) { + assertThat(ex) + .hasCauseThat() + .hasMessageThat() + .isEqualTo("Cannot read outside of the repository directory for path /somepath"); + } + try { + context.readFile(context.path("foo/../../somepath"), null); + fail("Expected error on reading path outside of the repository directory"); + } catch (RepositoryFunctionException ex) { + assertThat(ex) + .hasCauseThat() + .hasMessageThat() + .isEqualTo("Cannot read outside of the repository directory for path /somepath"); + } + } + @Test public void testSymlink() throws Exception { setUpContexForRule("test"); - context.createFile(context.path("foo"), "foobar", true, null); + context.createFile(context.path("foo"), "foobar", true, true, null); context.symlink(context.path("foo"), context.path("bar"), null); testOutputFile(outputDirectory.getChild("bar"), "foobar"); diff --git a/src/test/shell/bazel/bazel_workspaces_test.sh b/src/test/shell/bazel/bazel_workspaces_test.sh index 8d21cfa74880a2..b81c255374696f 100755 --- a/src/test/shell/bazel/bazel_workspaces_test.sh +++ b/src/test/shell/bazel/bazel_workspaces_test.sh @@ -292,6 +292,75 @@ function test_file() { ensure_contains_exactly 'executable: true' 1 } +function test_file_nonascii() { + set_workspace_command 'repository_ctx.file("filefile.sh", "echo fïlëfïlë", True)' + + build_and_process_log --exclude_rule "//external:local_config_cc" + + ensure_contains_exactly 'location: .*repos.bzl:2:3' 1 + ensure_contains_atleast 'rule: "//external:repo"' 1 + + # There are 3 file_event in external:repo as it is currently set up + ensure_contains_exactly 'file_event' 3 + ensure_contains_exactly 'path: ".*filefile.sh"' 1 + ensure_contains_exactly 'executable: true' 1 + + # This test file is in UTF-8, so the string passed to file() is UTF-8. + # Protobuf strings are Unicode encoded in UTF-8, so the logged text + # is double-encoded relative to the workspace command. + # + # >>> content = "echo f\u00EFl\u00EBf\u00EFl\u00EB".encode("utf8") + # >>> proto_content = content.decode("iso-8859-1").encode("utf8") + # >>> print("".join(chr(c) if c <= 0x7F else ("\\" + oct(c)[2:]) for c in proto_content)) + # echo f\303\203\302\257l\303\203\302\253f\303\203\302\257l\303\203\302\253 + # >>> + + ensure_contains_exactly 'content: "echo f\\303\\203\\302\\257l\\303\\203\\302\\253f\\303\\203\\302\\257l\\303\\203\\302\\253"' 1 +} + +function test_read() { + set_workspace_command ' + content = "echo filefile" + repository_ctx.file("filefile.sh", content, True) + read_result = repository_ctx.read("filefile.sh") + if read_result != content: + fail("read(): expected %r, got %r" % (content, read_result))' + + build_and_process_log --exclude_rule "//external:local_config_cc" + + ensure_contains_exactly 'location: .*repos.bzl:4:3' 1 + ensure_contains_exactly 'location: .*repos.bzl:5:17' 1 + ensure_contains_atleast 'rule: "//external:repo"' 2 + + ensure_contains_exactly 'read_event' 1 + ensure_contains_exactly 'path: ".*filefile.sh"' 2 +} + +function test_read_roundtrip_legacy_utf8() { + # See discussion on https://github.com/bazelbuild/bazel/pull/7309 + set_workspace_command ' + content = "echo fïlëfïlë" + repository_ctx.file("filefile.sh", content, True, legacy_utf8=True) + read_result = repository_ctx.read("filefile.sh") + + corrupted_content = "echo fïlëfïlë" + if read_result != corrupted_content: + fail("read(): expected %r, got %r" % (corrupted_content, read_result))' + + build_and_process_log --exclude_rule "//external:local_config_cc" +} + +function test_read_roundtrip_nolegacy_utf8() { + set_workspace_command ' + content = "echo fïlëfïlë" + repository_ctx.file("filefile.sh", content, True, legacy_utf8=False) + read_result = repository_ctx.read("filefile.sh") + if read_result != content: + fail("read(): expected %r, got %r" % (content, read_result))' + + build_and_process_log --exclude_rule "//external:local_config_cc" +} + function test_os() { set_workspace_command 'print(repository_ctx.os.name)'
train
train
2019-03-13T22:40:43
2017-09-20T02:48:27Z
jmillikin
test
bazelbuild/bazel/3872_3873
bazelbuild/bazel
bazelbuild/bazel/3872
bazelbuild/bazel/3873
[ "timestamp(timedelta=0.0, similarity=0.8750544054369024)" ]
ac2cd35438e13504336ced63b6a06581445b66a5
38331b4bcf299df1a81d7af55e16f4cb768b5e29
[]
[ "add \"python_version\": \"3\"", "add \"python_version\": \"2\"", "I recommend removing the non-linux configuration so you get a less noisy result. E.g. freebsd is a breakage at HEAD.", "Added", "Added", "Done", "I'm not sure what indentation it wants here." ]
2017-10-06T21:58:16Z
[ "type: feature request", "P3", "category: misc > testing" ]
CI: bazel-tests should add a Python 3.x configuration
The current [bazel-tests CI job](https://github.com/bazelbuild/bazel/blob/master/scripts/ci/bazel-tests.json) does not run against a Python 3.x interpreter, so issues like #3816 happen. We should add a configuration that does so, via the `--python_path` flag now, and perhaps via the `--python_top` flag later. An alternative would be to add an ArchLinux configuration, which has `/usr/bin/python` point to a Python 3.x interpreter.
[ "scripts/ci/bazel-tests.json" ]
[ "scripts/ci/bazel-tests.json" ]
[]
diff --git a/scripts/ci/bazel-tests.json b/scripts/ci/bazel-tests.json index 62af16f2da8a65..efd8bf1f11dc65 100644 --- a/scripts/ci/bazel-tests.json +++ b/scripts/ci/bazel-tests.json @@ -3,7 +3,17 @@ [ { "configurations": [ - {"node": "linux-x86_64"}, + { + "node": "linux-x86_64", + "python_version": "2" + }, + { + "node": "linux-x86_64", + "python_version": "3", + "parameters": { + "build_opts": ["--python_path=/usr/bin/python3"] + } + }, {"node": "ubuntu_16.04-x86_64"} ], "parameters": {
null
val
train
2017-12-20T22:39:27
2017-10-06T21:57:47Z
duggelz
test
bazelbuild/bazel/4028_4029
bazelbuild/bazel
bazelbuild/bazel/4028
bazelbuild/bazel/4029
[ "timestamp(timedelta=0.0, similarity=0.8606838243996491)" ]
d3fd691b95562a1cc9e3205f0ec8fe49e8d1f1c3
0edee4fb4786d676d6cc0023f0c9b6e8b75e9cae
[ "Hi John, internal reviewer asked for tests, could you add some to src/test/shell/bazel/apple/bazel_objc_test.sh please?", "Test added, to `cpp_darwin_integration_test.sh` -- this isn't Objective-C, it's just regular C++.\r\n\r\nI'm some trouble running the test (with changes or at HEAD) because Bazel gets into a...
[ "Ah I missed this one, can you pls use ifMac there?", "Can you pls move the fail onto the next line.", "`ifMac` is the opposite of what we want. These lines should only be added on non-MacOS platforms.", "This matches the existing style. Note that I think there might be something wrong with the current test c...
2017-11-06T21:32:53Z
[ "type: bug", "P2" ]
MacOS crosstool configures /usr/bin/strip with invalid flags
This report is against Bazel release 0.7.0. `tools/osx/crosstool/CROSSTOOL.tpl` configures `/usr/bin/strip` with multiple `-R` flags. In the GNU toolchain this flag removes a named section, but Clang (installed by Apple's dev tools) has a different definition of the `-R` flag. ``` -R filename Remove the symbol table entries for the global symbols listed in filename. This file has the same format as the -s filename option above. This option is usually used in combination with other options that save some symbols, -S, -x, etc. ``` This causes builds of stripped binaries to fail on MacOS: ``` $ ~/bin/bazel build -s //:hello.stripped # [...] >>>>> # //:hello [action 'Stripping hello.stripped for //:hello'] (cd /private/var/tmp/_bazel_jmillikin/6469710131e6db2fa36d059d1b1c2547/execroot/__main__ && \ exec env - \ PATH=/usr/local/bin:/usr/bin:/bin \ TMPDIR=/var/folders/bd/0cbzdsgs2lq1dtg56xn8c07c0000gn/T/ \ /usr/bin/strip -S -o bazel-out/local-fastbuild/bin/hello.stripped -R .gnu.switches.text.quote_paths -R .gnu.switches.text.bracket_paths -R .gnu.switches.text.system_paths -R .gnu.switches.text.cpp_defines -R .gnu.switches.text.cpp_includes -R .gnu.switches.text.cl_args -R .gnu.switches.text.lipo_info -R .gnu.switches.text.annotation bazel-out/local-fastbuild/bin/hello) ERROR: /Users/jmillikin/src/hello_cc/BUILD:1:1: Stripping hello.stripped for //:hello failed (Exit 1). fatal error: /Library/Developer/CommandLineTools/usr/bin/strip: only one -R option allowed Target //:hello.stripped failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 1.491s, Critical Path: 0.19s ``` Here's the workspace content to reproduce: ``` $ cat BUILD cc_binary( name = "hello", srcs = ["hello.cc"], ) $ cat hello.cc #include <cstdio> int main() { printf("Hello world!\n"); return 0; } ```
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java", "tools/osx/crosstool/CROSSTOOL.tpl" ]
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java", "tools/osx/crosstool/CROSSTOOL.tpl" ]
[ "src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL", "src/test/shell/bazel/cpp_darwin_integration_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java index caf3e36efefc7c..b093aec1992af4 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java @@ -938,24 +938,25 @@ public static String getCppActionConfigs( " flag: '-o'", " flag: '%{output_file}'", " }", - " flag_group {", - " flag: '-R'", - " flag: '.gnu.switches.text.quote_paths'", - " flag: '-R'", - " flag: '.gnu.switches.text.bracket_paths'", - " flag: '-R'", - " flag: '.gnu.switches.text.system_paths'", - " flag: '-R'", - " flag: '.gnu.switches.text.cpp_defines'", - " flag: '-R'", - " flag: '.gnu.switches.text.cpp_includes'", - " flag: '-R'", - " flag: '.gnu.switches.text.cl_args'", - " flag: '-R'", - " flag: '.gnu.switches.text.lipo_info'", - " flag: '-R'", - " flag: '.gnu.switches.text.annotation'", - " }", + ifLinux(platform, + " flag_group {", + " flag: '-R'", + " flag: '.gnu.switches.text.quote_paths'", + " flag: '-R'", + " flag: '.gnu.switches.text.bracket_paths'", + " flag: '-R'", + " flag: '.gnu.switches.text.system_paths'", + " flag: '-R'", + " flag: '.gnu.switches.text.cpp_defines'", + " flag: '-R'", + " flag: '.gnu.switches.text.cpp_includes'", + " flag: '-R'", + " flag: '.gnu.switches.text.cl_args'", + " flag: '-R'", + " flag: '.gnu.switches.text.lipo_info'", + " flag: '-R'", + " flag: '.gnu.switches.text.annotation'", + " }"), " flag_group {", " iterate_over: 'stripopts'", " flag: '%{stripopts}'", @@ -1073,6 +1074,7 @@ public static String getFeaturesToAppearLastInToolchain( } private static String ifLinux(CppPlatform platform, String... lines) { + // Platform `LINUX` also includes FreeBSD. return ifTrue(platform == CppPlatform.LINUX, lines); } diff --git a/tools/osx/crosstool/CROSSTOOL.tpl b/tools/osx/crosstool/CROSSTOOL.tpl index 8cd191b5329e04..d86f47c82cbfe1 100644 --- a/tools/osx/crosstool/CROSSTOOL.tpl +++ b/tools/osx/crosstool/CROSSTOOL.tpl @@ -1180,22 +1180,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -2841,22 +2825,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -4506,22 +4474,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -6191,22 +6143,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -7863,22 +7799,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -9516,22 +9436,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -11169,22 +11073,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -12842,22 +12730,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -14502,22 +14374,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -16156,22 +16012,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}"
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL index f653c9f220f64c..ea448ad9463bed 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MOCK_OSX_CROSSTOOL @@ -1299,22 +1299,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -3073,22 +3057,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -4842,22 +4810,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -6611,22 +6563,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -8388,22 +8324,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -10169,22 +10089,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -11973,22 +11877,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -13759,22 +13647,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -15560,22 +15432,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -17361,22 +17217,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -19185,22 +19025,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" @@ -20991,22 +20815,6 @@ toolchain { flag: "-S" flag: "-o" flag: "%{output_file}" - flag: "-R" - flag: ".gnu.switches.text.quote_paths" - flag: "-R" - flag: ".gnu.switches.text.bracket_paths" - flag: "-R" - flag: ".gnu.switches.text.system_paths" - flag: "-R" - flag: ".gnu.switches.text.cpp_defines" - flag: "-R" - flag: ".gnu.switches.text.cpp_includes" - flag: "-R" - flag: ".gnu.switches.text.cl_args" - flag: "-R" - flag: ".gnu.switches.text.lipo_info" - flag: "-R" - flag: ".gnu.switches.text.annotation" } flag_group { flag: "%{stripopts}" diff --git a/src/test/shell/bazel/cpp_darwin_integration_test.sh b/src/test/shell/bazel/cpp_darwin_integration_test.sh index d191ef83b8a045..2c23566fe39230 100755 --- a/src/test/shell/bazel/cpp_darwin_integration_test.sh +++ b/src/test/shell/bazel/cpp_darwin_integration_test.sh @@ -71,14 +71,28 @@ EOF } } EOF - assert_build //cpp/rpaths:test >& $TEST_log || fail "//cpp/rpaths:test didn't build" + assert_build //cpp/rpaths:test # Paths originally hardcoded in the binary assume workspace directory. Let's change the # directory and execute the binary to test whether the paths in the binary have been # updated to use @loader_path. cd bazel-bin - ./cpp/rpaths/test >& $TEST_log || \ + ./cpp/rpaths/test || \ fail "//cpp/rpaths:test execution failed, expected to return 0, but got $?" } +function test_osx_binary_strip() { + mkdir -p cpp/osx_binary_strip + cat >cpp/osx_binary_strip/BUILD <<EOF +cc_binary( + name = "main", + srcs = ["main.cc"], +) +EOF + cat >cpp/osx_binary_strip/main.cc <<EOF +int main() { return 0; } +EOF + assert_build //cpp/osx_binary_strip:main.stripped +} + run_suite "Tests for Bazel's C++ rules on Darwin"
test
train
2017-11-15T18:52:35
2017-11-06T21:30:34Z
jmillikin-stripe
test
bazelbuild/bazel/4063_6538
bazelbuild/bazel
bazelbuild/bazel/4063
bazelbuild/bazel/6538
[ "timestamp(timedelta=80465.0, similarity=0.8798468627057965)" ]
4ca2b6d5c4d201009ff21a3abbeddd9d58d4c95b
2c46f6fe93db718f1cdc9aef95a8af7adbbccb86
[ "Is this still an issue that needs to be corrected?\r\n", "If this uses the “zipper” target underneath then yes. There’s also a\nseparate issue about zipper itself.\n\nOn Sat, 11 Aug 2018 at 5:13 Josh Fischer <notifications@github.com> wrote:\n\n> Is this still an issue that needs to be corrected?\n>\n> —\n> You ...
[]
2018-10-27T15:30:10Z
[ "type: bug", "P2", "good first issue" ]
pkg_tar fails when src file name contains the '=' character
### Description of the problem / feature request / question: Cannot build simple `pkg_tar` target when a file contains the `=` character, e.g. if the file is named `a=b`. ### If possible, provide a minimal example to reproduce the problem: ``` mkdir mydir touch mydir/a=b pkg_tar( name = "test-tar", extension = "tar.gz", strip_prefix = "/", package_dir = "/home/user", srcs = glob(["mydir/**/*"]), mode = "0777", ) ``` ### Environment info * Operating System: Linux x64, Ubuntu 14.04 * Bazel version (output of `bazel info release`): release 0.7.0 ### Have you found anything relevant by searching the web? ### Anything else, information or logs or outputs that would be helpful? ``` with open(file_content, 'rb') as f: IOError: [Errno 2] No such file or directory: 'mydir/a' Target //prebuilt:test-tar failed to build ``` The `=` character is used as delimiter in `bazel-out/..../test-tar.args` which conflicts with the file name.
[ "tools/build_defs/pkg/BUILD", "tools/build_defs/pkg/build_tar.py", "tools/build_defs/pkg/build_test.sh", "tools/build_defs/pkg/pkg.bzl" ]
[ "tools/build_defs/pkg/BUILD", "tools/build_defs/pkg/build_tar.py", "tools/build_defs/pkg/build_test.sh", "tools/build_defs/pkg/pkg.bzl" ]
[]
diff --git a/tools/build_defs/pkg/BUILD b/tools/build_defs/pkg/BUILD index 2f4052e713c263..8cfac27f0daffa 100644 --- a/tools/build_defs/pkg/BUILD +++ b/tools/build_defs/pkg/BUILD @@ -96,6 +96,7 @@ genrule( outs = [ "etc/nsswitch.conf", "usr/titi", + "a=b", ], cmd = "for i in $(OUTS); do echo 1 >$$i; done", ) @@ -103,6 +104,7 @@ genrule( [pkg_tar( name = "test-tar-%s" % ext[1:], srcs = [ + ":a=b", ":etc/nsswitch.conf", ":usr/titi", ], diff --git a/tools/build_defs/pkg/build_tar.py b/tools/build_defs/pkg/build_tar.py index 90d602d3d353a5..bad4ab6d8903d5 100644 --- a/tools/build_defs/pkg/build_tar.py +++ b/tools/build_defs/pkg/build_tar.py @@ -266,7 +266,7 @@ def main(unused_argv): mode_map = {} if FLAGS.modes: for filemode in FLAGS.modes: - (f, mode) = filemode.split('=', 1) + (f, mode) = filemode.split(':', 1) if f[0] == '/': f = f[1:] mode_map[f] = int(mode, 8) @@ -277,7 +277,7 @@ def main(unused_argv): names_map = {} if FLAGS.owner_names: for file_owner in FLAGS.owner_names: - (f, owner) = file_owner.split('=', 1) + (f, owner) = file_owner.split(':', 1) (user, group) = owner.split('.', 1) if f[0] == '/': f = f[1:] @@ -288,7 +288,7 @@ def main(unused_argv): ids_map = {} if FLAGS.owners: for file_owner in FLAGS.owners: - (f, owner) = file_owner.split('=', 1) + (f, owner) = file_owner.split(':', 1) (user, group) = owner.split('.', 1) if f[0] == '/': f = f[1:] @@ -312,7 +312,7 @@ def file_attributes(filename): } for f in FLAGS.file: - (inf, tof) = f.split('=', 1) + (inf, tof) = f.split(':', 1) output.add_file(inf, tof, **file_attributes(tof)) for f in FLAGS.empty_file: output.add_empty_file(f, **file_attributes(f)) diff --git a/tools/build_defs/pkg/build_test.sh b/tools/build_defs/pkg/build_test.sh index 99bae8e8fcbfa6..a0837a2b8469cb 100755 --- a/tools/build_defs/pkg/build_test.sh +++ b/tools/build_defs/pkg/build_test.sh @@ -106,6 +106,7 @@ function get_changes() { function assert_content() { local listing="./ +./a=b ./etc/ ./etc/nsswitch.conf ./usr/ @@ -113,8 +114,10 @@ function assert_content() { ./usr/bin/ ./usr/bin/java -> /path/to/bin/java" check_eq "$listing" "$(get_tar_listing $1)" + check_eq "-rw-r--r--" "$(get_tar_permission $1 ./a=b)" check_eq "-rwxr-xr-x" "$(get_tar_permission $1 ./usr/titi)" check_eq "-rw-r--r--" "$(get_tar_permission $1 ./etc/nsswitch.conf)" + check_eq "42/24" "$(get_numeric_tar_owner $1 ./a=b)" check_eq "24/42" "$(get_numeric_tar_owner $1 ./etc/)" check_eq "24/42" "$(get_numeric_tar_owner $1 ./etc/nsswitch.conf)" check_eq "42/24" "$(get_numeric_tar_owner $1 ./usr/)" @@ -129,6 +132,7 @@ function assert_content() { function test_tar() { local listing="./ +./a=b ./etc/ ./etc/nsswitch.conf ./usr/ @@ -171,6 +175,7 @@ function test_deb() { return 0 fi local listing="./ +./a=b ./etc/ ./etc/nsswitch.conf ./usr/ @@ -180,6 +185,7 @@ function test_deb() { check_eq "$listing" "$(get_deb_listing test-deb.deb)" check_eq "-rwxr-xr-x" "$(get_deb_permission test-deb.deb ./usr/titi)" check_eq "-rw-r--r--" "$(get_deb_permission test-deb.deb ./etc/nsswitch.conf)" + check_eq "-rw-r--r--" "$(get_deb_permission test-deb.deb ./a=b)" get_deb_description test-deb.deb >$TEST_log expect_log "Description: toto" expect_log "Package: titi" diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl index 0e250b261e8283..f9ca70ce176363 100644 --- a/tools/build_defs/pkg/pkg.bzl +++ b/tools/build_defs/pkg/pkg.bzl @@ -44,7 +44,7 @@ def _pkg_tar_impl(ctx): file_inputs += run_files args += [ - "--file=%s=%s" % (f.path, dest_path(f, data_path)) + "--file=%s:%s" % (f.path, dest_path(f, data_path)) for f in file_inputs ] for target, f_dest_path in ctx.attr.files.items(): @@ -52,14 +52,14 @@ def _pkg_tar_impl(ctx): if len(target_files) != 1: fail("Inputs to pkg_tar.files_map must describe exactly one file.") file_inputs += [target_files[0]] - args += ["--file=%s=%s" % (target_files[0].path, f_dest_path)] + args += ["--file=%s:%s" % (target_files[0].path, f_dest_path)] if ctx.attr.modes: - args += ["--modes=%s=%s" % (key, ctx.attr.modes[key]) for key in ctx.attr.modes] + args += ["--modes=%s:%s" % (key, ctx.attr.modes[key]) for key in ctx.attr.modes] if ctx.attr.owners: - args += ["--owners=%s=%s" % (key, ctx.attr.owners[key]) for key in ctx.attr.owners] + args += ["--owners=%s:%s" % (key, ctx.attr.owners[key]) for key in ctx.attr.owners] if ctx.attr.ownernames: args += [ - "--owner_names=%s=%s" % (key, ctx.attr.ownernames[key]) + "--owner_names=%s:%s" % (key, ctx.attr.ownernames[key]) for key in ctx.attr.ownernames ] if ctx.attr.empty_files:
null
train
train
2018-10-27T01:41:49
2017-11-09T18:49:07Z
sghiaus
test
bazelbuild/bazel/4097_4265
bazelbuild/bazel
bazelbuild/bazel/4097
bazelbuild/bazel/4265
[ "timestamp(timedelta=0.0, similarity=0.8616565838617605)" ]
21f117ae6599b48719faa55064a745e5ff695865
bbd05c1497f7a2a60ecb8c2aa9ff4db1c84b6a86
[ "I think that #3855 should resolve this issue, but I'll test it to confirm.", "Hey thanks for bringing this to our attention, ccing some people that can help\r\n@jin @dkelmer @ahumesky ", "Thanks @aj-michael - I was able to reproduce @angersson's errors and can confirm that #3855 resolves the first one.\r\n\r\n...
[]
2017-12-11T01:07:58Z
[ "type: feature request" ]
Make android tools scripts Python3-compatible for building android apps
### Description of the problem / feature request / question: Google's TFLite team has discovered that the TF Lite Android demo application cannot build via Bazel with Python 3, because the android tools Bazel uses aren't Python-3 compatible. The first breaking point looks like `third_party/gflags`, but past that there seem to be additional version incompatibilities. ### If possible, provide a minimal example to reproduce the problem: Here's a very fast example: ```shell $ git clone http://github.com/bazelbuild/bazel /tmp/bazel $ cd /tmp/bazel $ python3 >>> import tools.android.aar_embedded_jars_extractor ``` I'm not actually sure how to do the same as the above in python 2, but that sequence of commands results in the same errors we see when trying to build the demo app (`No module named 'gflags'`). I can sort of fix this with `$ pip install python-gflags`, which makes Python not even try to use the local files (this seems like an ultimately buggy workaround). The import is fixed, but the build (below) is still busted with a str-to-buffer message problem which I've included at the very bottom of the issue. Here's how I ran the TF Lite app build. The build requires the [SDK setup steps for Tensorflow's WORKSPACE](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo). ```shell $ virtualenv --python=python3 --system-site-packages /tmp/py3 $ git clone http://github.com/tensorflow/tensorflow /tmp/tf $ cd /tmp/tf $ source /tmp/py3/bin/activate # prepare WORKSPACE, see link above $ ./configure # should default to /tmp/py3 python path $ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm ``` ### Environment info * Operating System: Ubuntu 14.04 LTS * Bazel version (output of `bazel info release`): release 0.7.0 ### Have you found anything relevant by searching the web? - #1580 seems generally relevant. - [A relevant-looking issue from rules_docker](https://github.com/bazelbuild/rules_docker/issues/169) - [Building the tflite demo app from source](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo) - [Where installing python-gflags was noted](https://github.com/mrmeku/brackets-closure-linter/issues/3) - [An SO question on the str buffer error](https://stackoverflow.com/questions/5471158/typeerror-str-does-not-support-the-buffer-interface) ### Anything else, information or logs or outputs that would be helpful? This incompatibility means that the TF Lite app can't be built (afaik) unless users install Python 2. Not a tremendous problem, but pretty inconvenient. From the build commands above, I get something like this: ``` (py3)❯ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm --logging=0 WARNING: The major revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' is 15. The major revisions supported by Bazel are [10, 11, 12, 13, 14]. Defaulting to revision 14. INFO: Analysed target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo (0 packages loaded). INFO: Found 1 target... ERROR: /usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/external/androidsdk/com.android.support/BUILD:4563:1: Filtering AAR native libs by architecture failed (Exit 1) Traceback (most recent call last): File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_native_libs_zip_creator.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_native_libs_zip_creator.py", line 26, in <module> from third_party.py import gflags File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_native_libs_zip_creator.runfiles/bazel_tools/third_party/py/gflags/__init__.py", line 1, in <module> from gflags import * ImportError: No module named 'gflags' Target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 0.440s, Critical Path: 0.11s FAILED: Build did NOT complete successfully ``` And here's the str-to-buffer problem after installing `pip install python-gflags`: ``` (py3)❯ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm --logging=0 WARNING: The major revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' is 15. The major revisions supported by Bazel are [10, 11, 12, 13, 14]. Defaulting to revision 14. INFO: Analysed target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo (50 packages loaded). INFO: Found 1 target... ERROR: /usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/external/androidsdk/com.android.support/BUILD:4563:1: Extracting classes.jar and libs/*.jar from support-fragment-25.2.0.aar failed (Exit 1) Traceback (most recent call last): File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 92, in <module> main() File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 87, in main _Main(FLAGS.input_aar, FLAGS.output_singlejar_param_file, FLAGS.output_dir) File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 67, in _Main output_dir_orig) File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 48, in ExtractEmbeddedJars singlejar_param_file.write("--exclude_build_data\n") TypeError: 'str' does not support the buffer interface Target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 10.214s, Critical Path: 0.54s FAILED: Build did NOT complete successfully ```
[ "tools/android/aar_embedded_jars_extractor.py", "tools/android/aar_native_libs_zip_creator.py", "tools/android/merge_manifests.py", "tools/android/merge_manifests_test.py", "tools/android/resource_extractor.py", "tools/android/stubify_manifest.py", "tools/build_defs/pkg/archive.py", "tools/objc/protob...
[ "tools/android/aar_embedded_jars_extractor.py", "tools/android/aar_native_libs_zip_creator.py", "tools/android/merge_manifests.py", "tools/android/merge_manifests_test.py", "tools/android/resource_extractor.py", "tools/android/stubify_manifest.py", "tools/build_defs/pkg/archive.py", "tools/objc/protob...
[]
diff --git a/tools/android/aar_embedded_jars_extractor.py b/tools/android/aar_embedded_jars_extractor.py index a46dd43b6fa538..393d3f4c5c3732 100644 --- a/tools/android/aar_embedded_jars_extractor.py +++ b/tools/android/aar_embedded_jars_extractor.py @@ -62,7 +62,7 @@ def _Main(input_aar, if not output_dir_orig: output_dir_orig = output_dir with zipfile.ZipFile(input_aar, "r") as aar: - with open(output_singlejar_param_file, "wb") as singlejar_param_file: + with open(output_singlejar_param_file, "w") as singlejar_param_file: ExtractEmbeddedJars(aar, singlejar_param_file, output_dir, output_dir_orig) diff --git a/tools/android/aar_native_libs_zip_creator.py b/tools/android/aar_native_libs_zip_creator.py index 0195d01cadb115..bcf5931ec7072d 100644 --- a/tools/android/aar_native_libs_zip_creator.py +++ b/tools/android/aar_native_libs_zip_creator.py @@ -63,8 +63,8 @@ def Main(input_aar_path, output_zip_path, cpu, input_aar_path_for_error_msg): try: CreateNativeLibsZip(input_aar, cpu, native_libs_zip) except UnsupportedArchitectureException: - print("AAR " + input_aar_path_for_error_msg + - " missing native libs for requested architecture: " + cpu) + print(("AAR " + input_aar_path_for_error_msg + + " missing native libs for requested architecture: " + cpu)) sys.exit(1) diff --git a/tools/android/merge_manifests.py b/tools/android/merge_manifests.py index 880c55f8503b12..3637030a990d7e 100644 --- a/tools/android/merge_manifests.py +++ b/tools/android/merge_manifests.py @@ -449,7 +449,7 @@ def main(): if FLAGS.exclude_permission: warning = _ValidateAndWarnPermissions(FLAGS.exclude_permission) if warning: - print warning + print(warning) merged_manifests = MergeManifests(_ReadFile(FLAGS.merger), _ReadFiles(FLAGS.mergee), diff --git a/tools/android/merge_manifests_test.py b/tools/android/merge_manifests_test.py index 62d0474e15a065..7567a489f7a48f 100644 --- a/tools/android/merge_manifests_test.py +++ b/tools/android/merge_manifests_test.py @@ -532,12 +532,12 @@ def testMerge(self): ['android.permission.READ_LOGS']) result = merger.Merge() expected = xml.dom.minidom.parseString(MANUALLY_MERGED).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result)) + self.assertEqual(Reformat(expected), Reformat(result)) def testReformat(self): text = ' a\n b\n\n\n \t c' expected = 'a\nb\nc' - self.assertEquals(expected, Reformat(text)) + self.assertEqual(expected, Reformat(text)) def testValidateAndWarnPermissions(self): permissions = ['android.permission.VIBRATE', 'android.permission.LAUGH'] @@ -589,7 +589,7 @@ def testMergeToCreateValidManifest(self): ['all']) result = merger.Merge() expected = xml.dom.minidom.parseString(VALID_MANIFEST).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result)) + self.assertEqual(Reformat(expected), Reformat(result)) def testMergeWithNoApplication(self): merger = merge_manifests.MergeManifests( @@ -609,7 +609,7 @@ def testMergeWithNamespaces(self): MERGED_MANIFEST_WITH_EXTRA_NAMESPACE).toprettyxml() # Make sure the result is valid xml (not missing xmlns declarations) result_reparsed = xml.dom.minidom.parseString(result).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result_reparsed)) + self.assertEqual(Reformat(expected), Reformat(result_reparsed)) def testMergeConflictingNamespaces(self): self.maxDiff = None @@ -618,7 +618,7 @@ def testMergeConflictingNamespaces(self): 'MANIFEST_WITH_CONFLICTING_NAMESPACE'), [(MANIFEST_WITH_EXTRA_NAMESPACE, 'MANIFEST_WITH_EXTRA_NAMESPACE')], ['all']) - with self.assertRaisesRegexp(merge_manifests.MalformedManifestException, + with self.assertRaisesRegex(merge_manifests.MalformedManifestException, 'different values for namespace xmlns:tools'): merger.Merge() diff --git a/tools/android/resource_extractor.py b/tools/android/resource_extractor.py index 2cd11d907c2809..473398cd4cc99c 100644 --- a/tools/android/resource_extractor.py +++ b/tools/android/resource_extractor.py @@ -95,7 +95,7 @@ def ExtractResources(input_jar, output_zip): def main(argv): if len(argv) != 3: - print USAGE + print(USAGE) sys.exit(1) with zipfile.ZipFile(argv[1], 'r') as input_jar: with zipfile.ZipFile(argv[2], 'w') as output_zip: diff --git a/tools/android/stubify_manifest.py b/tools/android/stubify_manifest.py index f415774938cd88..52a5be9f9ff251 100644 --- a/tools/android/stubify_manifest.py +++ b/tools/android/stubify_manifest.py @@ -164,5 +164,5 @@ def main(): try: main() except BadManifestException as e: - print e + print(e) sys.exit(1) diff --git a/tools/build_defs/pkg/archive.py b/tools/build_defs/pkg/archive.py index 9d5ddfa667d350..59728e0655b1cc 100644 --- a/tools/build_defs/pkg/archive.py +++ b/tools/build_defs/pkg/archive.py @@ -35,7 +35,7 @@ class SimpleArFile(object): with SimpleArFile(filename) as ar: nextFile = ar.next() while nextFile: - print nextFile.filename + print(nextFile.filename) nextFile = ar.next() Upon error, this class will raise a ArError exception. diff --git a/tools/objc/protobuf_compiler.py b/tools/objc/protobuf_compiler.py index bd789b7ddd0352..de6c4b9a702ba4 100644 --- a/tools/objc/protobuf_compiler.py +++ b/tools/objc/protobuf_compiler.py @@ -18,5 +18,5 @@ import sys if __name__ == '__main__': - print 'Bazel does not yet support protobuf compiling.' + print('Bazel does not yet support protobuf compiling.') sys.exit(1)
null
train
train
2017-12-16T01:16:04
2017-11-15T19:50:45Z
angerson
test
bazelbuild/bazel/4097_4313
bazelbuild/bazel
bazelbuild/bazel/4097
bazelbuild/bazel/4313
[ "timestamp(timedelta=31452.0, similarity=0.9220350633737152)" ]
8a2baea4513f0989be8dc5ea89ca9ddb5b2555eb
791d47313b69adaa003c89d5759815e351362539
[ "I think that #3855 should resolve this issue, but I'll test it to confirm.", "Hey thanks for bringing this to our attention, ccing some people that can help\r\n@jin @dkelmer @ahumesky ", "Thanks @aj-michael - I was able to reproduce @angersson's errors and can confirm that #3855 resolves the first one.\r\n\r\n...
[]
2017-12-16T00:02:30Z
[ "type: feature request" ]
Make android tools scripts Python3-compatible for building android apps
### Description of the problem / feature request / question: Google's TFLite team has discovered that the TF Lite Android demo application cannot build via Bazel with Python 3, because the android tools Bazel uses aren't Python-3 compatible. The first breaking point looks like `third_party/gflags`, but past that there seem to be additional version incompatibilities. ### If possible, provide a minimal example to reproduce the problem: Here's a very fast example: ```shell $ git clone http://github.com/bazelbuild/bazel /tmp/bazel $ cd /tmp/bazel $ python3 >>> import tools.android.aar_embedded_jars_extractor ``` I'm not actually sure how to do the same as the above in python 2, but that sequence of commands results in the same errors we see when trying to build the demo app (`No module named 'gflags'`). I can sort of fix this with `$ pip install python-gflags`, which makes Python not even try to use the local files (this seems like an ultimately buggy workaround). The import is fixed, but the build (below) is still busted with a str-to-buffer message problem which I've included at the very bottom of the issue. Here's how I ran the TF Lite app build. The build requires the [SDK setup steps for Tensorflow's WORKSPACE](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo). ```shell $ virtualenv --python=python3 --system-site-packages /tmp/py3 $ git clone http://github.com/tensorflow/tensorflow /tmp/tf $ cd /tmp/tf $ source /tmp/py3/bin/activate # prepare WORKSPACE, see link above $ ./configure # should default to /tmp/py3 python path $ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm ``` ### Environment info * Operating System: Ubuntu 14.04 LTS * Bazel version (output of `bazel info release`): release 0.7.0 ### Have you found anything relevant by searching the web? - #1580 seems generally relevant. - [A relevant-looking issue from rules_docker](https://github.com/bazelbuild/rules_docker/issues/169) - [Building the tflite demo app from source](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo) - [Where installing python-gflags was noted](https://github.com/mrmeku/brackets-closure-linter/issues/3) - [An SO question on the str buffer error](https://stackoverflow.com/questions/5471158/typeerror-str-does-not-support-the-buffer-interface) ### Anything else, information or logs or outputs that would be helpful? This incompatibility means that the TF Lite app can't be built (afaik) unless users install Python 2. Not a tremendous problem, but pretty inconvenient. From the build commands above, I get something like this: ``` (py3)❯ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm --logging=0 WARNING: The major revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' is 15. The major revisions supported by Bazel are [10, 11, 12, 13, 14]. Defaulting to revision 14. INFO: Analysed target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo (0 packages loaded). INFO: Found 1 target... ERROR: /usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/external/androidsdk/com.android.support/BUILD:4563:1: Filtering AAR native libs by architecture failed (Exit 1) Traceback (most recent call last): File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_native_libs_zip_creator.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_native_libs_zip_creator.py", line 26, in <module> from third_party.py import gflags File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_native_libs_zip_creator.runfiles/bazel_tools/third_party/py/gflags/__init__.py", line 1, in <module> from gflags import * ImportError: No module named 'gflags' Target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 0.440s, Critical Path: 0.11s FAILED: Build did NOT complete successfully ``` And here's the str-to-buffer problem after installing `pip install python-gflags`: ``` (py3)❯ bazel build //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo --cxxopt='--std=c++11' --config=android_arm --logging=0 WARNING: The major revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' is 15. The major revisions supported by Bazel are [10, 11, 12, 13, 14]. Defaulting to revision 14. INFO: Analysed target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo (50 packages loaded). INFO: Found 1 target... ERROR: /usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/external/androidsdk/com.android.support/BUILD:4563:1: Extracting classes.jar and libs/*.jar from support-fragment-25.2.0.aar failed (Exit 1) Traceback (most recent call last): File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 92, in <module> main() File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 87, in main _Main(FLAGS.input_aar, FLAGS.output_singlejar_param_file, FLAGS.output_dir) File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 67, in _Main output_dir_orig) File "/usr/local/google/home/angerson/.cache/bazel/_bazel_angerson/7b7f16644e8d0eb6d37d6401f95d6305/execroot/org_tensorflow/bazel-out/host/bin/external/bazel_tools/tools/android/aar_embedded_jars_extractor.runfiles/org_tensorflow/../bazel_tools/tools/android/aar_embedded_jars_extractor.py", line 48, in ExtractEmbeddedJars singlejar_param_file.write("--exclude_build_data\n") TypeError: 'str' does not support the buffer interface Target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 10.214s, Critical Path: 0.54s FAILED: Build did NOT complete successfully ```
[ "tools/android/aar_embedded_jars_extractor.py", "tools/android/aar_embedded_jars_extractor_test.py", "tools/android/aar_native_libs_zip_creator_test.py", "tools/android/aar_resources_extractor.py", "tools/android/aar_resources_extractor_test.py", "tools/android/build_incremental_dexmanifest.py", "tools/...
[ "tools/android/aar_embedded_jars_extractor.py", "tools/android/aar_embedded_jars_extractor_test.py", "tools/android/aar_native_libs_zip_creator_test.py", "tools/android/aar_resources_extractor.py", "tools/android/aar_resources_extractor_test.py", "tools/android/build_incremental_dexmanifest.py", "tools/...
[]
diff --git a/tools/android/aar_embedded_jars_extractor.py b/tools/android/aar_embedded_jars_extractor.py index 393d3f4c5c3732..92a2e5a950eefb 100644 --- a/tools/android/aar_embedded_jars_extractor.py +++ b/tools/android/aar_embedded_jars_extractor.py @@ -45,13 +45,14 @@ def ExtractEmbeddedJars(aar, if not output_dir_orig: output_dir_orig = output_dir jar_pattern = re.compile("^(classes|libs/.+)\\.jar$") - singlejar_param_file.write("--exclude_build_data\n") + singlejar_param_file.write(b"--exclude_build_data\n") for name in aar.namelist(): if jar_pattern.match(name): - singlejar_param_file.write("--sources\n") + singlejar_param_file.write(b"--sources\n") # output_dir may be a temporary junction, so write the original # (unshortened) path to the params file - singlejar_param_file.write(output_dir_orig + "/" + name + "\n") + singlejar_param_file.write( + (output_dir_orig + "/" + name + "\n").encode("utf-8")) aar.extract(name, output_dir) diff --git a/tools/android/aar_embedded_jars_extractor_test.py b/tools/android/aar_embedded_jars_extractor_test.py index 30f150e8505af9..e4cc6d8d6f7af8 100644 --- a/tools/android/aar_embedded_jars_extractor_test.py +++ b/tools/android/aar_embedded_jars_extractor_test.py @@ -14,9 +14,9 @@ """Tests for aar_embedded_jars_extractor.""" +import io import os import shutil -import StringIO import unittest import zipfile @@ -26,6 +26,11 @@ class AarEmbeddedJarsExtractor(unittest.TestCase): """Unit tests for aar_embedded_jars_extractor.py.""" + # Python 2 alias + if not hasattr(unittest.TestCase, 'assertCountEqual'): + def assertCountEqual(self, *args): + return self.assertItemsEqual(*args) + def setUp(self): os.chdir(os.environ["TEST_TMPDIR"]) @@ -33,47 +38,47 @@ def tearDown(self): shutil.rmtree("out_dir") def testNoJars(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") - param_file = StringIO.StringIO() + aar = zipfile.ZipFile(io.BytesIO(), "w") + param_file = io.BytesIO() os.makedirs("out_dir") aar_embedded_jars_extractor.ExtractEmbeddedJars(aar, param_file, "out_dir") self.assertEqual([], os.listdir("out_dir")) param_file.seek(0) - self.assertEqual("--exclude_build_data\n", param_file.read()) + self.assertEqual(b"--exclude_build_data\n", param_file.read()) def testClassesJarAndLibsJars(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") aar.writestr("classes.jar", "") aar.writestr("libs/a.jar", "") aar.writestr("libs/b.jar", "") - param_file = StringIO.StringIO() + param_file = io.BytesIO() os.makedirs("out_dir") aar_embedded_jars_extractor.ExtractEmbeddedJars(aar, param_file, "out_dir") - self.assertItemsEqual(["classes.jar", "libs"], os.listdir("out_dir")) - self.assertItemsEqual(["a.jar", "b.jar"], os.listdir("out_dir/libs")) + self.assertCountEqual(["classes.jar", "libs"], os.listdir("out_dir")) + self.assertCountEqual(["a.jar", "b.jar"], os.listdir("out_dir/libs")) param_file.seek(0) self.assertEqual( - ["--exclude_build_data\n", - "--sources\n", - "out_dir/classes.jar\n", - "--sources\n", - "out_dir/libs/a.jar\n", - "--sources\n", - "out_dir/libs/b.jar\n"], + [b"--exclude_build_data\n", + b"--sources\n", + b"out_dir/classes.jar\n", + b"--sources\n", + b"out_dir/libs/a.jar\n", + b"--sources\n", + b"out_dir/libs/b.jar\n"], param_file.readlines()) def testOnlyClassesJar(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") aar.writestr("classes.jar", "") - param_file = StringIO.StringIO() + param_file = io.BytesIO() os.makedirs("out_dir") aar_embedded_jars_extractor.ExtractEmbeddedJars(aar, param_file, "out_dir") self.assertEqual(["classes.jar"], os.listdir("out_dir")) param_file.seek(0) self.assertEqual( - ["--exclude_build_data\n", - "--sources\n", - "out_dir/classes.jar\n"], + [b"--exclude_build_data\n", + b"--sources\n", + b"out_dir/classes.jar\n"], param_file.readlines()) diff --git a/tools/android/aar_native_libs_zip_creator_test.py b/tools/android/aar_native_libs_zip_creator_test.py index 0e0210e448396d..3ec71a617a7e00 100644 --- a/tools/android/aar_native_libs_zip_creator_test.py +++ b/tools/android/aar_native_libs_zip_creator_test.py @@ -14,7 +14,7 @@ """Tests for aar_native_libs_zip_creator.""" -import StringIO +import io import unittest import zipfile @@ -25,25 +25,25 @@ class AarNativeLibsZipCreatorTest(unittest.TestCase): """Unit tests for aar_native_libs_zip_creator.py.""" def testAarWithNoLibs(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") - outzip = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") + outzip = zipfile.ZipFile(io.BytesIO(), "w") aar_native_libs_zip_creator.CreateNativeLibsZip(aar, "x86", outzip) self.assertEquals([], outzip.namelist()) def testAarWithMissingLibs(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") aar.writestr("jni/armeabi/foo.so", "") - outzip = zipfile.ZipFile(StringIO.StringIO(), "w") + outzip = zipfile.ZipFile(io.BytesIO(), "w") self.assertRaises( aar_native_libs_zip_creator.UnsupportedArchitectureException, aar_native_libs_zip_creator.CreateNativeLibsZip, aar, "x86", outzip) def testAarWithAllLibs(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") aar.writestr("jni/x86/foo.so", "") aar.writestr("jni/armeabi/foo.so", "") - outzip = zipfile.ZipFile(StringIO.StringIO(), "w") + outzip = zipfile.ZipFile(io.BytesIO(), "w") aar_native_libs_zip_creator.CreateNativeLibsZip(aar, "x86", outzip) self.assertIn("lib/x86/foo.so", outzip.namelist()) self.assertNotIn("lib/armeabi/foo.so", outzip.namelist()) diff --git a/tools/android/aar_resources_extractor.py b/tools/android/aar_resources_extractor.py index 61f9f4d3972035..5d875fbe12335e 100644 --- a/tools/android/aar_resources_extractor.py +++ b/tools/android/aar_resources_extractor.py @@ -78,11 +78,11 @@ def ExtractResources(aar, output_res_dir): with junction.TempJunction(os.path.dirname(empty_xml_filename)) as junc: xmlpath = os.path.join(junc, os.path.basename(empty_xml_filename)) with open(xmlpath, "wb") as empty_xml: - empty_xml.write("<resources/>") + empty_xml.write(b"<resources/>") else: os.makedirs(os.path.dirname(empty_xml_filename)) with open(empty_xml_filename, "wb") as empty_xml: - empty_xml.write("<resources/>") + empty_xml.write(b"<resources/>") def main(): diff --git a/tools/android/aar_resources_extractor_test.py b/tools/android/aar_resources_extractor_test.py index d5f630b3526ce7..efd08c962e803b 100644 --- a/tools/android/aar_resources_extractor_test.py +++ b/tools/android/aar_resources_extractor_test.py @@ -14,9 +14,9 @@ """Tests for aar_resources_extractor.""" +import io import os import shutil -import StringIO import unittest import zipfile @@ -30,6 +30,11 @@ def _HostPath(path): class AarResourcesExtractorTest(unittest.TestCase): """Unit tests for aar_resources_extractor.py.""" + # Python 2 alias + if not hasattr(unittest.TestCase, 'assertCountEqual'): + def assertCountEqual(self, *args): + return self.assertItemsEqual(*args) + def setUp(self): os.chdir(os.environ["TEST_TMPDIR"]) @@ -43,7 +48,7 @@ def DirContents(self, d): ] def testNoResources(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") os.makedirs("out_dir") aar_resources_extractor.ExtractResources(aar, "out_dir") self.assertEqual([_HostPath("out_dir/res/values/empty.xml")], @@ -52,7 +57,7 @@ def testNoResources(self): self.assertEqual("<resources/>", empty_xml.read()) def testContainsResources(self): - aar = zipfile.ZipFile(StringIO.StringIO(), "w") + aar = zipfile.ZipFile(io.BytesIO(), "w") aar.writestr("res/values/values.xml", "some values") aar.writestr("res/layouts/layout.xml", "some layout") os.makedirs("out_dir") @@ -61,7 +66,7 @@ def testContainsResources(self): _HostPath("out_dir/res/values/values.xml"), _HostPath("out_dir/res/layouts/layout.xml") ] - self.assertItemsEqual(expected_resources, self.DirContents("out_dir")) + self.assertCountEqual(expected_resources, self.DirContents("out_dir")) with open("out_dir/res/values/values.xml", "r") as values_xml: self.assertEqual("some values", values_xml.read()) with open("out_dir/res/layouts/layout.xml", "r") as layout_xml: diff --git a/tools/android/build_incremental_dexmanifest.py b/tools/android/build_incremental_dexmanifest.py index 6c372656ec2d51..e912d62a939d59 100644 --- a/tools/android/build_incremental_dexmanifest.py +++ b/tools/android/build_incremental_dexmanifest.py @@ -121,7 +121,7 @@ def Run(self, argv): self.AddDex(input_filename, None, input_filename) with open(argv[0], "wb") as manifest: - manifest.write("\n".join(self.manifest_lines)) + manifest.write(("\n".join(self.manifest_lines)).encode("utf-8")) def main(argv): diff --git a/tools/android/incremental_install.py b/tools/android/incremental_install.py index bad2e29c88a6c3..254db274fc76ab 100644 --- a/tools/android/incremental_install.py +++ b/tools/android/incremental_install.py @@ -221,7 +221,7 @@ def PushString(self, contents, remote): """Push a given string to a given path on the device in parallel.""" local = self._CreateLocalFile() with open(local, "wb") as f: - f.write(contents) + f.write(contents.encode("utf-8")) return self.Push(local, remote) def Pull(self, remote): @@ -237,7 +237,7 @@ def Pull(self, remote): try: self._Exec(["pull", remote, local]) with open(local, "rb") as f: - return f.read() + return f.read().decode("utf-8") except (AdbError, IOError): return None @@ -339,7 +339,7 @@ def ParseManifest(contents): def GetAppPackage(stub_datafile): """Returns the app package specified in a stub data file.""" with open(stub_datafile, "rb") as f: - return f.readlines()[1].strip() + return f.readlines()[1].decode("utf-8").strip() def UploadDexes(adb, execroot, app_dir, temp_dir, dexmanifest, full_install): @@ -605,7 +605,7 @@ def UploadNativeLibs(adb, native_lib_args, app_dir, full_install): f.result() install_manifest = [ - name + " " + checksum for name, checksum in install_checksums.iteritems()] + name + " " + checksum for name, checksum in install_checksums.items()] adb.PushString("\n".join(install_manifest), targetpath.join(app_dir, "native", "native_manifest")).result() @@ -693,7 +693,7 @@ def SplitIncrementalInstall(adb, app_package, execroot, split_main_apk, adb.InstallMultiple(targetpath.join(execroot, apk), app_package) install_manifest = [ - name + " " + checksum for name, checksum in install_checksums.iteritems()] + name + " " + checksum for name, checksum in install_checksums.items()] adb.PushString("\n".join(install_manifest), targetpath.join(app_dir, "split_manifest")).result() @@ -744,7 +744,7 @@ def IncrementalInstall(adb_path, VerifyInstallTimestamp(adb, app_package) with open(hostpath.join(execroot, dexmanifest), "rb") as f: - dexmanifest = f.read() + dexmanifest = f.read().decode("utf-8") UploadDexes(adb, execroot, app_dir, temp_dir, dexmanifest, bool(apk)) # TODO(ahumesky): UploadDexes waits for all the dexes to be uploaded, and # then UploadResources is called. We could instead enqueue everything @@ -776,16 +776,16 @@ def IncrementalInstall(adb_path, sys.exit("Error: Device unauthorized. Please check the confirmation " "dialog on your device.") except MultipleDevicesError as e: - sys.exit("Error: " + e.message + "\nTry specifying a device serial with " + sys.exit("Error: " + str(e) + "\nTry specifying a device serial with " "\"blaze mobile-install --adb_arg=-s --adb_arg=$ANDROID_SERIAL\"") except OldSdkException as e: sys.exit("Error: The device does not support the API level specified in " "the application's manifest. Check minSdkVersion in " "AndroidManifest.xml") except TimestampException as e: - sys.exit("Error:\n%s" % e.message) + sys.exit("Error:\n%s" % str(e)) except AdbError as e: - sys.exit("Error:\n%s" % e.message) + sys.exit("Error:\n%s" % str(e)) finally: shutil.rmtree(temp_dir, True) diff --git a/tools/android/incremental_install_test.py b/tools/android/incremental_install_test.py index 1181a591ef0496..5eee83fcad2ae2 100644 --- a/tools/android/incremental_install_test.py +++ b/tools/android/incremental_install_test.py @@ -49,7 +49,7 @@ def Exec(self, args): if cmd == "push": # "/test/adb push local remote" with open(args[2], "rb") as f: - content = f.read() + content = f.read().decode("utf-8") self.files[args[3]] = content elif cmd == "pull": # "/test/adb pull remote local" @@ -58,7 +58,7 @@ def Exec(self, args): content = self.files.get(remote) if content is not None: with open(local, "wb") as f: - f.write(content) + f.write(content.encode("utf-8")) else: returncode = 1 stderr = "remote object '%s' does not exist\n" % remote @@ -69,7 +69,7 @@ def Exec(self, args): elif cmd == "install-multiple": if args[3] == "-p": with open(args[5], "rb") as f: - content = f.read() + content = f.read().decode("utf-8") self.split_apks.add(content) else: self.package_timestamp = self._last_package_timestamp @@ -133,11 +133,12 @@ def setUp(self): # Write the stub datafile which contains the package name of the app. with open(self._STUB_DATAFILE, "wb") as f: - f.write("\n".join([self._OLD_APP_PACKGE, self._APP_PACKAGE])) + f.write(("\n".join([self._OLD_APP_PACKGE, self._APP_PACKAGE])) + .encode("utf-8")) # Write the local resource apk file. with open(self._RESOURCE_APK, "wb") as f: - f.write("resource apk") + f.write(b"resource apk") # Mock out subprocess.Popen to use our mock adb. self._popen_patch = mock.patch.object(incremental_install, "subprocess") @@ -157,7 +158,7 @@ def _CreateZip(self, name="zip1", *files): def _CreateLocalManifest(self, *lines): content = "\n".join(lines) with open(self._DEXMANIFEST, "wb") as f: - f.write(content) + f.write(content.encode("utf-8")) return content def _CreateRemoteManifest(self, *lines): @@ -205,7 +206,7 @@ def testUploadToPristineDevice(self): self._CreateZip() with open("dex1", "wb") as f: - f.write("content3") + f.write(b"content3") manifest = self._CreateLocalManifest( "zip1 zp1 ip1 0", @@ -224,10 +225,10 @@ def testUploadToPristineDevice(self): def testSplitInstallToPristineDevice(self): with open("split1", "wb") as f: - f.write("split_content1") + f.write(b"split_content1") with open("main", "wb") as f: - f.write("main_Content") + f.write(b"main_Content") self._CallIncrementalInstall( incremental=False, split_main_apk="main", split_apks=["split1"]) @@ -235,10 +236,10 @@ def testSplitInstallToPristineDevice(self): def testSplitInstallUnchanged(self): with open("split1", "wb") as f: - f.write("split_content1") + f.write(b"split_content1") with open("main", "wb") as f: - f.write("main_Content") + f.write(b"main_Content") self._CallIncrementalInstall( incremental=False, split_main_apk="main", split_apks=["split1"]) @@ -250,17 +251,17 @@ def testSplitInstallUnchanged(self): def testSplitInstallChanges(self): with open("split1", "wb") as f: - f.write("split_content1") + f.write(b"split_content1") with open("main", "wb") as f: - f.write("main_Content") + f.write(b"main_Content") self._CallIncrementalInstall( incremental=False, split_main_apk="main", split_apks=["split1"]) self.assertEqual(set(["split_content1"]), self._mock_adb.split_apks) with open("split1", "wb") as f: - f.write("split_content2") + f.write(b"split_content2") self._mock_adb.split_apks = set() self._CallIncrementalInstall( incremental=False, split_main_apk="main", split_apks=["split1"]) @@ -269,7 +270,7 @@ def testSplitInstallChanges(self): def testMissingNativeManifestWithIncrementalInstall(self): self._CreateZip() with open("liba.so", "wb") as f: - f.write("liba_1") + f.write(b"liba_1") # Upload a library to the device. native_libs = ["armeabi-v7a:liba.so"] @@ -285,7 +286,7 @@ def testMissingNativeManifestWithIncrementalInstall(self): def testNonIncrementalInstallOverwritesNativeLibs(self): self._CreateZip() with open("liba.so", "wb") as f: - f.write("liba_1") + f.write(b"liba_1") # Upload a library to the device. native_libs = ["armeabi-v7a:liba.so"] @@ -305,7 +306,7 @@ def testNonIncrementalInstallOverwritesNativeLibs(self): def testNativeAbiCompatibility(self): self._CreateZip() with open("liba.so", "wb") as f: - f.write("liba") + f.write(b"liba") native_libs = ["armeabi:liba.so"] self._mock_adb.SetAbi("arm64-v8a") @@ -315,9 +316,9 @@ def testNativeAbiCompatibility(self): def testUploadNativeLibs(self): self._CreateZip() with open("liba.so", "wb") as f: - f.write("liba_1") + f.write(b"liba_1") with open("libb.so", "wb") as f: - f.write("libb_1") + f.write(b"libb_1") native_libs = ["armeabi-v7a:liba.so", "armeabi-v7a:libb.so"] self._CallIncrementalInstall(incremental=False, native_libs=native_libs) @@ -326,7 +327,7 @@ def testUploadNativeLibs(self): # Change a library with open("libb.so", "wb") as f: - f.write("libb_2") + f.write(b"libb_2") self._CallIncrementalInstall(incremental=True, native_libs=native_libs) self.assertEqual("libb_2", self._GetDeviceFile("native/libb.so")) @@ -520,7 +521,7 @@ def testStartCold(self): self._CreateZip() with open("dex1", "wb") as f: - f.write("content3") + f.write(b"content3") self._CreateLocalManifest( "zip1 zp1 ip1 0", @@ -536,7 +537,7 @@ def testDebugStart(self): self._CreateZip() with open("dex1", "wb") as f: - f.write("content3") + f.write(b"content3") self._CreateLocalManifest( "zip1 zp1 ip1 0", diff --git a/tools/android/merge_manifests.py b/tools/android/merge_manifests.py index a12e53836c349d..520b03219c049c 100644 --- a/tools/android/merge_manifests.py +++ b/tools/android/merge_manifests.py @@ -379,7 +379,7 @@ def Merge(self): self._MergeTopLevelNamespaces(mergee_dom) for destination, values in sorted( - self._NODES_TO_COPY_FROM_MERGEE.iteritems()): + self._NODES_TO_COPY_FROM_MERGEE.items()): for node_to_copy in values: for node in mergee_dom.getElementsByTagName(node_to_copy): if self._IsDuplicate(node_to_copy, node): diff --git a/tools/android/resource_extractor_test.py b/tools/android/resource_extractor_test.py index de5b6a8b879485..db912ca19dcc14 100644 --- a/tools/android/resource_extractor_test.py +++ b/tools/android/resource_extractor_test.py @@ -14,7 +14,7 @@ """Tests for resource_extractor.""" -import StringIO +import io import unittest import zipfile @@ -24,8 +24,13 @@ class ResourceExtractorTest(unittest.TestCase): """Unit tests for resource_extractor.py.""" + # Python 2 alias + if not hasattr(unittest.TestCase, 'assertCountEqual'): + def assertCountEqual(self, *args): + return self.assertItemsEqual(*args) + def testJarWithEverything(self): - input_jar = zipfile.ZipFile(StringIO.StringIO(), "w") + input_jar = zipfile.ZipFile(io.BytesIO(), "w") for path in ( # Should not be included @@ -56,17 +61,17 @@ def testJarWithEverything(self): "not_CVS/include", "META-INF/services/foo"): input_jar.writestr(path, "") - output_zip = zipfile.ZipFile(StringIO.StringIO(), "w") + output_zip = zipfile.ZipFile(io.BytesIO(), "w") resource_extractor.ExtractResources(input_jar, output_zip) - self.assertItemsEqual(("c", "a/b", "bar/a", "a/not_package.html", + self.assertCountEqual(("c", "a/b", "bar/a", "a/not_package.html", "not_CVS/include", "META-INF/services/foo"), output_zip.namelist()) def testTimestampsAreTheSame(self): - input_jar = zipfile.ZipFile(StringIO.StringIO(), "w") + input_jar = zipfile.ZipFile(io.BytesIO(), "w") entry_info = zipfile.ZipInfo("a", (1982, 1, 1, 0, 0, 0)) input_jar.writestr(entry_info, "") - output_zip = zipfile.ZipFile(StringIO.StringIO(), "w") + output_zip = zipfile.ZipFile(io.BytesIO(), "w") resource_extractor.ExtractResources(input_jar, output_zip) self.assertEqual((1982, 1, 1, 0, 0, 0), output_zip.getinfo("a").date_time)
null
train
train
2017-12-18T23:36:01
2017-11-15T19:50:45Z
angerson
test
bazelbuild/bazel/4132_4134
bazelbuild/bazel
bazelbuild/bazel/4132
bazelbuild/bazel/4134
[ "timestamp(timedelta=0.0, similarity=0.865193421544384)" ]
0b30976d6a075577e9a9fc9df37ee4e784bb0ebb
6a890970dd44e562a0670ec84587425d98bf52cf
[]
[]
2017-11-20T22:05:54Z
[]
Improper formatting on aspects.html
https://docs.bazel.build/versions/master/skylark/aspects.html#advanced-example ![aspects](https://user-images.githubusercontent.com/15253456/33038876-eefb4f60-cdea-11e7-93c9-d8dc115cbe09.png)
[ "site/docs/skylark/aspects.md" ]
[ "site/docs/skylark/aspects.md" ]
[]
diff --git a/site/docs/skylark/aspects.md b/site/docs/skylark/aspects.md index 4d32c73a707e83..fa80e5f08d9f58 100644 --- a/site/docs/skylark/aspects.md +++ b/site/docs/skylark/aspects.md @@ -176,6 +176,7 @@ It shows how to use a provider to return values, how to use parameters to pass an argument into an aspect implementation, and how to invoke an aspect from a rule. FileCount.bzl file: + ```python FileCount = provider( fields = { @@ -218,6 +219,7 @@ file_count_rule = rule( ``` BUILD.bazel file: + ```python load('//file_count.bzl', 'file_count_rule')
null
val
train
2017-11-20T22:17:30
2017-11-20T20:04:26Z
tvolkert
test
bazelbuild/bazel/4174_4175
bazelbuild/bazel
bazelbuild/bazel/4174
bazelbuild/bazel/4175
[ "timestamp(timedelta=0.0, similarity=0.9192119149424052)" ]
0b2352de3101e87647d083f6089246079dda0f75
cb03cd3a4771f7adb168e524cb3d65fc16fb4c41
[]
[]
2017-11-28T04:29:40Z
[]
Broken link in tutorial for 'C++ use cases'
The [C++ and Bazel](https://docs.bazel.build/versions/master/bazel-and-cpp.html) page has a bad link to https://docs.bazel.build/versions/master/tutorial/cpp-use-cases.html with text `C++ common use cases` under the `Working with Bazel` section. This link should probably be to https://docs.bazel.build/versions/master/cpp-use-cases.html instead. The link to that page in the left-hand TOC sidebar resolves without issue.
[ "site/docs/bazel-and-cpp.md" ]
[ "site/docs/bazel-and-cpp.md" ]
[]
diff --git a/site/docs/bazel-and-cpp.md b/site/docs/bazel-and-cpp.md index 84e9ed75493987..41083c7c4390f9 100644 --- a/site/docs/bazel-and-cpp.md +++ b/site/docs/bazel-and-cpp.md @@ -21,7 +21,7 @@ projects with Bazel. The following resources will help you work with Bazel on C++ projects: * [Tutorial: Building a C++ project](tutorial/cpp.html) -* [C++ common use cases](tutorial/cpp-use-cases.html) +* [C++ common use cases](cpp-use-cases.html) * [C/C++ rules](https://docs.bazel.build/versions/master/be/c-cpp.html) ## Best practices
null
train
train
2017-11-28T02:39:59
2017-11-28T04:22:40Z
jonstewart
test
bazelbuild/bazel/4176_4236
bazelbuild/bazel
bazelbuild/bazel/4176
bazelbuild/bazel/4236
[ "timestamp(timedelta=0.0, similarity=0.9283720135274562)" ]
52aff7dcac17c73a221487acc147e631c75124cd
af220c8e4be759ac9d7a4e8a420323d2a2ad0c23
[ "Sounds like a nice improvement.\r\n\r\n@akira-baruah do you want to send your fix over as a pull request? :)", "@philwo Thanks - I made PR #4236, but haven't tested it on Windows yet." ]
[]
2017-12-05T18:16:26Z
[ "type: bug", "P3", "category: misc > misc" ]
bazel clean: don't suggest to use --async, if it is not supported on current platform
On Bazel@HEAD, on Windows: ``` $ bazel clean INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. ``` Now trying to pass `--async`, as suggested: ``` $ bazel clean --async INFO: --async cannot be used on non-Linux platforms, falling back to synchronous clean INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. ```
[ "src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java" ]
[ "src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java" ]
[ "src/test/java/com/google/devtools/build/lib/BUILD", "src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java index dfe0dd3bb1f697..6c6446214cc086 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java @@ -126,7 +126,8 @@ public ExitCode exec(CommandEnvironment env, OptionsProvider options) // MacOS and FreeBSD support setsid(2) but don't have /usr/bin/setsid, so if we wanted to // support --expunge_async on these platforms, we'd have to write a wrapper that calls setsid(2) // and exec(2). - if (async && OS.getCurrent() != OS.LINUX) { + boolean asyncSupport = OS.getCurrent() == OS.LINUX; + if (async && !asyncSupport) { String fallbackName = cleanOptions.expunge ? "--expunge" : "synchronous clean"; env.getReporter() .handle( @@ -138,7 +139,7 @@ public ExitCode exec(CommandEnvironment env, OptionsProvider options) } String cleanBanner = - async + (async || !asyncSupport) ? "Starting clean." : "Starting clean (this may take a while). " + "Consider using --async if the clean takes more than several minutes.";
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD index ba38e5698eb4bf..78d1569b98e80c 100644 --- a/src/test/java/com/google/devtools/build/lib/BUILD +++ b/src/test/java/com/google/devtools/build/lib/BUILD @@ -1029,7 +1029,10 @@ java_test( java_test( name = "runtime-tests", - srcs = glob(["runtime/*.java"]), + srcs = glob([ + "runtime/*.java", + "runtime/commands/*.java" + ]), test_class = "com.google.devtools.build.lib.AllTests", deps = [ ":foundations_testutil", diff --git a/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandTest.java b/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandTest.java new file mode 100644 index 00000000000000..98216924a9e552 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandTest.java @@ -0,0 +1,106 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// 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. +package com.google.devtools.build.lib.runtime.commands; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.common.collect.Lists; +import com.google.devtools.build.lib.analysis.BlazeDirectories; +import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; +import com.google.devtools.build.lib.analysis.ServerDirectories; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.runtime.BlazeCommand; +import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher; +import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.LockingMode; +import com.google.devtools.build.lib.runtime.BlazeModule; +import com.google.devtools.build.lib.runtime.BlazeRuntime; +import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions; +import com.google.devtools.build.lib.testutil.Scratch; +import com.google.devtools.build.lib.testutil.TestConstants; +import com.google.devtools.build.lib.util.OS; +import com.google.devtools.build.lib.util.io.RecordingOutErr; +import com.google.devtools.common.options.OptionsParser; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests {@link CleanCommand}. + */ +@RunWith(JUnit4.class) +public class CleanCommandTest { + + private final RecordingOutErr outErr = new RecordingOutErr(); + private Scratch scratch = new Scratch(); + private BlazeRuntime runtime; + private BlazeCommand command; + private BlazeCommandDispatcher dispatcher; + + @Before + public final void initializeRuntime() throws Exception { + String productName = TestConstants.PRODUCT_NAME; + ServerDirectories serverDirectories = + new ServerDirectories(scratch.dir("install"), scratch.dir("output")); + this.runtime = + new BlazeRuntime.Builder() + .setFileSystem(scratch.getFileSystem()) + .setProductName(productName) + .setServerDirectories(serverDirectories) + .setStartupOptionsProvider( + OptionsParser.newOptionsParser(BlazeServerStartupOptions.class)) + .addBlazeModule( + new BlazeModule() { + @Override + public void initializeRuleClasses(ConfiguredRuleClassProvider.Builder builder) { + // We must add these options so that the defaults package can be created. + builder.addConfigurationOptions(BuildConfiguration.Options.class); + // The tools repository is needed for createGlobals + builder.setToolsRepository(TestConstants.TOOLS_REPOSITORY); + } + }) + .build(); + BlazeDirectories directories = + new BlazeDirectories(serverDirectories, scratch.dir("workspace"), productName); + this.runtime.initWorkspace(directories, /* binTools= */ null); + this.command = new CleanCommand(); + this.dispatcher = new BlazeCommandDispatcher(this.runtime, this.command); + } + + @Test + public void testCleanWithAsyncDoesNotSuggestAsync() throws Exception { + List<String> commandLine = Lists.newArrayList("clean", "--async"); + this.dispatcher.exec(commandLine, LockingMode.ERROR_OUT, "test", outErr); + String output = outErr.toString(); + String suggestion = "Consider using --async"; + assertWithMessage("clean --async command shouldn't suggest using --async") + .that(output).doesNotContain(suggestion); + } + + @Test + public void testCleanSuggestsAsyncOnLinuxPlatformsOnly() throws Exception { + List<String> commandLine = Lists.newArrayList("clean"); + this.dispatcher.exec(commandLine, LockingMode.ERROR_OUT, "test", outErr); + String output = outErr.toString(); + String suggestion = "Consider using --async"; + if (OS.getCurrent() == OS.LINUX) { + assertWithMessage("clean command should suggest using --async on Linux platforms") + .that(output).contains(suggestion); + } else { + assertWithMessage("clean command shouldn't suggest using --async on non-Linux platforms") + .that(output).doesNotContain(suggestion); + } + } +}
train
train
2017-12-12T03:25:36
2017-11-28T06:55:08Z
davido
test
bazelbuild/bazel/4207_7649
bazelbuild/bazel
bazelbuild/bazel/4207
bazelbuild/bazel/7649
[ "timestamp(timedelta=0.0, similarity=1.0000000000000002)" ]
8c5b11af337ac6ef02aa28dd7cd49ef7af2f640f
50b58dfe336c8207ea6806bd970a373814316240
[]
[]
2019-03-06T15:46:12Z
[ "type: feature request", "P2" ]
Support changing the working directory of repository_ctx.execute
### Description of the feature request: I want to be able to direct `repository_ctx.execute` to run in a particular directory. I believe right now it executes under `external/` vs. `external/<repo_name>`, which is where it should be putting files. So unless every tool we invoke supports changing directories, this is inadequate. This can be worked around by trampolining through a script that changes into the appropriate directory. @damienmg FYI
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java", "src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java" ]
[ "src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/RepoWithRuleWritingTextGenerator.java", "src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/WorkspaceBlackBoxTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java index 077f2229be1950..9fdc2ca74cf39f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java @@ -46,6 +46,7 @@ import com.google.devtools.build.lib.syntax.SkylarkType; import com.google.devtools.build.lib.util.OsUtils; import com.google.devtools.build.lib.util.StringUtilities; +import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; @@ -296,8 +297,9 @@ public SkylarkExecutionResult execute( Integer timeout, SkylarkDict<String, String> environment, boolean quiet, + String workingDirectory, Location location) - throws EvalException, RepositoryFunctionException { + throws EvalException, RepositoryFunctionException, InterruptedException { WorkspaceRuleEvent w = WorkspaceRuleEvent.newExecuteEvent( arguments, @@ -309,10 +311,15 @@ public SkylarkExecutionResult execute( rule.getLabel().toString(), location); env.getListener().post(w); - createDirectory(outputDirectory); + + Path workingDirectoryPath = outputDirectory; + if (workingDirectory != null && !workingDirectory.isEmpty()) { + workingDirectoryPath = getPath("execute()", workingDirectory).getPath(); + } + createDirectory(workingDirectoryPath); return SkylarkExecutionResult.builder(osObject.getEnvironmentVariables()) .addArguments(arguments) - .setDirectory(outputDirectory.getPathFile()) + .setDirectory(workingDirectoryPath.getPathFile()) .addEnvironmentVariables(environment) .setTimeout(Math.round(timeout.longValue() * 1000 * timeoutScaling)) .setQuiet(quiet) diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java index d9485cb6c839ec..a648c7775553f3 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/repository/SkylarkRepositoryContextApi.java @@ -230,14 +230,22 @@ public void createFileFromTemplate( defaultValue = "True", named = true, doc = "If stdout and stderr should be printed to the terminal."), + @Param( + name = "working_directory", + type = String.class, + defaultValue = "\"\"", + named = true, + doc = "Working directory for command execution.\n" + + "Can be relative to the repository root or absolute."), }) public SkylarkExecutionResultApi execute( SkylarkList<Object> arguments, Integer timeout, SkylarkDict<String, String> environment, boolean quiet, + String workingDirectory, Location location) - throws EvalException, RepositoryFunctionExceptionT; + throws EvalException, RepositoryFunctionExceptionT, InterruptedException; @SkylarkCallable( name = "which",
diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/RepoWithRuleWritingTextGenerator.java b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/RepoWithRuleWritingTextGenerator.java index b3560591e00e2a..2ebf4ce697bdc3 100644 --- a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/RepoWithRuleWritingTextGenerator.java +++ b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/RepoWithRuleWritingTextGenerator.java @@ -33,13 +33,13 @@ */ public class RepoWithRuleWritingTextGenerator { - private static final String HELPER_FILE = "helper.bzl"; - private static final String RULE_NAME = "write_to_file"; + static final String HELPER_FILE = "helper.bzl"; + static final String RULE_NAME = "write_to_file"; static final String HELLO = "HELLO"; static final String TARGET = "write_text"; static final String OUT_FILE = "out"; - private static final String WRITE_TEXT_TO_FILE = + static final String WRITE_TEXT_TO_FILE = "def _impl(ctx):\n" + " out = ctx.actions.declare_file(ctx.attr.filename)\n" + " ctx.actions.write(out, ctx.attr.text)\n" diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/WorkspaceBlackBoxTest.java b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/WorkspaceBlackBoxTest.java index 6b6a022114fbea..0b4d6a867756f3 100644 --- a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/WorkspaceBlackBoxTest.java +++ b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/WorkspaceBlackBoxTest.java @@ -14,11 +14,16 @@ package com.google.devtools.build.lib.blackbox.tests.workspace; +import static com.google.common.truth.Truth.assertThat; + import com.google.devtools.build.lib.blackbox.framework.BuilderRunner; import com.google.devtools.build.lib.blackbox.framework.PathUtils; import com.google.devtools.build.lib.blackbox.junit.AbstractBlackBoxTest; import com.google.devtools.build.lib.util.OS; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; import org.junit.Test; /** End to end test of workspace-related functionality. */ @@ -68,11 +73,74 @@ public void testNotInMsys() throws Exception { BuilderRunner bazel = WorkspaceTestUtils.bazel(context()); // The build using "bash" should fail on Windows, and pass on Linux and Mac OS - if (OS.WINDOWS.equals(OS.getCurrent())) { + if (isWindows()) { bazel.shouldFail(); } bazel.build("check"); } + //echo %cd% + + @Test + public void testExecuteInWorkingDirectory() throws Exception { + String pwd = isWindows() ? "['cmd', '/c', 'echo %cd%']" : "['pwd']"; + String buildFileText = "\"\"\"" + String.join("\n", + RepoWithRuleWritingTextGenerator.loadRule("@main"), + RepoWithRuleWritingTextGenerator.callRule("debug_me", "out", "%s")) +"\"\"\" % stdout"; + context().write("repo_rule.bzl", + "def _impl(rctx):", + String.format( + " result = rctx.execute(%s, working_directory=rctx.attr.working_directory)", pwd), + " if result.return_code != 0:", + " fail('Execute failed: ' + result.stderr)", + // we want to compare the real paths, + // otherwise it is not clear how to verify the relative path variant + " wd = str(rctx.path(rctx.attr.working_directory))", + // pwd returns the path with '\n' in the end of the line; cut it + " stdout = result.stdout.strip(' \\n\\r').replace('\\\\', '/')", + " if wd != stdout:", + " fail('Wrong current directory: **%s**, expecting **%s**' % (stdout, wd))", + // create BUILD file with a target so we can call it; + // rule of a target is defined in the main repository + " rctx.file('BUILD', " + buildFileText + ")", + "check_wd = repository_rule(implementation = _impl,", + " attrs = { 'working_directory': attr.string() }", + ")"); + + context().write(RepoWithRuleWritingTextGenerator.HELPER_FILE, + RepoWithRuleWritingTextGenerator.WRITE_TEXT_TO_FILE); + context().write("BUILD"); + + Path tempDirectory = Files.createTempDirectory("temp-execute"); + context().write(WORKSPACE, + "workspace(name = 'main')", + "load(':repo_rule.bzl', 'check_wd')", + "check_wd(name = 'relative', working_directory = 'relative')", + "check_wd(name = 'relative2', working_directory = '../relative2')", + String.format("check_wd(name = 'absolute', working_directory = '%s')", + PathUtils.pathForStarlarkFile(tempDirectory)), + String.format("check_wd(name = 'absolute2', working_directory = '%s')", + PathUtils.pathForStarlarkFile(tempDirectory.resolve("non_existent_child"))) + ); + + BuilderRunner bazel = WorkspaceTestUtils.bazel(context()); + bazel.build("@relative//:debug_me"); + Path outFile = context().resolveBinPath(bazel, "external/relative/out"); + assertThat(outFile.toFile().exists()).isTrue(); + List<String> lines = PathUtils.readFile(outFile); + assertThat(lines.size()).isEqualTo(1); + assertThat(Paths.get(lines.get(0)).endsWith(Paths.get("external/relative/relative"))).isTrue(); + + bazel.build("@relative2//:debug_me"); + bazel.build("@absolute//:debug_me"); + + bazel.build("@absolute2//:debug_me"); + Path outFile2 = context().resolveBinPath(bazel, "external/absolute2/out"); + assertThat(outFile2.toFile().exists()).isTrue(); + List<String> lines2 = PathUtils.readFile(outFile2); + assertThat(lines2.size()).isEqualTo(1); + assertThat(Paths.get(lines2.get(0)).equals( + tempDirectory.resolve("non_existent_child"))).isTrue(); + } @Test public void testWorkspaceChanges() throws Exception { @@ -113,6 +181,9 @@ public void testPathWithSpace() throws Exception { bazel.help(); } + private boolean isWindows() { + return OS.WINDOWS.equals(OS.getCurrent()); + } // TODO(ichern) move other tests from workspace_test.sh here. }
train
train
2019-03-06T16:23:39
2017-12-01T14:35:38Z
mattmoor
test
bazelbuild/bazel/4222_4705
bazelbuild/bazel
bazelbuild/bazel/4222
bazelbuild/bazel/4705
[ "timestamp(timedelta=1.0, similarity=0.8857976795019705)" ]
66c52e37d83371d93cea712c73f6b7355e0a0d0c
493e72da7672d83f7329eb1b3456931f03cd04df
[ "cc @razvanm", "@brandjon , not sure if anyone owns this area of Bazel; could you maybe take a look?", "I can look in my spare cycles but I won't be able to get to this soon.", "Forwarding to dslomov as requested.", "BazelWorkspaceStatusAction.equals is incorrect - it doesn't check for equality of the clien...
[ "add a non-stable key as well, assert that changing it will not trigger a rebuild", "Please remove the `.sh` ending here and in other `mktemp` calls.\r\nOn macOS `mktemp` requires that the XXXs be at the end of the template, otherwise the command creates a file called literally `wsc-XXXXXXXX.sh`.", "Good point ...
2018-02-26T03:42:49Z
[ "type: bug", "P3", "category: misc > misc" ]
clientEnv is cached for workspace status command
Please provide the following information. The more we know about your system and use case, the more easily and likely we can help. ### Description of the problem / feature request / question: The client environment passed to the BazelWorkspaceStatusModule is cached across runs. https://github.com/bazelbuild/bazel/blob/d926bc40260549b997a6a5a1e82d9e7999dbb65e/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java#L106 This means we have to do `bazel clean` whenever any stable value changes as a result of change in environment variables. ### If possible, provide a minimal example to reproduce the problem: File env_status.sh ``` #!/bin/bash env | sed -e 's/^/STABLE_/' -e 's/\=/ /' ``` File WORKSPACE is empty. Demonstration: ``` (bazel build --workspace_status_command=./env_status.sh @bazel_tools//tools/zip:zipper 2>&1 && cat bazel-out/stable-status.txt) | grep STABLE_FOO # Not found; expected. # Set a new environment variable and check. export FOO="Checking environment input." (bazel build --workspace_status_command=./env_status.sh @bazel_tools//tools/zip:zipper 2>&1 && cat bazel-out/stable-status.txt) | grep STABLE_FOO # Not found; unexpected. # Clean cache and try again. bazel clean (bazel build --workspace_status_command=./env_status.sh @bazel_tools//tools/zip:zipper 2>&1 && cat bazel-out/stable-status.txt) | grep STABLE_FOO # Found; expected. unset FOO (bazel build --workspace_status_command=./env_status.sh @bazel_tools//tools/zip:zipper 2>&1 && cat bazel-out/stable-status.txt) | grep STABLE_FOO # Found; unexpected. ``` ### Environment info * Operating System: macOS 10.13.1 * Bazel version (output of `bazel info release`): release 0.8.0-homebrew ### Have you found anything relevant by searching the web? Nothing related to client environment in relation to stable or volatile status. ### Anything else, information or logs or outputs that would be helpful?
[ "src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java" ]
[ "src/test/shell/bazel/bazel_workspace_status_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java index 9a74ccc95fa64d..ebd3171ebdf8b8 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java @@ -252,15 +252,18 @@ public boolean equals(Object o) { return false; } + // We consider clientEnv in equality because we pass it when executing the workspace status command + BazelWorkspaceStatusAction that = (BazelWorkspaceStatusAction) o; - return this.stableStatus.equals(that.stableStatus) + return this.clientEnv.equals(that.clientEnv) + && this.stableStatus.equals(that.stableStatus) && this.volatileStatus.equals(that.volatileStatus) && this.options.equals(that.options); } @Override public int hashCode() { - return Objects.hash(stableStatus, volatileStatus, options); + return Objects.hash(clientEnv, stableStatus, volatileStatus, options); } @Override
diff --git a/src/test/shell/bazel/bazel_workspace_status_test.sh b/src/test/shell/bazel/bazel_workspace_status_test.sh index 9d589efc08fbc4..508dabb9055b68 100755 --- a/src/test/shell/bazel/bazel_workspace_status_test.sh +++ b/src/test/shell/bazel/bazel_workspace_status_test.sh @@ -48,7 +48,7 @@ EOF function test_workspace_status_parameters() { create_new_workspace - local cmd=$TEST_TMPDIR/status.sh + local cmd=`mktemp $TEST_TMPDIR/wsc-XXXXXXXX` cat > $cmd <<EOF #!/bin/bash @@ -74,7 +74,7 @@ EOF function test_workspace_status_cpp() { create_new_workspace - local cmd=$TEST_TMPDIR/status.sh + local cmd=`mktemp $TEST_TMPDIR/wsc-XXXXXXXX` cat > $cmd <<EOF #!/bin/bash @@ -135,13 +135,14 @@ EOF function test_stable_and_volatile_status() { create_new_workspace - cat >$TEST_TMPDIR/wsc.sh <<EOF + local wsc=`mktemp $TEST_TMPDIR/wsc-XXXXXXXX` + cat >$wsc <<EOF #!/bin/bash cat $TEST_TMPDIR/status EOF - chmod +x $TEST_TMPDIR/wsc.sh + chmod +x $wsc cat > BUILD <<'EOF' genrule( @@ -157,7 +158,7 @@ STABLE_NAME alice NUMBER 1 EOF - bazel build --workspace_status_command=$TEST_TMPDIR/wsc.sh --stamp //:a || fail "build failed" + bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" assert_contains "STABLE_NAME alice" bazel-genfiles/ao assert_contains "NUMBER 1" bazel-genfiles/ao @@ -168,7 +169,7 @@ NUMBER 2 EOF # Changes to volatile fields should not result in a rebuild - bazel build --workspace_status_command=$TEST_TMPDIR/wsc.sh --stamp //:a || fail "build failed" + bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" assert_contains "STABLE_NAME alice" bazel-genfiles/ao assert_contains "NUMBER 1" bazel-genfiles/ao @@ -178,10 +179,54 @@ NUMBER 3 EOF # Changes to stable fields should result in a rebuild - bazel build --workspace_status_command=$TEST_TMPDIR/wsc.sh --stamp //:a || fail "build failed" + bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" assert_contains "STABLE_NAME bob" bazel-genfiles/ao assert_contains "NUMBER 3" bazel-genfiles/ao } +function test_env_var_in_workspace_status() { + create_new_workspace + local wsc=`mktemp $TEST_TMPDIR/wsc-XXXXXXXX` + cat >$wsc <<'EOF' +#!/bin/bash + +echo "STABLE_ENV" ${STABLE_VAR} +echo "VOLATILE_ENV" ${VOLATILE_VAR} +EOF + + chmod +x $wsc + + cat > BUILD <<'EOF' +genrule( + name = "a", + srcs = [], + outs = ["ao"], + cmd="(echo volatile; cat bazel-out/volatile-status.txt; echo; echo stable; cat bazel-out/stable-status.txt; echo) > $@", + stamp=1) +EOF + + STABLE_VAR=alice VOLATILE_VAR=one bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" + assert_contains "STABLE_ENV alice" bazel-out/stable-status.txt + assert_contains "VOLATILE_ENV one" bazel-out/volatile-status.txt + assert_contains "STABLE_ENV alice" bazel-genfiles/ao + assert_contains "VOLATILE_ENV one" bazel-genfiles/ao + + # Changes to the env var should be reflected into the stable-status file, and thus trigger a rebuild + STABLE_VAR=bob VOLATILE_VAR=two bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" + assert_contains "STABLE_ENV bob" bazel-out/stable-status.txt + assert_contains "VOLATILE_ENV two" bazel-out/volatile-status.txt + assert_contains "STABLE_ENV bob" bazel-genfiles/ao + assert_contains "VOLATILE_ENV two" bazel-genfiles/ao + + # Changes to volatile fields should not result in a rebuild (but should update the stable & volatile status files) + STABLE_VAR=bob VOLATILE_VAR=three bazel build --workspace_status_command=$wsc --stamp //:a || fail "build failed" + assert_contains "STABLE_ENV bob" bazel-out/stable-status.txt + assert_contains "VOLATILE_ENV three" bazel-out/volatile-status.txt + # We did not rebuild, so the output remains at the previous values + assert_contains "STABLE_ENV bob" bazel-genfiles/ao + assert_contains "VOLATILE_ENV two" bazel-genfiles/ao + +} + run_suite "workspace status tests"
test
train
2018-03-06T03:22:55
2017-12-04T13:55:34Z
siddharthab
test
bazelbuild/bazel/4255_6472
bazelbuild/bazel
bazelbuild/bazel/4255
bazelbuild/bazel/6472
[ "timestamp(timedelta=0.0, similarity=0.8619646931969689)" ]
12987e858cca0e517f429fec2340ef69a2b9260a
7376bfc385945473ba57e4a345f9a5ebebd25f3e
[ "I know nothing about zsh.\r\n\r\n@schroederc : I believe you added the zsh completion script to Bazel in commit https://github.com/bazelbuild/bazel/commit/6b2766dd0, so I'm hoping you can help.\r\n@damienmg : you approved Cody's change, you may know about zsh.", "also confused by this sentence", "The `_bazel` ...
[]
2018-10-23T08:13:44Z
[ "type: documentation (cleanup)", "P3", "team-Bazel" ]
Can someone elaborate on the instructions to install zsh completion?
I'm looking at the instructions for how to install zsh completion [here](https://docs.bazel.build/versions/master/install.html#zsh) and am left a little confused about what to do. I'm only a casual user of ZSH, so I think I'm missing something fundamental. ># Getting zsh completion > >Bazel also comes with a zsh completion script. To install it: > >Add this script to a directory on your `$fpath`: >``` >fpath[1,0]=~/.zsh/completion/ >mkdir -p ~/.zsh/completion/ >cp scripts/zsh_completion/_bazel ~/.zsh/completion >``` > >You may have to call `rm -f ~/.zcompdump; compinit` the first time to make it work. > >Optionally, add the following to your .zshrc. >``` ># This way the completion script does not have to parse Bazel's options ># repeatedly. The directory in cache-path must be created manually. >zstyle ':completion:*' use-cache on >zstyle ':completion:*' cache-path ~/.zsh/cache >``` The second step is very clear, but the first is confusing to me. My `$fpath` includes a whole list of directories. So should I just pick a directory and write a file with the contents of that first script? Does it matter what I name it? Is there an existing convention I should be following? I'm reviewing the docs for zsh functions at http://zsh.sourceforge.net/Doc/Release/Functions.html, but I'm still unsure of how to proceed.
[ "site/_layouts/documentation.html", "site/docs/install-os-x.md", "site/docs/install-ubuntu.md" ]
[ "site/_layouts/documentation.html", "site/docs/completion.md", "site/docs/install-os-x.md", "site/docs/install-ubuntu.md" ]
[]
diff --git a/site/_layouts/documentation.html b/site/_layouts/documentation.html index 04b2fd401b1ea1..77410c6b11d506 100644 --- a/site/_layouts/documentation.html +++ b/site/_layouts/documentation.html @@ -47,6 +47,7 @@ <h3>Using Bazel</h3> <li><a href="/versions/{{ site.version }}/install-os-x.html">Installing on macOS</a></li> <li><a href="/versions/{{ site.version }}/install-windows.html">Installing on Windows</a></li> <li><a href="/versions/{{ site.version }}/install-compile-source.html">Compiling from Source</a></li> + <li><a href="/versions/{{ site.version }}/completion.html">Command-Line Completion</a></li> <li><a href="/versions/{{ site.version }}/ide.html">Integrating with IDEs</a></li> </ul> </li> diff --git a/site/docs/completion.md b/site/docs/completion.md new file mode 100644 index 00000000000000..4936bf6aaa8713 --- /dev/null +++ b/site/docs/completion.md @@ -0,0 +1,90 @@ +--- +layout: documentation +title: "Command-Line Completion" +--- + +# Command-Line Completion + +You can enable command-line completion (also known as tab-completion) in Bash +and Zsh. This lets you tab-complete command names, flags names and flag values, +and target names. + +<h2 id="bash">Bash completion</h2> + +Bazel comes with a Bash completion script. + +If you installed Bazel: + +* From the APT repository, then you're done -- the Bash completion script is + already installed in `/etc/bash_completion.d`. + +* From the installer downloaded from GitHub, then: + 1. Locate the absolute path of the completion file. The installer copied it + to the `bin` directory. + + Example: if you ran the installer with `--user`, this will be + `$HOME/.bazel/bin`. If you ran the installer as root, this will be + `/usr/local/bazel/bin`. + 2. Do one of the following: + * Either copy this file to your completion directory (if you have + one). + + Example: on Ubuntu this is the `/etc/bash_completion.d` directory. + * Or source the completion file from Bash's RC file. + + Add a line similar to the one below to your `~/.bashrc` (on Ubuntu) + or `~/.bash_profile` (on macOS), using the path to your completion + file's absolute path: + + ``` + source /path/to/bazel-complete.bash + ``` + +* Via [bootstrapping](install-compile-source.html), then: + 1. Build the completion script: + + ``` + bazel build //scripts:bazel-complete.bash + ``` + 2. The completion file is built under + `bazel-bin/scripts/bazel-complete.bash`. + + Do one of the following: + * Either copy this file to your completion directory (if you have + one). + + Example: on Ubuntu this is the `/etc/bash_completion.d` directory + * Or copy it somewhere on your local disk, e.g. to `$HOME`, and + source the completion file from Bash's RC file. + + Add a line similar to the one below to your `~/.bashrc` (on Ubuntu) + or `~/.bash_profile` (on macOS), using the path to your completion + file's absolute path: + + ``` + source /path/to/bazel-complete.bash + ``` + +<h2 name="zsh">Zsh completion</h2> + +Bazel also comes with a Zsh completion script. To install it: + +1. Add this script to a directory on your `$fpath`: + + ``` + fpath[1,0]=~/.zsh/completion/ + mkdir -p ~/.zsh/completion/ + cp scripts/zsh_completion/_bazel ~/.zsh/completion + ``` + + You may have to call `rm -f ~/.zcompdump; compinit` + the first time to make it work. + +2. Optionally, add the following to your .zshrc. + + ``` + # This way the completion script does not have to parse Bazel's options + # repeatedly. The directory in cache-path must be created manually. + zstyle ':completion:*' use-cache on + zstyle ':completion:*' cache-path ~/.zsh/cache + ``` diff --git a/site/docs/install-os-x.md b/site/docs/install-os-x.md index eb8a5aced14465..77f2f7d4e5ab0e 100644 --- a/site/docs/install-os-x.md +++ b/site/docs/install-os-x.md @@ -13,8 +13,8 @@ Install Bazel on macOS using one of the following methods: Bazel comes with two completion scripts. After installing Bazel, you can: -* Access the [bash completion script](install.md) -* Install the [zsh completion script](install.md) +* Access the [bash completion script](completion.md#bash) +* Install the [zsh completion script](completion.md#zsh) ## <a name="install-with-installer-mac-os-x"></a>Installing using binary installer diff --git a/site/docs/install-ubuntu.md b/site/docs/install-ubuntu.md index ba36e6d3a4b6b3..a52ae8b39165ad 100644 --- a/site/docs/install-ubuntu.md +++ b/site/docs/install-ubuntu.md @@ -18,8 +18,8 @@ Install Bazel on Ubuntu using one of the following methods: Bazel comes with two completion scripts. After installing Bazel, you can: -* Access the [bash completion script](install.md) -* Install the [zsh completion script](install.md) +* Access the [bash completion script](completion.md#bash) +* Install the [zsh completion script](completion.md#zsh) ## <a name="install-with-installer-ubuntu"></a>Installing using binary installer
null
test
train
2018-10-22T23:27:46
2017-12-07T20:52:28Z
vmrob
test
bazelbuild/bazel/4378_5385
bazelbuild/bazel
bazelbuild/bazel/4378
bazelbuild/bazel/5385
[ "timestamp(timedelta=0.0, similarity=0.9039208917346069)" ]
348225e4d25b9259489c1ed66eb7eca7612cddcc
273b4dd14a7359d90defd2e257be53b65f5bfefe
[ "We ran into the same problem in all our own windows builder machines. Removing the following two directories fixed the problem: C:\\Users\\builder\\\\_bazel_LOCAL\\ SERVICE/install/dc4fe1b7fd90df4d3976b7aaa4b41899 and cygwin /tmp/_bazel_LOCAL\\ SERVICE/install/dc4fe1b7fd90df4d3976b7aaa4b41899. But it is not addre...
[]
2018-06-13T12:41:38Z
[ "type: bug", "P1", "platform: windows", "category: misc > misc", "breakage" ]
Windows: Error: corrupt installation
I noticed this error in many places, my local machine, [Bazel CI](https://ci.bazel.io/blue/organizations/jenkins/bazel-tests/detail/bazel-tests/1606/pipeline), [Tensorflow CI](http://ci.tensorflow.org/job/tf-master-win-bzl/2189/console), ``` Error: corrupt installation: file 'C:\tmp/_bazel_pcloudy/install/6f94f50e4679b4d40059370500e5cb9c/_embedded_binaries/A-server.jar' modified. Please remove 'C:\tmp/_bazel_pcloudy/install/6f94f50e4679b4d40059370500e5cb9c' and try again. ``` The interesting part is that, it happens with every old Bazel versions **in the new year**! The file timestamps are all set to `Jan 1 2027`. ``` pcloudy@tensorflow-jenkins-win-gpu2-slave MSYS ~/workspace/tensorflow $ ll /c/tmp/_bazel_pcloudy/install/6f94f50e4679b4d40059370500e5cb9c/_embedded_binaries total 44894 -rw-r--r-- 1 pcloudy None 45074399 Jan 1 2027 A-server.jar -rwxr-xr-x 1 pcloudy None 257536 Jan 1 2027 build-runfiles.exe drwxr-xr-x 1 pcloudy None 0 Oct 19 16:13 embedded_tools -rw-r--r-- 1 pcloudy None 33 Jan 1 2027 install_base_key -rw-r--r-- 1 pcloudy None 4 Jan 1 2027 java.version -rw-r--r-- 1 pcloudy None 3849 Jan 1 2027 jdk.BUILD -rwxr-xr-x 1 pcloudy None 90112 Jan 1 2027 linux-sandbox.exe -rwxr-xr-x 1 pcloudy None 257536 Jan 1 2027 process-wrapper.exe -rwxr-xr-x 1 pcloudy None 272896 Jan 1 2027 windows_jni.dll -rwxr-xr-x 1 pcloudy None 698 Jan 1 2027 xcode-locator ``` @laszlocsomor Do you have any idea about this? Is there anything wrong with our file invalid mechanism? FYI @mhlopko
[ "src/main/cpp/util/file_windows.cc" ]
[ "src/main/cpp/util/file_windows.cc" ]
[]
diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc index 537852eb70b310..ee045a3718f510 100644 --- a/src/main/cpp/util/file_windows.cc +++ b/src/main/cpp/util/file_windows.cc @@ -114,16 +114,59 @@ class WindowsFileMtime : public IFileMtime { bool SetToDistantFuture(const string& path) override; private: + // 1 year in FILETIME. + static const ULARGE_INTEGER kOneYear; // 9 years in the future. const FILETIME near_future_; // 10 years in the future. const FILETIME distant_future_; - static FILETIME GetNow(); - static FILETIME GetFuture(WORD years); + static ULARGE_INTEGER&& OneYearDelay(); + static const FILETIME GetNow(); + static const FILETIME GetFuture(WORD years); static bool Set(const string& path, const FILETIME& time); }; +const ULARGE_INTEGER WindowsFileMtime::kOneYear = + std::move(WindowsFileMtime::OneYearDelay()); + +ULARGE_INTEGER&& WindowsFileMtime::OneYearDelay() { + SYSTEMTIME now; + GetSystemTime(&now); + now.wMonth = 1; + now.wDayOfWeek = 0; + now.wDay = 1; + now.wHour = 0; + now.wMinute = 0; + now.wSecond = 0; + now.wMilliseconds = 0; + + FILETIME now_ft; + if (!::SystemTimeToFileTime(&now, &now_ft)) { + string err = GetLastErrorString(); + BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) + << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 1 failed: " + << err; + } + ULARGE_INTEGER t1; + t1.LowPart = now_ft.dwLowDateTime; + t1.HighPart = now_ft.dwHighDateTime; + + now.wYear++; + if (!::SystemTimeToFileTime(&now, &now_ft)) { + string err = GetLastErrorString(); + BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) + << "WindowsFileMtime::OneYearDelay: SystemTimeToFileTime 2 failed: " + << err; + } + ULARGE_INTEGER t2; + t2.LowPart = now_ft.dwLowDateTime; + t2.HighPart = now_ft.dwHighDateTime; + + t2.QuadPart -= t1.QuadPart; + return std::move(t2); +} + bool WindowsFileMtime::GetIfInDistantFuture(const string& path, bool* result) { if (path.empty()) { return false; @@ -215,36 +258,23 @@ bool WindowsFileMtime::Set(const string& path, const FILETIME& time) { /* lpLastWriteTime */ &time) == TRUE; } -FILETIME WindowsFileMtime::GetNow() { - SYSTEMTIME sys_time; - ::GetSystemTime(&sys_time); - FILETIME file_time; - if (!::SystemTimeToFileTime(&sys_time, &file_time)) { - BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) - << "WindowsFileMtime::GetNow: SystemTimeToFileTime failed: " - << GetLastErrorString(); - } - return file_time; -} - -FILETIME WindowsFileMtime::GetFuture(WORD years) { - SYSTEMTIME future_time; - GetSystemTime(&future_time); - future_time.wYear += years; - future_time.wMonth = 1; - future_time.wDayOfWeek = 0; - future_time.wDay = 1; - future_time.wHour = 0; - future_time.wMinute = 0; - future_time.wSecond = 0; - future_time.wMilliseconds = 0; - FILETIME file_time; - if (!::SystemTimeToFileTime(&future_time, &file_time)) { - BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) - << "WindowsFileMtime::GetFuture: SystemTimeToFileTime failed: " - << GetLastErrorString(); - } - return file_time; +const FILETIME WindowsFileMtime::GetNow() { + FILETIME now; + GetSystemTimeAsFileTime(&now); + return now; +} + +const FILETIME WindowsFileMtime::GetFuture(WORD years) { + FILETIME result; + GetSystemTimeAsFileTime(&result); + + ULARGE_INTEGER result_value; + result_value.LowPart = result.dwLowDateTime; + result_value.HighPart = result.dwHighDateTime; + result_value.QuadPart += kOneYear.QuadPart * years; + result.dwLowDateTime = result_value.LowPart; + result.dwHighDateTime = result_value.HighPart; + return result; } IFileMtime* CreateFileMtime() { return new WindowsFileMtime(); }
null
val
train
2018-06-13T14:10:15
2018-01-02T16:29:36Z
meteorcloudy
test
bazelbuild/bazel/4381_5287
bazelbuild/bazel
bazelbuild/bazel/4381
bazelbuild/bazel/5287
[ "timestamp(timedelta=1.0, similarity=0.9110885140979402)" ]
ab0132928467970d55426dd32580b03508b3b68a
406a104e219f2393aa1d31fa0e1c142aeda06ba1
[ "The android_common jars need to be updated for this to work. I'll take a look.", "Adding some more info to help repro:\r\n\r\n### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.\r\n\r\nWorking app on master:\r\nhttps://github.com/hasadna/hasadna\r\nTo r...
[]
2018-05-29T02:18:59Z
[ "type: feature request", "P2" ]
Android: support font in XML
### Description of the problem / feature request / question: Bazel does not support newly-added Android feature [Fonts in XML](https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html) ### Environment info * Operating System: macOS 10.13.2 * Bazel version (output of `bazel info release`): release 0.9.0-homebrew ### Log ``` $ bazel build --verbose_failures :android ERROR: app/BUILD:11:22: in resource_files attribute of android_binary rule //app:android: 'app/src/main/res/font/heebo_black.ttf' is not in the expected resource directory structure of <resource directory>/{anim,animator,color,drawable,interpolator,layout,menu,mipmap,raw,transition,values,xml}/<file> ERROR: Analysis of target '//app:android' failed; build aborted: Analysis of target '//app:android' failed; build aborted INFO: Elapsed time: 0.296s FAILED: Build did NOT complete successfully (1 packages loaded) ```
[]
[ "src/test/shell/bazel/android/testdata/LICENSE.txt" ]
[ "src/test/shell/bazel/android/BUILD", "src/test/shell/bazel/android/resource_processing_integration_test.sh" ]
diff --git a/src/test/shell/bazel/android/testdata/LICENSE.txt b/src/test/shell/bazel/android/testdata/LICENSE.txt new file mode 100755 index 00000000000000..75b52484ea471f --- /dev/null +++ b/src/test/shell/bazel/android/testdata/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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.
diff --git a/src/test/shell/bazel/android/BUILD b/src/test/shell/bazel/android/BUILD index 06245c74996150..359d746e4af83c 100644 --- a/src/test/shell/bazel/android/BUILD +++ b/src/test/shell/bazel/android/BUILD @@ -117,3 +117,15 @@ sh_test( ], shard_count = 4, ) + +sh_test( + name = "resource_processing_integration_test", + size = "medium", + srcs = ["resource_processing_integration_test.sh"], + data = [ + ":android_helper", + "//external:android_sdk_for_testing", + "//src/test/shell/bazel:test-deps", + ":testdata/roboto.ttf", + ], +) diff --git a/src/test/shell/bazel/android/resource_processing_integration_test.sh b/src/test/shell/bazel/android/resource_processing_integration_test.sh new file mode 100755 index 00000000000000..1362d7ec983bd2 --- /dev/null +++ b/src/test/shell/bazel/android/resource_processing_integration_test.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# +# Copyright 2017 The Bazel Authors. All rights reserved. +# +# 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. + +# For these tests to run do the following: +# +# 1. Install an Android SDK from https://developer.android.com +# 2. Set the $ANDROID_HOME environment variable +# 3. Uncomment the line in WORKSPACE containing android_sdk_repository +# +# Note that if the environment is not set up as above android_integration_test +# will silently be ignored and will be shown as passing. + +# Load the test setup defined in the parent directory +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +source "${CURRENT_DIR}/android_helper.sh" \ + || { echo "android_helper.sh not found!" >&2; exit 1; } +fail_if_no_android_sdk + +source "${CURRENT_DIR}/../../integration_test_setup.sh" \ + || { echo "integration_test_setup.sh not found!" >&2; exit 1; } + +function setup_font_resources() { + rm java/bazel/BUILD + + cat > java/bazel/BUILD <<EOF +package(default_visibility = ["//visibility:public"]) +aar_import( + name = "aar", + aar = "sample.aar", +) +android_library( + name = "lib", + srcs = ["Lib.java"], + deps = [":aar"], +) +android_binary( + name = "bin", + srcs = ["MainActivity.java"], + resource_files = glob(["res/**"]), + manifest = "AndroidManifest.xml", + deps = [":lib"], +) +EOF + mkdir -p java/bazel/res/font + cp "$TEST_SRCDIR/io_bazel/src/test/shell/bazel/android/testdata/roboto.ttf" \ + java/bazel/res/font/ + + mkdir -p java/bazel/res/values + cat > java/bazel/res/values/styles.xml <<EOF +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="AppTheme"> + <item name="android:fontFamily">@font/roboto</item> + </style> +</resources> +EOF + + cat > java/bazel/AndroidManifest.xml <<EOF +<manifest + xmlns:android="http://schemas.android.com/apk/res/android" + package="bazel.android"> + <application + android:label="Bazel App" + android:theme="@style/AppTheme" > + <activity + android:name="bazel.MainActivity" + android:label="Bazel" /> + </application> +</manifest> +EOF +} + +function test_font_support() { + create_new_workspace + setup_android_sdk_support + create_android_binary + setup_font_resources + + assert_build //java/bazel:bin +} + +run_suite "Resource processing integration tests"
train
train
2018-05-31T19:25:00
2018-01-03T18:17:41Z
vmax
test
bazelbuild/bazel/4511_4512
bazelbuild/bazel
bazelbuild/bazel/4511
bazelbuild/bazel/4512
[ "timestamp(timedelta=0.0, similarity=0.8578533362755757)" ]
344b08c032b5520ba333fae4a4ab9d1d64eec6f8
278c7167b9edd79d4a1ad5c33c03f3cf7cdedabd
[]
[]
2018-01-24T01:45:29Z
[]
Skylint crashes when invoked on a file with a nested function.
### Description of the problem / feature request: > Skylint crashes with an error below when analyzing a .bzl file with a nested function. A file with ``` def yo(): def bar(): pass ``` will cause Skylint crash: ``` Exception in thread "main" java.lang.IllegalStateException at com.google.common.base.Preconditions.checkState(Preconditions.java:485) at com.google.devtools.skylark.skylint.ControlFlowChecker.visit(ControlFlowChecker.java:159) at com.google.devtools.build.lib.syntax.FunctionDefStatement.accept(FunctionDefStatement.java:78) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visit(SyntaxTreeVisitor.java:28) at com.google.devtools.skylark.skylint.ControlFlowChecker.visitBlock(ControlFlowChecker.java:86) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visit(SyntaxTreeVisitor.java:141) at com.google.devtools.skylark.skylint.ControlFlowChecker.visit(ControlFlowChecker.java:161) at com.google.devtools.build.lib.syntax.FunctionDefStatement.accept(FunctionDefStatement.java:78) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visit(SyntaxTreeVisitor.java:28) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visitAll(SyntaxTreeVisitor.java:34) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visitBlock(SyntaxTreeVisitor.java:47) at com.google.devtools.skylark.skylint.ControlFlowChecker.visitBlock(ControlFlowChecker.java:75) at com.google.devtools.build.lib.syntax.SyntaxTreeVisitor.visit(SyntaxTreeVisitor.java:62) at com.google.devtools.skylark.skylint.ControlFlowChecker.check(ControlFlowChecker.java:68) at com.google.devtools.skylark.skylint.Linter.lint(Linter.java:122) at com.google.devtools.skylark.skylint.Skylint.main(Skylint.java:48) ERROR: Non-zero return code '1' from command: Process exited with status 1 ``` ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. > run Skylint on file with content described above ### Any other information, logs, or outputs that you want to share? > Technically nested functions are already covered by Skylint linter, because EventHandler errors that happen during build file parsing are recorded as parse-error, but CFChecker does not know about this, so either CFChecker should be made resilient to this issue, or parse errors should prevent other checkers from running. I have a patch for the first option, but believe that second option may be a better one.
[ "scripts/ij.bazelproject", "src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java", "src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java" ]
[ "scripts/ij.bazelproject", "src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java", "src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java" ]
[]
diff --git a/scripts/ij.bazelproject b/scripts/ij.bazelproject index e90868242d2cf0..f13282c5b8ced5 100644 --- a/scripts/ij.bazelproject +++ b/scripts/ij.bazelproject @@ -20,3 +20,4 @@ targets: //src/test/... -//src/test/docker/... //src/tools/remote/... + //src/tools/skylark/... diff --git a/src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java b/src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java index db28c52f6dba94..729e3e3f08d7ed 100644 --- a/src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java +++ b/src/tools/skylark/java/com/google/devtools/skylark/skylint/ControlFlowChecker.java @@ -46,7 +46,8 @@ // TODO(skylark-team): Check for unreachable statements public class ControlFlowChecker extends SyntaxTreeVisitor { private static final String MISSING_RETURN_VALUE_CATEGORY = "missing-return-value"; - public static final String UNREACHABLE_STATEMENT_CATEGORY = "unreachable-statement"; + private static final String UNREACHABLE_STATEMENT_CATEGORY = "unreachable-statement"; + private static final String NESTED_FUNCTION_CATEGORY = "nested-function"; private final List<Issue> issues = new ArrayList<>(); @@ -156,7 +157,16 @@ public static boolean isFail(Expression expression) { @Override public void visit(FunctionDefStatement node) { - Preconditions.checkState(cfi == null); + if (cfi != null) { + issues.add( + Issue.create( + NESTED_FUNCTION_CATEGORY, + node.getIdentifier() + " is a nested function which is not allowed." + + " Consider inlining it or moving it to top-level." + + " For more details, have a look at the Skylark documentation.", + node.getLocation())); + return; + } cfi = ControlFlowInfo.entry(); super.visit(node); if (cfi.hasReturnWithValue && (!cfi.returnsAlwaysExplicitly || cfi.hasReturnWithoutValue)) { diff --git a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java index 6d7a673accc5e0..839e47c3490920 100644 --- a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java +++ b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/ControlFlowCheckerTest.java @@ -15,6 +15,7 @@ package com.google.devtools.skylark.skylint; import com.google.common.truth.Truth; +import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.syntax.BuildFileAST; import java.util.List; import org.junit.Test; @@ -23,15 +24,20 @@ @RunWith(JUnit4.class) public class ControlFlowCheckerTest { - private static List<Issue> findIssues(String... lines) { + private static List<Issue> findIssues(EventHandler eventHandler, String... lines) { String content = String.join("\n", lines); BuildFileAST ast = - BuildFileAST.parseString( - event -> { + BuildFileAST.parseString( + eventHandler, + content); + return ControlFlowChecker.check(ast); + } + + private static List<Issue> findIssues(String... lines) { + return findIssues(event -> { throw new IllegalArgumentException(event.getMessage()); }, - content); - return ControlFlowChecker.check(ast); + lines); } @Test @@ -59,6 +65,24 @@ public void testIfElseReturnMissing() throws Exception { + " For more details, have a look at the documentation. [missing-return-value]"); } + @Test + public void testNestedFunction() { + Truth.assertThat( + findIssues( + event -> { + }, + "def foo():", + " def bar():", + " pass", + " return") + .toString()) + .contains( + "2:3-3:8: bar is a nested function which is not allowed." + + " Consider inlining it or moving it to top-level." + + " For more details, have a look at the Skylark documentation." + + " [nested-function]"); + } + @Test public void testIfElseReturnValueMissing() throws Exception { String messages =
null
train
train
2018-01-24T00:34:32
2018-01-24T01:40:18Z
ttsugriy
test
bazelbuild/bazel/4561_9976
bazelbuild/bazel
bazelbuild/bazel/4561
bazelbuild/bazel/9976
[ "timestamp(timedelta=1.0, similarity=0.8941857375009304)" ]
75cbf829a51c5e2b24f9d1382667dfdf81d18bda
d267cc4567e55040f5dd0c59e66bfc7ac3c21552
[ "The same error in tensorflow:\r\n```\r\nERROR: C:/users/chebotarev_v/documents/src/tensorflow/tensorflow/contrib/lite/BUILD:62:1: output 'tensorflow/contrib/lite/libcontext.ifso' was not created\r\nERROR: C:/users/chebotarev_v/documents/src/tensorflow/tensorflow/contrib/lite/BUILD:62:1: Couldn't build file tensorf...
[ "Seems name of function is not very good, because def file created by this function is suitable only for `.dll`. Maybe createTrivial**Dll**DefFileAction is better? ", "I think the fact we are creating a DEF file implies it's for a Windows DLL, there's no DEF file for shared library on other platforms, right?", ...
2019-10-09T13:58:03Z
[ "type: feature request", "P2", "platform: windows", "category: misc > misc" ]
Building Windows DLL without exports fails
### Description of the problem / feature request: In order to produce import library for a DLL bazel uses `/IMPLIB` flag of the linker and expect that it will force creating import library in the place specified: https://msdn.microsoft.com/en-us/library/67wc07b9.aspx Unfortunately, this flag is not managing the fact of creating or not creating import library but only sets the name for it. If DLL does not export anything, linker do not create it by design. Unluckily, we actively use DLLs without imports for a reason. The output of bazel is as follows: ``` C:\Users\Chebotarev_V\Documents\bazel-issues\windows-dll-without-exports>bazel build ... INFO: Analysed target //:hellolib.dll (8 packages loaded). INFO: Found 1 target... ERROR: C:/users/chebotarev_v/documents/bazel-issues/windows-dll-without-exports/BUILD:3:1: output 'hellolib.ifso' was not created ERROR: C:/users/chebotarev_v/documents/bazel-issues/windows-dll-without-exports/BUILD:3:1: not all outputs were created or valid Target //:hellolib.dll failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 49.652s, Critical Path: 1.14s FAILED: Build did NOT complete successfully ``` Please find an example in my repository: https://github.com/excitoon/bazel-issues/tree/master/windows-dll-without-exports ### Feature requests: what underlying problem are you trying to solve with this feature? We need building DLLs without exports. ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. https://github.com/excitoon/bazel-issues/tree/master/windows-dll-without-exports ### What operating system are you running Bazel on? Windows 10 x64 ### What's the output of `bazel info release`? ``` Build label: 0.10.0 Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Thu Nov 9 22:42:19 +50056 (1517474731339) Build timestamp: 1517474731339 Build timestamp as int: 1517474731339 ``` ### Have you found anything relevant by searching the web? Nothing expect mentioned.
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java", "src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java", "src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java" ]
[ "src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java", "src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java", "src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java" ]
[ "src/test/py/bazel/bazel_windows_cpp_test.py" ]
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index f4ffbd86fd8970..660daabd4ab923 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -430,7 +430,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont CcLinkingContext depsCcLinkingContext = collectCcLinkingContext(ruleContext); Artifact generatedDefFile = null; - Artifact customDefFile = null; + Artifact winDefFile = null; if (isLinkShared(ruleContext)) { if (featureConfiguration.isEnabled(CppRuleClasses.TARGETS_WINDOWS)) { ImmutableList.Builder<Artifact> objectFiles = ImmutableList.builder(); @@ -457,7 +457,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont CppHelper.createDefFileActions( ruleContext, defParser, objectFiles.build(), binary.getFilename()); } - customDefFile = common.getWinDefFile(); + winDefFile = CppHelper.getWindowsDefFileForLinking(ruleContext, common.getWinDefFile(), generatedDefFile, featureConfiguration); } } @@ -507,8 +507,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont cppConfiguration, linkType, pdbFile, - generatedDefFile, - customDefFile); + winDefFile); CcLinkingOutputs ccLinkingOutputsBinary = ccLinkingOutputsAndCcLinkingInfo.first; @@ -697,8 +696,7 @@ public static Pair<CcLinkingOutputs, CcLauncherInfo> createTransitiveLinkingActi CppConfiguration cppConfiguration, LinkTargetType linkType, Artifact pdbFile, - Artifact generatedDefFile, - Artifact customDefFile) + Artifact winDefFile) throws InterruptedException, RuleErrorException { CcCompilationOutputs.Builder ccCompilationOutputsBuilder = CcCompilationOutputs.builder() @@ -823,11 +821,7 @@ public static Pair<CcLinkingOutputs, CcLauncherInfo> createTransitiveLinkingActi .setPdbFile(pdbFile) .setFake(fake); - if (customDefFile != null) { - ccLinkingHelper.setDefFile(customDefFile); - } else if (CppHelper.shouldUseGeneratedDefFile(ruleContext, featureConfiguration)) { - ccLinkingHelper.setDefFile(generatedDefFile); - } + ccLinkingHelper.setDefFile(winDefFile); return Pair.of( ccLinkingHelper.link(ccCompilationOutputsWithOnlyObjects), diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java index 814b066c590861..ee3cb3de730089 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java @@ -311,11 +311,10 @@ public static void init( if (ruleContext.getRule().getImplicitOutputsFunction() != ImplicitOutputsFunction.NONE || !ccCompilationOutputs.isEmpty()) { if (featureConfiguration.isEnabled(CppRuleClasses.TARGETS_WINDOWS)) { - // If user specifies a custom DEF file, then we use it. - Artifact defFile = common.getWinDefFile(); + Artifact customDefFile = common.getWinDefFile(); + Artifact generatedDefFile = null; Artifact defParser = common.getDefParser(); - Artifact generatedDefFile = null; if (defParser != null) { try { generatedDefFile = @@ -332,18 +331,7 @@ public static void init( throw ruleContext.throwWithRuleError(e.getMessage()); } } - - // If no DEF file is specified and the windows_export_all_symbols feature is enabled, parse - // object files to generate DEF file and use it to export symbols - if we have a parser. - // Otherwise, use no DEF file. - if (defFile == null - && CppHelper.shouldUseGeneratedDefFile(ruleContext, featureConfiguration)) { - defFile = generatedDefFile; - } - - if (defFile != null) { - linkingHelper.setDefFile(defFile); - } + linkingHelper.setDefFile(CppHelper.getWindowsDefFileForLinking(ruleContext, customDefFile, generatedDefFile, featureConfiguration)); } ccLinkingOutputs = linkingHelper.link(ccCompilationOutputs); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java index b576d4b7d5ff34..7f45281fb4b7e0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java @@ -47,6 +47,7 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.actions.ActionConstructionContext; import com.google.devtools.build.lib.analysis.actions.CustomCommandLine; +import com.google.devtools.build.lib.analysis.actions.FileWriteAction; import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.analysis.actions.SymlinkAction; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; @@ -62,6 +63,7 @@ import com.google.devtools.build.lib.packages.Type; import com.google.devtools.build.lib.rules.cpp.CcLinkingContext.Linkstamp; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.ExpansionException; +import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Feature; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.Tool; import com.google.devtools.build.lib.rules.cpp.Link.LinkTargetType; @@ -885,6 +887,42 @@ public static Artifact createDefFileActions( return defFile; } + /** + * Create action for generating an empty DEF file without any exports, should only be used when + * targeting Windows. + * + * @return The artifact of an empty DEF file. + */ + private static Artifact createEmptyDefFileAction(RuleContext ruleContext) { + Artifact trivialDefFile = + ruleContext.getBinArtifact( + ruleContext.getLabel().getName() + + ".gen.empty" + + Iterables.getOnlyElement(CppFileTypes.WINDOWS_DEF_FILE.getExtensions())); + ruleContext.registerAction(FileWriteAction.create(ruleContext, trivialDefFile, "", false)); + return trivialDefFile; + } + + /** + * Decide which DEF file should be used for the linking action. + * + * @return The artifact of the DEF file that should be used for the linking action. + */ + public static Artifact getWindowsDefFileForLinking( + RuleContext ruleContext, Artifact customDefFile, Artifact generatedDefFile, FeatureConfiguration featureConfiguration) { + // 1. If a custom DEF file is specified in win_def_file attribute, use it. + // 2. If a generated DEF file is available and should be used, use it. + // 3. Otherwise, we use a empty DEF file to ensure the import library will be generated. + if (customDefFile != null) { + return customDefFile; + } else if (generatedDefFile != null && CppHelper.shouldUseGeneratedDefFile(ruleContext, featureConfiguration)) { + return generatedDefFile; + } else { + return createEmptyDefFileAction(ruleContext); + } + } + + /** * Returns true if the build implied by the given config and toolchain uses --start-lib/--end-lib * ld options.
diff --git a/src/test/py/bazel/bazel_windows_cpp_test.py b/src/test/py/bazel/bazel_windows_cpp_test.py index 4c8e45bace7569..0cca8e5e44e7cf 100644 --- a/src/test/py/bazel/bazel_windows_cpp_test.py +++ b/src/test/py/bazel/bazel_windows_cpp_test.py @@ -138,15 +138,15 @@ def testBuildDynamicLibraryWithUserExportedSymbol(self): self.AssertExitCode(exit_code, 0, stderr) # TODO(pcloudy): change suffixes to .lib and .dll after making DLL - # extensions correct on - # Windows. + # extensions correct on Windows. import_library = os.path.join(bazel_bin, 'A.if.lib') shared_library = os.path.join(bazel_bin, 'A.dll') - def_file = os.path.join(bazel_bin, 'A.gen.def') + empty_def_file = os.path.join(bazel_bin, 'A.gen.empty.def') + self.assertTrue(os.path.exists(import_library)) self.assertTrue(os.path.exists(shared_library)) - # DEF file shouldn't be generated for //:A - self.assertFalse(os.path.exists(def_file)) + # An empty DEF file should be generated for //:A + self.assertTrue(os.path.exists(empty_def_file)) def testBuildDynamicLibraryWithExportSymbolFeature(self): self.createProjectFiles() @@ -159,8 +159,7 @@ def testBuildDynamicLibraryWithExportSymbolFeature(self): self.AssertExitCode(exit_code, 0, stderr) # TODO(pcloudy): change suffixes to .lib and .dll after making DLL - # extensions correct on - # Windows. + # extensions correct on Windows. import_library = os.path.join(bazel_bin, 'B.if.lib') shared_library = os.path.join(bazel_bin, 'B.dll') def_file = os.path.join(bazel_bin, 'B.gen.def') @@ -175,8 +174,15 @@ def testBuildDynamicLibraryWithExportSymbolFeature(self): 'build', '//:B', '--output_groups=dynamic_library', '--features=no_windows_export_all_symbols' ]) - self.AssertExitCode(exit_code, 1, stderr) - self.assertIn('output \'B.if.lib\' was not created', ''.join(stderr)) + self.AssertExitCode(exit_code, 0, stderr) + import_library = os.path.join(bazel_bin, 'B.if.lib') + shared_library = os.path.join(bazel_bin, 'B.dll') + empty_def_file = os.path.join(bazel_bin, 'B.gen.empty.def') + self.assertTrue(os.path.exists(import_library)) + self.assertTrue(os.path.exists(shared_library)) + # An empty DEF file should be generated for //:B + self.assertTrue(os.path.exists(empty_def_file)) + self.AssertFileContentNotContains(empty_def_file, 'hello_B') def testBuildCcBinaryWithDependenciesDynamicallyLinked(self): self.createProjectFiles() @@ -195,7 +201,7 @@ def testBuildCcBinaryWithDependenciesDynamicallyLinked(self): # a_shared_library self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'A.dll'))) # a_def_file - self.assertFalse(os.path.exists(os.path.join(bazel_bin, 'A.gen.def'))) + self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'A.gen.empty.def'))) # b_import_library self.assertTrue(os.path.exists(os.path.join(bazel_bin, 'B.if.lib'))) # b_shared_library @@ -505,6 +511,29 @@ def testGetDefFileOfSharedLibraryFromCcBinary(self): self.AssertFileContentContains(def_file, 'hello_B') self.AssertFileContentContains(def_file, 'hello_C') + def testBuildSharedLibraryWithoutAnySymbolExported(self): + self.createProjectFiles() + self.ScratchFile( + 'BUILD', + [ + 'cc_binary(', + ' name = "A.dll",', + ' srcs = ["a.cc", "a.h"],', + ' copts = ["/DNO_DLLEXPORT"],', + ' linkshared = 1,' + ')', + ]) + bazel_bin = self.getBazelInfo('bazel-bin') + + exit_code, _, stderr = self.RunBazel(['build', '//:A.dll']) + self.AssertExitCode(exit_code, 0, stderr) + + # Although windows_export_all_symbols is not specified for this target, + # we should still be able to build a DLL without any symbol exported. + empty_def_file = os.path.join(bazel_bin, 'A.dll.gen.empty.def') + self.assertTrue(os.path.exists(empty_def_file)) + self.AssertFileContentNotContains(empty_def_file, 'hello_A') + def testUsingDefFileGeneratedFromCcLibrary(self): self.CreateWorkspaceWithDefaultRepos('WORKSPACE') self.ScratchFile('lib_A.cc', ['void hello_A() {}'])
train
train
2019-10-16T12:14:05
2018-02-01T19:36:28Z
excitoon
test
bazelbuild/bazel/4628_5155
bazelbuild/bazel
bazelbuild/bazel/4628
bazelbuild/bazel/5155
[ "timestamp(timedelta=0.0, similarity=0.8425062060806989)" ]
8aa610bb7fce80440a563f91b32783716f51e77d
21909b47cb61b26d6032f479855feac2ffe9fc5e
[ "We should expect that most users will want to specify this flag in a .bazelrc file", "Over to @buchgr who wrote the current notification about streaming target and identifier.", "Hi Dave,\r\n\r\nI am not convinced that a flag is the right way to go about this. I think instead we should extend the BES protocol ...
[]
2018-05-03T20:08:34Z
[ "P1" ]
BEP: Add a config option for results base URL (feature request)
When streaming results to a BEP endpoint, we should notify the user as to where they can view those results. (Currently, the user has to manually construct the URL from the invocation ID reported in Bazel CLI and a base URL of the BEP server.) **Please add a flag:** `--results_url_base` ...this will be used like: `bazel build //... --results_url_base=https://example.com/results/invocations/` when this flag is present, Bazel will print to the log (as soon as the invocation ID is known:) `streaming results to ${results_url_base}${invocation_id}` e.g. `streaming results to https://example.com/results/invocations/XXXX-YYYY-ZZZZ`
[ "src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java", "src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java" ]
[ "src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java", "src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java index bc806be07cac74..e59707fac184f1 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java @@ -20,6 +20,7 @@ import static java.lang.String.format; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions; @@ -218,11 +219,17 @@ private BuildEventTransport tryCreateBesTransport( logger.fine(format("Will create BuildEventServiceTransport streaming to '%s'", besOptions.besBackend)); - commandLineReporter.handle( - Event.info( - format( - "Streaming Build Event Protocol to %s build_request_id: %s invocation_id: %s", - besOptions.besBackend, buildRequestId, invocationId))); + final String message; + if (!Strings.isNullOrEmpty(besOptions.besResultsUrl)) { + String url = besOptions.besResultsUrl.endsWith("/") + ? besOptions.besResultsUrl + : besOptions.besResultsUrl + "/"; + message = "Streaming Build Event Protocol to " + url + invocationId; + } else { + message = format("Streaming Build Event Protocol to %s build_request_id: %s " + + "invocation_id: %s", besOptions.besBackend, buildRequestId, invocationId); + } + commandLineReporter.handle(Event.info(message)); BuildEventTransport besTransport = new BuildEventServiceTransport( diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java index 0d1adae2430ed1..d32547e88dc96f 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceOptions.java @@ -104,4 +104,15 @@ public class BuildEventServiceOptions extends OptionsBase { + "event, even if larger than the specified value." ) public long besOuterrBufferSize; + + @Option( + name = "bes_results_url", + defaultValue = "", + documentationCategory = OptionDocumentationCategory.LOGGING, + effectTags = {OptionEffectTag.TERMINAL_OUTPUT}, + help = "Specifies the base URL where a user can view the information streamed to the BES backend. " + + "Bazel will output the URL appended by the invocation id to the terminal." + + ) + public String besResultsUrl; }
null
test
train
2018-05-03T21:53:41
2018-02-12T20:33:38Z
davidstanke
test
bazelbuild/bazel/4666_7354
bazelbuild/bazel
bazelbuild/bazel/4666
bazelbuild/bazel/7354
[ "timestamp(timedelta=26195.0, similarity=0.8626952166192586)" ]
0fc8deec015214006a289fa6bd0fd9cd99bbba5b
06c74313012ac1cfeb00d93086517d3d90dae048
[]
[]
2019-02-05T15:28:06Z
[]
remote/bugs: some tests aren't cached remotely
These three tests aren't cached remotely on our CI. ``` //src/test/shell/bazel:bazel_determinism_test //src/test/shell/bazel:bazel_bootstrap_distfile_test //scripts/release:release_test ``` Need to investigate why this is the case. cc: @ulfjack @philwo
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index 4ef09ad268f260..2da0cc1203d446 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -90,7 +90,7 @@ final class RemoteSpawnCache implements SpawnCache { @Override public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context) throws InterruptedException, IOException, ExecException { - if (!Spawns.mayBeCached(spawn)) { + if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) { return SpawnCache.NO_RESULT_NO_STORE; } boolean checkCache = options.remoteAcceptCached;
null
train
train
2019-02-05T16:41:18
2018-02-20T13:23:42Z
buchgr
test
bazelbuild/bazel/4698_7354
bazelbuild/bazel
bazelbuild/bazel/4698
bazelbuild/bazel/7354
[ "timestamp(timedelta=26444.0, similarity=0.8479604725701331)" ]
0fc8deec015214006a289fa6bd0fd9cd99bbba5b
06c74313012ac1cfeb00d93086517d3d90dae048
[]
[]
2019-02-05T15:28:06Z
[]
remote/documentation: mention remote caching on CircleCI in the documentation
https://github.com/notnoopci/bazel-remote-proxy
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index 4ef09ad268f260..2da0cc1203d446 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -90,7 +90,7 @@ final class RemoteSpawnCache implements SpawnCache { @Override public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context) throws InterruptedException, IOException, ExecException { - if (!Spawns.mayBeCached(spawn)) { + if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) { return SpawnCache.NO_RESULT_NO_STORE; } boolean checkCache = options.remoteAcceptCached;
null
val
train
2019-02-05T16:41:18
2018-02-23T23:39:30Z
buchgr
test
bazelbuild/bazel/4742_5371
bazelbuild/bazel
bazelbuild/bazel/4742
bazelbuild/bazel/5371
[ "timestamp(timedelta=0.0, similarity=0.9448327089095196)" ]
b689036a6b203a1eb9bbd22738a1c7fbe949243f
8163b8ede6c87ea2ac1391edb3d454eec32652d8
[ "NDK17 is was released. I haven't tested with bazel 0.14rc, but I don't see this being in the changelog.", "I haven't had free cycles to work on this yet. Bumping to P1 for re-prioritization. ", "That's great thank you!", "@steeve WIP: https://github.com/bazelbuild/bazel/pull/5371", "When calling `./configu...
[ "This will \"pass\" on CI because the test is disabled. The CI has r15, not r17." ]
2018-06-11T22:36:37Z
[ "type: feature request", "P1" ]
Support NDK 17
r17 is expected to land [in May 2018.](https://github.com/android-ndk/ndk/wiki#release-schedule) Betas 1 and 2 will be released this month (March) and next month (April) respectively. https://android.googlesource.com/platform/ndk/+/ndk-release-r17/CHANGELOG.md [Relevant changes:](https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md#ndk-r17) - `libc++`/`@androidndk//:toolchain-libcpp` will become the default STL. The other STLs will be removed in r18, or moved to another project. - GCC will no longer be supported. - Removed support for building against `armeabi`, `mips`, and `mips64`. - ~Removed support for API levels 14 and 15. New minimum is 16.~ - [clang is updated to v6.0.2, build 4691093](https://android.googlesource.com/platform/prebuilts/clang/host/darwin-x86/+/refs/heads/ndk-release-r17/clang-4691093/AndroidVersion.txt)
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java", "src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java", "src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ApiLevel...
[ "src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java", "src/test/shell/bazel/android/android_ndk_integration_test.sh" ]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java index c5aedb7df5d5c3..8823899c055306 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/AndroidNdkCrosstools.java @@ -21,6 +21,7 @@ import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r12.NdkMajorRevisionR12; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r13.NdkMajorRevisionR13; import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r15.NdkMajorRevisionR15; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17.NdkMajorRevisionR17; import com.google.devtools.build.lib.util.OS; import java.util.Map; @@ -46,6 +47,7 @@ private AndroidNdkCrosstools() {} // The only difference between r15 and r16 is that old headers are removed, forcing // usage of the unified headers. Support for unified headers were added in r15. .put(16, new NdkMajorRevisionR15("5.0.300080")) // no changes relevant to Bazel + .put(17, new NdkMajorRevisionR17("6.0.2")) .build(); public static final Map.Entry<Integer, NdkMajorRevision> LATEST_KNOWN_REVISION = diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java new file mode 100644 index 00000000000000..fca2b82a09f294 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/AndroidNdkCrosstoolsR17.java @@ -0,0 +1,109 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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. + +package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.DefaultCpuToolchain; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** Generates a CrosstoolRelease proto for the Android NDK. */ +final class AndroidNdkCrosstoolsR17 { + + /** + * Creates a CrosstoolRelease proto for the Android NDK, given the API level to use and the + * release revision. The crosstools are generated through code rather than checked in as a flat + * file to reduce the amount of templating needed (for parameters like the release name and + * certain paths), to reduce duplication, and to make it easier to support future versions of the + * NDK. TODO(bazel-team): Eventually we should move this into Skylark so the crosstools can be + * updated independently of Bazel itself. + * + * @return A CrosstoolRelease for the Android NDK. + */ + static CrosstoolRelease create( + NdkPaths ndkPaths, StlImpl stlImpl, String hostPlatform, String clangVersion) { + return CrosstoolRelease.newBuilder() + .setMajorVersion("android") + .setMinorVersion("") + .setDefaultTargetCpu("armeabi") + .addAllDefaultToolchain(getDefaultCpuToolchains(stlImpl, clangVersion)) + .addAllToolchain(createToolchains(ndkPaths, stlImpl, hostPlatform, clangVersion)) + .build(); + } + + private static ImmutableList<CToolchain> createToolchains( + NdkPaths ndkPaths, StlImpl stlImpl, String hostPlatform, String clangVersion) { + + List<CToolchain.Builder> toolchainBuilders = new ArrayList<>(); + toolchainBuilders.addAll(new ArmCrosstools(ndkPaths, stlImpl, clangVersion).createCrosstools()); + toolchainBuilders.addAll(new X86Crosstools(ndkPaths, stlImpl, clangVersion).createCrosstools()); + + ImmutableList.Builder<CToolchain> toolchains = new ImmutableList.Builder<>(); + + // Set attributes common to all toolchains. + for (CToolchain.Builder toolchainBuilder : toolchainBuilders) { + toolchainBuilder + .setHostSystemName(hostPlatform) + .setTargetLibc("local") + .setAbiVersion(toolchainBuilder.getTargetCpu()) + .setAbiLibcVersion("local"); + + // builtin_sysroot is set individually on each toolchain. + // platforms/arch sysroot + toolchainBuilder.addCxxBuiltinIncludeDirectory("%sysroot%/usr/include"); + // unified headers sysroot, from ndk15 and up + toolchainBuilder.addCxxBuiltinIncludeDirectory( + ndkPaths.createBuiltinSysroot() + "/usr/include"); + toolchainBuilder.addUnfilteredCxxFlag( + "-isystem%ndk%/usr/include".replace("%ndk%", ndkPaths.createBuiltinSysroot())); + + toolchains.add(toolchainBuilder.build()); + } + + return toolchains.build(); + } + + private static ImmutableList<DefaultCpuToolchain> getDefaultCpuToolchains( + StlImpl stlImpl, String clangVersion) { + // TODO(bazel-team): It would be better to auto-generate this somehow. + + ImmutableMap<String, String> defaultCpus = + ImmutableMap.<String, String>builder() + // arm + .put("armeabi-v7a", "arm-linux-androideabi-clang" + clangVersion + "-v7a") + .put("arm64-v8a", "aarch64-linux-android-clang" + clangVersion) + + // x86 + .put("x86", "x86-clang" + clangVersion) + .put("x86_64", "x86_64-clang" + clangVersion) + .build(); + + ImmutableList.Builder<DefaultCpuToolchain> defaultCpuToolchains = ImmutableList.builder(); + for (Map.Entry<String, String> defaultCpu : defaultCpus.entrySet()) { + defaultCpuToolchains.add( + DefaultCpuToolchain.newBuilder() + .setCpu(defaultCpu.getKey()) + .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()) + .build()); + } + return defaultCpuToolchains.build(); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ApiLevelR17.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ApiLevelR17.java new file mode 100644 index 00000000000000..46a0ba4d2a5b71 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ApiLevelR17.java @@ -0,0 +1,67 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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. + +package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; + +import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; +import com.google.devtools.build.lib.events.EventHandler; + +/** Class which encodes information from the Android NDK makefiles about API levels. */ +final class ApiLevelR17 extends ApiLevel { + /** This is the contents of {@code platforms/android-*} */ + private static final ImmutableListMultimap<String, String> API_LEVEL_TO_ARCHITECTURES = + ImmutableListMultimap.<String, String>builder() + .putAll("14", "arm", "x86") + .putAll("15", "arm", "x86") + .putAll("16", "arm", "x86") + .putAll("17", "arm", "x86") + .putAll("18", "arm", "x86") + .putAll("19", "arm", "x86") + .putAll("21", "arm", "x86", "arm64", "x86_64") + .putAll("22", "arm", "x86", "arm64", "x86_64") + .putAll("23", "arm", "x86", "arm64", "x86_64") + .putAll("24", "arm", "x86", "arm64", "x86_64") + .putAll("26", "arm", "x86", "arm64", "x86_64") + .putAll("27", "arm", "x86", "arm64", "x86_64") + .putAll("28", "arm", "x86", "arm64", "x86_64") + .build(); + + /** This map fill in the gaps of {@code API_LEVEL_TO_ARCHITECTURES}. */ + private static final ImmutableMap<String, String> API_EQUIVALENCIES = + ImmutableMap.<String, String>builder() + .put("10", "14") + .put("11", "14") + .put("12", "14") + .put("13", "14") + .put("14", "14") + .put("15", "14") + .put("16", "16") + .put("17", "16") + .put("18", "18") + .put("19", "19") + .put("20", "19") + .put("21", "21") + .put("22", "22") + .put("23", "23") + .put("24", "24") + .put("25", "24") + .put("26", "26") + .put("27", "27") + .put("28", "28") + .build(); + + ApiLevelR17(EventHandler eventHandler, String repositoryName, String apiLevel) { + super(API_LEVEL_TO_ARCHITECTURES, API_EQUIVALENCIES, eventHandler, repositoryName, apiLevel); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ArmCrosstools.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ArmCrosstools.java new file mode 100644 index 00000000000000..eb6a0fec7fa226 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/ArmCrosstools.java @@ -0,0 +1,171 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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. + +package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationMode; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationModeFlags; + +/** + * Crosstool definitions for ARM. These values are based on the setup.mk files in the Android NDK + * toolchain directories. + */ +final class ArmCrosstools { + private final NdkPaths ndkPaths; + private final StlImpl stlImpl; + private final String clangVersion; + + ArmCrosstools(NdkPaths ndkPaths, StlImpl stlImpl, String clangVersion) { + this.ndkPaths = ndkPaths; + this.stlImpl = stlImpl; + this.clangVersion = clangVersion; + } + + ImmutableList<CToolchain.Builder> createCrosstools() { + CToolchain.Builder aarch64Toolchain = createAarch64ClangToolchain(); + CToolchain.Builder armeabiToolchain = createArmeabiClangToolchain(); + + stlImpl.addStlImpl(aarch64Toolchain, "4.9"); + stlImpl.addStlImpl(armeabiToolchain, "4.9"); + + return ImmutableList.<CToolchain.Builder>builder() + .add(aarch64Toolchain) + .add(armeabiToolchain) + .build(); + } + + private CToolchain.Builder createAarch64ClangToolchain() { + String toolchainName = "aarch64-linux-android-4.9"; + String targetPlatform = "aarch64-linux-android"; + String gccToolchain = ndkPaths.createGccToolchainPath(toolchainName); + String llvmTriple = "aarch64-none-linux-android"; + + return CToolchain.newBuilder() + .setToolchainIdentifier("aarch64-linux-android-clang" + clangVersion) + .setTargetSystemName(targetPlatform) + .setTargetCpu("arm64-v8a") + .setCompiler("clang" + clangVersion) + .addAllToolPath(ndkPaths.createClangToolpaths(toolchainName, targetPlatform, null)) + .addCxxBuiltinIncludeDirectory( + ndkPaths.createClangToolchainBuiltinIncludeDirectory(clangVersion)) + .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm64")) + + // Compiler flags + .addCompilerFlag("-gcc-toolchain") + .addCompilerFlag(gccToolchain) + .addCompilerFlag("-target") + .addCompilerFlag(llvmTriple) + .addCompilerFlag("-ffunction-sections") + .addCompilerFlag("-funwind-tables") + .addCompilerFlag("-fstack-protector-strong") + .addCompilerFlag("-fpic") + .addCompilerFlag("-Wno-invalid-command-line-argument") + .addCompilerFlag("-Wno-unused-command-line-argument") + .addCompilerFlag("-no-canonical-prefixes") + .addCompilerFlag( + "-isystem%ndk%/usr/include/%triple%" + .replace("%ndk%", ndkPaths.createBuiltinSysroot()) + .replace("%triple%", targetPlatform)) + .addCompilerFlag("-D__ANDROID_API__=" + ndkPaths.getCorrectedApiLevel("arm")) + + // Linker flags + .addLinkerFlag("-gcc-toolchain") + .addLinkerFlag(gccToolchain) + .addLinkerFlag("-target") + .addLinkerFlag(llvmTriple) + .addLinkerFlag("-no-canonical-prefixes") + + // Additional release flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.OPT) + .addCompilerFlag("-O2") + .addCompilerFlag("-g") + .addCompilerFlag("-DNDEBUG")) + + // Additional debug flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.DBG) + .addCompilerFlag("-O0") + .addCompilerFlag("-UNDEBUG")); + } + + private CToolchain.Builder createArmeabiClangToolchain() { + String toolchainName = "arm-linux-androideabi-4.9"; + String targetPlatform = "arm-linux-androideabi"; + String gccToolchain = ndkPaths.createGccToolchainPath("arm-linux-androideabi-4.9"); + + return CToolchain.newBuilder() + .setToolchainIdentifier("arm-linux-androideabi-clang" + clangVersion + "-v7a") + .setTargetCpu("armeabi-v7a") + .setTargetSystemName("arm-linux-androideabi") + .setCompiler("clang" + clangVersion) + .addAllToolPath(ndkPaths.createClangToolpaths(toolchainName, targetPlatform, null)) + .addCxxBuiltinIncludeDirectory( + ndkPaths.createClangToolchainBuiltinIncludeDirectory(clangVersion)) + .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("arm")) + .addCompilerFlag("-D__ANDROID_API__=" + ndkPaths.getCorrectedApiLevel("arm")) + .addCompilerFlag( + "-isystem%ndk%/usr/include/%triple%" + .replace("%ndk%", ndkPaths.createBuiltinSysroot()) + .replace("%triple%", targetPlatform)) + + // Compiler flags + .addCompilerFlag("-target") + .addCompilerFlag("armv7-none-linux-androideabi") // LLVM_TRIPLE + .addCompilerFlag("-march=armv7-a") + .addCompilerFlag("-mfloat-abi=softfp") + .addCompilerFlag("-mfpu=vfpv3-d16") + .addCompilerFlag("-gcc-toolchain") + .addCompilerFlag(gccToolchain) + .addCompilerFlag("-fpic") + .addCompilerFlag("-ffunction-sections") + .addCompilerFlag("-funwind-tables") + .addCompilerFlag("-fstack-protector-strong") + .addCompilerFlag("-Wno-invalid-command-line-argument") + .addCompilerFlag("-Wno-unused-command-line-argument") + .addCompilerFlag("-no-canonical-prefixes") + + // Linker flags + .addLinkerFlag("-target") + .addLinkerFlag("armv7-none-linux-androideabi") // LLVM_TRIPLE + .addLinkerFlag("-Wl,--fix-cortex-a8") + .addLinkerFlag("-gcc-toolchain") + .addLinkerFlag(gccToolchain) + .addLinkerFlag("-no-canonical-prefixes") + + // Additional release flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.OPT) + .addCompilerFlag("-mthumb") + .addCompilerFlag("-Os") + .addCompilerFlag("-g") + .addCompilerFlag("-DNDEBUG")) + + // Additional debug flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.DBG) + .addCompilerFlag("-g") + .addCompilerFlag("-fno-strict-aliasing") + .addCompilerFlag("-O0") + .addCompilerFlag("-UNDEBUG")); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/NdkMajorRevisionR17.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/NdkMajorRevisionR17.java new file mode 100644 index 00000000000000..22e01b17df850d --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/NdkMajorRevisionR17.java @@ -0,0 +1,43 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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. + +package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; + +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; +import com.google.devtools.build.lib.events.EventHandler; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease; + +/** Logic specific to Android NDK R17. */ +public class NdkMajorRevisionR17 implements NdkMajorRevision { + private final String clangVersion; + + public NdkMajorRevisionR17(String clangVersion) { + this.clangVersion = clangVersion; + } + + @Override + public CrosstoolRelease crosstoolRelease( + NdkPaths ndkPaths, StlImpl stlImpl, String hostPlatform) { + return AndroidNdkCrosstoolsR17 + .create(ndkPaths, stlImpl, hostPlatform, clangVersion); + } + + @Override + public ApiLevel apiLevel(EventHandler eventHandler, String name, String apiLevel) { + return new ApiLevelR17(eventHandler, name, apiLevel); + } +} diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/X86Crosstools.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/X86Crosstools.java new file mode 100644 index 00000000000000..e2887b8e707539 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/ndkcrosstools/r17/X86Crosstools.java @@ -0,0 +1,118 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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. + +package com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r17; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths; +import com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationMode; +import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CompilationModeFlags; + +/** + * Crosstool definitions for x86. These values are based on the setup.mk files in the Android NDK + * toolchain directories. + */ +final class X86Crosstools { + private final NdkPaths ndkPaths; + private final StlImpl stlImpl; + private final String clangVersion; + + X86Crosstools(NdkPaths ndkPaths, StlImpl stlImpl, String clangVersion) { + this.ndkPaths = ndkPaths; + this.stlImpl = stlImpl; + this.clangVersion = clangVersion; + } + + ImmutableList<CToolchain.Builder> createCrosstools() { + /** x86 */ + // clang + CToolchain.Builder x86Clang = + createBaseX86ClangToolchain("x86", "i686", "i686-linux-android") + // Workaround for https://code.google.com/p/android/issues/detail?id=220159. + .addCompilerFlag("-mstackrealign") + .setToolchainIdentifier("x86-clang" + clangVersion) + .setTargetCpu("x86") + .addAllToolPath(ndkPaths.createClangToolpaths("x86-4.9", "i686-linux-android", null)) + .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("x86")); + + stlImpl.addStlImpl(x86Clang, "4.9"); + + /** x86_64 */ + CToolchain.Builder x8664Clang = + createBaseX86ClangToolchain("x86_64", "x86_64", "x86_64-linux-android") + .setToolchainIdentifier("x86_64-clang" + clangVersion) + .setTargetCpu("x86_64") + .addAllToolPath( + ndkPaths.createClangToolpaths("x86_64-4.9", "x86_64-linux-android", null)) + .setBuiltinSysroot(ndkPaths.createBuiltinSysroot("x86_64")); + + stlImpl.addStlImpl(x8664Clang, "4.9"); + + return ImmutableList.of(x86Clang, x8664Clang); + } + + private CToolchain.Builder createBaseX86ClangToolchain( + String x86Arch, String llvmArch, String triple) { + String gccToolchain = ndkPaths.createGccToolchainPath(x86Arch + "-4.9"); + String llvmTriple = llvmArch + "-none-linux-android"; + + return CToolchain.newBuilder() + .setCompiler("clang" + clangVersion) + .addCxxBuiltinIncludeDirectory( + ndkPaths.createClangToolchainBuiltinIncludeDirectory(clangVersion)) + + // Compiler flags + .addCompilerFlag("-gcc-toolchain") + .addCompilerFlag(gccToolchain) + .addCompilerFlag("-target") + .addCompilerFlag(llvmTriple) + .addCompilerFlag("-ffunction-sections") + .addCompilerFlag("-funwind-tables") + .addCompilerFlag("-fstack-protector-strong") + .addCompilerFlag("-fPIC") + .addCompilerFlag("-Wno-invalid-command-line-argument") + .addCompilerFlag("-Wno-unused-command-line-argument") + .addCompilerFlag("-no-canonical-prefixes") + .addCompilerFlag( + "-isystem%ndk%/usr/include/%triple%" + .replace("%ndk%", ndkPaths.createBuiltinSysroot()) + .replace("%triple%", triple)) + .addCompilerFlag("-D__ANDROID_API__=" + ndkPaths.getCorrectedApiLevel(x86Arch)) + + // Linker flags + .addLinkerFlag("-gcc-toolchain") + .addLinkerFlag(gccToolchain) + .addLinkerFlag("-target") + .addLinkerFlag(llvmTriple) + .addLinkerFlag("-no-canonical-prefixes") + + // Additional release flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.OPT) + .addCompilerFlag("-O2") + .addCompilerFlag("-g") + .addCompilerFlag("-DNDEBUG")) + + // Additional debug flags + .addCompilationModeFlags( + CompilationModeFlags.newBuilder() + .setMode(CompilationMode.DBG) + .addCompilerFlag("-O0") + .addCompilerFlag("-g")) + .setTargetSystemName("x86-linux-android"); + } +}
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java index 232a553d5d6652..a6811235841331 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryTest.java @@ -102,7 +102,7 @@ public void testInvalidNdkReleaseTxt() throws Exception { eventCollector, "The revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' " + "could not be determined (the revision string found is 'not a valid release string')." - + " Bazel will attempt to treat the NDK as if it was r16."); + + " Bazel will attempt to treat the NDK as if it was r17."); } @Test @@ -128,7 +128,7 @@ public void testInvalidNdkSourceProperties() throws Exception { eventCollector, "The revision of the Android NDK referenced by android_ndk_repository rule 'androidndk' " + "could not be determined (the revision string found is 'invalid package revision'). " - + "Bazel will attempt to treat the NDK as if it was r16."); + + "Bazel will attempt to treat the NDK as if it was r17."); } @Test @@ -145,16 +145,16 @@ public void testUnsupportedNdkVersion() throws Exception { scratch.overwriteFile( "/ndk/source.properties", "Pkg.Desc = Android NDK", - "Pkg.Revision = 17.0.3675639-beta2"); + "Pkg.Revision = 18.0.3675639-beta2"); invalidatePackages(); assertThat(getConfiguredTarget("@androidndk//:files")).isNotNull(); MoreAsserts.assertContainsEvent( eventCollector, "The major revision of the Android NDK referenced by android_ndk_repository rule " - + "'androidndk' is 17. The major revisions supported by Bazel are " - + "[10, 11, 12, 13, 14, 15, 16]. Bazel will attempt to treat the NDK as if it was " - + "r16."); + + "'androidndk' is 18. The major revisions supported by Bazel are " + + "[10, 11, 12, 13, 14, 15, 16, 17]. Bazel will attempt to treat the NDK as if it was " + + "r17."); } @Test diff --git a/src/test/shell/bazel/android/android_ndk_integration_test.sh b/src/test/shell/bazel/android/android_ndk_integration_test.sh index c8e85e7ee304a4..cf4a99a7485a61 100755 --- a/src/test/shell/bazel/android/android_ndk_integration_test.sh +++ b/src/test/shell/bazel/android/android_ndk_integration_test.sh @@ -175,7 +175,7 @@ EOF function check_num_sos() { num_sos=$(unzip -Z1 bazel-bin/java/bazel/bin.apk '*.so' | wc -l | sed -e 's/[[:space:]]//g') - assert_equals "5" "$num_sos" + assert_equals "4" "$num_sos" } function check_soname() { @@ -202,9 +202,9 @@ function test_android_binary() { setup_android_ndk_support create_android_binary - cpus="armeabi,armeabi-v7a,arm64-v8a,x86,x86_64" + cpus="armeabi-v7a,arm64-v8a,x86,x86_64" - bazel build -s //java/bazel:bin --fat_apk_cpu="$cpus" || fail "build failed" + assert_build //java/bazel:bin --fat_apk_cpu="$cpus" check_num_sos check_soname } @@ -215,12 +215,9 @@ function test_android_binary_clang() { setup_android_ndk_support create_android_binary - cpus="armeabi,armeabi-v7a,arm64-v8a,x86,x86_64" + cpus="armeabi-v7a,arm64-v8a,x86,x86_64" - bazel build -s //java/bazel:bin \ - --fat_apk_cpu="$cpus" \ - --android_compiler=clang5.0.300080 \ - || fail "build failed" + assert_build //java/bazel:bin --fat_apk_cpu="$cpus" check_num_sos check_soname } @@ -240,12 +237,11 @@ EOF #include <arm_neon.h> int main() { return 0; } EOF - bazel build //:foo \ - --compiler=clang5.0.300080 \ + assert_build :foo \ + --compiler=clang6.0.2 \ --cpu=armeabi-v7a \ --crosstool_top=//external:android/crosstool \ - --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ - || fail "build failed" + --host_crosstool_top=@bazel_tools//tools/cpp:toolchain } function test_android_ndk_repository_path_from_environment() { @@ -270,8 +266,8 @@ android_ndk_repository( api_level = 25, ) EOF - bazel build @androidndk//:files >& $TEST_log && fail "Should have failed" - expect_log "Either the path attribute of android_ndk_repository" + assert_build_fails @androidndk//:files \ + "Either the path attribute of android_ndk_repository" } function test_android_ndk_repository_wrong_path() { @@ -284,8 +280,8 @@ android_ndk_repository( path = "$TEST_TMPDIR/some_dir", ) EOF - bazel build @androidndk//:files >& $TEST_log && fail "Should have failed" - expect_log "Unable to read the Android NDK at $TEST_TMPDIR/some_dir, the path may be invalid." \ + assert_build_fails @androidndk//:files \ + "Unable to read the Android NDK at $TEST_TMPDIR/some_dir, the path may be invalid." \ " Is the path in android_ndk_repository() or \$ANDROID_NDK_HOME set correctly?" } @@ -301,7 +297,7 @@ EOF cat > foo.cc <<EOF int main() { return 0; } EOF - bazel build //:foo.stripped \ + assert_build //:foo.stripped \ --cpu=armeabi-v7a \ --crosstool_top=//external:android/crosstool \ --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \ @@ -406,7 +402,7 @@ function test_crosstool_libcpp_with_multiarch() { setup_android_ndk_support create_android_binary - cpus="armeabi,armeabi-v7a,arm64-v8a,x86,x86_64" + cpus="armeabi-v7a,arm64-v8a,x86,x86_64" assert_build //java/bazel:bin \ --fat_apk_cpu="$cpus" \
train
train
2018-06-11T23:11:40
2018-03-01T15:25:11Z
jin
test
bazelbuild/bazel/4751_7174
bazelbuild/bazel
bazelbuild/bazel/4751
bazelbuild/bazel/7174
[ "timestamp(timedelta=93630.0, similarity=0.9122858267918214)" ]
ce91f76e659cee6940d0f5e10c2bbd7e43be76d4
7cdb4016b15dbfb86cbf3eb58ac481d3cb47021a
[ "Is anyone investigating?", "I just tried to collect evidence that this is an instance of existing issue, but I cannot find any. But I vaguely remember strange issues with skylark repositories on mac like this one.", "Thanks. Marcel, may I assign this to you or is there someone for whom it's a better fit?", "...
[ "nit: could you call it \"toInputPath\" or something more concrete than \"toPath\"? Otherwise the ~sloppy~ hurried coder (not that I speak of my own experience, \\*ahem\\*) might believe this function does nothing but a trivial conversion (e.g. calling Artifact.toPath)." ]
2019-01-18T09:30:32Z
[ "P0", "platform: apple", "team-Rules-CPP", "team-Remote-Exec" ]
Unexpected IO error (Not a directory)
``` ERROR: /Users/buildkite/builds/darwin-x86-64-1-1/bazel/re2/BUILD:26:1: Couldn't build file _objs/re2/re2/filtered_re2.o: C++ compilation of rule '//:re2' failed: Unexpected IO error.: /private/var/tmp/_bazel_buildkite/90b05a586a8f6522c740e54d1334c7a0/execroot/ com_googlesource_code_re2/external/local_config_cc/wrapped_clang (Not a directory) ``` We see this error frequently on macOS. @mhlopko suggested that it's a somewhat known bug in external repositories. cc: @aehlig @dslomov
[ "src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java", "src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java", "src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java" ]
[ "src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java", "src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java", "src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java index f7a9e0734a44e8..83829e364ed1f4 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact; import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; +import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Collection; @@ -218,4 +219,16 @@ public static List<ActionInput> expandArtifacts(Iterable<? extends ActionInput> public static Iterable<String> toExecPaths(Iterable<? extends ActionInput> artifacts) { return Iterables.transform(artifacts, EXEC_PATH_STRING_FORMATTER); } + + /** + * Returns the {@link Path} for an {@link ActionInput}. + */ + public static Path toPath(ActionInput input, Path execRoot) { + Preconditions.checkNotNull(input, "input"); + Preconditions.checkNotNull(execRoot, "execRoot"); + + return (input instanceof Artifact) + ? ((Artifact) input).getPath() + : execRoot.getRelative(input.getExecPath()); + } } diff --git a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java index 683024e7a7fd6e..a564131b813e81 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java @@ -16,6 +16,7 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.devtools.build.lib.actions.ActionInput; +import com.google.devtools.build.lib.actions.ActionInputHelper; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.DigestOfDirectoryException; import com.google.devtools.build.lib.actions.FileArtifactValue; @@ -60,10 +61,7 @@ public FileArtifactValue getMetadata(ActionInput input) throws IOException { .get( input.getExecPathString(), () -> { - Path path = - (input instanceof Artifact) - ? ((Artifact) input).getPath() - : execRoot.getRelative(input.getExecPath()); + Path path = ActionInputHelper.toPath(input, execRoot); try { FileArtifactValue metadata = FileArtifactValue.create(path); if (metadata.getType().isDirectory()) { diff --git a/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java b/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java index f684ac5fb96309..1336a3fa47bbcc 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java +++ b/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java @@ -340,7 +340,7 @@ private TreeNode buildParentNode( Preconditions.checkArgument( inputsStart == inputsEnd - 1, "Encountered two inputs with the same path."); ActionInput input = inputs.get(inputsStart); - Path leafPath = execRoot.getRelative(input.getExecPathString()); + Path leafPath = ActionInputHelper.toPath(input, execRoot); if (!(input instanceof VirtualActionInput) && uploadSymlinks) { FileStatus stat = leafPath.stat(Symlinks.NOFOLLOW); if (stat.isSymbolicLink()) { @@ -405,7 +405,7 @@ private synchronized Directory getOrComputeDirectory(TreeNode node) throws IOExc if (uploadSymlinks) { // We need to stat the input to check whether it is a symlink. // getInputMetadata only gives target metadata. - Path inputPath = execRoot.getRelative(input.getExecPath()); + Path inputPath = ActionInputHelper.toPath(input, execRoot); FileStatus stat = inputPath.stat(Symlinks.NOFOLLOW); if (stat.isSymbolicLink()) { PathFragment target = inputPath.readSymbolicLink();
null
train
train
2019-01-18T10:25:47
2018-03-02T08:53:16Z
buchgr
test
bazelbuild/bazel/4801_4826
bazelbuild/bazel
bazelbuild/bazel/4801
bazelbuild/bazel/4826
[ "timestamp(timedelta=0.0, similarity=0.8452821693772827)" ]
658662136e65f54f93a0c81c7fb78dd6b46b55a6
c628e25a915b9512149803772bd8d09590d6d21e
[ "Hm, you're right, I just downloaded the zip file and computed sha256 on it, getting `a36bac432d0dbd8c98249e484b2b69dd5720afa4abb58711a3c3def1c0bfa21d`. /cc @kstanger ", "Any idea why the hash changed?", "They may have force-pushed a new version.\r\nThis is what @kstanger wrote to me:\r\n\r\n> It's possible tha...
[]
2018-03-12T09:57:10Z
[ "type: bug", "P2" ]
Bazel j2obc WORKSPACE sha is invalid
### Description of the problem / feature request: Bazels j2obc WORKSPACE file sha is different to the githubs release https://github.com/bazelbuild/bazel/blob/master/WORKSPACE#L39 . ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. Running `bazel fetch @bazel_j2objc//...` outputs: ```sh ERROR: Error downloading [https://github.com/google/j2objc/releases/download/2.0.3/j2objc-2.0.3.zip] to /private/var/tmp/_bazel_edwardmcfarlane/337d342990a69aca0642298fdb696d05/external/bazel_j2objc/j2objc-2.0.3.zip: Checksum was a36bac432d0dbd8c98249e484b2b69dd5720afa4abb58711a3c3def1c0bfa21d but wanted 529ee99e6f0e3f88edef61aeae4f13dc6e5eb8183993ced191338422b0e1fbeb Building: no action ``` ### What operating system are you running Bazel on? Mac, installed via brew. ### What's the output of `bazel info release`? `release 0.10.0-homebrew` ### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ? ```sh git@github.com:afking/bazel.git d3e102c9fb62f4416099dc9f097a5f207aa7d442 d3e102c9fb62f4416099dc9f097a5f207aa7d442 ```
[ "WORKSPACE" ]
[ "WORKSPACE" ]
[]
diff --git a/WORKSPACE b/WORKSPACE index ccbf0dc027c5f6..3108c989bef30b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -36,7 +36,8 @@ bind( http_archive( name = "bazel_j2objc", url = "https://github.com/google/j2objc/releases/download/2.0.3/j2objc-2.0.3.zip", - sha256 = "529ee99e6f0e3f88edef61aeae4f13dc6e5eb8183993ced191338422b0e1fbeb", + # Computed using "shasum -a 256 j2objc-2.0.3.zip" + sha256 = "a36bac432d0dbd8c98249e484b2b69dd5720afa4abb58711a3c3def1c0bfa21d", strip_prefix = "j2objc-2.0.3", )
null
train
train
2018-03-11T07:32:11
2018-03-08T14:29:28Z
emcfarlane
test
bazelbuild/bazel/4813_4818
bazelbuild/bazel
bazelbuild/bazel/4813
bazelbuild/bazel/4818
[ "timestamp(timedelta=0.0, similarity=0.909734931898169)" ]
d6a98282e229b311dd56e65b72003197120f299a
8fa06de4b6f5e5eff15b47a15f376b3d7c30eb90
[ "/cc @davido ", "I agree with this approach but I would also mention that it could be hard to try to detect/ignore all possible corrupted MSVC installations. And in context of another C++ based project: LibreOffice, we generally advice developers to always avoid messing around with multiple MSVC installations on ...
[ "opt: I think it'd be easier to read if you added \"installation\" after \"build tools\"", "Please don't add `check_exists` here; instead, extract the error handling from this method to its call sites. Let this method just find the script (as its name says) or return None if not found, and let the caller deal wit...
2018-03-09T15:45:53Z
[ "type: feature request", "P2", "platform: windows" ]
Windows: Bazel should be able to build non-c++ rules when VC is not installed correctly
Bazel currently can ignore VC configuration if VC isn't installed at all. But a wrong VC installation could block the configuration even when we don't need to build C++ rules. See https://github.com/bazelbuild/migration-tooling/issues/85
[ "tools/cpp/vc_path_not_found.bat", "tools/cpp/windows_cc_configure.bzl" ]
[ "tools/cpp/vc_installation_error.bat.tpl", "tools/cpp/windows_cc_configure.bzl" ]
[]
diff --git a/tools/cpp/vc_path_not_found.bat b/tools/cpp/vc_installation_error.bat.tpl similarity index 89% rename from tools/cpp/vc_path_not_found.bat rename to tools/cpp/vc_installation_error.bat.tpl index 18e3581f54b852..cb44b1413f77d7 100644 --- a/tools/cpp/vc_path_not_found.bat +++ b/tools/cpp/vc_installation_error.bat.tpl @@ -17,7 +17,8 @@ echo. 1>&2 echo The target you are compiling requires Visual C++ build tools. 1>&2 -echo Bazel couldn't find Visual C++ build tools on your machine. 1>&2 +echo Bazel couldn't find a valid Visual C++ build tools installation on your machine. 1>&2 +%{vc_error_message} echo Please check your installation following https://docs.bazel.build/versions/master/windows.html#using 1>&2 echo. 1>&2 diff --git a/tools/cpp/windows_cc_configure.bzl b/tools/cpp/windows_cc_configure.bzl index 7381c11bb40af9..1a49b2ca1471f4 100644 --- a/tools/cpp/windows_cc_configure.bzl +++ b/tools/cpp/windows_cc_configure.bzl @@ -124,7 +124,7 @@ def find_vc_path(repository_ctx): # 2. Check if VS%VS_VERSION%COMNTOOLS is set, if true then try to find and use # vcvarsqueryregistry.bat to detect VC++. - auto_configure_warning("Looking for VS%VERSION%COMNTOOLS environment variables," + + auto_configure_warning("Looking for VS%VERSION%COMNTOOLS environment variables, " + "eg. VS140COMNTOOLS") for vscommontools_env in ["VS140COMNTOOLS", "VS120COMNTOOLS", "VS110COMNTOOLS", "VS100COMNTOOLS", "VS90COMNTOOLS"]: @@ -163,7 +163,7 @@ def find_vc_path(repository_ctx): vc_dir = line[line.find("REG_SZ") + len("REG_SZ"):].strip() + suffix if not vc_dir: - return "visual-studio-not-found" + return None auto_configure_warning("Visual C++ build tools found at %s" % vc_dir) return vc_dir @@ -185,7 +185,8 @@ def _find_vcvarsall_bat_script(repository_ctx, vc_path): vcvarsall = vc_path + "\\VCVARSALL.BAT" if not repository_ctx.path(vcvarsall).exists: - auto_configure_fail(vcvarsall + " doesn't exist, please check your VC++ installation") + return None + return vcvarsall @@ -214,7 +215,7 @@ def find_msvc_tool(repository_ctx, vc_path, tool): # C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.10.24930\bin\HostX64\x64 dirs = repository_ctx.path(vc_path + "\\Tools\\MSVC").readdir() if len(dirs) < 1: - auto_configure_fail("VC++ build tools directory not found under " + vc_path + "\\Tools\\MSVC") + return None # Normally there should be only one child directory under %VC_PATH%\TOOLS\MSVC, # but iterate every directory to be more robust. for path in dirs: @@ -227,9 +228,22 @@ def find_msvc_tool(repository_ctx, vc_path, tool): tool_path = vc_path + "\\bin\\amd64\\" + tool if not repository_ctx.path(tool_path).exists: - auto_configure_fail(tool_path + " not found, please check your VC++ installation.") + return None + return tool_path +def _find_missing_vc_tools(repository_ctx, vc_path): + """Check if any required tool is missing under given VC path.""" + missing_tools = [] + if not _find_vcvarsall_bat_script(repository_ctx, vc_path): + missing_tools.append("VCVARSALL.BAT") + + for tool in ["cl.exe", "link.exe", "lib.exe", "ml64.exe"]: + if not find_msvc_tool(repository_ctx, vc_path, tool): + missing_tools.append(tool) + + return missing_tools + def _is_support_whole_archive(repository_ctx, vc_path): """Run MSVC linker alone to see if it supports /WHOLEARCHIVE.""" @@ -296,9 +310,23 @@ def configure_windows_toolchain(repository_ctx): repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.static"), "BUILD") vc_path = find_vc_path(repository_ctx) - if vc_path == "visual-studio-not-found": - vc_path_error_script = "vc_path_not_found.bat" - repository_ctx.symlink(Label("@bazel_tools//tools/cpp:vc_path_not_found.bat"), vc_path_error_script) + missing_tools = None + vc_installation_error_script = "vc_installation_error.bat" + if not vc_path: + tpl(repository_ctx, vc_installation_error_script, {"%{vc_error_message}" : ""}) + else: + missing_tools = _find_missing_vc_tools(repository_ctx, vc_path) + if missing_tools: + tpl(repository_ctx, vc_installation_error_script, { + "%{vc_error_message}" : "\r\n".join([ + "echo. 1>&2", + "echo Visual C++ build tools seems to be installed at %s 1>&2" % vc_path, + "echo But Bazel can't find the following tools: 1>&2", + "echo %s 1>&2" % ", ".join(missing_tools), + "echo. 1>&2", + ])}) + + if not vc_path or missing_tools: tpl(repository_ctx, "CROSSTOOL", { "%{cpu}": "x64_windows", "%{default_toolchain_name}": "msvc_x64", @@ -307,14 +335,18 @@ def configure_windows_toolchain(repository_ctx): "%{msvc_env_path}": "", "%{msvc_env_include}": "", "%{msvc_env_lib}": "", - "%{msvc_cl_path}": vc_path_error_script, - "%{msvc_link_path}": vc_path_error_script, - "%{msvc_lib_path}": vc_path_error_script, + "%{msvc_cl_path}": vc_installation_error_script, + "%{msvc_ml_path}": vc_installation_error_script, + "%{msvc_link_path}": vc_installation_error_script, + "%{msvc_lib_path}": vc_installation_error_script, + "%{dbg_mode_debug}": "/DEBUG", + "%{fastbuild_mode_debug}": "/DEBUG", "%{compilation_mode_content}": "", "%{content}": _get_escaped_windows_msys_crosstool_content(repository_ctx), "%{msys_x64_mingw_content}": _get_escaped_windows_msys_crosstool_content(repository_ctx, use_mingw = True), "%{opt_content}": "", "%{dbg_content}": "", + "%{link_content}": "", "%{cxx_builtin_include_directory}": "", "%{coverage}": "", })
null
train
train
2018-03-14T03:20:35
2018-03-09T09:58:05Z
meteorcloudy
test
bazelbuild/bazel/4839_7354
bazelbuild/bazel
bazelbuild/bazel/4839
bazelbuild/bazel/7354
[ "timestamp(timedelta=26307.0, similarity=0.8492214731048833)" ]
0fc8deec015214006a289fa6bd0fd9cd99bbba5b
06c74313012ac1cfeb00d93086517d3d90dae048
[ "building a merkle tree should not be much more expensive than building a list if implemented correctly.", "Does this still hold true compared to the comment mentioned here: https://github.com/bazelbuild/bazel/pull/7583#issuecomment-468568192?", "I don't know. You'd have to benchmark the current merkle tree imp...
[]
2019-02-05T15:28:06Z
[]
remote/performance: don't construct a merkle tree for remote caching
Remote caching doesn't benefit from constructing a merkle. Some users reported significant performance overheads from constructing the merkle tree. We might just want to compute the hash of the list of input file hashes instead. cc: @benjaminp
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index 4ef09ad268f260..2da0cc1203d446 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -90,7 +90,7 @@ final class RemoteSpawnCache implements SpawnCache { @Override public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context) throws InterruptedException, IOException, ExecException { - if (!Spawns.mayBeCached(spawn)) { + if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) { return SpawnCache.NO_RESULT_NO_STORE; } boolean checkCache = options.remoteAcceptCached;
null
train
train
2019-02-05T16:41:18
2018-03-13T15:24:57Z
buchgr
test
bazelbuild/bazel/4844_7354
bazelbuild/bazel
bazelbuild/bazel/4844
bazelbuild/bazel/7354
[ "timestamp(timedelta=26421.0, similarity=0.8546858998698029)" ]
0fc8deec015214006a289fa6bd0fd9cd99bbba5b
06c74313012ac1cfeb00d93086517d3d90dae048
[ "#4889 is a stab at this", "This is a duplicate of #4889 ", "Hi @buchgr, on this project, is a PR normally considered a duplicate of the feature request which requests it?", "@buchgr would you consider reopening this issue?", "FYI -- elsewhere (issue #4789) I mentioned that S3's weak consistency model could...
[]
2019-02-05T15:28:06Z
[ "type: feature request", "P3" ]
remote/feature: support AWS S3 as a remote caching backend
We have heard from many users who want to use AWS S3 as a remote caching backend for Bazel just as they currently do with Google Cloud Storage. This is useful when running inside Travis or CircleCI (https://github.com/notnoopci/bazel-remote-proxy) as these SaaS products already run inside AWS. From skimming over the AWS S3 API documentation it seems that the APIs are mostly compatible, except for authentication. So implementing this feature will likely just mean to add AWS authentication to Bazel. cc: @davidstanke @alexeagle
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[ "src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index 4ef09ad268f260..2da0cc1203d446 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -90,7 +90,7 @@ final class RemoteSpawnCache implements SpawnCache { @Override public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context) throws InterruptedException, IOException, ExecException { - if (!Spawns.mayBeCached(spawn)) { + if (!Spawns.mayBeCached(spawn) || !Spawns.mayBeExecutedRemotely(spawn)) { return SpawnCache.NO_RESULT_NO_STORE; } boolean checkCache = options.remoteAcceptCached;
null
train
train
2019-02-05T16:41:18
2018-03-14T10:01:05Z
buchgr
test
bazelbuild/bazel/4864_4866
bazelbuild/bazel
bazelbuild/bazel/4864
bazelbuild/bazel/4866
[ "timestamp(timedelta=1.0, similarity=0.8861591060261476)" ]
df296a483aca5a3612e356908cc2ca2c207a3cbb
cc94075f295121b382c86175c7f106a6c86f4cca
[ "That's perfect.\r\nI think the crux of the matter is at https://github.com/bazelbuild/bazel/blob/d1119fa583ff659a80828d1b67cc980b04f6b386/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidNdkRepositoryFunction.java#L340-L344\r\n\r\nWhich is weird because the path should be in that list as a `-...
[]
2018-03-16T19:05:22Z
[ "type: bug", "P1" ]
NDK runtime libs are not part of the toolchain's all_files outputs
For `libc++`, the runtime libs are not in the outputs of the toolchain, causing linktime errors in sandboxed mode. Sample of affected files: ``` external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64 external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++.so external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++_static.a external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++_shared.so external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++abi.a external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libandroid_support.a external/androidndk/ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++.a ``` See conversation at https://github.com/bazelbuild/bazel/issues/3923#issuecomment-372750002 for more details. Cause: the generated `%toolchain%-all-files` filegroups does not contain the `libs` folder: Generated `external/androidndk/BUILD.bazel` snippet: ``` cc_toolchain( name = "aarch64-linux-android-clang5.0.300080-libcpp", all_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", compiler_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", cpu = "arm64-v8a", dwp_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", dynamic_runtime_libs = [":libcpp-arm64-v8a-dynamic-runtime-libraries"], linker_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", objcopy_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", static_runtime_libs = [":libcpp-arm64-v8a-static-runtime-libraries"], strip_files = ":aarch64-linux-android-clang5.0.300080-libcpp-all_files", supports_param_files = 0, ) filegroup( name = "aarch64-linux-android-clang5.0.300080-libcpp-all_files", srcs = glob(["ndk/toolchains/llvm/**"]) + glob([ "ndk/platforms/android-26/arch-arm64/**/*", "ndk/sources/android/support/include/**/*", "ndk/sources/cxx-stl/llvm-libc++/include/**/*", "ndk/sources/cxx-stl/llvm-libc++abi/include/**/*", "ndk/sysroot/**/*", "ndk/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/**/*", ]), ) ``` Fix: The `aarch64-linux-android-clang5.0.300080-libcpp-all_files` filegroup glob should also contain `ndk/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/*`. Same for other toolchains. cc @steeve
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt" ]
[ "src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt" ]
[]
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt index 2019792fd335a5..7a5322b5f61957 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_template.txt @@ -22,6 +22,9 @@ filegroup( name = "%toolchainName%-all_files", srcs = glob(["ndk/toolchains/%toolchainDirectory%/**"]) + glob([ %toolchainFileGlobs% - ]), + ]) + [ + ":%dynamicRuntimeLibs%", + ":%staticRuntimeLibs%", + ], )
null
train
train
2018-03-16T19:56:57
2018-03-15T23:15:16Z
jin
test
bazelbuild/bazel/4870_4874
bazelbuild/bazel
bazelbuild/bazel/4870
bazelbuild/bazel/4874
[ "timestamp(timedelta=80.0, similarity=0.8598852016196619)" ]
3a7b8bc2abeaf8b8647c037bed1dd5fd73b8392b
3042400a28766afa0520e2d80bf37e4e9445b70f
[ "Actuall there are three options. The one you havn't mentioned: `--experimental_strict_action_env`. Without this options, the local action cache is useless, if the workspace location changed (clone project in two different locations). See also discussion on the #3042, where local action cache was introduced.\r\n\r\...
[ "I wonder if we should just call this feature \"Disk Cache\". I think \"local action cache\" is confusing because it's not only caching actions but also the output and I think it's easy to confuse with Bazel's actual action cache.\r\n\r\nSo what do you think about calling this \"Disk Cache\" and the flag `--disk_ca...
2018-03-19T22:44:22Z
[ "type: feature request", "P3" ]
improve --experimental_local_disk_cache
Many users like the `--experimental_local_disk_cache` option, but it needs some improvements. - Replace the two options `--experimental_local_disk_cache` and `--experimental_local_disk_cache_path` with one `--local_disk_cache=/path/to/disk/cache`. - Add a `--local_disk_cache_size=SIZE` option to specify an upper bound on the folder. A LRU cache is probably fine. We'll probably need to introduce a `lockfile` to make sure only one Bazel server uses the cache at a time. - Document it. Probably https://docs.bazel.build/versions/master/remote-caching.html is a good place. cc: @davido
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "src/test/shell/bazel/BUILD", "src/test/shell/bazel/build_cache_test.sh" ]
diff --git a/site/docs/remote-caching.md b/site/docs/remote-caching.md index 163f1122f2ad69..a256240cbd7cb6 100644 --- a/site/docs/remote-caching.md +++ b/site/docs/remote-caching.md @@ -28,6 +28,7 @@ make builds significantly faster. * [Delete content from the remote cache](#delete-content-from-the-remote-cache) * [Known Issues](#known-issues) * [External Links](#external-links) +* [Build cache](#build-cache) * [Bazel remote execution (in development)](#bazel-remote-execution-in-development) ## Remote caching overview @@ -306,6 +307,31 @@ You may want to delete content from the cache to: * Create a clean cache after a cache was poisoned * Reduce the amount of storage used by deleting old outputs +## Build cache + +Bazel can use a directory on the filesystem as a remote cache. This is +useful for sharing build artifacts when switching branches and/or working +on multiple workspaces of the same project i.e. multiple checkouts. Bazel +does not garbage collect the directory and thus one might want to set up a +cron job or similar to periodically clean up the directory. The build cache +can be enabled with the following flags. + +``` +build --build_cache=/path/to/build/cache +``` + +Additionally, one can pass a user specific path to the --build_cache flag +via the ~ character. Bazel will replace this with the current user's home +directory. This comes in handy when one wants to enable the build cache for +all developers of a project via the project's checked in `.bazelrc` file. + +To have cache hits across different workspaces, additional option should be +used: + +``` +build --experimental_strict_action_env +``` + ## Known issues **Input file modification during a Build** diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java index f3a2baec314327..16dc3f0bbce7b4 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java @@ -60,7 +60,7 @@ public Iterable<? extends ActionContext> getActionContexts() { String buildRequestId = env.getBuildRequestId().toString(); String commandId = env.getCommandId().toString(); - if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.experimentalLocalDiskCache) { + if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.buildCache != null) { RemoteSpawnCache spawnCache = new RemoteSpawnCache( env.getExecRoot(), diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java index b60241d5c798f6..35828724e9db4c 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java @@ -190,27 +190,18 @@ public final class RemoteOptions extends OptionsBase { ) public boolean experimentalRemoteSpawnCache; - // TODO(davido): Find a better place for this and the next option. + // TODO(davido): Find a better place for this option. @Option( - name = "experimental_local_disk_cache", - defaultValue = "false", - category = "remote", - documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, - effectTags = {OptionEffectTag.UNKNOWN}, - help = "Whether to use the experimental local disk cache." - ) - public boolean experimentalLocalDiskCache; - - @Option( - name = "experimental_local_disk_cache_path", + name = "build_cache", defaultValue = "null", category = "remote", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, converter = OptionsUtils.PathFragmentConverter.class, - help = "A file path to a local disk cache." + help = "A path to a directory where Bazel can read and write actions and action outputs. " + + "If the directory does not exist, it will be created." ) - public PathFragment experimentalLocalDiskCachePath; + public PathFragment buildCache; @Option( name = "experimental_guard_against_concurrent_changes", diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java index 70a323ffeb8ba7..1f35dfdafb85dc 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java +++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java @@ -46,10 +46,10 @@ public static SimpleBlobStore createRest(RemoteOptions options, Credentials cred } } - public static SimpleBlobStore createLocalDisk(RemoteOptions options, Path workingDirectory) + public static SimpleBlobStore createBuildCache(RemoteOptions options, Path workingDirectory) throws IOException { return new OnDiskBlobStore( - workingDirectory.getRelative(checkNotNull(options.experimentalLocalDiskCachePath))); + workingDirectory.getRelative(checkNotNull(options.buildCache))); } public static SimpleBlobStore create( @@ -58,8 +58,8 @@ public static SimpleBlobStore create( if (isRestUrlOptions(options)) { return createRest(options, creds); } - if (workingDirectory != null && isLocalDiskCache(options)) { - return createLocalDisk(options, workingDirectory); + if (workingDirectory != null && isBuildCache(options)) { + return createBuildCache(options, workingDirectory); } throw new IllegalArgumentException( "Unrecognized concurrent map RemoteOptions: must specify " @@ -67,11 +67,11 @@ public static SimpleBlobStore create( } public static boolean isRemoteCacheOptions(RemoteOptions options) { - return isRestUrlOptions(options) || isLocalDiskCache(options); + return isRestUrlOptions(options) || isBuildCache(options); } - public static boolean isLocalDiskCache(RemoteOptions options) { - return options.experimentalLocalDiskCache; + public static boolean isBuildCache(RemoteOptions options) { + return options.buildCache != null; } private static boolean isRestUrlOptions(RemoteOptions options) {
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index d271c43627b192..8f593e565bc11d 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -318,9 +318,9 @@ sh_test( ) sh_test( - name = "local_action_cache_test", + name = "build_cache_test", size = "small", - srcs = ["local_action_cache_test.sh"], + srcs = ["build_cache_test.sh"], data = [":test-deps"], ) diff --git a/src/test/shell/bazel/local_action_cache_test.sh b/src/test/shell/bazel/build_cache_test.sh similarity index 95% rename from src/test/shell/bazel/local_action_cache_test.sh rename to src/test/shell/bazel/build_cache_test.sh index 60c9c4ecc1abf4..0333398c7bc7a2 100755 --- a/src/test/shell/bazel/local_action_cache_test.sh +++ b/src/test/shell/bazel/build_cache_test.sh @@ -27,7 +27,7 @@ function test_local_action_cache() { local execution_file="${TEST_TMPDIR}/run.log" local input_file="foo.in" local output_file="bazel-genfiles/foo.txt" - local flags="--experimental_local_disk_cache_path=$cache --experimental_local_disk_cache" + local flags="--build_cache=$cache" rm -rf $cache mkdir $cache
val
train
2018-03-22T23:13:47
2018-03-19T10:37:43Z
buchgr
test
bazelbuild/bazel/4870_5118
bazelbuild/bazel
bazelbuild/bazel/4870
bazelbuild/bazel/5118
[ "timestamp(timedelta=159043.0, similarity=0.8863782482598617)" ]
a6b141d89e68e77c7d1df10b072f838a7dba99ae
b3e1a650e1f4de567c1acb0f9832032ffac97f7b
[ "Actuall there are three options. The one you havn't mentioned: `--experimental_strict_action_env`. Without this options, the local action cache is useless, if the workspace location changed (clone project in two different locations). See also discussion on the #3042, where local action cache was introduced.\r\n\r\...
[]
2018-04-30T15:09:28Z
[ "type: feature request", "P3" ]
improve --experimental_local_disk_cache
Many users like the `--experimental_local_disk_cache` option, but it needs some improvements. - Replace the two options `--experimental_local_disk_cache` and `--experimental_local_disk_cache_path` with one `--local_disk_cache=/path/to/disk/cache`. - Add a `--local_disk_cache_size=SIZE` option to specify an upper bound on the folder. A LRU cache is probably fine. We'll probably need to introduce a `lockfile` to make sure only one Bazel server uses the cache at a time. - Document it. Probably https://docs.bazel.build/versions/master/remote-caching.html is a good place. cc: @davido
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "src/test/shell/bazel/BUILD", "src/test/shell/bazel/disk_cache_test.sh" ]
diff --git a/site/docs/remote-caching.md b/site/docs/remote-caching.md index 163f1122f2ad69..7a949d9d271b57 100644 --- a/site/docs/remote-caching.md +++ b/site/docs/remote-caching.md @@ -28,6 +28,7 @@ make builds significantly faster. * [Delete content from the remote cache](#delete-content-from-the-remote-cache) * [Known Issues](#known-issues) * [External Links](#external-links) +* [Disk cache](#disk-cache) * [Bazel remote execution (in development)](#bazel-remote-execution-in-development) ## Remote caching overview @@ -306,6 +307,30 @@ You may want to delete content from the cache to: * Create a clean cache after a cache was poisoned * Reduce the amount of storage used by deleting old outputs +## Disk cache + +Bazel can use a directory on the filesystem as a remote cache. This is +useful for sharing build artifacts when switching branches and/or working +on multiple workspaces of the same project i.e. multiple checkouts. Bazel +does not garbage collect the directory and thus one might want to set up a +cron job or similar to periodically clean up the directory. The disk cache +can be enabled with the following flags. + +``` +build --disk_cache=/path/to/build/cache +``` + +Additionally, one can pass a user specific path to the `--disk_cache` flag +via the `~` character. Bazel will replace this with the current user's home +directory. This comes in handy when one wants to enable the disk cache for +all developers of a project via the project's checked in `.bazelrc` file. + +To have cache hits across different workspaces, the flag should be used: + +``` +build --experimental_strict_action_env +``` + ## Known issues **Input file modification during a Build** diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java index 8877f98572fb90..df8c312ef54a8f 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java @@ -64,7 +64,7 @@ public Iterable<? extends ActionContext> getActionContexts() { String buildRequestId = env.getBuildRequestId().toString(); String commandId = env.getCommandId().toString(); - if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.experimentalLocalDiskCache) { + if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.diskCache != null) { RemoteSpawnCache spawnCache = new RemoteSpawnCache( env.getExecRoot(), diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java index dd4f5a0d04878a..385edf5adf5300 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java @@ -175,25 +175,16 @@ public final class RemoteOptions extends OptionsBase { ) public boolean experimentalRemoteSpawnCache; - // TODO(davido): Find a better place for this and the next option. @Option( - name = "experimental_local_disk_cache", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, - effectTags = {OptionEffectTag.UNKNOWN}, - help = "Whether to use the experimental local disk cache." - ) - public boolean experimentalLocalDiskCache; - - @Option( - name = "experimental_local_disk_cache_path", + name = "disk_cache", defaultValue = "null", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, converter = OptionsUtils.PathFragmentConverter.class, - help = "A file path to a local disk cache." + help = "A path to a directory where Bazel can read and write actions and action outputs. " + + "If the directory does not exist, it will be created." ) - public PathFragment experimentalLocalDiskCachePath; + public PathFragment diskCache; @Option( name = "experimental_guard_against_concurrent_changes", diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java index 70a323ffeb8ba7..2a408042f1eeba 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java +++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java @@ -21,6 +21,7 @@ import com.google.devtools.build.lib.remote.blobstore.SimpleBlobStore; import com.google.devtools.build.lib.remote.blobstore.http.HttpBlobStore; import com.google.devtools.build.lib.vfs.Path; +import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; import java.net.URI; import java.util.concurrent.TimeUnit; @@ -34,8 +35,7 @@ public final class SimpleBlobStoreFactory { private SimpleBlobStoreFactory() {} - public static SimpleBlobStore createRest(RemoteOptions options, Credentials creds) - throws IOException { + public static SimpleBlobStore createRest(RemoteOptions options, Credentials creds) { try { return new HttpBlobStore( URI.create(options.remoteHttpCache), @@ -46,20 +46,22 @@ public static SimpleBlobStore createRest(RemoteOptions options, Credentials cred } } - public static SimpleBlobStore createLocalDisk(RemoteOptions options, Path workingDirectory) + public static SimpleBlobStore createDiskCache(Path workingDirectory, PathFragment diskCachePath) throws IOException { - return new OnDiskBlobStore( - workingDirectory.getRelative(checkNotNull(options.experimentalLocalDiskCachePath))); + Path cacheDir = workingDirectory.getRelative(checkNotNull(diskCachePath)); + if (!cacheDir.exists()) { + cacheDir.createDirectoryAndParents(); + } + return new OnDiskBlobStore(cacheDir); } - public static SimpleBlobStore create( - RemoteOptions options, @Nullable Credentials creds, @Nullable Path workingDirectory) - throws IOException { + public static SimpleBlobStore create(RemoteOptions options, @Nullable Credentials creds, + @Nullable Path workingDirectory) throws IOException { if (isRestUrlOptions(options)) { return createRest(options, creds); } - if (workingDirectory != null && isLocalDiskCache(options)) { - return createLocalDisk(options, workingDirectory); + if (workingDirectory != null && isDiskCache(options)) { + return createDiskCache(workingDirectory, options.diskCache); } throw new IllegalArgumentException( "Unrecognized concurrent map RemoteOptions: must specify " @@ -67,11 +69,11 @@ public static SimpleBlobStore create( } public static boolean isRemoteCacheOptions(RemoteOptions options) { - return isRestUrlOptions(options) || isLocalDiskCache(options); + return isRestUrlOptions(options) || isDiskCache(options); } - public static boolean isLocalDiskCache(RemoteOptions options) { - return options.experimentalLocalDiskCache; + public static boolean isDiskCache(RemoteOptions options) { + return options.diskCache != null; } private static boolean isRestUrlOptions(RemoteOptions options) {
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index f9c51e0e888afb..bfa6d6cd935614 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -332,9 +332,9 @@ sh_test( ) sh_test( - name = "local_action_cache_test", + name = "disk_cache_test", size = "small", - srcs = ["local_action_cache_test.sh"], + srcs = ["disk_cache_test.sh"], data = [":test-deps"], ) diff --git a/src/test/shell/bazel/local_action_cache_test.sh b/src/test/shell/bazel/disk_cache_test.sh similarity index 94% rename from src/test/shell/bazel/local_action_cache_test.sh rename to src/test/shell/bazel/disk_cache_test.sh index 60c9c4ecc1abf4..ef224cafefdba7 100755 --- a/src/test/shell/bazel/local_action_cache_test.sh +++ b/src/test/shell/bazel/disk_cache_test.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Test the local action cache +# Test the local disk cache # # Load the test setup defined in the parent directory @@ -27,7 +27,7 @@ function test_local_action_cache() { local execution_file="${TEST_TMPDIR}/run.log" local input_file="foo.in" local output_file="bazel-genfiles/foo.txt" - local flags="--experimental_local_disk_cache_path=$cache --experimental_local_disk_cache" + local flags="--disk_cache=$cache" rm -rf $cache mkdir $cache
train
train
2018-04-30T17:08:13
2018-03-19T10:37:43Z
buchgr
test
bazelbuild/bazel/4870_5119
bazelbuild/bazel
bazelbuild/bazel/4870
bazelbuild/bazel/5119
[ "timestamp(timedelta=3363.0, similarity=0.8716044316966144)" ]
345b5b7ffe48e17ab1e115c4c8df91dcb6094abc
f8cd21f0862cc34710fbf846563c7ccf328f26b5
[ "Actuall there are three options. The one you havn't mentioned: `--experimental_strict_action_env`. Without this options, the local action cache is useless, if the workspace location changed (clone project in two different locations). See also discussion on the #3042, where local action cache was introduced.\r\n\r\...
[]
2018-04-30T15:17:53Z
[ "type: feature request", "P3" ]
improve --experimental_local_disk_cache
Many users like the `--experimental_local_disk_cache` option, but it needs some improvements. - Replace the two options `--experimental_local_disk_cache` and `--experimental_local_disk_cache_path` with one `--local_disk_cache=/path/to/disk/cache`. - Add a `--local_disk_cache_size=SIZE` option to specify an upper bound on the folder. A LRU cache is probably fine. We'll probably need to introduce a `lockfile` to make sure only one Bazel server uses the cache at a time. - Document it. Probably https://docs.bazel.build/versions/master/remote-caching.html is a good place. cc: @davido
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "site/docs/remote-caching.md", "src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java", "src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java" ]
[ "src/test/shell/bazel/BUILD", "src/test/shell/bazel/disk_cache_test.sh" ]
diff --git a/site/docs/remote-caching.md b/site/docs/remote-caching.md index 163f1122f2ad69..7a949d9d271b57 100644 --- a/site/docs/remote-caching.md +++ b/site/docs/remote-caching.md @@ -28,6 +28,7 @@ make builds significantly faster. * [Delete content from the remote cache](#delete-content-from-the-remote-cache) * [Known Issues](#known-issues) * [External Links](#external-links) +* [Disk cache](#disk-cache) * [Bazel remote execution (in development)](#bazel-remote-execution-in-development) ## Remote caching overview @@ -306,6 +307,30 @@ You may want to delete content from the cache to: * Create a clean cache after a cache was poisoned * Reduce the amount of storage used by deleting old outputs +## Disk cache + +Bazel can use a directory on the filesystem as a remote cache. This is +useful for sharing build artifacts when switching branches and/or working +on multiple workspaces of the same project i.e. multiple checkouts. Bazel +does not garbage collect the directory and thus one might want to set up a +cron job or similar to periodically clean up the directory. The disk cache +can be enabled with the following flags. + +``` +build --disk_cache=/path/to/build/cache +``` + +Additionally, one can pass a user specific path to the `--disk_cache` flag +via the `~` character. Bazel will replace this with the current user's home +directory. This comes in handy when one wants to enable the disk cache for +all developers of a project via the project's checked in `.bazelrc` file. + +To have cache hits across different workspaces, the flag should be used: + +``` +build --experimental_strict_action_env +``` + ## Known issues **Input file modification during a Build** diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java index 8877f98572fb90..df8c312ef54a8f 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java @@ -64,7 +64,7 @@ public Iterable<? extends ActionContext> getActionContexts() { String buildRequestId = env.getBuildRequestId().toString(); String commandId = env.getCommandId().toString(); - if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.experimentalLocalDiskCache) { + if (remoteOptions.experimentalRemoteSpawnCache || remoteOptions.diskCache != null) { RemoteSpawnCache spawnCache = new RemoteSpawnCache( env.getExecRoot(), diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java index dd4f5a0d04878a..385edf5adf5300 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java @@ -175,25 +175,16 @@ public final class RemoteOptions extends OptionsBase { ) public boolean experimentalRemoteSpawnCache; - // TODO(davido): Find a better place for this and the next option. @Option( - name = "experimental_local_disk_cache", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, - effectTags = {OptionEffectTag.UNKNOWN}, - help = "Whether to use the experimental local disk cache." - ) - public boolean experimentalLocalDiskCache; - - @Option( - name = "experimental_local_disk_cache_path", + name = "disk_cache", defaultValue = "null", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.UNKNOWN}, converter = OptionsUtils.PathFragmentConverter.class, - help = "A file path to a local disk cache." + help = "A path to a directory where Bazel can read and write actions and action outputs. " + + "If the directory does not exist, it will be created." ) - public PathFragment experimentalLocalDiskCachePath; + public PathFragment diskCache; @Option( name = "experimental_guard_against_concurrent_changes", diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java index 70a323ffeb8ba7..2a408042f1eeba 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java +++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreFactory.java @@ -21,6 +21,7 @@ import com.google.devtools.build.lib.remote.blobstore.SimpleBlobStore; import com.google.devtools.build.lib.remote.blobstore.http.HttpBlobStore; import com.google.devtools.build.lib.vfs.Path; +import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; import java.net.URI; import java.util.concurrent.TimeUnit; @@ -34,8 +35,7 @@ public final class SimpleBlobStoreFactory { private SimpleBlobStoreFactory() {} - public static SimpleBlobStore createRest(RemoteOptions options, Credentials creds) - throws IOException { + public static SimpleBlobStore createRest(RemoteOptions options, Credentials creds) { try { return new HttpBlobStore( URI.create(options.remoteHttpCache), @@ -46,20 +46,22 @@ public static SimpleBlobStore createRest(RemoteOptions options, Credentials cred } } - public static SimpleBlobStore createLocalDisk(RemoteOptions options, Path workingDirectory) + public static SimpleBlobStore createDiskCache(Path workingDirectory, PathFragment diskCachePath) throws IOException { - return new OnDiskBlobStore( - workingDirectory.getRelative(checkNotNull(options.experimentalLocalDiskCachePath))); + Path cacheDir = workingDirectory.getRelative(checkNotNull(diskCachePath)); + if (!cacheDir.exists()) { + cacheDir.createDirectoryAndParents(); + } + return new OnDiskBlobStore(cacheDir); } - public static SimpleBlobStore create( - RemoteOptions options, @Nullable Credentials creds, @Nullable Path workingDirectory) - throws IOException { + public static SimpleBlobStore create(RemoteOptions options, @Nullable Credentials creds, + @Nullable Path workingDirectory) throws IOException { if (isRestUrlOptions(options)) { return createRest(options, creds); } - if (workingDirectory != null && isLocalDiskCache(options)) { - return createLocalDisk(options, workingDirectory); + if (workingDirectory != null && isDiskCache(options)) { + return createDiskCache(workingDirectory, options.diskCache); } throw new IllegalArgumentException( "Unrecognized concurrent map RemoteOptions: must specify " @@ -67,11 +69,11 @@ public static SimpleBlobStore create( } public static boolean isRemoteCacheOptions(RemoteOptions options) { - return isRestUrlOptions(options) || isLocalDiskCache(options); + return isRestUrlOptions(options) || isDiskCache(options); } - public static boolean isLocalDiskCache(RemoteOptions options) { - return options.experimentalLocalDiskCache; + public static boolean isDiskCache(RemoteOptions options) { + return options.diskCache != null; } private static boolean isRestUrlOptions(RemoteOptions options) {
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index f9c51e0e888afb..bfa6d6cd935614 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -332,9 +332,9 @@ sh_test( ) sh_test( - name = "local_action_cache_test", + name = "disk_cache_test", size = "small", - srcs = ["local_action_cache_test.sh"], + srcs = ["disk_cache_test.sh"], data = [":test-deps"], ) diff --git a/src/test/shell/bazel/local_action_cache_test.sh b/src/test/shell/bazel/disk_cache_test.sh similarity index 94% rename from src/test/shell/bazel/local_action_cache_test.sh rename to src/test/shell/bazel/disk_cache_test.sh index 60c9c4ecc1abf4..ef224cafefdba7 100755 --- a/src/test/shell/bazel/local_action_cache_test.sh +++ b/src/test/shell/bazel/disk_cache_test.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Test the local action cache +# Test the local disk cache # # Load the test setup defined in the parent directory @@ -27,7 +27,7 @@ function test_local_action_cache() { local execution_file="${TEST_TMPDIR}/run.log" local input_file="foo.in" local output_file="bazel-genfiles/foo.txt" - local flags="--experimental_local_disk_cache_path=$cache --experimental_local_disk_cache" + local flags="--disk_cache=$cache" rm -rf $cache mkdir $cache
train
train
2018-04-30T17:12:06
2018-03-19T10:37:43Z
buchgr
test
bazelbuild/bazel/4878_4981
bazelbuild/bazel
bazelbuild/bazel/4878
bazelbuild/bazel/4981
[ "timestamp(timedelta=0.0, similarity=0.9055867788501569)" ]
36bac4d8d1883292b81888140244a36cff45944a
da84adb1388e314a102c4ac6d4e03ac422f6cd23
[ "Blocking https://github.com/bazelbuild/bazel/issues/4582", "Can we close this issue or is it still a release blocker for 0.12.0?", "It's no longer a blocker, but it's also not resolved." ]
[]
2018-04-09T13:13:37Z
[ "P3" ]
runfiles,Python: move to //tools/python/runfiles
### Description of the problem / feature request: The language-specific tools should be under `//tools/<language>/<tool>` but the Python-specific runfiles library is currently under `@bazel_tools//tools/runfiles:py-runfiles` (in Bazel 0.12.0 release candidate). See also https://github.com/bazelbuild/bazel/pull/4873
[ "src/tools/runfiles/BUILD", "tools/BUILD", "tools/python/BUILD" ]
[ "src/tools/runfiles/BUILD", "tools/BUILD", "tools/python/BUILD", "tools/python/runfiles/BUILD", "tools/python/runfiles/BUILD.tools" ]
[ "src/test/py/bazel/runfiles_test.py", "src/test/py/bazel/testdata/runfiles_test/bar/BUILD.mock", "src/test/py/bazel/testdata/runfiles_test/bar/bar.py", "src/test/py/bazel/testdata/runfiles_test/foo/BUILD.mock", "src/test/py/bazel/testdata/runfiles_test/foo/foo.py" ]
diff --git a/src/tools/runfiles/BUILD b/src/tools/runfiles/BUILD index 0df3386cad158d..81e156d4b7dc32 100644 --- a/src/tools/runfiles/BUILD +++ b/src/tools/runfiles/BUILD @@ -22,24 +22,11 @@ filegroup( "BUILD.tools", "runfiles.cc", "runfiles.h", - "runfiles.py", "//src/tools/runfiles/java/com/google/devtools/build/runfiles:embedded_tools", ], visibility = ["//src:__pkg__"], ) -py_library( - name = "py-runfiles", - srcs = ["runfiles.py"], -) - -py_test( - name = "py-runfiles-test", - srcs = ["runfiles_test.py"], - main = "runfiles_test.py", - deps = [":py-runfiles"], -) - cc_library( name = "cc-runfiles", srcs = ["runfiles.cc"], diff --git a/tools/BUILD b/tools/BUILD index 4488574d28943b..21a95fc486899a 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -57,7 +57,7 @@ filegroup( "//tools/def_parser:srcs", "//tools/platforms:srcs", "//tools/objc:srcs", - "//tools/python:srcs", + "//tools/python:embedded_tools", "//tools/runfiles:embedded_tools", "//tools/test:srcs", "//tools/osx/crosstool:srcs", diff --git a/tools/python/BUILD b/tools/python/BUILD index 6933f9d4197a4e..ab09128e0c8650 100644 --- a/tools/python/BUILD +++ b/tools/python/BUILD @@ -6,10 +6,28 @@ sh_binary( ) filegroup( - name = "srcs", + name = "srcs_and_embedded_tools", srcs = [ # Tools are build from the workspace for tests. "2to3.sh", "BUILD", ], + visibility = ["//visibility:private"], +) + +filegroup( + name = "srcs", + srcs = [ + ":srcs_and_embedded_tools", + "//tools/python/runfiles:srcs", + ], +) + +filegroup( + name = "embedded_tools", + srcs = [ + ":srcs_and_embedded_tools", + "//tools/python/runfiles:embedded_tools", + ], + visibility = ["//tools:__pkg__"], ) diff --git a/tools/python/runfiles/BUILD b/tools/python/runfiles/BUILD new file mode 100644 index 00000000000000..2723302bb4cdc6 --- /dev/null +++ b/tools/python/runfiles/BUILD @@ -0,0 +1,34 @@ +package(default_visibility = ["//visibility:private"]) + +filegroup( + name = "srcs", + srcs = glob( + ["**"], + exclude = [ + ".*", + "*~", + ], + ), + visibility = ["//tools/python:__pkg__"], +) + +filegroup( + name = "embedded_tools", + srcs = [ + "BUILD.tools", + "runfiles.py", + ], + visibility = ["//tools/python:__pkg__"], +) + +py_library( + name = "runfiles", + testonly = 1, + srcs = ["runfiles.py"], +) + +py_library( + name = "runfiles_test", + srcs = ["runfiles_test.py"], + visibility = ["//visibility:public"], +) diff --git a/tools/python/runfiles/BUILD.tools b/tools/python/runfiles/BUILD.tools new file mode 100644 index 00000000000000..4080d68774d468 --- /dev/null +++ b/tools/python/runfiles/BUILD.tools @@ -0,0 +1,5 @@ +py_library( + name = "runfiles", + srcs = ["runfiles.py"], + visibility = ["//visibility:public"], +)
diff --git a/src/test/py/bazel/runfiles_test.py b/src/test/py/bazel/runfiles_test.py index 1a9a6703b2eed3..a348b932f9370b 100644 --- a/src/test/py/bazel/runfiles_test.py +++ b/src/test/py/bazel/runfiles_test.py @@ -74,7 +74,7 @@ def _AssertPythonRunfilesLibraryInBazelToolsRepo(self, family, lang_name): for s, t in [ ("WORKSPACE.mock", "WORKSPACE"), ("foo/BUILD.mock", "foo/BUILD"), - ("foo/runfiles.py", "foo/runfiles.py"), + ("foo/foo.py", "foo/foo.py"), ("foo/datadep/hello.txt", "foo/datadep/hello.txt"), ("bar/BUILD.mock", "bar/BUILD"), ("bar/bar.py", "bar/bar.py"), @@ -131,19 +131,15 @@ def _AssertPythonRunfilesLibraryInBazelToolsRepo(self, family, lang_name): i += 2 - # TODO(laszlocsomor): re-enable after - # https://github.com/bazelbuild/bazel/issues/4878 is fixed. - # def testPythonRunfilesLibraryInBazelToolsRepo(self): - # self._AssertPythonRunfilesLibraryInBazelToolsRepo("py", "Python") + def testPythonRunfilesLibraryInBazelToolsRepo(self): + self._AssertPythonRunfilesLibraryInBazelToolsRepo("py", "Python") def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self): for s, t in [ ("WORKSPACE.mock", "WORKSPACE"), ("bar/BUILD.mock", "bar/BUILD"), - # TODO(laszlocsomor): uncomment Python files after - # https://github.com/bazelbuild/bazel/issues/4878 is fixed. - # ("bar/bar.py", "bar/bar.py"), - # ("bar/bar-py-data.txt", "bar/bar-py-data.txt"), + ("bar/bar.py", "bar/bar.py"), + ("bar/bar-py-data.txt", "bar/bar-py-data.txt"), ("bar/Bar.java", "bar/Bar.java"), ("bar/bar-java-data.txt", "bar/bar-java-data.txt"), ]: @@ -155,12 +151,10 @@ def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self): self.AssertExitCode(exit_code, 0, stderr) bazel_bin = stdout[0] - exit_code, _, stderr = self.RunBazel(["build", "//bar:bar-java"]) + exit_code, _, stderr = self.RunBazel(["build", "//bar:bar-py", "//bar:bar-java"]) self.AssertExitCode(exit_code, 0, stderr) - # TODO(laszlocsomor): add Python after - # https://github.com/bazelbuild/bazel/issues/4878 is fixed. - for lang in [("java", "Java", "Bar.java")]: + for lang in [("py", "Python", "bar.py"), ("java", "Java", "Bar.java")]: if test_base.TestBase.IsWindows(): bin_path = os.path.join(bazel_bin, "bar/bar-%s.exe" % lang[0]) else: diff --git a/src/test/py/bazel/testdata/runfiles_test/bar/BUILD.mock b/src/test/py/bazel/testdata/runfiles_test/bar/BUILD.mock index 92098bce73213e..b6d52f717e9d2c 100644 --- a/src/test/py/bazel/testdata/runfiles_test/bar/BUILD.mock +++ b/src/test/py/bazel/testdata/runfiles_test/bar/BUILD.mock @@ -5,7 +5,7 @@ py_binary( srcs = ["bar.py"], data = ["bar-py-data.txt"], main = "bar.py", - deps = ["@bazel_tools//tools/runfiles:py-runfiles"], + deps = ["@bazel_tools//tools/python/runfiles"], ) java_binary( diff --git a/src/test/py/bazel/testdata/runfiles_test/bar/bar.py b/src/test/py/bazel/testdata/runfiles_test/bar/bar.py index a88b10b28ba73e..43d21525a54c42 100644 --- a/src/test/py/bazel/testdata/runfiles_test/bar/bar.py +++ b/src/test/py/bazel/testdata/runfiles_test/bar/bar.py @@ -14,7 +14,7 @@ """Mock Python binary, only used in tests.""" from __future__ import print_function -from bazel_tools.tools.runfiles import runfiles +from bazel_tools.tools.python.runfiles import runfiles print('Hello Python Bar!') r = runfiles.Create() diff --git a/src/test/py/bazel/testdata/runfiles_test/foo/BUILD.mock b/src/test/py/bazel/testdata/runfiles_test/foo/BUILD.mock index 15a3a7d467b3ad..04fc23ebace7e3 100644 --- a/src/test/py/bazel/testdata/runfiles_test/foo/BUILD.mock +++ b/src/test/py/bazel/testdata/runfiles_test/foo/BUILD.mock @@ -1,13 +1,13 @@ py_binary( name = "runfiles-py", - srcs = ["runfiles.py"], + srcs = ["foo.py"], data = [ "datadep/hello.txt", "//bar:bar-py", "//bar:bar-java", ], - main = "runfiles.py", - deps = ["@bazel_tools//tools/runfiles:py-runfiles"], + main = "foo.py", + deps = ["@bazel_tools//tools/python/runfiles"], ) java_binary( diff --git a/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py b/src/test/py/bazel/testdata/runfiles_test/foo/foo.py similarity index 97% rename from src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py rename to src/test/py/bazel/testdata/runfiles_test/foo/foo.py index 32100447e95c55..47fd6197f3083d 100644 --- a/src/test/py/bazel/testdata/runfiles_test/foo/runfiles.py +++ b/src/test/py/bazel/testdata/runfiles_test/foo/foo.py @@ -18,7 +18,7 @@ import os import subprocess -from bazel_tools.tools.runfiles import runfiles +from bazel_tools.tools.python.runfiles import runfiles def IsWindows():
train
train
2018-04-09T14:30:56
2018-03-20T09:00:12Z
laszlocsomor
test
bazelbuild/bazel/4950_6996
bazelbuild/bazel
bazelbuild/bazel/4950
bazelbuild/bazel/6996
[ "timestamp(timedelta=1.0, similarity=0.8754318251166257)" ]
60bc1e14242cc9bd7c51188cc3d1feb4453efacc
7e2da8f139b5f78fa9ac6b771e472594f4d81404
[ "@laszlocsomor wdyt?", "I think we can add it!", "@excitoon : Would you mind sending a PR with the documentation changes? I'd be happy to review it.", "@laszlocsomor Okay, I just didn't know you have documentation in github as well. I'll make that PR soon.", "Thanks! Yes, the files are under https://github....
[ "Cool! Do you have any information about maintenance as well? E.g. how does one update the package after a Bazel release?\r\n\r\nAlso, do you plan to own this package? If so, could you please add info about that here, so if there are questions about the Scoop package, people know whom to ask?", "ping", "@laszlo...
2018-12-25T19:13:56Z
[ "type: feature request", "type: documentation (cleanup)", "P4", "platform: windows", "area-Windows", "team-OSS" ]
Installation Bazel using Scoop package manager on Windows
### Description of the problem / feature request: Hi. I'm maintaining Bazel Scoop package. Can you add it to this page? https://docs.bazel.build/versions/master/install-windows.html Scoop is Windows package manager, it is like Chocolatey, but it is completely free and more developer-specific (and [more](https://github.com/lukesampson/scoop/wiki/Chocolatey-Comparison)). The recipe is as follows: ``` scoop bucket add user https://github.com/excitoon/scoop-user.git scoop bucket add versions scoop install user/bazel ``` P.S. `versions` repository is needed because Bazel depends on Python 2. Kind regards, Vladimir. ### Feature requests: what underlying problem are you trying to solve with this feature? That will improve convenience of installing Bazel on Windows.
[ "site/docs/install-windows.md" ]
[ "site/docs/install-windows.md" ]
[]
diff --git a/site/docs/install-windows.md b/site/docs/install-windows.md index f390995a3f3f8f..10dedc3023b10a 100644 --- a/site/docs/install-windows.md +++ b/site/docs/install-windows.md @@ -48,6 +48,7 @@ title: Installing Bazel on Windows ### Other ways to get Bazel * [Install Bazel using the Chocolatey package manager](#install-using-chocolatey) +* [Install Bazel using the Scoop package manager](#install-using-scoop) * [Compile Bazel from source](install-compile-source.html) #### Install using Chocolatey @@ -66,6 +67,20 @@ See [Chocolatey installation and package maintenance guide](https://bazel.build/windows-chocolatey-maintenance.html) for more information about the Chocolatey package. +#### Install using Scoop + +1. Install the [Scoop](https://scoop.sh/) package manager using PowerShell command: + + iex (new-object net.webclient).downloadstring('https://get.scoop.sh') + +2. Install the Bazel package: + + scoop install bazel + +See [Scoop installation and package maintenance +guide](https://bazel.build/windows-scoop-maintenance.html) for more +information about the Scoop package. + ### Using Bazel Once you have installed Bazel, see [Using Bazel on Windows](windows.html).
null
test
train
2019-02-25T14:29:40
2018-04-01T13:18:37Z
excitoon
test
bazelbuild/bazel/4965_5814
bazelbuild/bazel
bazelbuild/bazel/4965
bazelbuild/bazel/5814
[ "timestamp(timedelta=0.0, similarity=0.8774277923163243)" ]
9ed9d8ac4347408d15c8fce7c9c07e5c8e658b30
1381a546cd94d4dbc76bf51471b9c71e94b578fd
[ "Shall we reopen this, since 0e81f9aad49215fe4a13092e64384d9c0ef1ba76 reverted the fix?", "+1 this was surprising to me that it wasn't failing the build", "+1 this still happens in bazel-1.1.0", "Could we re-open this issue? We are hitting it in 3.1.0, and in our case it's definitely signals bugs. Our of de...
[]
2018-08-08T21:47:33Z
[ "type: bug" ]
runfiles conflicts print an ERROR message but don't fail the build
``` $ cat rule.bzl def _will_break(ctx): ctx.actions.write(ctx.outputs.executable, '') other_file = ctx.actions.declare_file('other-file') ctx.actions.write(other_file, '') return struct(runfiles=ctx.runfiles(symlinks={ctx.outputs.executable.short_path: other_file})) will_break = rule( executable = True, implementation = _will_break, ) $ cat BUILD load(':rule.bzl', 'will_break') will_break(name='x') $ bazel --batch build //:x INFO: Analysed target //:x (4 packages loaded). INFO: Found 1 target... ERROR: /home/benjamin/repos/k/BUILD:2:1: overwrote runfile x, was symlink to /home/benjamin/.cache/bazel/_bazel_benjamin/c65d72cc374bbf6340b06c981e4234e9/execroot/__main__/bazel-out/k8-fastbuild/bin/other-file, now symlink to /home/benjamin/.cache/bazel/_bazel_benjamin/c65d72cc374bbf6340b06c981e4234e9/execroot/__main__/bazel-out/k8-fastbuild/bin/x Target //:x up-to-date: bazel-bin/x INFO: Elapsed time: 1.131s, Critical Path: 0.02s INFO: 1 process, local. INFO: Build completed successfully, 5 total actions $ echo $? 0 ``` Generally, I expect a non-zero exit code if an `ERROR` message is printed.
[ "src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java" ]
[ "src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java" ]
[ "src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java", "src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java index 3c2811eb981a83..70ea2d168bef79 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java @@ -360,12 +360,22 @@ public NestedSet<String> getEmptyFilenames() { .build(); } + /** Returns the symlinks as a map from path fragment to artifact. */ + public Map<PathFragment, Artifact> getSymlinksAsMap() { + try { + return entriesToMap(symlinks, null); + } catch (IOException e) { + throw new IllegalStateException("unexpected since we passed a null conflict checker", e); + } + } + /** * Returns the symlinks as a map from path fragment to artifact. * * @param checker If not null, check for conflicts using this checker. */ - public Map<PathFragment, Artifact> getSymlinksAsMap(@Nullable ConflictChecker checker) { + public Map<PathFragment, Artifact> getSymlinksAsMap(@Nullable ConflictChecker checker) + throws IOException { return entriesToMap(symlinks, checker); } @@ -502,11 +512,9 @@ public ManifestBuilder( this.sawWorkspaceName = legacyExternalRunfiles; } - /** - * Adds a map under the workspaceName. - */ + /** Adds a map under the workspaceName. */ public void addUnderWorkspace( - Map<PathFragment, Artifact> inputManifest, ConflictChecker checker) { + Map<PathFragment, Artifact> inputManifest, ConflictChecker checker) throws IOException { for (Map.Entry<PathFragment, Artifact> entry : inputManifest.entrySet()) { PathFragment path = entry.getKey(); if (isUnderWorkspace(path)) { @@ -522,10 +530,9 @@ public void addUnderWorkspace( } } - /** - * Adds a map to the root directory. - */ - public void add(Map<PathFragment, Artifact> inputManifest, ConflictChecker checker) { + /** Adds a map to the root directory. */ + public void add(Map<PathFragment, Artifact> inputManifest, ConflictChecker checker) + throws IOException { for (Map.Entry<PathFragment, Artifact> entry : inputManifest.entrySet()) { checker.put(manifest, checkForWorkspace(entry.getKey()), entry.getValue()); } @@ -571,12 +578,22 @@ public NestedSet<SymlinkEntry> getRootSymlinks() { return rootSymlinks; } + /** Returns the root symlinks as a map from path fragment to artifact. */ + public Map<PathFragment, Artifact> getRootSymlinksAsMap() { + try { + return entriesToMap(rootSymlinks, null); + } catch (IOException e) { + throw new IllegalStateException("unexpected since we passed a null conflict checker", e); + } + } + /** * Returns the root symlinks as a map from path fragment to artifact. * * @param checker If not null, check for conflicts using this checker. */ - public Map<PathFragment, Artifact> getRootSymlinksAsMap(@Nullable ConflictChecker checker) { + public Map<PathFragment, Artifact> getRootSymlinksAsMap(@Nullable ConflictChecker checker) + throws IOException { return entriesToMap(rootSymlinks, checker); } @@ -585,7 +602,12 @@ public Map<PathFragment, Artifact> getRootSymlinksAsMap(@Nullable ConflictChecke * account. */ public Map<PathFragment, Artifact> asMapWithoutRootSymlinks() { - Map<PathFragment, Artifact> result = entriesToMap(symlinks, null); + Map<PathFragment, Artifact> result; + try { + result = entriesToMap(symlinks, null); + } catch (IOException e) { + throw new IllegalStateException("unexpected since we passed a null conflict checker", e); + } // If multiple artifacts have the same root-relative path, the last one in the list will win. // That is because the runfiles tree cannot contain the same artifact for different // configurations, because it only uses root-relative paths. @@ -645,11 +667,11 @@ public boolean isEmpty() { * * @param entrySet Sequence of entries to add. * @param checker If not null, check for conflicts with this checker, otherwise silently allow - * entries to overwrite previous entries. + * entries to overwrite previous entries. * @return Map<PathFragment, Artifact> Map of runfile entries. */ private static Map<PathFragment, Artifact> entriesToMap( - Iterable<SymlinkEntry> entrySet, @Nullable ConflictChecker checker) { + Iterable<SymlinkEntry> entrySet, @Nullable ConflictChecker checker) throws IOException { checker = (checker != null) ? checker : ConflictChecker.IGNORE_CHECKER; Map<PathFragment, Artifact> map = new LinkedHashMap<>(); for (SymlinkEntry entry : entrySet) { @@ -686,9 +708,6 @@ public static final class ConflictChecker { /** Location for eventHandler warnings. Ignored if eventHandler is null. */ private final Location location; - /** Type of event to emit */ - private final EventKind eventKind; - /** Construct a ConflictChecker for the given reporter with the given behavior */ public ConflictChecker(ConflictPolicy policy, EventHandler eventHandler, Location location) { if (eventHandler == null) { @@ -698,7 +717,6 @@ public ConflictChecker(ConflictPolicy policy, EventHandler eventHandler, Locatio } this.eventHandler = eventHandler; this.location = location; - this.eventKind = (policy == ConflictPolicy.ERROR) ? EventKind.ERROR : EventKind.WARNING; } /** @@ -708,7 +726,8 @@ public ConflictChecker(ConflictPolicy policy, EventHandler eventHandler, Locatio * @param path Path fragment to use as key in map. * @param artifact Artifact to store in map. This may be null to indicate an empty file. */ - public void put(Map<PathFragment, Artifact> map, PathFragment path, Artifact artifact) { + public void put(Map<PathFragment, Artifact> map, PathFragment path, Artifact artifact) + throws IOException { Preconditions.checkArgument( artifact == null || !artifact.isMiddlemanArtifact(), "%s", artifact); if (policy != ConflictPolicy.IGNORE && map.containsKey(path)) { @@ -719,13 +738,18 @@ public void put(Map<PathFragment, Artifact> map, PathFragment path, Artifact art (previous == null) ? "empty file" : previous.getExecPath().toString(); String artifactStr = (artifact == null) ? "empty file" : artifact.getExecPath().toString(); - String message = - String.format( - "overwrote runfile %s, was symlink to %s, now symlink to %s", - path.getSafePathString(), - previousStr, - artifactStr); - eventHandler.handle(Event.of(eventKind, location, message)); + if (policy == ConflictPolicy.WARN) { + String message = + String.format( + "overwrote runfile %s, was symlink to %s, now symlink to %s", + path.getSafePathString(), previousStr, artifactStr); + eventHandler.handle(Event.of(EventKind.WARNING, location, message)); + } else { + throw new IOException( + String.format( + "runfile %s mapped to both %s and %s", + path.getSafePathString(), previousStr, artifactStr)); + } } } map.put(path, artifact); @@ -1169,13 +1193,13 @@ public Runfiles merge(RunfilesApi other) { public void fingerprint(Fingerprint fp) { fp.addBoolean(getLegacyExternalRunfiles()); fp.addPath(getSuffix()); - Map<PathFragment, Artifact> symlinks = getSymlinksAsMap(null); + Map<PathFragment, Artifact> symlinks = getSymlinksAsMap(); fp.addInt(symlinks.size()); for (Map.Entry<PathFragment, Artifact> symlink : symlinks.entrySet()) { fp.addPath(symlink.getKey()); fp.addPath(symlink.getValue().getExecPath()); } - Map<PathFragment, Artifact> rootSymlinks = getRootSymlinksAsMap(null); + Map<PathFragment, Artifact> rootSymlinks = getRootSymlinksAsMap(); fp.addInt(rootSymlinks.size()); for (Map.Entry<PathFragment, Artifact> rootSymlink : rootSymlinks.entrySet()) { fp.addPath(rootSymlink.getKey());
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java index 54d215a31f7454..51b54bec83a592 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java @@ -15,6 +15,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -27,6 +28,7 @@ import com.google.devtools.build.lib.testutil.FoundationTestCase; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.Root; +import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -132,16 +134,8 @@ private void checkConflictWarning() { assertThat(Iterables.getOnlyElement(eventCollector).getKind()).isEqualTo(EventKind.WARNING); } - private void checkConflictError() { - assertContainsEvent("overwrote runfile"); - assertWithMessage("ConflictChecker.put should have errored once") - .that(eventCollector.count()) - .isEqualTo(1); - assertThat(Iterables.getOnlyElement(eventCollector).getKind()).isEqualTo(EventKind.ERROR); - } - @Test - public void testPutCatchesConflict() { + public void testPutCatchesConflict() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -158,25 +152,24 @@ public void testPutCatchesConflict() { } @Test - public void testPutReportsError() { + public void testPutReportsError() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); Artifact artifactC = new Artifact(PathFragment.create("c"), root); Map<PathFragment, Artifact> map = new LinkedHashMap<>(); - // Same as above but with ERROR not WARNING Runfiles.ConflictChecker checker = new Runfiles.ConflictChecker(Runfiles.ConflictPolicy.ERROR, reporter, null); checker.put(map, pathA, artifactB); reporter.removeHandler(failFastHandler); // So it doesn't throw AssertionError - checker.put(map, pathA, artifactC); - assertThat(map.entrySet()).containsExactly(Maps.immutableEntry(pathA, artifactC)); - checkConflictError(); + assertThat(assertThrows(IOException.class, () -> checker.put(map, pathA, artifactC))) + .hasMessageThat() + .isEqualTo("runfile a mapped to both b and c"); } @Test - public void testPutCatchesConflictBetweenNullAndNotNull() { + public void testPutCatchesConflictBetweenNullAndNotNull() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -191,7 +184,7 @@ public void testPutCatchesConflictBetweenNullAndNotNull() { } @Test - public void testPutCatchesConflictBetweenNotNullAndNull() { + public void testPutCatchesConflictBetweenNotNullAndNull() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -207,7 +200,7 @@ public void testPutCatchesConflictBetweenNotNullAndNull() { } @Test - public void testPutIgnoresConflict() { + public void testPutIgnoresConflict() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -223,7 +216,7 @@ public void testPutIgnoresConflict() { } @Test - public void testPutIgnoresConflictNoListener() { + public void testPutIgnoresConflictNoListener() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -239,7 +232,7 @@ public void testPutIgnoresConflictNoListener() { } @Test - public void testPutIgnoresSameArtifact() { + public void testPutIgnoresSameArtifact() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); Artifact artifactB = new Artifact(PathFragment.create("b"), root); @@ -256,7 +249,7 @@ public void testPutIgnoresSameArtifact() { } @Test - public void testPutIgnoresNullAndNull() { + public void testPutIgnoresNullAndNull() throws Exception { PathFragment pathA = PathFragment.create("a"); Map<PathFragment, Artifact> map = new LinkedHashMap<>(); @@ -270,7 +263,7 @@ public void testPutIgnoresNullAndNull() { } @Test - public void testPutNoConflicts() { + public void testPutNoConflicts() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathA = PathFragment.create("a"); PathFragment pathB = PathFragment.create("b"); @@ -324,7 +317,7 @@ public void testBuilderMergeConflictPolicyInheritStrictest() { } @Test - public void testLegacyRunfilesStructure() { + public void testLegacyRunfilesStructure() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment workspaceName = PathFragment.create("wsname"); PathFragment pathB = PathFragment.create("external/repo/b"); @@ -345,7 +338,7 @@ public void testLegacyRunfilesStructure() { } @Test - public void testRunfileAdded() { + public void testRunfileAdded() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment workspaceName = PathFragment.create("wsname"); PathFragment pathB = PathFragment.create("external/repo/b"); @@ -368,7 +361,7 @@ public void testRunfileAdded() { // TODO(kchodorow): remove this once the default workspace name is always set. @Test - public void testConflictWithExternal() { + public void testConflictWithExternal() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); PathFragment pathB = PathFragment.create("repo/b"); PathFragment externalPathB = Label.EXTERNAL_PACKAGE_NAME.getRelative(pathB); @@ -392,7 +385,7 @@ public void testConflictWithExternal() { } @Test - public void testMergeWithSymlinks() { + public void testMergeWithSymlinks() throws Exception { ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(scratch.resolve("/workspace"))); Artifact artifactA = new Artifact(PathFragment.create("a/target"), root); Artifact artifactB = new Artifact(PathFragment.create("b/target"), root); @@ -406,8 +399,8 @@ public void testMergeWithSymlinks() { .build(); Runfiles runfilesC = runfilesA.merge(runfilesB); - assertThat(runfilesC.getSymlinksAsMap(null).get(sympathA)).isEqualTo(artifactA); - assertThat(runfilesC.getSymlinksAsMap(null).get(sympathB)).isEqualTo(artifactB); + assertThat(runfilesC.getSymlinksAsMap().get(sympathA)).isEqualTo(artifactA); + assertThat(runfilesC.getSymlinksAsMap().get(sympathB)).isEqualTo(artifactB); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java index d98c16f4bc8543..3326125cb85c89 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleImplementationFunctionsTest.java @@ -65,6 +65,7 @@ import com.google.devtools.build.lib.testutil.MoreAsserts; import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.build.lib.util.OsUtils; +import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -925,8 +926,10 @@ public void testRunfilesSymlinkConflict() throws Exception { "symlinks = {'sym1': artifacts[1]})"); Runfiles runfiles = (Runfiles) result; reporter.removeHandler(failFastHandler); // So it doesn't throw exception - runfiles.getRunfilesInputs(reporter, null); - assertContainsEvent("ERROR <no location>: overwrote runfile"); + assertThat( + assertThrows(IOException.class, () -> runfiles.getRunfilesInputs(reporter, null))) + .hasMessageThat() + .isEqualTo("runfile __main__/sym1 mapped to both foo/b.img and foo/a.txt"); } private Iterable<Artifact> getRunfileArtifacts(Object runfiles) {
train
train
2018-09-03T16:32:05
2018-04-04T21:59:37Z
benjaminp
test
bazelbuild/bazel/4982_7356
bazelbuild/bazel
bazelbuild/bazel/4982
bazelbuild/bazel/7356
[ "timestamp(timedelta=0.0, similarity=0.8541927905712915)" ]
e2e235359ccdc4b6a122586b9d7c99abbddd65f5
9d4e6bed0acc3426a9a12002e59dc8dba926885f
[ "this is an issue with `cc_library` not detecting the `--apple_bitcode` flag and/or the C++ crosstool being incompatible with bitcode", "I've started to take a stab at this https://github.com/bazelbuild/bazel/pull/7356", "This appears to be solved in 0.24.", "Yep! Thanks!", "I am still seeing this issue wit...
[ "Can we keep this if we don't have bitcode? I don't know if this is being relied upon by other folks who need to run install_name_tool.", "Why are you removing this?", "Sure, do you have an example of how we can do that in the crosstool format? ", "I think this case is really only if you want to hide your sym...
2019-02-05T16:40:45Z
[ "type: bug", "P2", "team-Rules-CPP" ]
--apple_bitcode flag ineffective on iOS targets
(originally posted as https://github.com/bazelbuild/rules_apple/issues/163) When creating an `apple_static_library` target like [1] and building this via `bazel build --apple_bitcode=embedded --ios_multi_cpus=arm64 -c opt //:myappletarget` the bitcode is not being included in the actual build causing issues when trying to run the code on-device similar to: ``` /Project/myapplelibrary.a(lib1.o) does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 ``` However, specifying `--copt=-fembed-bitcode` causes a conflict with the `-fdata-sections` and `-ffunction-sections` flags that bazel uses by default. How can this be resolved? Is there some way I can resolve this temporarily? This is for `bazel 0.11.1` running on MacOS with latest released XCode. The references to `b/73546952` and `b/35091927` at https://github.com/bazelbuild/rules_apple/blob/master/test/ios_application_test.sh#L838 and https://github.com/bazelbuild/rules_apple/blob/master/test/configurations.bzl#L21 make me believe you're tracking this issue internally already? [1] ``` cc_library( name="mynativedependency"], srcs=["lib1.c"], hdrs=["lib1.h"]) apple_static_library( name="myappletarget", deps=[":mynativedependency"], platform_type="ios", minimum_os_version="9.0", visibility = ["//visibility:public"]) ```
[ "tools/osx/crosstool/cc_toolchain_config.bzl.tpl" ]
[ "tools/osx/crosstool/cc_toolchain_config.bzl.tpl" ]
[]
diff --git a/tools/osx/crosstool/cc_toolchain_config.bzl.tpl b/tools/osx/crosstool/cc_toolchain_config.bzl.tpl index 2dd5d2ffe7b4be..81bdaac48771b7 100644 --- a/tools/osx/crosstool/cc_toolchain_config.bzl.tpl +++ b/tools/osx/crosstool/cc_toolchain_config.bzl.tpl @@ -3333,7 +3333,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "arm64-apple-ios", @@ -3354,7 +3353,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "arm64-apple-tvos", @@ -3375,7 +3373,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "arm64e-apple-ios", @@ -3396,7 +3393,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "armv7-apple-ios", @@ -3417,7 +3413,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "armv7-apple-watchos", @@ -3438,7 +3433,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "i386-apple-ios", @@ -3459,7 +3453,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "i386-apple-watchos", @@ -3480,7 +3473,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "x86_64-apple-ios", @@ -3501,7 +3493,6 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-headerpad_max_install_names", "-no-canonical-prefixes", "-target", "x86_64-apple-tvos", @@ -3521,7 +3512,7 @@ def _impl(ctx): ["objc-executable", "objc++-executable"], flag_groups = [ flag_group( - flags = ["-headerpad_max_install_names", "-no-canonical-prefixes"], + flags = ["-no-canonical-prefixes"], ), ], ), @@ -3553,12 +3544,14 @@ def _impl(ctx): ["objc-executable", "objc++-executable"], flag_groups = [ flag_group( - flags = ["-headerpad_max_install_names", "-no-canonical-prefixes"], + flags = ["-no-canonical-prefixes"], ), ], ), ], ) + else: + fail("Unreachable") output_execpath_flags_feature = feature( name = "output_execpath_flags", @@ -4363,8 +4356,6 @@ def _impl(ctx): provides = ["profile"], ) - bitcode_embedded_feature = feature(name = "bitcode_embedded") - link_libcpp_feature = feature( name = "link_libc++", enabled = True, @@ -5169,8 +5160,6 @@ def _impl(ctx): ], ) - bitcode_embedded_markers_feature = feature(name = "bitcode_embedded_markers") - dead_strip_feature = feature( name = "dead_strip", flag_sets = [ @@ -5402,6 +5391,88 @@ def _impl(ctx): ], ) + headerpad_feature = feature( + name = "headerpad", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions + [ + ACTION_NAMES.objc_executable, + ACTION_NAMES.objcpp_executable, + ], + flag_groups = [flag_group(flags = ["-headerpad_max_install_names"])], + with_features = [with_feature_set(not_features = [ + "bitcode_embedded", + "bitcode_embedded_markers", + ])], + ), + ], + ) + + if (ctx.attr.cpu == "ios_arm64" + or ctx.attr.cpu == "ios_arm64e" + or ctx.attr.cpu == "ios_armv7" + or ctx.attr.cpu == "tvos_arm64" + or ctx.attr.cpu == "watchos_arm64_32" + or ctx.attr.cpu == "watchos_armv7k" + or ctx.attr.cpu == "darwin_x86_64"): + bitcode_embedded_feature = feature( + name = "bitcode_embedded", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [flag_group(flags = ["-fembed-bitcode"])], + ), + flag_set( + actions = all_link_actions + [ + ACTION_NAMES.objc_executable, + ACTION_NAMES.objcpp_executable, + ], + flag_groups = [flag_group(flags = [ + "-fembed-bitcode", + "-Xlinker", + "-bitcode_verify", + "-Xlinker", + "-bitcode_hide_symbols", + "-Xlinker", + "-bitcode_symbol_map", + "-Xlinker", + "BITCODE_TOUCH_SYMBOL_MAP=%{bitcode_symbol_map_path}", + ])], + ), + ], + ) + + bitcode_embedded_markers_feature = feature( + name = "bitcode_embedded_markers", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [flag_group(flags = ["-fembed-bitcode-marker"])], + ), + flag_set( + actions = all_link_actions + [ + ACTION_NAMES.objc_executable, + ACTION_NAMES.objcpp_executable, + ], + flag_groups = [flag_group(flags = ["-fembed-bitcode-marker"])], + ), + ], + ) + else: + bitcode_embedded_markers_feature = feature(name = "bitcode_embedded_markers") + bitcode_embedded_feature = feature(name = "bitcode_embedded") + if (ctx.attr.cpu == "ios_arm64" or ctx.attr.cpu == "ios_arm64e" or ctx.attr.cpu == "ios_armv7" @@ -5461,6 +5532,7 @@ def _impl(ctx): gcc_coverage_map_format_feature, apply_default_compiler_flags_feature, include_system_dirs_feature, + headerpad_feature, bitcode_embedded_feature, bitcode_embedded_markers_feature, objc_arc_feature, @@ -5531,6 +5603,7 @@ def _impl(ctx): gcc_coverage_map_format_feature, apply_default_compiler_flags_feature, include_system_dirs_feature, + headerpad_feature, bitcode_embedded_feature, bitcode_embedded_markers_feature, objc_arc_feature, @@ -5603,6 +5676,7 @@ def _impl(ctx): gcc_coverage_map_format_feature, apply_default_compiler_flags_feature, include_system_dirs_feature, + headerpad_feature, bitcode_embedded_feature, bitcode_embedded_markers_feature, objc_arc_feature, @@ -5719,4 +5793,4 @@ cc_toolchain_config = rule( }, provides = [CcToolchainConfigInfo], executable = True, -) \ No newline at end of file +)
null
train
train
2019-02-07T06:01:52
2018-04-09T15:09:21Z
th0br0
test
bazelbuild/bazel/5018_6863
bazelbuild/bazel
bazelbuild/bazel/5018
bazelbuild/bazel/6863
[ "timestamp(timedelta=0.0, similarity=0.9201973749546071)" ]
12b96466ee0d6ab83f7d4cd24be110bb5021281d
c4cc3dab44d8ac4b300f012124a64c4fbfc045d1
[]
[ "This is right, but it is confusing. because the implementation is a little too clever. It happens to be that all the allowed file types are of the form .tar.XX where XX is a valid compression.\r\nTo make this more readable, ee should simply have a map of allowed file extensions to the compression method they belon...
2018-12-07T12:46:31Z
[ "type: bug", "P4", "team-Bazel" ]
pkg_tar with extension tgz does not apply gzip compression
### Description of the problem / feature request: `pkg_tar` with the extension `tgz` does not gzip the tar file. Using the extensions `tar.gz` does gzip the tar The [documentation here](https://docs.bazel.build/versions/master/be/pkg.html) indicate `tgz` extensions should apply gzip compressed ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. ``` pkg_tar( name = "content", srcs = [ "testdata/bat/bat", "testdata/baz", ], ) pkg_tar( name = "gzip_content", extension = "tgz", deps = [ ":content", ], ) ``` ``` $ file gzip_content.tgz gzip_content.tgz: POSIX tar archive (GNU) ``` ``` $ file gzip_content.tar.gz gzip_content.tar.gz: gzip compressed data, was "gzip_content.tar", max compression ``` ### What operating system are you running Bazel on? macOS High Sierra 10.13.4 ### What's the output of `bazel info release`? release 0.12.0-homebrew
[ "tools/build_defs/pkg/pkg.bzl" ]
[ "tools/build_defs/pkg/pkg.bzl" ]
[]
diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl index 93ff5daf3e6e38..62cf4d94aee497 100644 --- a/tools/build_defs/pkg/pkg.bzl +++ b/tools/build_defs/pkg/pkg.bzl @@ -92,6 +92,8 @@ def _pkg_tar_impl(ctx): if dotPos > 0: dotPos += 1 args += ["--compression=%s" % ctx.attr.extension[dotPos:]] + elif ctx.attr.extension == "tgz": + args += ["--compression=gz"] args += ["--tar=" + f.path for f in ctx.files.deps] args += [ "--link=%s:%s" % (_quote(k, protect = ":"), ctx.attr.symlinks[k])
null
test
train
2018-12-07T12:24:16
2018-04-14T01:44:58Z
dprotaso
test
bazelbuild/bazel/5047_5665
bazelbuild/bazel
bazelbuild/bazel/5047
bazelbuild/bazel/5665
[ "timestamp(timedelta=35.0, similarity=0.856995870885839)" ]
168e7c9b86603f4ccfd372b3de8ac07b2eb6a759
87ad3a8e76a68fb63390bfd1f98e4cb4dccfa900
[ "cc @buchgr @ixdy @rmmh\r\nI've spent a fair bit of time trying to make this reproducible, unsuccesfuly. even digging through [our logs](https://k8s-gubernator.appspot.com/builds/kubernetes-jenkins/pr-logs/directory/pull-kubernetes-bazel-build) most runs are either successful or actual failures, but this happens of...
[]
2018-07-24T20:39:09Z
[ "P1" ]
builds with remote caching sometimes fails on incomplete downloads
### Description of the problem / feature request: Sometimes builds with http remote caching enabled fail with `Failed to delete output files after incomplete download. Cannot continue with local execution.` See EG the logs here: https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/62063/pull-kubernetes-bazel-test/38632/ ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. I've had some difficulty making this bug reproducible unfortunately, you need to have remote caching enabled and fail to download to an entry, which often still succeeds and falls back to local building. ### What operating system are you running Bazel on? A debian jessie based docker container. ### What's the output of `bazel info release`? `release 0.11.0` ### Any other information, logs, or outputs that you want to share? https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/62063/pull-kubernetes-bazel-test/38632/ https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/62723/pull-kubernetes-bazel-build/38747/
[ "src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java" ]
[ "src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java", "src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java" ]
[ "src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java index ef90223d838f9f..66f29c5120166d 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java @@ -13,8 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.remote; -import static com.google.devtools.build.lib.remote.util.Utils.getFromFuture; - +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; @@ -27,6 +26,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety; import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode; import com.google.devtools.build.lib.remote.util.DigestUtil; +import com.google.devtools.build.lib.remote.util.Utils; import com.google.devtools.build.lib.util.io.FileOutErr; import com.google.devtools.build.lib.vfs.Dirent; import com.google.devtools.build.lib.vfs.FileStatus; @@ -170,68 +170,84 @@ public void onFailure(Throwable t) { // TODO(olaola): will need to amend to include the TreeNodeRepository for updating. public void download(ActionResult result, Path execRoot, FileOutErr outErr) throws ExecException, IOException, InterruptedException { - try { - Context ctx = Context.current(); - List<FuturePathBooleanTuple> fileDownloads = - Collections.synchronizedList( - new ArrayList<>(result.getOutputFilesCount() + result.getOutputDirectoriesCount())); - for (OutputFile file : result.getOutputFilesList()) { - Path path = execRoot.getRelative(file.getPath()); - ListenableFuture<Void> download = - retrier.executeAsync( - () -> ctx.call(() -> downloadFile(path, file.getDigest(), file.getContent()))); - fileDownloads.add(new FuturePathBooleanTuple(download, path, file.getIsExecutable())); - } + Context ctx = Context.current(); + List<FuturePathBooleanTuple> fileDownloads = + Collections.synchronizedList( + new ArrayList<>(result.getOutputFilesCount() + result.getOutputDirectoriesCount())); + for (OutputFile file : result.getOutputFilesList()) { + Path path = execRoot.getRelative(file.getPath()); + ListenableFuture<Void> download = + retrier.executeAsync( + () -> ctx.call(() -> downloadFile(path, file.getDigest(), file.getContent()))); + fileDownloads.add(new FuturePathBooleanTuple(download, path, file.getIsExecutable())); + } - List<ListenableFuture<Void>> dirDownloads = - new ArrayList<>(result.getOutputDirectoriesCount()); - for (OutputDirectory dir : result.getOutputDirectoriesList()) { - SettableFuture<Void> dirDownload = SettableFuture.create(); - ListenableFuture<byte[]> protoDownload = - retrier.executeAsync(() -> ctx.call(() -> downloadBlob(dir.getTreeDigest()))); - Futures.addCallback( - protoDownload, - new FutureCallback<byte[]>() { - @Override - public void onSuccess(byte[] b) { - try { - Tree tree = Tree.parseFrom(b); - Map<Digest, Directory> childrenMap = new HashMap<>(); - for (Directory child : tree.getChildrenList()) { - childrenMap.put(digestUtil.compute(child), child); - } - Path path = execRoot.getRelative(dir.getPath()); - fileDownloads.addAll(downloadDirectory(path, tree.getRoot(), childrenMap, ctx)); - dirDownload.set(null); - } catch (IOException e) { - dirDownload.setException(e); + List<ListenableFuture<Void>> dirDownloads = new ArrayList<>(result.getOutputDirectoriesCount()); + for (OutputDirectory dir : result.getOutputDirectoriesList()) { + SettableFuture<Void> dirDownload = SettableFuture.create(); + ListenableFuture<byte[]> protoDownload = + retrier.executeAsync(() -> ctx.call(() -> downloadBlob(dir.getTreeDigest()))); + Futures.addCallback( + protoDownload, + new FutureCallback<byte[]>() { + @Override + public void onSuccess(byte[] b) { + try { + Tree tree = Tree.parseFrom(b); + Map<Digest, Directory> childrenMap = new HashMap<>(); + for (Directory child : tree.getChildrenList()) { + childrenMap.put(digestUtil.compute(child), child); } + Path path = execRoot.getRelative(dir.getPath()); + fileDownloads.addAll(downloadDirectory(path, tree.getRoot(), childrenMap, ctx)); + dirDownload.set(null); + } catch (IOException e) { + dirDownload.setException(e); } + } - @Override - public void onFailure(Throwable t) { - dirDownload.setException(t); - } - }, - MoreExecutors.directExecutor()); - dirDownloads.add(dirDownload); - } + @Override + public void onFailure(Throwable t) { + dirDownload.setException(t); + } + }, + MoreExecutors.directExecutor()); + dirDownloads.add(dirDownload); + } - fileDownloads.addAll(downloadOutErr(result, outErr, ctx)); + // Subsequently we need to wait for *every* download to finish, even if we already know that + // one failed. That's so that when exiting this method we can be sure that all downloads have + // finished and don't race with the cleanup routine. + // TODO(buchgr): Look into cancellation. - for (ListenableFuture<Void> dirDownload : dirDownloads) { - // Block on all directory download futures, so that we can be sure that we have discovered - // all file downloads and can subsequently safely iterate over the list of file downloads. + IOException downloadException = null; + try { + fileDownloads.addAll(downloadOutErr(result, outErr, ctx)); + } catch (IOException e) { + downloadException = e; + } + for (ListenableFuture<Void> dirDownload : dirDownloads) { + // Block on all directory download futures, so that we can be sure that we have discovered + // all file downloads and can subsequently safely iterate over the list of file downloads. + try { getFromFuture(dirDownload); + } catch (IOException e) { + downloadException = downloadException == null ? e : downloadException; } + } - for (FuturePathBooleanTuple download : fileDownloads) { + for (FuturePathBooleanTuple download : fileDownloads) { + try { getFromFuture(download.getFuture()); if (download.getPath() != null) { download.getPath().setExecutable(download.isExecutable()); } + } catch (IOException e) { + downloadException = downloadException == null ? e : downloadException; } - } catch (IOException downloadException) { + } + + if (downloadException != null) { try { // Delete any (partially) downloaded output files, since any subsequent local execution // of this action may expect none of the output files to exist. @@ -261,6 +277,11 @@ public void onFailure(Throwable t) { } } + @VisibleForTesting + protected <T> T getFromFuture(ListenableFuture<T> f) throws IOException, InterruptedException { + return Utils.getFromFuture(f); + } + /** Tuple of {@code ListenableFuture, Path, boolean}. */ private static class FuturePathBooleanTuple { private final ListenableFuture<?> future; diff --git a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java index b1b0d604df366e..8e6269a44d8dfa 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/SimpleBlobStoreActionCache.java @@ -14,8 +14,6 @@ package com.google.devtools.build.lib.remote; -import static com.google.devtools.build.lib.remote.util.Utils.getFromFuture; - import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture;
diff --git a/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java b/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java index fe4881c4745300..9afa20aae2807c 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java +++ b/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java @@ -16,18 +16,44 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningScheduledExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.common.util.concurrent.SettableFuture; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.clock.JavaClock; import com.google.devtools.build.lib.remote.AbstractRemoteActionCache.UploadManifest; +import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode; import com.google.devtools.build.lib.remote.util.DigestUtil; +import com.google.devtools.build.lib.remote.util.DigestUtil.ActionKey; +import com.google.devtools.build.lib.remote.util.Utils; +import com.google.devtools.build.lib.util.io.FileOutErr; import com.google.devtools.build.lib.vfs.DigestHashFunction; import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; import com.google.devtools.remoteexecution.v1test.ActionResult; +import com.google.devtools.remoteexecution.v1test.Command; +import com.google.devtools.remoteexecution.v1test.Digest; +import com.google.devtools.remoteexecution.v1test.OutputFile; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nullable; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -40,6 +66,13 @@ public class AbstractRemoteActionCacheTests { private Path execRoot; private final DigestUtil digestUtil = new DigestUtil(DigestHashFunction.SHA256); + private static ListeningScheduledExecutorService retryService; + + @BeforeClass + public static void beforeEverything() { + retryService = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(1)); + } + @Before public void setUp() throws Exception { fs = new InMemoryFileSystem(new JavaClock(), DigestHashFunction.SHA256); @@ -47,6 +80,11 @@ public void setUp() throws Exception { execRoot.createDirectory(); } + @AfterClass + public static void afterEverything() { + retryService.shutdownNow(); + } + @Test public void uploadSymlinkAsFile() throws Exception { ActionResult.Builder result = ActionResult.newBuilder(); @@ -92,4 +130,118 @@ public void uploadSymlinkInDirectory() throws Exception { .hasMessageThat() .contains("Only regular files and directories may be uploaded to a remote cache."); } + + @Test + public void onErrorWaitForRemainingDownloadsToComplete() + throws InterruptedException, ExecException { + // If one or more downloads of output files / directories fail then the code should + // wait for all downloads to have been completed before it tries to clean up partially + // downloaded files. + + Path stdout = fs.getPath("/execroot/stdout"); + Path stderr = fs.getPath("/execroot/stderr"); + + Map<Digest, ListenableFuture<byte[]>> downloadResults = new HashMap<>(); + Path file1 = fs.getPath("/execroot/file1"); + Digest digest1 = digestUtil.compute("file1".getBytes()); + downloadResults.put(digest1, Futures.immediateFuture("file1".getBytes())); + Path file2 = fs.getPath("/execroot/file2"); + Digest digest2 = digestUtil.compute("file2".getBytes()); + downloadResults.put(digest2, Futures.immediateFailedFuture(new IOException("download failed"))); + Path file3 = fs.getPath("/execroot/file3"); + Digest digest3 = digestUtil.compute("file3".getBytes()); + downloadResults.put(digest3, Futures.immediateFuture("file3".getBytes())); + + RemoteOptions options = new RemoteOptions(); + RemoteRetrier retrier = new RemoteRetrier(options, (e) -> false, retryService, + Retrier.ALLOW_ALL_CALLS); + List<ListenableFuture<?>> blockingDownloads = new ArrayList<>(); + AtomicInteger numSuccess = new AtomicInteger(); + AtomicInteger numFailures = new AtomicInteger(); + AbstractRemoteActionCache cache = new DefaultRemoteActionCache(options, digestUtil, retrier) { + @Override + public ListenableFuture<Void> downloadBlob(Digest digest, OutputStream out) { + SettableFuture<Void> result = SettableFuture.create(); + Futures.addCallback(downloadResults.get(digest), new FutureCallback<byte[]>() { + @Override + public void onSuccess(byte[] bytes) { + numSuccess.incrementAndGet(); + try { + out.write(bytes); + out.close(); + result.set(null); + } catch (IOException e) { + result.setException(e); + } + } + + @Override + public void onFailure(Throwable throwable) { + numFailures.incrementAndGet(); + result.setException(throwable); + } + }, MoreExecutors.directExecutor()); + return result; + } + + @Override + protected <T> T getFromFuture(ListenableFuture<T> f) + throws IOException, InterruptedException { + blockingDownloads.add(f); + return Utils.getFromFuture(f); + } + }; + + ActionResult result = ActionResult.newBuilder() + .setExitCode(0) + .addOutputFiles(OutputFile.newBuilder().setPath(file1.getPathString()).setDigest(digest1)) + .addOutputFiles(OutputFile.newBuilder().setPath(file2.getPathString()).setDigest(digest2)) + .addOutputFiles(OutputFile.newBuilder().setPath(file3.getPathString()).setDigest(digest3)) + .build(); + try { + cache.download(result, execRoot, new FileOutErr(stdout, stderr)); + } catch (IOException e) { + assertThat(numSuccess.get()).isEqualTo(2); + assertThat(numFailures.get()).isEqualTo(1); + assertThat(blockingDownloads).hasSize(3); + assertThat(Throwables.getRootCause(e)).hasMessageThat().isEqualTo("download failed"); + } + } + + private static class DefaultRemoteActionCache extends AbstractRemoteActionCache { + + public DefaultRemoteActionCache(RemoteOptions options, + DigestUtil digestUtil, Retrier retrier) { + super(options, digestUtil, retrier); + } + + @Override + public void ensureInputsPresent(TreeNodeRepository repository, Path execRoot, TreeNode root, + Command command) throws IOException, InterruptedException { + throw new UnsupportedOperationException(); + } + + @Nullable + @Override + ActionResult getCachedActionResult(ActionKey actionKey) + throws IOException, InterruptedException { + throw new UnsupportedOperationException(); + } + + @Override + void upload(ActionKey actionKey, Path execRoot, Collection<Path> files, FileOutErr outErr, + boolean uploadAction) throws ExecException, IOException, InterruptedException { + throw new UnsupportedOperationException(); + } + + @Override + protected ListenableFuture<Void> downloadBlob(Digest digest, OutputStream out) { + throw new UnsupportedOperationException(); + } + + @Override + public void close() { + throw new UnsupportedOperationException(); + } + } }
train
train
2018-07-24T22:00:06
2018-04-18T20:14:44Z
BenTheElder
test
bazelbuild/bazel/5055_9246
bazelbuild/bazel
bazelbuild/bazel/5055
bazelbuild/bazel/9246
[ "timestamp(timedelta=15149.0, similarity=0.9111177149131282)" ]
7c91751ae799f25522a19306488ada8a0185fb49
b9dfc3a3de17b9972992f1b9e02725000ff8aa75
[ "We've talked about different solutions to this problem in the past, but the easiest solution is to accept multiple rc files (#4502), which will let users keep platform specific flags in the global rc while keeping project specific flags in a workspace rc file. The workspace one can be shared between different plat...
[ "Is this cast safe? Shouldn't it be `(Boolean)` and check for null?", "If you inlined this, you wouldn't need to import Multiset.\r\nAlso, call `containsKey` instead of `keys().contains` -- it's possible that the latter constructs a set and the former doesn't.", "Why make a copy?\r\n\r\n(I realize this is old c...
2019-08-26T13:02:41Z
[ "type: feature request", "P2", "team-OSS" ]
bazelrc: multiplatform support
### Description of the problem / feature request: I'd like to have some mechanism to use platform-specific flags in bazelrc files. ### Feature requests: what underlying problem are you trying to solve with this feature? Motivation is to let checked-in, project-specific bazelrc files work on all platforms. Flags dealing with paths (e.g. `--output_user_root`), envvars (e.g. `--test_env`), and external programs or shells (e.g. `--workspace_status_command`) are all platform-specific.
[ "src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java", "src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java" ]
[ "src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java", "src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java" ]
[ "src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java" ]
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java index 9944a75537cb43..7ec11cfde637c3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java @@ -18,6 +18,7 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventHandler; @@ -25,6 +26,7 @@ import com.google.devtools.build.lib.runtime.commands.ProjectFileSupport; import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy; import com.google.devtools.build.lib.util.ExitCode; +import com.google.devtools.build.lib.util.OS; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.common.options.InvocationPolicyEnforcer; @@ -315,6 +317,27 @@ ExitCode parseOptions(List<String> args, ExtendedEventHandler eventHandler) { return ExitCode.SUCCESS; } + /** + * If --enable_platform_specific_config is true and the corresponding config definition exists, + * we should enable the platform specific config. + */ + private boolean shouldEnablePlatformSpecificConfig( + OptionValueDescription enablePlatformSpecificConfigDescription, + ListMultimap<String, RcChunkOfArgs> commandToRcArgs) { + if (enablePlatformSpecificConfigDescription == null || + !(boolean) enablePlatformSpecificConfigDescription.getValue()) { + return false; + } + + for (String commandName : getCommandNamesToParse(commandAnnotation)) { + String defaultConfigDef = commandName + ":" + OS.getCurrent().getCanonicalName(); + if (commandToRcArgs.containsKey(defaultConfigDef)) { + return true; + } + } + return false; + } + /** * Expand the values of --config according to the definitions provided in the rc files and the * applicable command. @@ -325,23 +348,30 @@ void expandConfigOptions( OptionValueDescription configValueDescription = optionsParser.getOptionValueDescription("config"); - if (configValueDescription == null || configValueDescription.getCanonicalInstances() == null) { - // No --config values were set, we can avoid this whole thing. - return; + if (configValueDescription != null && configValueDescription.getCanonicalInstances() != null) { + // Find the base set of configs. This does not include the config options that might be + // recursively included. + ImmutableList<ParsedOptionDescription> configInstances = + ImmutableList.copyOf(configValueDescription.getCanonicalInstances()); + + // Expand the configs that are mentioned in the input. Flatten these expansions before parsing + // them, to preserve order. + for (ParsedOptionDescription configInstance : configInstances) { + String configValueToExpand = (String) configInstance.getConvertedValue(); + List<String> expansion = getExpansion(eventHandler, commandToRcArgs, configValueToExpand); + optionsParser.parseArgsAsExpansionOfOption( + configInstance, String.format("expanded from --%s", configValueToExpand), expansion); + } } - // Find the base set of configs. This does not include the config options that might be - // recursively incuded. - ImmutableList<ParsedOptionDescription> configInstances = - ImmutableList.copyOf(configValueDescription.getCanonicalInstances()); - - // Expand the configs that are mentioned in the input. Flatten these expansions before parsing - // them, to preserve order. - for (ParsedOptionDescription configInstance : configInstances) { - String configValueToExpand = (String) configInstance.getConvertedValue(); - List<String> expansion = getExpansion(eventHandler, commandToRcArgs, configValueToExpand); + OptionValueDescription enablePlatformSpecificConfigDescription = + optionsParser.getOptionValueDescription("enable_platform_specific_config"); + if (shouldEnablePlatformSpecificConfig(enablePlatformSpecificConfigDescription, commandToRcArgs)) { + List<String> expansion = getExpansion(eventHandler, commandToRcArgs, OS.getCurrent().getCanonicalName()); optionsParser.parseArgsAsExpansionOfOption( - configInstance, String.format("expanded from --%s", configValueToExpand), expansion); + Iterables.getOnlyElement(enablePlatformSpecificConfigDescription.getCanonicalInstances()), + String.format("enabled by --enable_platform_specific_config"), + expansion); } // At this point, we've expanded everything, identify duplicates, if any, to warn about diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java index 1ce51636186c64..772204c57eb08c 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java @@ -56,6 +56,20 @@ public class CommonCommandOptions extends OptionsBase { + "your build may break in the future due to deprecations or other changes.") public Void allIncompatibleChanges; + @Option( + name = "enable_platform_specific_config", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + effectTags = {OptionEffectTag.UNKNOWN}, + help = + "If true, Bazel picks up host-OS-specific config lines from bazelrc files. For example, " + + "if the host OS is Linux and you run bazel build, Bazel picks up lines starting " + + "with build:linux. Supported OS identifiers are linux, osx, windows, and freebsd. " + + "Enabling this flag is equivalent to using --config=linux on Linux, " + + "--config=windows on Windows, etc." + ) + public boolean enablePlatformSpecificConfig; + @Option( name = "config", defaultValue = "",
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java index 21726009d0e842..f6e434d8e018b5 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/BlazeOptionHandlerTest.java @@ -29,6 +29,7 @@ import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.TestConstants; +import com.google.devtools.build.lib.util.OS; import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.OptionsParsingResult; @@ -155,6 +156,16 @@ private ListMultimap<String, RcChunkOfArgs> structuredArgsFromImportedRcsWithOnl return structuredArgs; } + private ListMultimap<String, RcChunkOfArgs> structuredArgsForDifferentPlatforms() { + ListMultimap<String, RcChunkOfArgs> structuredArgs = ArrayListMultimap.create(); + structuredArgs.put("c0:linux", new RcChunkOfArgs("rc1", ImmutableList.of("command_linux"))); + structuredArgs.put("c0:windows", new RcChunkOfArgs("rc1", ImmutableList.of("command_windows"))); + structuredArgs.put("c0:osx", new RcChunkOfArgs("rc1", ImmutableList.of("command_osx"))); + structuredArgs.put("c0:freebsd", new RcChunkOfArgs("rc1", ImmutableList.of("command_freebsd"))); + structuredArgs.put("c0:platform_config", new RcChunkOfArgs("rc1", ImmutableList.of("--enable_platform_specific_config"))); + return structuredArgs; + } + @Test public void testStructureRcOptionsAndConfigs_argumentless() throws Exception { ListMultimap<String, RcChunkOfArgs> structuredRc = @@ -297,6 +308,62 @@ public void testExpandConfigOptions_withConfig() throws Exception { .containsExactly("Found applicable config definition c0:config in file rc1: b"); } + @Test + public void testExpandConfigOptions_withPlatformSpecificConfigEnabled() throws Exception { + parser.parse("--enable_platform_specific_config"); + optionHandler.expandConfigOptions(eventHandler, structuredArgsForDifferentPlatforms()); + switch (OS.getCurrent()) { + case LINUX: + assertThat(parser.getResidue()).containsExactly("command_linux"); + break; + case DARWIN: + assertThat(parser.getResidue()).containsExactly("command_osx"); + break; + case WINDOWS: + assertThat(parser.getResidue()).containsExactly("command_windows"); + break; + case FREEBSD: + assertThat(parser.getResidue()).containsExactly("command_freebsd"); + break; + default: + assertThat(parser.getResidue()).isEmpty(); + } + } + + @Test + public void testExpandConfigOptions_withPlatformSpecificConfigEnabledInConfig() throws Exception { + // --enable_platform_specific_config itself will affect the selecting of config sections. + // Because Bazel expands config sections recursively, we want to make sure it's fine to enable + // --enable_platform_specific_config via another config section. + parser.parse("--config=platform_config"); + optionHandler.expandConfigOptions(eventHandler, structuredArgsForDifferentPlatforms()); + switch (OS.getCurrent()) { + case LINUX: + assertThat(parser.getResidue()).containsExactly("command_linux"); + break; + case DARWIN: + assertThat(parser.getResidue()).containsExactly("command_osx"); + break; + case WINDOWS: + assertThat(parser.getResidue()).containsExactly("command_windows"); + break; + case FREEBSD: + assertThat(parser.getResidue()).containsExactly("command_freebsd"); + break; + default: + assertThat(parser.getResidue()).isEmpty(); + } + } + + @Test + public void testExpandConfigOptions_withPlatformSpecificConfigEnabledWhenNothingSpecified() + throws Exception { + parser.parse("--enable_platform_specific_config"); + optionHandler.parseRcOptions(eventHandler, ArrayListMultimap.create()); + assertThat(eventHandler.getEvents()).isEmpty(); + assertThat(parser.getResidue()).isEmpty(); + } + @Test public void testExpandConfigOptions_withConfigForUnapplicableCommand() throws Exception { parser.parse("--config=other");
train
train
2019-08-26T14:49:21
2018-04-19T12:46:49Z
laszlocsomor
test
bazelbuild/bazel/5178_8975
bazelbuild/bazel
bazelbuild/bazel/5178
bazelbuild/bazel/8975
[ "timestamp(timedelta=0.0, similarity=0.8726004225422561)" ]
d115133e2e11e03c7db6a596f1094fe8895845f3
a9892800700ded2de3fea126aff3de9c54b4d91c
[ "In addition, if the Xcode is not installed, Bazel could work well. A same issue occurred before, and I just uninstalled the Xcode, and then it could work.", "Are you using VSCode by any chance? ", "@sergiocampama Yeap. Anything to do with it?", "Check out https://github.com/bazelbuild/bazel/issues/4603, it h...
[]
2019-07-24T22:31:30Z
[ "P4", "category: rules > ObjC / iOS / J2ObjC", "z-team-Apple" ]
Compatibility with Xcode and Command Line Developer Tools on macOS
### Description of the problem / feature request: As you know, `xcode-select` is used to select the developer directory on macOS. Both Xcode and Command Line Developer Tools are installed in my Mac. Due to the reason that the compiler Xcode provides seems not to support the OpenMP, I need to switch to the Command Line Developer Tools. I've executed the command `sudo xcode-select -s /Library/Developer/CommandLineTools`, but when I build with Bazel, it still told me that `Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, try: "bazel clean --expunge" to re-run Xcode configuration`. And of course, I've cleaned the workspace and rerun the command, but it was useless. ### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible. 1. Install Xcode, and now the active developer directory will be switched to Xcode. 2. Open the `Terminal.app`, execute `sudo xcode-select -s /Library/Developer/CommandLineTools` to switch back to the Command Line Developer Tools. 3. Build with Bazel. ### What operating system are you running Bazel on? `macOS High Sierra 10.13.4` ### What's the output of `bazel info release`? `release 0.12.0-homebrew` ### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ? Private branch of TensorFlow. ### Have you found anything relevant by searching the web? Nope. ### Any other information, logs, or outputs that you want to share? ```Shell $ bazel clean --expunge WARNING: ignoring http_proxy in environment. INFO: Starting clean. $ bazel build --copt=-DINTEL_MKL_DNN --config=mkl -c opt //tensorflow/tools/pip_package:build_pip_package WARNING: ignoring http_proxy in environment. .............. WARNING: /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/protobuf_archive/WORKSPACE:1: Workspace name in /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions ERROR: /private/var/tmp/_bazel_shilei/d84c9594019614910b5a52be437fcea4/external/local_config_cc/BUILD:50:5: in apple_cc_toolchain rule @local_config_cc//:cc-compiler-darwin_x86_64: Xcode version must be specified to use an Apple CROSSTOOL. If your Xcode version has changed recently, try: "bazel clean --expunge" to re-run Xcode configuration ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-darwin_x86_64' failed; build aborted INFO: Elapsed time: 13.244s FAILED: Build did NOT complete successfully (63 packages loaded) currently loading: tensorflow/python ... (2 packages) $ xcode-select -p /Library/Developer/CommandLineTools ```
[ "tools/osx/xcode_configure.bzl" ]
[ "tools/osx/xcode_configure.bzl" ]
[]
diff --git a/tools/osx/xcode_configure.bzl b/tools/osx/xcode_configure.bzl index 566b513031f7fc..764f07dd65f971 100644 --- a/tools/osx/xcode_configure.bzl +++ b/tools/osx/xcode_configure.bzl @@ -186,20 +186,6 @@ def _darwin_build_file(repository_ctx): _EXECUTE_TIMEOUT, ) - # "xcodebuild -version" failing may be indicative of no versions of xcode - # installed, which is an acceptable machine configuration to have for using - # bazel. Thus no print warning should be emitted here. - if (xcodebuild_result.return_code != 0): - error_msg = ( - "Running xcodebuild -version failed, " + - "return code {code}, stderr: {err}, stdout: {out}" - ).format( - code = xcodebuild_result.return_code, - err = xcodebuild_result.stderr, - out = xcodebuild_result.stdout, - ) - return VERSION_CONFIG_STUB + "\n# Error: " + error_msg.replace("\n", " ") + "\n" - (toolchains, xcodeloc_err) = run_xcode_locator( repository_ctx, Label(repository_ctx.attr.xcode_locator), @@ -208,8 +194,11 @@ def _darwin_build_file(repository_ctx): if xcodeloc_err: return VERSION_CONFIG_STUB + "\n# Error: " + xcodeloc_err + "\n" - default_xcode_version = _search_string(xcodebuild_result.stdout, "Xcode ", "\n") - default_xcode_build_version = _search_string(xcodebuild_result.stdout, "Build version ", "\n") + default_xcode_version = "" + default_xcode_build_version = "" + if xcodebuild_result.return_code == 0: + default_xcode_version = _search_string(xcodebuild_result.stdout, "Xcode ", "\n") + default_xcode_build_version = _search_string(xcodebuild_result.stdout, "Build version ", "\n") default_xcode_target = "" target_names = [] buildcontents = "" @@ -220,14 +209,19 @@ def _darwin_build_file(repository_ctx): developer_dir = toolchain.developer_dir target_name = "version%s" % version.replace(".", "_") buildcontents += _xcode_version_output(repository_ctx, target_name, version, aliases, developer_dir) - target_names.append("':%s'" % target_name) + target_label = "':%s'" % target_name + target_names.append(target_label) if (version.startswith(default_xcode_version) and version.endswith(default_xcode_build_version)): - default_xcode_target = target_name + default_xcode_target = target_label buildcontents += "xcode_config(name = 'host_xcodes'," if target_names: buildcontents += "\n versions = [%s]," % ", ".join(target_names) + if not default_xcode_target and target_names: + default_xcode_target = sorted(target_names, reverse = True)[0] + print("No default Xcode version is set with 'xcode-select' picking %s" % default_xcode_target) if default_xcode_target: - buildcontents += "\n default = ':%s'," % default_xcode_target + buildcontents += "\n default = %s," % default_xcode_target + buildcontents += "\n)\n" buildcontents += "available_xcodes(name = 'host_available_xcodes'," if target_names:
null
val
train
2020-02-25T22:53:29
2018-05-09T07:52:58Z
shiltian
test