Skip to content

Commit 14a11be

Browse files
committed
extensions: gate module_ctx.extension_metadata(reproducible = ...) appropriately
`reproducible` was added in Bazel 7.1.0; gating this argument allows older Bazel versions to use rules_cc 0.0.13 and newer. Note that this change (use of `reproducible`) came from Bazel itself in bazelbuild/bazel#22335; it made its way over to `rules_cc` via bazelbuild@c2549f6 (see bazelbuild/bazel@1c4e78a). More context [here](bazel-contrib/toolchains_llvm#389 (comment)).
1 parent ba3ec91 commit 14a11be

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module(
77
bazel_dep(name = "bazel_skylib", version = "1.7.1")
88
bazel_dep(name = "platforms", version = "0.0.10")
99
bazel_dep(name = "protobuf", version = "27.0")
10+
bazel_dep(name = "bazel_features", version = "1.19.0")
1011

1112
cc_configure = use_extension("//cc:extensions.bzl", "cc_configure_extension")
1213
use_repo(cc_configure, "local_config_cc", "local_config_cc_toolchains")

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
2424

2525
bazel_skylib_workspace()
2626

27+
http_archive(
28+
name = "bazel_features",
29+
sha256 = "3646ffd447753490b77d2380fa63f4d55dd9722e565d84dfda01536b48e183da",
30+
strip_prefix = "bazel_features-1.19.0",
31+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.19.0/bazel_features-v1.19.0.tar.gz",
32+
)
33+
34+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
35+
36+
bazel_features_deps()
37+
2738
http_archive(
2839
name = "rules_testing",
2940
sha256 = "02c62574631876a4e3b02a1820cb51167bb9cdcdea2381b2fa9d9b8b11c407c4",

cc/extensions.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
# limitations under the License.
1414
"""Module extension for cc auto configuration."""
1515

16+
load("@bazel_features//:feature.bzl", "bazel_features")
1617
load("//cc/private/toolchain:cc_configure.bzl", "cc_autoconf", "cc_autoconf_toolchains")
1718

1819
def _cc_configure_extension_impl(ctx):
1920
cc_autoconf_toolchains(name = "local_config_cc_toolchains")
2021
cc_autoconf(name = "local_config_cc")
21-
return ctx.extension_metadata(reproducible = True)
22+
23+
has_reproducible = bazel_features.external_deps.extension_metadata_has_reproducible
24+
return ctx.extension_metadata(
25+
**(dict(reproducible = True) if has_reproducible else {})
26+
)
2227

2328
cc_configure_extension = module_extension(implementation = _cc_configure_extension_impl)

0 commit comments

Comments
 (0)