Skip to content

Commit 570c512

Browse files
authored
Add feature check for repository_ctx.getenv (#94)
Bazel 7.1 and 8.0 added a `repository_ctx.getenv` function which lazily declares environment variables (see bazelbuild/bazel#19511). This patch adds a feature check for it for use outside of repository rule implementations.
1 parent ab5ccc3 commit 570c512

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

features.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ _external_deps = struct(
6969
# https://github.com/bazelbuild/bazel/commit/c796aba6ee36970956ea32b46a2f121bb4d1818a
7070
# https://github.com/bazelbuild/bazel/commit/e730201e6bf8d6c1c80433b5b42305c3167a8660
7171
extension_metadata_has_reproducible = ge_same_major("7.1.0") or ge("8.0.0-pre.20240213.1"),
72+
# Whether repository_ctx#getenv exists (#19511)
73+
# Note: This primarily targets conditionally adding environ
74+
# attributes to repository rule declarations. Inside repository rule
75+
# implementations, consider using the simpler and more descriptive
76+
# hasattr(repository_ctx, "getenv") as an alternative.
77+
# https://github.com/bazelbuild/bazel/commit/c230e39fb225edd206ed0aa07cfcdd8c51589965
78+
# https://github.com/bazelbuild/bazel/commit/25815511434d17f2843f73e0ff5231f3d80bc44e
79+
repository_ctx_has_getenv = ge_same_major("7.1.0") or ge("8.0.0-pre.20240128.3"),
7280
)
7381

7482
_flags = struct(

0 commit comments

Comments
 (0)