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 26, 2023
1 parent 8fbef9f commit f143fa2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion private/version_repo.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
load(":parse.bzl", "parse_version")

def _version_repo_impl(rctx):
rctx.file("BUILD.bazel")
allow_unresolved_symlinks_flag = (
"experimental_allow_unresolved_symlinks"
if parse_version(native.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"
},
))
rctx.file("version.bzl", "version = '" + native.bazel_version + "'")

version_repo = repository_rule(_version_repo_impl)

0 comments on commit f143fa2

Please sign in to comment.