Merge changes from topic "app_set" am: 25f15a18e5
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1893517 Change-Id: I292481d4d1729e657c39283f0f0804ec77fce70a
This commit is contained in:
@@ -52,10 +52,10 @@ var (
|
||||
// A copy rule.
|
||||
Cp = pctx.AndroidStaticRule("Cp",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out",
|
||||
Command: "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out$extraCmds",
|
||||
Description: "cp $out",
|
||||
},
|
||||
"cpFlags")
|
||||
"cpFlags", "extraCmds")
|
||||
|
||||
// A copy rule that only updates the output if it changed.
|
||||
CpIfChanged = pctx.AndroidStaticRule("CpIfChanged",
|
||||
@@ -68,10 +68,10 @@ var (
|
||||
|
||||
CpExecutable = pctx.AndroidStaticRule("CpExecutable",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out && chmod +x $out",
|
||||
Command: "rm -f $out && cp $cpPreserveSymlinks $cpFlags $in $out && chmod +x $out$extraCmds",
|
||||
Description: "cp $out",
|
||||
},
|
||||
"cpFlags")
|
||||
"cpFlags", "extraCmds")
|
||||
|
||||
// A timestamp touch rule.
|
||||
Touch = pctx.AndroidStaticRule("Touch",
|
||||
|
@@ -456,6 +456,9 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []by
|
||||
for _, dep := range install.implicitDeps {
|
||||
fmt.Fprintf(buf, " %s", dep.String())
|
||||
}
|
||||
if extraFiles := install.extraFiles; extraFiles != nil {
|
||||
fmt.Fprintf(buf, " %s", extraFiles.zip.String())
|
||||
}
|
||||
if len(install.orderOnlyDeps) > 0 {
|
||||
fmt.Fprintf(buf, " |")
|
||||
}
|
||||
@@ -463,12 +466,14 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []by
|
||||
fmt.Fprintf(buf, " %s", dep.String())
|
||||
}
|
||||
fmt.Fprintln(buf)
|
||||
|
||||
fmt.Fprintf(buf, "\trm -f $@ && cp -f %s $< $@", preserveSymlinksFlag)
|
||||
fmt.Fprintln(buf, "\t@echo \"Install $@\"")
|
||||
fmt.Fprintf(buf, "\trm -f $@ && cp -f %s $< $@\n", preserveSymlinksFlag)
|
||||
if install.executable {
|
||||
fmt.Fprintf(buf, " && chmod +x $@")
|
||||
fmt.Fprintf(buf, "\tchmod +x $@\n")
|
||||
}
|
||||
if extraFiles := install.extraFiles; extraFiles != nil {
|
||||
fmt.Fprintf(buf, "\tunzip -qDD -d '%s' '%s'\n", extraFiles.dir.String(), extraFiles.zip.String())
|
||||
}
|
||||
fmt.Fprintln(buf)
|
||||
fmt.Fprintln(buf)
|
||||
}
|
||||
|
||||
@@ -504,6 +509,7 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []by
|
||||
fromStr = symlink.absFrom
|
||||
}
|
||||
|
||||
fmt.Fprintln(buf, "\t@echo \"Symlink $@\"")
|
||||
fmt.Fprintf(buf, "\trm -f $@ && ln -sfn %s $@", fromStr)
|
||||
fmt.Fprintln(buf)
|
||||
fmt.Fprintln(buf)
|
||||
|
@@ -381,6 +381,16 @@ type ModuleContext interface {
|
||||
// for which IsInstallDepNeeded returns true.
|
||||
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
|
||||
|
||||
// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
|
||||
// directory, and also unzip a zip file containing extra files to install into the same
|
||||
// directory.
|
||||
//
|
||||
// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
|
||||
// installed file will be returned by PackagingSpecs() on this module or by
|
||||
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
||||
// for which IsInstallDepNeeded returns true.
|
||||
InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...Path) InstallPath
|
||||
|
||||
// InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
|
||||
// directory.
|
||||
//
|
||||
@@ -2235,10 +2245,16 @@ type katiInstall struct {
|
||||
implicitDeps Paths
|
||||
orderOnlyDeps Paths
|
||||
executable bool
|
||||
extraFiles *extraFilesZip
|
||||
|
||||
absFrom string
|
||||
}
|
||||
|
||||
type extraFilesZip struct {
|
||||
zip Path
|
||||
dir InstallPath
|
||||
}
|
||||
|
||||
type katiInstalls []katiInstall
|
||||
|
||||
// BuiltInstalled returns the katiInstalls in the form used by $(call copy-many-files) in Make, a
|
||||
@@ -2852,12 +2868,20 @@ func (m *moduleContext) skipInstall() bool {
|
||||
|
||||
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
|
||||
deps ...Path) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, false)
|
||||
return m.installFile(installPath, name, srcPath, deps, false, nil)
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
|
||||
deps ...Path) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, true)
|
||||
return m.installFile(installPath, name, srcPath, deps, true, nil)
|
||||
}
|
||||
|
||||
func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
|
||||
extraZip Path, deps ...Path) InstallPath {
|
||||
return m.installFile(installPath, name, srcPath, deps, false, &extraFilesZip{
|
||||
zip: extraZip,
|
||||
dir: installPath,
|
||||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
|
||||
@@ -2878,7 +2902,8 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
|
||||
return spec
|
||||
}
|
||||
|
||||
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []Path, executable bool) InstallPath {
|
||||
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []Path,
|
||||
executable bool, extraZip *extraFilesZip) InstallPath {
|
||||
|
||||
fullInstallPath := installPath.Join(m, name)
|
||||
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
|
||||
@@ -2906,6 +2931,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
|
||||
implicitDeps: implicitDeps,
|
||||
orderOnlyDeps: orderOnlyDeps,
|
||||
executable: executable,
|
||||
extraFiles: extraZip,
|
||||
})
|
||||
} else {
|
||||
rule := Cp
|
||||
@@ -2913,6 +2939,13 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
|
||||
rule = CpExecutable
|
||||
}
|
||||
|
||||
extraCmds := ""
|
||||
if extraZip != nil {
|
||||
extraCmds += fmt.Sprintf(" && unzip -qDD -d '%s' '%s'",
|
||||
extraZip.dir.String(), extraZip.zip.String())
|
||||
implicitDeps = append(implicitDeps, extraZip.zip)
|
||||
}
|
||||
|
||||
m.Build(pctx, BuildParams{
|
||||
Rule: rule,
|
||||
Description: "install " + fullInstallPath.Base(),
|
||||
@@ -2921,6 +2954,9 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat
|
||||
Implicits: implicitDeps,
|
||||
OrderOnly: orderOnlyDeps,
|
||||
Default: !m.Config().KatiEnabled(),
|
||||
Args: map[string]string{
|
||||
"extraCmds": extraCmds,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -263,7 +263,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Expected %s to be AndroidAppSet", fi.module))
|
||||
}
|
||||
fmt.Fprintln(w, "LOCAL_APK_SET_INSTALL_FILE :=", as.InstallFile())
|
||||
fmt.Fprintln(w, "LOCAL_APK_SET_INSTALL_FILE :=", as.PackedAdditionalOutputs().String())
|
||||
fmt.Fprintln(w, "LOCAL_APKCERTS_FILE :=", as.APKCertsFile().String())
|
||||
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_android_app_set.mk")
|
||||
case nativeSharedLib, nativeExecutable, nativeTest:
|
||||
|
@@ -442,7 +442,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
} else {
|
||||
if fi.class == appSet {
|
||||
copyCommands = append(copyCommands,
|
||||
fmt.Sprintf("unzip -qDD -d %s %s", destPathDir, fi.builtFile.String()))
|
||||
fmt.Sprintf("unzip -qDD -d %s %s", destPathDir,
|
||||
fi.module.(*java.AndroidAppSet).PackedAdditionalOutputs().String()))
|
||||
} else {
|
||||
copyCommands = append(copyCommands, "cp -f "+fi.builtFile.String()+" "+destPath)
|
||||
}
|
||||
|
@@ -356,7 +356,7 @@ type Zip2ZipWriter interface {
|
||||
|
||||
// Writes out selected entries, renaming them as needed
|
||||
func (apkSet *ApkSet) writeApks(selected SelectionResult, config TargetConfig,
|
||||
writer Zip2ZipWriter, partition string) ([]string, error) {
|
||||
outFile io.Writer, zipWriter Zip2ZipWriter, partition string) ([]string, error) {
|
||||
// Renaming rules:
|
||||
// splits/MODULE-master.apk to STEM.apk
|
||||
// else
|
||||
@@ -406,8 +406,14 @@ func (apkSet *ApkSet) writeApks(selected SelectionResult, config TargetConfig,
|
||||
origin, inName, outName)
|
||||
}
|
||||
entryOrigin[outName] = inName
|
||||
if err := writer.CopyFrom(apkFile, outName); err != nil {
|
||||
return nil, err
|
||||
if outName == config.stem+".apk" {
|
||||
if err := writeZipEntryToFile(outFile, apkFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
if err := zipWriter.CopyFrom(apkFile, outName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if partition != "" {
|
||||
apkcerts = append(apkcerts, fmt.Sprintf(
|
||||
@@ -426,14 +432,13 @@ func (apkSet *ApkSet) extractAndCopySingle(selected SelectionResult, outFile *os
|
||||
if !ok {
|
||||
return fmt.Errorf("Couldn't find apk path %s", selected.entries[0])
|
||||
}
|
||||
inputReader, _ := apk.Open()
|
||||
_, err := io.Copy(outFile, inputReader)
|
||||
return err
|
||||
return writeZipEntryToFile(outFile, apk)
|
||||
}
|
||||
|
||||
// Arguments parsing
|
||||
var (
|
||||
outputFile = flag.String("o", "", "output file containing extracted entries")
|
||||
outputFile = flag.String("o", "", "output file for primary entry")
|
||||
zipFile = flag.String("zip", "", "output file containing additional extracted entries")
|
||||
targetConfig = TargetConfig{
|
||||
screenDpi: map[android_bundle_proto.ScreenDensity_DensityAlias]bool{},
|
||||
abis: map[android_bundle_proto.Abi_AbiAlias]int{},
|
||||
@@ -494,7 +499,8 @@ func (s screenDensityFlagValue) Set(densityList string) error {
|
||||
|
||||
func processArgs() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, `usage: extract_apks -o <output-file> -sdk-version value -abis value `+
|
||||
fmt.Fprintln(os.Stderr, `usage: extract_apks -o <output-file> [-zip <output-zip-file>] `+
|
||||
`-sdk-version value -abis value `+
|
||||
`-screen-densities value {-stem value | -extract-single} [-allow-prereleased] `+
|
||||
`[-apkcerts <apkcerts output file> -partition <partition>] <APK set>`)
|
||||
flag.PrintDefaults()
|
||||
@@ -510,7 +516,8 @@ func processArgs() {
|
||||
flag.StringVar(&targetConfig.stem, "stem", "", "output entries base name in the output zip file")
|
||||
flag.Parse()
|
||||
if (*outputFile == "") || len(flag.Args()) != 1 || *version == 0 ||
|
||||
(targetConfig.stem == "" && !*extractSingle) || (*apkcertsOutput != "" && *partition == "") {
|
||||
((targetConfig.stem == "" || *zipFile == "") && !*extractSingle) ||
|
||||
(*apkcertsOutput != "" && *partition == "") {
|
||||
flag.Usage()
|
||||
}
|
||||
targetConfig.sdkVersion = int32(*version)
|
||||
@@ -542,13 +549,20 @@ func main() {
|
||||
if *extractSingle {
|
||||
err = apkSet.extractAndCopySingle(sel, outFile)
|
||||
} else {
|
||||
writer := zip.NewWriter(outFile)
|
||||
zipOutputFile, err := os.Create(*zipFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer zipOutputFile.Close()
|
||||
|
||||
zipWriter := zip.NewWriter(zipOutputFile)
|
||||
defer func() {
|
||||
if err := writer.Close(); err != nil {
|
||||
if err := zipWriter.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
apkcerts, err := apkSet.writeApks(sel, targetConfig, writer, *partition)
|
||||
|
||||
apkcerts, err := apkSet.writeApks(sel, targetConfig, outFile, zipWriter, *partition)
|
||||
if err == nil && *apkcertsOutput != "" {
|
||||
apkcertsFile, err := os.Create(*apkcertsOutput)
|
||||
if err != nil {
|
||||
@@ -567,3 +581,13 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func writeZipEntryToFile(outFile io.Writer, zipEntry *zip.File) error {
|
||||
reader, err := zipEntry.Open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer reader.Close()
|
||||
_, err = io.Copy(outFile, reader)
|
||||
return err
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -437,8 +438,8 @@ type testCaseWriteApks struct {
|
||||
stem string
|
||||
partition string
|
||||
// what we write from what
|
||||
expectedZipEntries map[string]string
|
||||
expectedApkcerts []string
|
||||
zipEntries map[string]string
|
||||
expectedApkcerts []string
|
||||
}
|
||||
|
||||
func TestWriteApks(t *testing.T) {
|
||||
@@ -448,7 +449,7 @@ func TestWriteApks(t *testing.T) {
|
||||
moduleName: "mybase",
|
||||
stem: "Foo",
|
||||
partition: "system",
|
||||
expectedZipEntries: map[string]string{
|
||||
zipEntries: map[string]string{
|
||||
"Foo.apk": "splits/mybase-master.apk",
|
||||
"Foo-xhdpi.apk": "splits/mybase-xhdpi.apk",
|
||||
},
|
||||
@@ -462,7 +463,7 @@ func TestWriteApks(t *testing.T) {
|
||||
moduleName: "base",
|
||||
stem: "Bar",
|
||||
partition: "product",
|
||||
expectedZipEntries: map[string]string{
|
||||
zipEntries: map[string]string{
|
||||
"Bar.apk": "universal.apk",
|
||||
},
|
||||
expectedApkcerts: []string{
|
||||
@@ -471,23 +472,46 @@ func TestWriteApks(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
apkSet := ApkSet{entries: make(map[string]*zip.File)}
|
||||
sel := SelectionResult{moduleName: testCase.moduleName}
|
||||
for _, in := range testCase.expectedZipEntries {
|
||||
apkSet.entries[in] = &zip.File{FileHeader: zip.FileHeader{Name: in}}
|
||||
sel.entries = append(sel.entries, in)
|
||||
}
|
||||
writer := testZip2ZipWriter{make(map[string]string)}
|
||||
config := TargetConfig{stem: testCase.stem}
|
||||
apkcerts, err := apkSet.writeApks(sel, config, writer, testCase.partition)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(testCase.expectedZipEntries, writer.entries) {
|
||||
t.Errorf("expected zip entries %v, got %v", testCase.expectedZipEntries, writer.entries)
|
||||
}
|
||||
if !reflect.DeepEqual(testCase.expectedApkcerts, apkcerts) {
|
||||
t.Errorf("expected apkcerts %v, got %v", testCase.expectedApkcerts, apkcerts)
|
||||
}
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
testZipBuf := &bytes.Buffer{}
|
||||
testZip := zip.NewWriter(testZipBuf)
|
||||
for _, in := range testCase.zipEntries {
|
||||
f, _ := testZip.Create(in)
|
||||
f.Write([]byte(in))
|
||||
}
|
||||
testZip.Close()
|
||||
|
||||
zipReader, _ := zip.NewReader(bytes.NewReader(testZipBuf.Bytes()), int64(testZipBuf.Len()))
|
||||
|
||||
apkSet := ApkSet{entries: make(map[string]*zip.File)}
|
||||
sel := SelectionResult{moduleName: testCase.moduleName}
|
||||
for _, f := range zipReader.File {
|
||||
apkSet.entries[f.Name] = f
|
||||
sel.entries = append(sel.entries, f.Name)
|
||||
}
|
||||
|
||||
zipWriter := testZip2ZipWriter{make(map[string]string)}
|
||||
outWriter := &bytes.Buffer{}
|
||||
config := TargetConfig{stem: testCase.stem}
|
||||
apkcerts, err := apkSet.writeApks(sel, config, outWriter, zipWriter, testCase.partition)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expectedZipEntries := make(map[string]string)
|
||||
for k, v := range testCase.zipEntries {
|
||||
if k != testCase.stem+".apk" {
|
||||
expectedZipEntries[k] = v
|
||||
}
|
||||
}
|
||||
if !reflect.DeepEqual(expectedZipEntries, zipWriter.entries) {
|
||||
t.Errorf("expected zip entries %v, got %v", testCase.zipEntries, zipWriter.entries)
|
||||
}
|
||||
if !reflect.DeepEqual(testCase.expectedApkcerts, apkcerts) {
|
||||
t.Errorf("expected apkcerts %v, got %v", testCase.expectedApkcerts, apkcerts)
|
||||
}
|
||||
if g, w := outWriter.String(), testCase.zipEntries[testCase.stem+".apk"]; !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("expected output file contents %q, got %q", testCase.stem+".apk", outWriter.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -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...)
|
||||
},
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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{
|
||||
|
Reference in New Issue
Block a user