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
This commit is contained in:
parent
9cad90f966
commit
a43ae1366e
3 changed files with 14 additions and 7 deletions
|
@ -3703,6 +3703,8 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
|
||||||
commonAttrs := android.CommonAttributes{}
|
commonAttrs := android.CommonAttributes{}
|
||||||
if a.testApex {
|
if a.testApex {
|
||||||
commonAttrs.Testonly = proptools.BoolPtr(true)
|
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
|
return attrs, props, commonAttrs
|
||||||
|
|
|
@ -1475,10 +1475,11 @@ apex_test {
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("apex", "test_com.android.apogee", AttrNameToString{
|
MakeBazelTarget("apex", "test_com.android.apogee", AttrNameToString{
|
||||||
"file_contexts": `"file_contexts_file"`,
|
"file_contexts": `"file_contexts_file"`,
|
||||||
"manifest": `"apex_manifest.json"`,
|
"base_apex_name": `"com.android.apogee"`,
|
||||||
"testonly": `True`,
|
"manifest": `"apex_manifest.json"`,
|
||||||
"tests": `[":cc_test_1"]`,
|
"testonly": `True`,
|
||||||
|
"tests": `[":cc_test_1"]`,
|
||||||
}),
|
}),
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
if apiDomain, exists := testApexNameToApiDomain[apexName]; exists {
|
||||||
return apiDomain
|
return apiDomain
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1237,7 @@ func createInApexConfigSetting(ctx android.TopDownMutatorContext, apexName strin
|
||||||
defer apiDomainConfigSettingLock.Unlock()
|
defer apiDomainConfigSettingLock.Unlock()
|
||||||
|
|
||||||
// Return if a config_setting has already been created
|
// Return if a config_setting has already been created
|
||||||
apiDomain := getApiDomain(apexName)
|
apiDomain := GetApiDomain(apexName)
|
||||||
acsm := getApiDomainConfigSettingMap(ctx.Config())
|
acsm := getApiDomainConfigSettingMap(ctx.Config())
|
||||||
if _, exists := (*acsm)[apiDomain]; exists {
|
if _, exists := (*acsm)[apiDomain]; exists {
|
||||||
return
|
return
|
||||||
|
@ -1270,7 +1274,7 @@ func inApexConfigSetting(apexAvailable string) string {
|
||||||
if apexAvailable == android.AvailableToAnyApex {
|
if apexAvailable == android.AvailableToAnyApex {
|
||||||
return bazel.AndroidAndInApex
|
return bazel.AndroidAndInApex
|
||||||
}
|
}
|
||||||
apiDomain := getApiDomain(apexAvailable)
|
apiDomain := GetApiDomain(apexAvailable)
|
||||||
return "//build/bazel/rules/apex:" + apiDomain
|
return "//build/bazel/rules/apex:" + apiDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue