Skip to content

Commit 4959d34

Browse files
gregmagolancopybara-github
authored andcommitted
fix: export constraints.bzl file from @local_config_platform so it can be used in downstream bzl_library targets
Downstream rule sets may depend on `@local_config_platform//:constraints.bzl` but when they do there is no way easy way to make that load statement compatible with `bzl_library`. This change makes it possible to use `bzl_library` on starlark code that loads from `@local_config_platform//:constraints.bzl`. For example, ``` bzl_library( name = "local_config_platform_constraints", srcs = ["@local_config_platform//:constraints.bzl"], ) bzl_library( name = "platform_utils", srcs = ["//lib/private:platform_utils.bzl"], deps = [":local_config_platform_constraints"], ) ``` Closes bazelbuild#16665. PiperOrigin-RevId: 486957479 Change-Id: I328b7a3722aea95b3151ed88f23c277ed4154202
1 parent 5903c31 commit 4959d34

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ private static String buildFileContent(String repositoryName) {
175175
"platform(name = 'host',",
176176
" # Auto-detected host platform constraints.",
177177
" constraint_values = HOST_CONSTRAINTS,",
178-
")"),
178+
")",
179+
"exports_files([",
180+
" # Export constraints.bzl for use in downstream bzl_library targets.",
181+
" 'constraints.bzl',",
182+
"])"),
179183
repositoryName);
180184
}
181185

0 commit comments

Comments
 (0)