From 240af807c935225d98b630666000cc03934f2ce7 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 8 Apr 2022 08:11:59 -0700 Subject: [PATCH] Allow select() specialization resolution to work with constraint_values. https://github.com/bazelbuild/bazel/issues/14604 RELNOTES: Allow specialization to work with constraint_values. PiperOrigin-RevId: 440367861 --- .../build/docgen/templates/be/functions.vm | 6 +- .../config/ConfigMatchingProvider.java | 21 +- .../platform/ConstraintValueInfo.java | 2 + .../build/lib/rules/config/ConfigSetting.java | 2 + .../lib/rules/config/ConfigSettingTest.java | 222 +++++++++++++++++- 5 files changed, 237 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm index 24d31883910a2f..a8c6d3fc54c705 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm @@ -616,10 +616,8 @@ sh_binary(
  • If multiple conditions match and one is a specialization of the others, the specialization takes precedence. Condition B is considered a - specialization of condition A if B has all the same flags as A plus some - additional flags. However, the number of constraint values that A and B have - are not considered in this comparison -- one condition cannot match a - platform more than another condition does. + specialization of condition A if B has all the same flags and constraint + values as A plus some additional flags and constraint values.
  • If multiple conditions match and one is not a specialization of all the others, Bazel fails with an error. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java index a70351e5414508..2784da50265026 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigMatchingProvider.java @@ -50,9 +50,15 @@ public static ConfigMatchingProvider create( ImmutableMultimap settingsMap, ImmutableMap flagSettingsMap, RequiredConfigFragmentsProvider requiredFragmentOptions, + ImmutableSet