Split asm and c flags and srcs in bp2build output

This allows removal of almost all current items from the mixed build
denylist, which were previously broken due to being unable to separately
control flags for compilations of different languages within the same
target.

Note that this does not appropriately implement asm/c srcs and flags for
either the shared variant or the static variant. This will require a
followup.

Test: bp2build.sh and mixed_libc.sh CI scripts
Test: Updated b2build tests

Change-Id: I28cf7437ee96cdf2fdbcb1eda2303691cff08ba4
This commit is contained in:
Chris Parsons
2021-05-21 18:50:44 -04:00
parent c2d8fa0515
commit af24cdd99f
7 changed files with 171 additions and 51 deletions

View File

@@ -137,6 +137,54 @@ func SubtractStrings(haystack []string, needle []string) []string {
return strings
}
// Return all needles in a given haystack, where needleFn is true for needles.
func FilterLabelList(haystack LabelList, needleFn func(string) bool) LabelList {
var includes []Label
for _, inc := range haystack.Includes {
if needleFn(inc.Label) {
includes = append(includes, inc)
}
}
return LabelList{Includes: includes, Excludes: haystack.Excludes}
}
// Return all needles in a given haystack, where needleFn is true for needles.
func FilterLabelListAttribute(haystack LabelListAttribute, needleFn func(string) bool) LabelListAttribute {
var result LabelListAttribute
result.Value = FilterLabelList(haystack.Value, needleFn)
for arch := range PlatformArchMap {
result.SetValueForArch(arch, FilterLabelList(haystack.GetValueForArch(arch), needleFn))
}
for os := range PlatformOsMap {
result.SetValueForOS(os, FilterLabelList(haystack.GetValueForOS(os), needleFn))
}
return result
}
// Subtract needle from haystack
func SubtractBazelLabelListAttribute(haystack LabelListAttribute, needle LabelListAttribute) LabelListAttribute {
var result LabelListAttribute
for arch := range PlatformArchMap {
result.SetValueForArch(arch,
SubtractBazelLabelList(haystack.GetValueForArch(arch), needle.GetValueForArch(arch)))
}
for os := range PlatformOsMap {
result.SetValueForOS(os,
SubtractBazelLabelList(haystack.GetValueForOS(os), needle.GetValueForOS(os)))
}
result.Value = SubtractBazelLabelList(haystack.Value, needle.Value)
return result
}
// Subtract needle from haystack
func SubtractBazelLabels(haystack []Label, needle []Label) []Label {
// This is really a set