Merge changes from topic "app_set" am: 25f15a18e5 am: cf0dd40fb3 am: 80547efe96 am: 6bf007ed59

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

Change-Id: Idd87ffac9012edc088dbc48cbea33241a591d128
This commit is contained in:
Colin Cross
2021-11-19 03:31:26 +00:00
committed by Automerger Merge Worker
11 changed files with 184 additions and 68 deletions

View File

@@ -696,12 +696,12 @@ func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{
android.AndroidMkEntries{
Class: "APPS",
OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile())
entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
},

View File

@@ -55,10 +55,10 @@ type AndroidAppSet struct {
android.DefaultableModuleBase
prebuilt android.Prebuilt
properties AndroidAppSetProperties
packedOutput android.WritablePath
installFile string
apkcertsFile android.ModuleOutPath
properties AndroidAppSetProperties
packedOutput android.WritablePath
primaryOutput android.WritablePath
apkcertsFile android.ModuleOutPath
}
func (as *AndroidAppSet) Name() string {
@@ -78,11 +78,11 @@ func (as *AndroidAppSet) Privileged() bool {
}
func (as *AndroidAppSet) OutputFile() android.Path {
return as.packedOutput
return as.primaryOutput
}
func (as *AndroidAppSet) InstallFile() string {
return as.installFile
func (as *AndroidAppSet) PackedAdditionalOutputs() android.Path {
return as.packedOutput
}
func (as *AndroidAppSet) APKCertsFile() android.Path {
@@ -114,11 +114,11 @@ func SupportedAbis(ctx android.ModuleContext) []string {
func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
as.packedOutput = android.PathForModuleOut(ctx, ctx.ModuleName()+".zip")
as.primaryOutput = android.PathForModuleOut(ctx, as.BaseModuleName()+".apk")
as.apkcertsFile = android.PathForModuleOut(ctx, "apkcerts.txt")
// We are assuming here that the install file in the APK
// set has `.apk` suffix. If it doesn't the build will fail.
// APK sets containing APEX files are handled elsewhere.
as.installFile = as.BaseModuleName() + ".apk"
screenDensities := "all"
if dpis := ctx.Config().ProductAAPTPrebuiltDPI(); len(dpis) > 0 {
screenDensities = strings.ToUpper(strings.Join(dpis, ","))
@@ -127,11 +127,11 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
// TODO(asmundak): do we support device features
ctx.Build(pctx,
android.BuildParams{
Rule: extractMatchingApks,
Description: "Extract APKs from APK set",
Output: as.packedOutput,
ImplicitOutput: as.apkcertsFile,
Inputs: android.Paths{as.prebuilt.SingleSourcePath(ctx)},
Rule: extractMatchingApks,
Description: "Extract APKs from APK set",
Output: as.primaryOutput,
ImplicitOutputs: android.WritablePaths{as.packedOutput, as.apkcertsFile},
Inputs: android.Paths{as.prebuilt.SingleSourcePath(ctx)},
Args: map[string]string{
"abis": strings.Join(SupportedAbis(ctx), ","),
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
@@ -140,10 +140,21 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
"stem": as.BaseModuleName(),
"apkcerts": as.apkcertsFile.String(),
"partition": as.PartitionTag(ctx.DeviceConfig()),
"zip": as.packedOutput.String(),
},
})
var installDir android.InstallPath
if as.Privileged() {
installDir = android.PathForModuleInstall(ctx, "priv-app", as.BaseModuleName())
} else {
installDir = android.PathForModuleInstall(ctx, "app", as.BaseModuleName())
}
ctx.InstallFileWithExtraFilesZip(installDir, as.BaseModuleName()+".apk", as.primaryOutput, as.packedOutput)
}
func (as *AndroidAppSet) InstallBypassMake() bool { return true }
// android_app_set extracts a set of APKs based on the target device
// configuration and installs this set as "split APKs".
// The extracted set always contains an APK whose name is

View File

@@ -17,19 +17,20 @@ package java
import (
"fmt"
"reflect"
"strings"
"testing"
"android/soong/android"
)
func TestAndroidAppSet(t *testing.T) {
ctx, _ := testJava(t, `
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app_set {
name: "foo",
set: "prebuilts/apks/app.apks",
prerelease: true,
}`)
module := ctx.ModuleForTests("foo", "android_common")
module := result.ModuleForTests("foo", "android_common")
const packedSplitApks = "foo.zip"
params := module.Output(packedSplitApks)
if params.Rule == nil {
@@ -41,9 +42,22 @@ func TestAndroidAppSet(t *testing.T) {
if s := params.Args["partition"]; s != "system" {
t.Errorf("wrong partition value: '%s', expected 'system'", s)
}
mkEntries := android.AndroidMkEntriesForTest(t, ctx, module.Module())[0]
android.AssertPathRelativeToTopEquals(t, "incorrect output path",
"out/soong/.intermediates/foo/android_common/foo.apk", params.Output)
android.AssertPathsRelativeToTopEquals(t, "incorrect implicit output paths",
[]string{
"out/soong/.intermediates/foo/android_common/foo.zip",
"out/soong/.intermediates/foo/android_common/apkcerts.txt",
},
params.ImplicitOutputs.Paths())
mkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, module.Module())[0]
actualInstallFile := mkEntries.EntryMap["LOCAL_APK_SET_INSTALL_FILE"]
expectedInstallFile := []string{"foo.apk"}
expectedInstallFile := []string{
strings.Replace(params.ImplicitOutputs[0].String(), android.OutSoongDir, result.Config.SoongOutDir(), 1),
}
if !reflect.DeepEqual(actualInstallFile, expectedInstallFile) {
t.Errorf("Unexpected LOCAL_APK_SET_INSTALL_FILE value: '%s', expected: '%s',",
actualInstallFile, expectedInstallFile)

View File

@@ -120,14 +120,14 @@ var (
"extractMatchingApks",
blueprint.RuleParams{
Command: `rm -rf "$out" && ` +
`${config.ExtractApksCmd} -o "${out}" -allow-prereleased=${allow-prereleased} ` +
`${config.ExtractApksCmd} -o "${out}" -zip "${zip}" -allow-prereleased=${allow-prereleased} ` +
`-sdk-version=${sdk-version} -abis=${abis} ` +
`--screen-densities=${screen-densities} --stem=${stem} ` +
`-apkcerts=${apkcerts} -partition=${partition} ` +
`${in}`,
CommandDeps: []string{"${config.ExtractApksCmd}"},
},
"abis", "allow-prereleased", "screen-densities", "sdk-version", "stem", "apkcerts", "partition")
"abis", "allow-prereleased", "screen-densities", "sdk-version", "stem", "apkcerts", "partition", "zip")
turbine, turbineRE = pctx.RemoteStaticRules("turbine",
blueprint.RuleParams{