summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Jingwen Chen <jingwen@google.com> 2022-09-29 16:56:02 +0000
committer Jingwen Chen <jingwen@google.com> 2022-10-03 09:20:47 +0000
commitbea58093b4f2cea35665b24003ec094f133aedab (patch)
treec14e94c4afb810c59030de6e0a54c5896933759b /java
parent44022c867db08b0c120e827b69cc5019789b54a8 (diff)
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
Diffstat (limited to 'java')
-rwxr-xr-xjava/app.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/java/app.go b/java/app.go
index 1955e2a73..a42816593 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1489,6 +1489,20 @@ type bazelAndroidAppAttributes struct {
Certificate_name *string
}
+// ParseCertificateToAttribute splits the certificate prop into a certificate
+// label attribute or a certificate_name string attribute.
+func ParseCertificateToAttribute(ctx android.TopDownMutatorContext, certificate *string) (*string, *bazel.Label) {
+ var certificateLabel *bazel.Label
+ certificateName := proptools.StringDefault(certificate, "")
+ certModule := android.SrcIsModule(certificateName)
+ if certModule != "" {
+ c := android.BazelLabelForModuleDepSingle(ctx, certificateName)
+ certificateLabel = &c
+ certificate = nil
+ }
+ return certificate, certificateLabel
+}
+
// ConvertWithBp2build is used to convert android_app to Bazel.
func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
commonAttrs, depLabels := a.convertLibraryAttrsBp2Build(ctx)
@@ -1498,15 +1512,7 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
aapt := a.convertAaptAttrsWithBp2Build(ctx)
- var certificate *bazel.Label
- certificateNamePtr := a.overridableAppProperties.Certificate
- certificateName := proptools.StringDefault(certificateNamePtr, "")
- certModule := android.SrcIsModule(certificateName)
- if certModule != "" {
- c := android.BazelLabelForModuleDepSingle(ctx, certificateName)
- certificate = &c
- certificateNamePtr = nil
- }
+ certificateName, certificate := ParseCertificateToAttribute(ctx, a.overridableAppProperties.Certificate)
attrs := &bazelAndroidAppAttributes{
commonAttrs,
aapt,
@@ -1514,7 +1520,7 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
// TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
a.overridableAppProperties.Package_name,
certificate,
- certificateNamePtr,
+ certificateName,
}
props := bazel.BazelTargetModuleProperties{