convert android_app certificate property, bp2build
The android_app certificate property can be converted to the
@android_rules debug_signing_keys attribute in Bazel after converting
the .pk8/.pem key pairs to a JKS keystore in Starlark.
Test: b build -s //frameworks/base/tests/appwidgets/AppWidgetHostTest
and verify includes SignApk action with generated keystore
Bug: 194133023
Change-Id: I2c4276f94a7856fc68a7674e89742f887dca31b4
diff --git a/java/app.go b/java/app.go
index e4432ff..96fd61a 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1443,7 +1443,7 @@
props := bazel.BazelTargetModuleProperties{
Rule_class: "android_app_certificate",
- Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl",
+ Bzl_load_location: "//build/bazel/rules/android:android_app_certificate.bzl",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
@@ -1451,9 +1451,11 @@
type bazelAndroidAppAttributes struct {
*javaLibraryAttributes
- Manifest bazel.Label
- Custom_package *string
- Resource_files bazel.LabelListAttribute
+ Manifest bazel.Label
+ Custom_package *string
+ Resource_files bazel.LabelListAttribute
+ Certificate *bazel.Label
+ Certificate_name *string
}
// ConvertWithBp2build is used to convert android_app to Bazel.
@@ -1470,15 +1472,30 @@
resourceFiles.Includes = append(resourceFiles.Includes, files...)
}
+ 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
+ }
+
attrs := &bazelAndroidAppAttributes{
libAttrs,
android.BazelLabelForModuleSrcSingle(ctx, manifest),
// TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
a.overridableAppProperties.Package_name,
bazel.MakeLabelListAttribute(resourceFiles),
+ certificate,
+ certificateNamePtr,
}
- props := bazel.BazelTargetModuleProperties{Rule_class: "android_binary",
- Bzl_load_location: "@rules_android//rules:rules.bzl"}
+
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "android_binary",
+ Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
+ }
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: a.Name()}, attrs)