Share certificate bp2build between android_app and apex.
The certificate module is handled the same in Soong between android apps
and apexes, so share the bp2build code as well.
There are a few changes in this CL:
- If override_apex.certificate is unset, the generated apex also unsets
it. This prevents the generated apex from using the base apex's
certificate, which is most likely incorrect (e.g. google variant using
the cert for the aosp variant). Instead, rely on the default
certificate handling in the macro.
- If the certificate prop is a string, then it gets generated into
certificate_name in order to disambiguate. This behavior is identical
to android_app.
Test: added various unit tests.
Bug: 249089160
Fixes: 249089160
Change-Id: I99e18964ff546429a985d0f64dc21e2c69d35d9d
diff --git a/apex/apex.go b/apex/apex.go
index 2e54e7e..498c8c0 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2659,9 +2659,13 @@
}
// Certificate
- if overridableProperties.Certificate != nil {
- attrs.Certificate = bazel.LabelAttribute{}
- attrs.Certificate.SetValue(android.BazelLabelForModuleDepSingle(ctx, *overridableProperties.Certificate))
+ if overridableProperties.Certificate == nil {
+ // delegated to the rule attr default
+ attrs.Certificate = nil
+ } else {
+ certificateName, certificate := java.ParseCertificateToAttribute(ctx, overridableProperties.Certificate)
+ attrs.Certificate_name = certificateName
+ attrs.Certificate = certificate
}
// Prebuilts
@@ -3335,7 +3339,8 @@
Android_manifest bazel.LabelAttribute
File_contexts bazel.LabelAttribute
Key bazel.LabelAttribute
- Certificate bazel.LabelAttribute
+ Certificate *bazel.Label // used when the certificate prop is a module
+ Certificate_name *string // used when the certificate prop is a string
Min_sdk_version *string
Updatable bazel.BoolAttribute
Installable bazel.BoolAttribute
@@ -3397,10 +3402,7 @@
keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Key))
}
- var certificateLabelAttribute bazel.LabelAttribute
- if a.overridableProperties.Certificate != nil {
- certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Certificate))
- }
+ certificateName, certificate := java.ParseCertificateToAttribute(ctx, a.overridableProperties.Certificate)
nativeSharedLibs := &convertedNativeSharedLibs{
Native_shared_libs_32: bazel.LabelListAttribute{},
@@ -3456,7 +3458,8 @@
File_contexts: fileContextsLabelAttribute,
Min_sdk_version: minSdkVersion,
Key: keyLabelAttribute,
- Certificate: certificateLabelAttribute,
+ Certificate: certificate,
+ Certificate_name: certificateName,
Updatable: updatableAttribute,
Installable: installableAttribute,
Native_shared_libs_32: nativeSharedLibs.Native_shared_libs_32,