bp2build support for instruction_set
Convert `instruction_set: "arm"` to an
"arm_isa_arm" bazel feature.
Bug: 215719349
Test: go tests
Change-Id: Ib976d23d2a57e8c0ab5d83ec994a0b7f3c69a7fe
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 9880444..3fe0802 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -282,6 +282,8 @@
compilerAttributes
linkerAttributes
+ // A combination of compilerAttributes.features and linkerAttributes.features
+ features bazel.StringListAttribute
protoDependency *bazel.LabelAttribute
}
@@ -323,6 +325,8 @@
stubsSymbolFile *string
stubsVersions bazel.StringListAttribute
+
+ features bazel.StringListAttribute
}
type filterOutFn func(string) bool
@@ -386,6 +390,13 @@
ca.absoluteIncludes.SetSelectValue(axis, config, props.Include_dirs)
ca.localIncludes.SetSelectValue(axis, config, localIncludeDirs)
+ instructionSet := proptools.StringDefault(props.Instruction_set, "")
+ if instructionSet == "arm" {
+ ca.features.SetSelectValue(axis, config, []string{"arm_isa_arm", "-arm_isa_thumb"})
+ } else if instructionSet != "" && instructionSet != "thumb" {
+ ctx.ModuleErrorf("Unknown value for instruction_set: %s", instructionSet)
+ }
+
// In Soong, cflags occur on the command line before -std=<val> flag, resulting in the value being
// overridden. In Bazel we always allow overriding, via flags; however, this can cause
// incompatibilities, so we remove "-std=" flags from Cflag properties while leaving it in other
@@ -686,9 +697,13 @@
(&compilerAttrs).srcs.Add(&convertedLSrcs.srcName)
(&compilerAttrs).cSrcs.Add(&convertedLSrcs.cSrcName)
+ features := compilerAttrs.features.Clone().Append(linkerAttrs.features)
+ features.DeduplicateAxesFromBase()
+
return baseAttributes{
compilerAttrs,
linkerAttrs,
+ *features,
protoDep.protoDep,
}
}