From ce993c49aeb16b9d64f76fd408ef0b5fa2e8bf63 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 10 Jan 2024 20:31:01 +0100 Subject: [PATCH] [7.0.1] Avoid emitting canonical labels into generated repos (#20840) As long as #20722 isn't resolved, the canonical name for the given apparent name can change without the repo rule being refetched. Closes #20810. PiperOrigin-RevId: 597048244 Change-Id: I225424cc32e572b26c6d6e76e2c09c4d2e6a4ba6 Closes #20825 --- MODULE.bazel.lock | 12 +++++----- src/test/tools/bzlmod/MODULE.bazel.lock | 32 +++++++++++++++---------- tools/build_defs/repo/http.bzl | 3 --- tools/build_defs/repo/jvm.bzl | 6 ----- 4 files changed, 26 insertions(+), 27 deletions(-) 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/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": [] } } } 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 )