Merge "bp2build: Fix apex.binaries to be a LabelListAttribute." am: 8d0bd355fd am: d6b0aab0cd am: ed10ce524f

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1913474

Change-Id: Id5a70bc05cbf3a70a98395d3029707076715a021
This commit is contained in:
Jingwen Chen
2021-12-13 11:02:24 +00:00
committed by Automerger Merge Worker
2 changed files with 35 additions and 29 deletions

View File

@@ -3270,7 +3270,7 @@ type bazelApexBundleAttributes struct {
Updatable bazel.BoolAttribute Updatable bazel.BoolAttribute
Installable bazel.BoolAttribute Installable bazel.BoolAttribute
Native_shared_libs bazel.LabelListAttribute Native_shared_libs bazel.LabelListAttribute
Binaries bazel.StringListAttribute Binaries bazel.LabelListAttribute
Prebuilts bazel.LabelListAttribute Prebuilts bazel.LabelListAttribute
} }
@@ -3329,8 +3329,8 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts) prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList) prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
binaries := module.properties.ApexNativeDependencies.Binaries binaries := android.BazelLabelForModuleDeps(ctx, module.properties.ApexNativeDependencies.Binaries)
binariesStringListAttribute := bazel.MakeStringListAttribute(binaries) binariesLabelListAttribute := bazel.MakeLabelListAttribute(binaries)
var updatableAttribute bazel.BoolAttribute var updatableAttribute bazel.BoolAttribute
if module.properties.Updatable != nil { if module.properties.Updatable != nil {
@@ -3352,7 +3352,7 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB
Updatable: updatableAttribute, Updatable: updatableAttribute,
Installable: installableAttribute, Installable: installableAttribute,
Native_shared_libs: nativeSharedLibsLabelListAttribute, Native_shared_libs: nativeSharedLibsLabelListAttribute,
Binaries: binariesStringListAttribute, Binaries: binariesLabelListAttribute,
Prebuilts: prebuiltsLabelListAttribute, Prebuilts: prebuiltsLabelListAttribute,
} }

View File

@@ -19,6 +19,7 @@ import (
"android/soong/apex" "android/soong/apex"
"android/soong/cc" "android/soong/cc"
"android/soong/java" "android/soong/java"
"android/soong/sh"
"testing" "testing"
) )
@@ -32,6 +33,8 @@ func registerApexModuleTypes(ctx android.RegistrationContext) {
// CC module types needed as they can be APEX dependencies // CC module types needed as they can be APEX dependencies
cc.RegisterCCBuildComponents(ctx) cc.RegisterCCBuildComponents(ctx)
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
ctx.RegisterModuleType("cc_binary", cc.BinaryFactory)
ctx.RegisterModuleType("cc_library", cc.LibraryFactory) ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory) ctx.RegisterModuleType("apex_key", apex.ApexKeyFactory)
ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory) ctx.RegisterModuleType("android_app_certificate", java.AndroidAppCertificateFactory)
@@ -40,60 +43,63 @@ func registerApexModuleTypes(ctx android.RegistrationContext) {
func TestApexBundleSimple(t *testing.T) { func TestApexBundleSimple(t *testing.T) {
runApexTestCase(t, bp2buildTestCase{ runApexTestCase(t, bp2buildTestCase{
description: "apex - simple example", description: "apex - example with all props",
moduleTypeUnderTest: "apex", moduleTypeUnderTest: "apex",
moduleTypeUnderTestFactory: apex.BundleFactory, moduleTypeUnderTestFactory: apex.BundleFactory,
moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build, moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build,
filesystem: map[string]string{}, filesystem: map[string]string{},
blueprint: ` blueprint: `
apex_key { apex_key {
name: "com.android.apogee.key", name: "com.android.apogee.key",
public_key: "com.android.apogee.avbpubkey", public_key: "com.android.apogee.avbpubkey",
private_key: "com.android.apogee.pem", private_key: "com.android.apogee.pem",
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
android_app_certificate { android_app_certificate {
name: "com.android.apogee.certificate", name: "com.android.apogee.certificate",
certificate: "com.android.apogee", certificate: "com.android.apogee",
bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_1",
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
cc_library { cc_library {
name: "native_shared_lib_2", name: "native_shared_lib_1",
bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_2",
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
// TODO(b/194878861): Add bp2build support for prebuilt_etc // TODO(b/194878861): Add bp2build support for prebuilt_etc
cc_library { cc_library {
name: "pretend_prebuilt_1", name: "pretend_prebuilt_1",
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
// TODO(b/194878861): Add bp2build support for prebuilt_etc // TODO(b/194878861): Add bp2build support for prebuilt_etc
cc_library { cc_library {
name: "pretend_prebuilt_2", name: "pretend_prebuilt_2",
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
filegroup { filegroup {
name: "com.android.apogee-file_contexts", name: "com.android.apogee-file_contexts",
srcs: [ srcs: [
"com.android.apogee-file_contexts", "com.android.apogee-file_contexts",
], ],
bazel_module: { bp2build_available: false }, bazel_module: { bp2build_available: false },
} }
cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
apex { apex {
name: "com.android.apogee", name: "com.android.apogee",
manifest: "apogee_manifest.json", manifest: "apogee_manifest.json",
androidManifest: "ApogeeAndroidManifest.xml", androidManifest: "ApogeeAndroidManifest.xml",
file_contexts: "com.android.apogee-file_contexts", file_contexts: "com.android.apogee-file_contexts",
min_sdk_version: "29", min_sdk_version: "29",
key: "com.android.apogee.key", key: "com.android.apogee.key",
certificate: "com.android.apogee.certificate", certificate: "com.android.apogee.certificate",
@@ -104,8 +110,8 @@ apex {
"native_shared_lib_2", "native_shared_lib_2",
], ],
binaries: [ binaries: [
"binary_1", "cc_binary_1",
"binary_2", "sh_binary_2",
], ],
prebuilts: [ prebuilts: [
"pretend_prebuilt_1", "pretend_prebuilt_1",
@@ -117,8 +123,8 @@ apex {
makeBazelTarget("apex", "com.android.apogee", attrNameToString{ makeBazelTarget("apex", "com.android.apogee", attrNameToString{
"android_manifest": `"ApogeeAndroidManifest.xml"`, "android_manifest": `"ApogeeAndroidManifest.xml"`,
"binaries": `[ "binaries": `[
"binary_1", ":cc_binary_1",
"binary_2", ":sh_binary_2",
]`, ]`,
"certificate": `":com.android.apogee.certificate"`, "certificate": `":com.android.apogee.certificate"`,
"file_contexts": `":com.android.apogee-file_contexts"`, "file_contexts": `":com.android.apogee-file_contexts"`,