bp2build: Split export_{includes,system_includes}
The specification of exporting includes vs system includes has an impact
on inclusion sort order. Conflating the two caused some symbols to not
be resolved correctly.
Bug: 198403271
Test: build/bazel/ci/bp2build.sh
Test: USE_BAZEL_ANALYSIS=1 m libbacktrace_no_dex succeeds with libc++_*
modules removed from mixed build denylist (would fail otherwise)
Change-Id: I08aff253d8962dc678ed10214b1c171330e0fe19
This commit is contained in:
@@ -743,6 +743,31 @@ func (sla *StringListAttribute) SortedConfigurationAxes() []ConfigurationAxis {
|
||||
return keys
|
||||
}
|
||||
|
||||
// DeduplicateAxesFromBase ensures no duplication of items between the no-configuration value and
|
||||
// configuration-specific values. For example, if we would convert this StringListAttribute as:
|
||||
// ["a", "b", "c"] + select({
|
||||
// "//condition:one": ["a", "d"],
|
||||
// "//conditions:default": [],
|
||||
// })
|
||||
// after this function, we would convert this StringListAttribute as:
|
||||
// ["a", "b", "c"] + select({
|
||||
// "//condition:one": ["d"],
|
||||
// "//conditions:default": [],
|
||||
// })
|
||||
func (sla *StringListAttribute) DeduplicateAxesFromBase() {
|
||||
base := sla.Value
|
||||
for axis, configToList := range sla.ConfigurableValues {
|
||||
for config, list := range configToList {
|
||||
remaining := SubtractStrings(list, base)
|
||||
if len(remaining) == 0 {
|
||||
delete(sla.ConfigurableValues[axis], config)
|
||||
} else {
|
||||
sla.ConfigurableValues[axis][config] = remaining
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TryVariableSubstitution, replace string substitution formatting within each string in slice with
|
||||
// Starlark string.format compatible tag for productVariable.
|
||||
func TryVariableSubstitutions(slice []string, productVariable string) ([]string, bool) {
|
||||
|
||||
@@ -293,3 +293,74 @@ func TestResolveExcludes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeduplicateAxesFromBase(t *testing.T) {
|
||||
attr := StringListAttribute{
|
||||
Value: []string{
|
||||
"all_include",
|
||||
"arm_include",
|
||||
"android_include",
|
||||
"linux_x86_include",
|
||||
},
|
||||
ConfigurableValues: configurableStringLists{
|
||||
ArchConfigurationAxis: stringListSelectValues{
|
||||
"arm": []string{"arm_include"},
|
||||
"x86": []string{"x86_include"},
|
||||
},
|
||||
OsConfigurationAxis: stringListSelectValues{
|
||||
"android": []string{"android_include"},
|
||||
"linux": []string{"linux_include"},
|
||||
},
|
||||
OsArchConfigurationAxis: stringListSelectValues{
|
||||
"linux_x86": {"linux_x86_include"},
|
||||
},
|
||||
ProductVariableConfigurationAxis("a"): stringListSelectValues{
|
||||
"a": []string{"not_in_value"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
attr.DeduplicateAxesFromBase()
|
||||
|
||||
expectedBaseIncludes := []string{
|
||||
"all_include",
|
||||
"arm_include",
|
||||
"android_include",
|
||||
"linux_x86_include",
|
||||
}
|
||||
if !reflect.DeepEqual(expectedBaseIncludes, attr.Value) {
|
||||
t.Errorf("Expected Value includes %q, got %q", attr.Value, expectedBaseIncludes)
|
||||
}
|
||||
expectedConfiguredIncludes := configurableStringLists{
|
||||
ArchConfigurationAxis: stringListSelectValues{
|
||||
"x86": []string{"x86_include"},
|
||||
},
|
||||
OsConfigurationAxis: stringListSelectValues{
|
||||
"linux": []string{"linux_include"},
|
||||
},
|
||||
OsArchConfigurationAxis: stringListSelectValues{},
|
||||
ProductVariableConfigurationAxis("a"): stringListSelectValues{
|
||||
"a": []string{"not_in_value"},
|
||||
},
|
||||
}
|
||||
for _, axis := range attr.SortedConfigurationAxes() {
|
||||
if _, ok := expectedConfiguredIncludes[axis]; !ok {
|
||||
t.Errorf("Found unexpected axis %s", axis)
|
||||
continue
|
||||
}
|
||||
expectedForAxis := expectedConfiguredIncludes[axis]
|
||||
gotForAxis := attr.ConfigurableValues[axis]
|
||||
if len(expectedForAxis) != len(gotForAxis) {
|
||||
t.Errorf("Expected %d configs for %s, got %d: %s", len(expectedForAxis), axis, len(gotForAxis), gotForAxis)
|
||||
}
|
||||
for config, value := range gotForAxis {
|
||||
if expected, ok := expectedForAxis[config]; ok {
|
||||
if !reflect.DeepEqual(expected, value) {
|
||||
t.Errorf("For %s, expected: %#v, got %#v", axis, expected, value)
|
||||
}
|
||||
} else {
|
||||
t.Errorf("Got unexpected config %q for %s", config, axis)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user