Add bp2build converter for cc library stubs and use the stub library target of a library while linking it in APEXs.
Bug: 231322789
Test: with this CL on internal master,
1) b build --verbose_failures //vendor/google/modules/AdbdGoogle:com.google.android.adbd --config=android_x86_64
2) adb install bazel-bin/vendor/google/modules/AdbdGoogle/com.google.android.adbd.apex, and adbd is activated successfully on cuttlefish device.
3) m mts && mts-tradefed run mts-adbd, and there is no failure with cuttlefish device
4) packages/modules/adb/test_device.py, and there is no failure with cuttlefish device.
Change-Id: I81b6f5336cacf35c68957ae2dac65f985b6eafb9
diff --git a/bazel/configurability.go b/bazel/configurability.go
index 0ab49eb..d9b0a12 100644
--- a/bazel/configurability.go
+++ b/bazel/configurability.go
@@ -27,7 +27,7 @@
archX86_64 = "x86_64"
// OsType names in arch.go
- osAndroid = "android"
+ OsAndroid = "android"
osDarwin = "darwin"
osLinux = "linux_glibc"
osLinuxMusl = "linux_musl"
@@ -64,6 +64,9 @@
ConditionsDefaultSelectKey = "//conditions:default"
productVariableBazelPackage = "//build/bazel/product_variables"
+
+ AndroidAndInApex = "android-in_apex"
+ AndroidAndNonApex = "android-non_apex"
)
var (
@@ -85,7 +88,7 @@
// A map of target operating systems to the Bazel label of the
// constraint_value for the @platforms//os:os constraint_setting
platformOsMap = map[string]string{
- osAndroid: "//build/bazel/platforms/os:android",
+ OsAndroid: "//build/bazel/platforms/os:android",
osDarwin: "//build/bazel/platforms/os:darwin",
osLinux: "//build/bazel/platforms/os:linux",
osLinuxMusl: "//build/bazel/platforms/os:linux_musl",
@@ -120,7 +123,7 @@
// TODO(cparsons): Source from arch.go; this task is nontrivial, as it currently results
// in a cyclic dependency.
osToArchMap = map[string][]string{
- osAndroid: {archArm, archArm64, archX86, archX86_64},
+ OsAndroid: {archArm, archArm64, archX86, archX86_64},
osLinux: {archX86, archX86_64},
osLinuxMusl: {archX86, archX86_64},
osDarwin: {archArm64, archX86_64},
@@ -128,6 +131,12 @@
// TODO(cparsons): According to arch.go, this should contain archArm, archArm64, as well.
osWindows: {archX86, archX86_64},
}
+
+ osAndInApexMap = map[string]string{
+ AndroidAndInApex: "//build/bazel/rules/apex:android-in_apex",
+ AndroidAndNonApex: "//build/bazel/rules/apex:android-non_apex",
+ ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
+ }
)
// basic configuration types
@@ -139,6 +148,7 @@
os
osArch
productVariables
+ osAndInApex
)
func osArchString(os string, arch string) string {
@@ -152,6 +162,7 @@
os: "os",
osArch: "arch_os",
productVariables: "product_variables",
+ osAndInApex: "os_in_apex",
}[ct]
}
@@ -175,6 +186,10 @@
}
case productVariables:
// do nothing
+ case osAndInApex:
+ if _, ok := osAndInApexMap[config]; !ok {
+ panic(fmt.Errorf("Unknown os+in_apex config: %s", config))
+ }
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ct))
}
@@ -198,6 +213,8 @@
return ConditionsDefaultSelectKey
}
return fmt.Sprintf("%s:%s", productVariableBazelPackage, config)
+ case osAndInApex:
+ return osAndInApexMap[config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ca.configurationType))
}
@@ -212,6 +229,8 @@
OsConfigurationAxis = ConfigurationAxis{configurationType: os}
// An axis for arch+os-specific configurations
OsArchConfigurationAxis = ConfigurationAxis{configurationType: osArch}
+ // An axis for os+in_apex-specific configurations
+ OsAndInApexAxis = ConfigurationAxis{configurationType: osAndInApex}
)
// ProductVariableConfigurationAxis returns an axis for the given product variable