Merge "Add initial bp2build support for converting android_app_certificate modules."
This commit is contained in:
@@ -28,6 +28,7 @@ bootstrap_go_package {
|
|||||||
"soong-sh",
|
"soong-sh",
|
||||||
],
|
],
|
||||||
testSrcs: [
|
testSrcs: [
|
||||||
|
"android_app_certificate_conversion_test.go",
|
||||||
"apex_conversion_test.go",
|
"apex_conversion_test.go",
|
||||||
"apex_key_conversion_test.go",
|
"apex_key_conversion_test.go",
|
||||||
"build_conversion_test.go",
|
"build_conversion_test.go",
|
||||||
|
49
bp2build/android_app_certificate_conversion_test.go
Normal file
49
bp2build/android_app_certificate_conversion_test.go
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// Copyright 2021 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package bp2build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/java"
|
||||||
|
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runAndroidAppCertificateTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||||
|
t.Helper()
|
||||||
|
runBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func registerAndroidAppCertificateModuleTypes(ctx android.RegistrationContext) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAndroidAppCertificateSimple(t *testing.T) {
|
||||||
|
runAndroidAppCertificateTestCase(t, bp2buildTestCase{
|
||||||
|
description: "Android app certificate - simple example",
|
||||||
|
moduleTypeUnderTest: "android_app_certificate",
|
||||||
|
moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
|
||||||
|
moduleTypeUnderTestBp2BuildMutator: java.AndroidAppCertificateBp2Build,
|
||||||
|
filesystem: map[string]string{},
|
||||||
|
blueprint: `
|
||||||
|
android_app_certificate {
|
||||||
|
name: "com.android.apogee.cert",
|
||||||
|
certificate: "chamber_of_secrets_dir",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`android_app_certificate(
|
||||||
|
name = "com.android.apogee.cert",
|
||||||
|
certificate = "chamber_of_secrets_dir",
|
||||||
|
)`}})
|
||||||
|
}
|
@@ -10,6 +10,7 @@ bootstrap_go_package {
|
|||||||
"blueprint-pathtools",
|
"blueprint-pathtools",
|
||||||
"soong",
|
"soong",
|
||||||
"soong-android",
|
"soong-android",
|
||||||
|
"soong-bazel",
|
||||||
"soong-cc",
|
"soong-cc",
|
||||||
"soong-dexpreopt",
|
"soong-dexpreopt",
|
||||||
"soong-genrule",
|
"soong-genrule",
|
||||||
|
61
java/app.go
61
java/app.go
@@ -26,6 +26,7 @@ import (
|
|||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/bazel"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
"android/soong/dexpreopt"
|
"android/soong/dexpreopt"
|
||||||
"android/soong/tradefed"
|
"android/soong/tradefed"
|
||||||
@@ -42,6 +43,8 @@ func RegisterAppBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
|
ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
|
||||||
ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
|
ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
|
||||||
ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
|
ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
|
||||||
|
|
||||||
|
android.RegisterBp2BuildMutator("android_app_certificate", AndroidAppCertificateBp2Build)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AndroidManifest.xml merging
|
// AndroidManifest.xml merging
|
||||||
@@ -1371,3 +1374,61 @@ func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk andr
|
|||||||
outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base())
|
outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base())
|
||||||
return outputFile
|
return outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Bazel / bp2build
|
||||||
|
|
||||||
|
type bazelAndroidAppCertificateAttributes struct {
|
||||||
|
Certificate string
|
||||||
|
}
|
||||||
|
|
||||||
|
type bazelAndroidAppCertificate struct {
|
||||||
|
android.BazelTargetModuleBase
|
||||||
|
bazelAndroidAppCertificateAttributes
|
||||||
|
}
|
||||||
|
|
||||||
|
func BazelAndroidAppCertificateFactory() android.Module {
|
||||||
|
module := &bazelAndroidAppCertificate{}
|
||||||
|
module.AddProperties(&module.bazelAndroidAppCertificateAttributes)
|
||||||
|
android.InitBazelTargetModule(module)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
|
func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) {
|
||||||
|
module, ok := ctx.Module().(*AndroidAppCertificate)
|
||||||
|
if !ok {
|
||||||
|
// Not an Android app certificate
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !module.ConvertWithBp2build(ctx) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ctx.ModuleType() != "android_app_certificate" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
androidAppCertificateBp2BuildInternal(ctx, module)
|
||||||
|
}
|
||||||
|
|
||||||
|
func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) {
|
||||||
|
var certificate string
|
||||||
|
if module.properties.Certificate != nil {
|
||||||
|
certificate = *module.properties.Certificate
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs := &bazelAndroidAppCertificateAttributes{
|
||||||
|
Certificate: certificate,
|
||||||
|
}
|
||||||
|
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "android_app_certificate",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(BazelAndroidAppCertificateFactory, module.Name(), props, attrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *bazelAndroidAppCertificate) Name() string {
|
||||||
|
return m.BaseModuleName()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *bazelAndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
|
||||||
|
Reference in New Issue
Block a user