Allows prebuilts in override_apex.
Bug: 197787336
Test: Create an override_apex that uses a different `prebuilts` than its
base. Observe built contents.
Test: apex_test.go
Change-Id: I7666ed6cfe3f2fa5dd81e5f8c1961477dabbbd3c
diff --git a/apex/apex.go b/apex/apex.go
index 6bafcae..fbf6a6f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -111,9 +111,6 @@
// 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 @@
// 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 @@
// 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 @@
}
}
- 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 @@
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) == "" {
@@ -3282,7 +3283,7 @@
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 e0bf5e5..dc66ae6 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -6074,6 +6074,7 @@
key: "myapex.key",
apps: ["app"],
bpfs: ["bpf"],
+ prebuilts: ["myetc"],
overrides: ["oldapex"],
updatable: false,
}
@@ -6083,6 +6084,7 @@
base: "myapex",
apps: ["override_app"],
bpfs: ["override_bpf"],
+ prebuilts: ["override_myetc"],
overrides: ["unknownapex"],
logging_parent: "com.foo.bar",
package_name: "test.overridden.package",
@@ -6131,6 +6133,16 @@
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)
@@ -6152,6 +6164,9 @@
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" {