Skip to content

Commit

Permalink
feat: expose a config_setting for allow_unresolved_symlinks
Browse files Browse the repository at this point in the history
Allows a principled solution for rules like rules_js that need to have starlark logic conditional on the value, without a breaking change in Bazel 7 as the flag has been renamed.

Unblocks aspect-build/rules_js#1102
  • Loading branch information
alexeagle committed Jul 27, 2023
1 parent 8fbef9f commit 0bd9d28
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions private/globals_repo.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
load("//private:parse.bzl", "parse_version")

def _globals_repo_impl(rctx):
rctx.file("BUILD.bazel")

bazel_version = parse_version(native.bazel_version)

allow_unresolved_symlinks_flag = (
"experimental_allow_unresolved_symlinks"
if bazel_version < parse_version("7.0.0")
else "allow_unresolved_symlinks"
)

rctx.file("BUILD.bazel", """\
# @generated by version_repo.bzl
# Allow rules to sense the value of this flag, which was renamed.
config_setting(
name = "allow_unresolved_symlinks",
values = {allow_unresolved_symlinks},
visibility = ["//visibility:public"],
)
""".format(
allow_unresolved_symlinks = {
allow_unresolved_symlinks_flag: "true"
},
))

lines = ["globals = struct("]
for global_, version in rctx.attr.globals.items():
if not _is_valid_identifier(global_):
Expand Down

0 comments on commit 0bd9d28

Please sign in to comment.