Skip to content

Commit a5ce392

Browse files
authored
bzlmod: prevent extension from registering repos (#1374)
1 parent dfc8131 commit a5ce392

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

foreign_cc/extensions.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def _init(module_ctx):
2121
register_default_tools = False,
2222
register_preinstalled_tools = False,
2323
register_built_pkgconfig_toolchain = True,
24+
# These should be registered via bzlmod entries instead
25+
register_repos = False,
2426
)
2527

2628
versions = {

foreign_cc/repositories.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def rules_foreign_cc_dependencies(
1717
register_preinstalled_tools = True,
1818
register_built_tools = True,
1919
register_toolchains = True,
20-
register_built_pkgconfig_toolchain = True):
20+
register_built_pkgconfig_toolchain = True,
21+
register_repos = True):
2122
"""Call this function from the WORKSPACE file to initialize rules_foreign_cc \
2223
dependencies and let neccesary code generation happen \
2324
(Code generation is needed to support different variants of the C++ Starlark API.).
@@ -59,6 +60,10 @@ def rules_foreign_cc_dependencies(
5960
startup --windows_enable_symlinks -> This is required to enable symlinking to avoid long runfile paths
6061
build --action_env=MSYS=winsymlinks:nativestrict -> This is required to enable symlinking to avoid long runfile paths
6162
startup --output_user_root=C:/b -> This is required to keep paths as short as possible
63+
64+
register_repos: If true, use repository rules to register the required
65+
dependencies. (If you are using bzlmod, you probably do not want to set
66+
this since it will create shadow copies of these repos)
6267
"""
6368

6469
register_framework_toolchains(register_toolchains = register_toolchains)
@@ -83,6 +88,9 @@ def rules_foreign_cc_dependencies(
8388
if register_preinstalled_tools:
8489
preinstalled_toolchains()
8590

91+
if not register_repos:
92+
return
93+
8694
maybe(
8795
http_archive,
8896
name = "bazel_features",

0 commit comments

Comments
 (0)