summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2023-05-08 18:33:16 +0000
committer Spandan Das <spandandas@google.com> 2023-05-08 19:04:32 +0000
commita43ae1366ea312f1865ad672d82ed2480f4109e8 (patch)
tree560e972d79e034b509c6df2261a59dbff912b69d
parent9cad90f966cb3245accfb1cd788cc0ee1c6048f9 (diff)
For test apexes, base_apex_name is the api domain
apex_test do not "override" the source apexes that they test. However, similar to override_apexes, test apexes have the same path (/apex/<apex_name>) on device. Instead of creating another property, reuse the existing base_apex_name property. The use case for this will be for creating selection statements for stub/impl selection. Test: go test ./bp2build Change-Id: I4b7548e0e0fc920e407e1c5e5c00e87efc6e70c9
-rw-r--r--apex/apex.go2
-rw-r--r--bp2build/apex_conversion_test.go9
-rw-r--r--cc/bp2build.go10
3 files changed, 14 insertions, 7 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 69547c3b7..e01406bc6 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3703,6 +3703,8 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
commonAttrs := android.CommonAttributes{}
if a.testApex {
commonAttrs.Testonly = proptools.BoolPtr(true)
+ // Set the api_domain of the test apex
+ attrs.Base_apex_name = proptools.StringPtr(cc.GetApiDomain(a.Name()))
}
return attrs, props, commonAttrs
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go
index 1cc3f22ed..390cabe1f 100644
--- a/bp2build/apex_conversion_test.go
+++ b/bp2build/apex_conversion_test.go
@@ -1475,10 +1475,11 @@ apex_test {
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("apex", "test_com.android.apogee", AttrNameToString{
- "file_contexts": `"file_contexts_file"`,
- "manifest": `"apex_manifest.json"`,
- "testonly": `True`,
- "tests": `[":cc_test_1"]`,
+ "file_contexts": `"file_contexts_file"`,
+ "base_apex_name": `"com.android.apogee"`,
+ "manifest": `"apex_manifest.json"`,
+ "testonly": `True`,
+ "tests": `[":cc_test_1"]`,
}),
}})
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 6e91bffa2..ca8d60902 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -1210,7 +1210,11 @@ var (
}
)
-func getApiDomain(apexName string) string {
+// GetApiDomain returns the canonical name of the apex. This is synonymous to the apex_name definition.
+// https://cs.android.com/android/_/android/platform/build/soong/+/e3f0281b8897da1fe23b2f4f3a05f1dc87bcc902:apex/prebuilt.go;l=81-83;drc=2dc7244af985a6ad701b22f1271e606cabba527f;bpv=1;bpt=0
+// For test apexes, it uses a naming convention heuristic to determine the api domain.
+// TODO (b/281548611): Move this build/soong/android
+func GetApiDomain(apexName string) string {
if apiDomain, exists := testApexNameToApiDomain[apexName]; exists {
return apiDomain
}
@@ -1233,7 +1237,7 @@ func createInApexConfigSetting(ctx android.TopDownMutatorContext, apexName strin
defer apiDomainConfigSettingLock.Unlock()
// Return if a config_setting has already been created
- apiDomain := getApiDomain(apexName)
+ apiDomain := GetApiDomain(apexName)
acsm := getApiDomainConfigSettingMap(ctx.Config())
if _, exists := (*acsm)[apiDomain]; exists {
return
@@ -1270,7 +1274,7 @@ func inApexConfigSetting(apexAvailable string) string {
if apexAvailable == android.AvailableToAnyApex {
return bazel.AndroidAndInApex
}
- apiDomain := getApiDomain(apexAvailable)
+ apiDomain := GetApiDomain(apexAvailable)
return "//build/bazel/rules/apex:" + apiDomain
}