bp2build: add configurable attribute (select) support.
This CL adds a basic framework to support configurable string_list
attributes, selecting on the Arch variant (x86, x86_64, arm, arm64).
It offers fine-grained controls to map individual configurable
properties (arch_variant) to configurable Bazel attributes, starting
with the string_list type for the copts property for cc_object.
This design is primarily motivated to have minimal boilerplate in
bp2build mutators, allowing anyone to opt-in configurable attributes,
and modify intermediate states before passing them on into the
CreateBazelTargetModule instantiator.
Fixes: 178130668
Test: go tests
Test: build/bazel/scripts/milestone-2/demo.sh
Change-Id: Id6f04d7c560312a93e193d7ca4e1b7ceb6062260
diff --git a/bp2build/configurability.go b/bp2build/configurability.go
new file mode 100644
index 0000000..47cf3c6
--- /dev/null
+++ b/bp2build/configurability.go
@@ -0,0 +1,15 @@
+package bp2build
+
+import "android/soong/android"
+
+// Configurability support for bp2build.
+
+var (
+ // A map of architectures to the Bazel label of the constraint_value.
+ platformArchMap = map[android.ArchType]string{
+ android.Arm: "@bazel_tools//platforms:arm",
+ android.Arm64: "@bazel_tools//platforms:aarch64",
+ android.X86: "@bazel_tools//platforms:x86_32",
+ android.X86_64: "@bazel_tools//platforms:x86_64",
+ }
+)