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 72f5fb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Alias the target since the globals repo isn't visible to dependent workspaces.
alias(
name = "allow_unresolved_symlinks",
actual = "@bazel_features_globals//:allow_unresolved_symlinks",
)
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 bazel_features/private/globals_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 72f5fb7

Please sign in to comment.