From 4959d34e844714b793b2c6fa05016a9a6eaa7044 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 8 Nov 2022 08:23:57 -0800 Subject: [PATCH] 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 #16665. PiperOrigin-RevId: 486957479 Change-Id: I328b7a3722aea95b3151ed88f23c277ed4154202 --- .../lib/bazel/repository/LocalConfigPlatformFunction.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java index 7f188bffb75706..eecf41a30ecd59 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java @@ -175,7 +175,11 @@ private static String buildFileContent(String repositoryName) { "platform(name = 'host',", " # Auto-detected host platform constraints.", " constraint_values = HOST_CONSTRAINTS,", - ")"), + ")", + "exports_files([", + " # Export constraints.bzl for use in downstream bzl_library targets.", + " 'constraints.bzl',", + "])"), repositoryName); }