diff options
Diffstat (limited to 'apex')
| -rw-r--r-- | apex/androidmk.go | 2 | ||||
| -rw-r--r-- | apex/apex.go | 52 | ||||
| -rw-r--r-- | apex/apex_test.go | 44 | ||||
| -rw-r--r-- | apex/builder.go | 4 | ||||
| -rw-r--r-- | apex/prebuilt.go | 4 |
5 files changed, 76 insertions, 30 deletions
diff --git a/apex/androidmk.go b/apex/androidmk.go index 2f1090421..94b81163d 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -382,7 +382,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) stemSuffix := apexType.suffix() if a.isCompressed { - stemSuffix = ".capex" + stemSuffix = imageCapexSuffix } fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+stemSuffix) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) diff --git a/apex/apex.go b/apex/apex.go index 6bafcae52..e3edc681d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -111,9 +111,6 @@ type apexBundleProperties struct { // List of java libraries that are embedded inside this APEX bundle. Java_libs []string - // List of prebuilt files that are embedded inside this APEX bundle. - Prebuilts []string - // List of platform_compat_config files that are embedded inside this APEX bundle. Compat_configs []string @@ -291,6 +288,9 @@ type overridableProperties struct { // List of APKs that are embedded inside this APEX. Apps []string + // List of prebuilt files that are embedded inside this APEX bundle. + Prebuilts []string + // List of runtime resource overlays (RROs) that are embedded inside this APEX. Rros []string @@ -684,7 +684,6 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { // each target os/architectures, appropriate dependencies are selected by their // target.<os>.multilib.<type> groups and are added as (direct) dependencies. targets := ctx.MultiTargets() - config := ctx.DeviceConfig() imageVariation := a.getImageVariation(ctx) a.combineProperties(ctx) @@ -758,23 +757,6 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if prebuilts := a.properties.Prebuilts; len(prebuilts) > 0 { - // For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device) - // regardless of the TARGET_PREFER_* setting. See b/144532908 - archForPrebuiltEtc := config.Arches()[0] - for _, arch := range config.Arches() { - // Prefer 64-bit arch if there is any - if arch.ArchType.Multilib == "lib64" { - archForPrebuiltEtc = arch - break - } - } - ctx.AddFarVariationDependencies([]blueprint.Variation{ - {Mutator: "os", Variation: ctx.Os().String()}, - {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, - }, prebuiltTag, prebuilts...) - } - // Common-arch dependencies come next commonVariation := ctx.Config().AndroidCommonTarget.Variations() ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...) @@ -814,6 +796,25 @@ func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...) ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...) ctx.AddFarVariationDependencies(commonVariation, rroTag, a.overridableProperties.Rros...) + if prebuilts := a.overridableProperties.Prebuilts; len(prebuilts) > 0 { + // For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device) + // regardless of the TARGET_PREFER_* setting. See b/144532908 + arches := ctx.DeviceConfig().Arches() + if len(arches) != 0 { + archForPrebuiltEtc := arches[0] + for _, arch := range arches { + // Prefer 64-bit arch if there is any + if arch.ArchType.Multilib == "lib64" { + archForPrebuiltEtc = arch + break + } + } + ctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "os", Variation: ctx.Os().String()}, + {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, + }, prebuiltTag, prebuilts...) + } + } // Dependencies for signing if String(a.overridableProperties.Key) == "" { @@ -1151,9 +1152,10 @@ const ( const ( // File extensions of an APEX for different packaging methods - imageApexSuffix = ".apex" - zipApexSuffix = ".zipapex" - flattenedSuffix = ".flattened" + imageApexSuffix = ".apex" + imageCapexSuffix = ".capex" + zipApexSuffix = ".zipapex" + flattenedSuffix = ".flattened" // variant names each of which is for a packaging method imageApexType = "image" @@ -3282,7 +3284,7 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs) nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList) - prebuilts := module.properties.Prebuilts + prebuilts := module.overridableProperties.Prebuilts prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts) prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList) diff --git a/apex/apex_test.go b/apex/apex_test.go index daaa5cb46..6027f9b46 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4640,6 +4640,35 @@ func TestPrebuiltFilenameOverride(t *testing.T) { } } +func TestApexSetFilenameOverride(t *testing.T) { + testApex(t, ` + apex_set { + name: "com.company.android.myapex", + apex_name: "com.android.myapex", + set: "company-myapex.apks", + filename: "com.company.android.myapex.apex" + } + `).ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex") + + testApex(t, ` + apex_set { + name: "com.company.android.myapex", + apex_name: "com.android.myapex", + set: "company-myapex.apks", + filename: "com.company.android.myapex.capex" + } + `).ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex") + + testApexError(t, `filename should end in .apex or .capex for apex_set`, ` + apex_set { + name: "com.company.android.myapex", + apex_name: "com.android.myapex", + set: "company-myapex.apks", + filename: "some-random-suffix" + } + `) +} + func TestPrebuiltOverrides(t *testing.T) { ctx := testApex(t, ` prebuilt_apex { @@ -6080,6 +6109,7 @@ func TestOverrideApex(t *testing.T) { key: "myapex.key", apps: ["app"], bpfs: ["bpf"], + prebuilts: ["myetc"], overrides: ["oldapex"], updatable: false, } @@ -6089,6 +6119,7 @@ func TestOverrideApex(t *testing.T) { base: "myapex", apps: ["override_app"], bpfs: ["override_bpf"], + prebuilts: ["override_myetc"], overrides: ["unknownapex"], logging_parent: "com.foo.bar", package_name: "test.overridden.package", @@ -6137,6 +6168,16 @@ func TestOverrideApex(t *testing.T) { name: "override_bpf", srcs: ["override_bpf.c"], } + + prebuilt_etc { + name: "myetc", + src: "myprebuilt", + } + + prebuilt_etc { + name: "override_myetc", + src: "override_myprebuilt", + } `, withManifestPackageNameOverrides([]string{"myapex:com.android.myapex"})) originalVariant := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(android.OverridableModule) @@ -6158,6 +6199,9 @@ func TestOverrideApex(t *testing.T) { ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o") ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o") + ensureNotContains(t, copyCmds, "image.apex/etc/myetc") + ensureContains(t, copyCmds, "image.apex/etc/override_myetc") + apexBundle := module.Module().(*apexBundle) name := apexBundle.Name() if name != "override_myapex" { diff --git a/apex/builder.go b/apex/builder.go index 5baa5c0cc..3177ee075 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -786,7 +786,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { if apexType == imageApex && (compressionEnabled || a.testOnlyShouldForceCompression()) { a.isCompressed = true - unsignedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+".capex.unsigned") + unsignedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+imageCapexSuffix+".unsigned") compressRule := android.NewRuleBuilder(pctx, ctx) compressRule.Command(). @@ -800,7 +800,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { FlagWithOutput("--output ", unsignedCompressedOutputFile) compressRule.Build("compressRule", "Generate unsigned compressed APEX file") - signedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+".capex") + signedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+imageCapexSuffix) if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_SIGNAPK") { args["outCommaList"] = signedCompressedOutputFile.String() } diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 1bb0fb582..c4794dc89 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -924,8 +924,8 @@ func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) { func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.installFilename = a.InstallFilename() - if !strings.HasSuffix(a.installFilename, imageApexSuffix) { - ctx.ModuleErrorf("filename should end in %s for apex_set", imageApexSuffix) + if !strings.HasSuffix(a.installFilename, imageApexSuffix) && !strings.HasSuffix(a.installFilename, imageCapexSuffix) { + ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix) } inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path() |