bundle config for apexes are auto-generated am: bd15961043 am: 878e45861b

Change-Id: I81b00c7a680f8b5017eb299d2535690e74b68f30
This commit is contained in:
Automerger Merge Worker 2020-02-29 09:53:04 +00:00
commit c62d85ffc9
2 changed files with 71 additions and 5 deletions

View File

@ -3693,6 +3693,35 @@ func TestApexWithJniLibs_Errors(t *testing.T) {
}))
}
func TestAppBundle(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
apps: ["AppFoo"],
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
android_app {
name: "AppFoo",
srcs: ["foo/bar/MyClass.java"],
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
}
`)
bundleConfigRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Description("Bundle Config")
content := bundleConfigRule.Args["content"]
ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`)
}
func TestMain(m *testing.M) {
run := func() int {
setUp()

View File

@ -15,6 +15,7 @@
package apex
import (
"encoding/json"
"fmt"
"path/filepath"
"runtime"
@ -136,15 +137,17 @@ var (
})
apexBundleRule = pctx.StaticRule("apexBundleRule", blueprint.RuleParams{
Command: `${zip2zip} -i $in -o $out ` +
Command: `${zip2zip} -i $in -o $out.base ` +
`apex_payload.img:apex/${abi}.img ` +
`apex_manifest.json:root/apex_manifest.json ` +
`apex_manifest.pb:root/apex_manifest.pb ` +
`AndroidManifest.xml:manifest/AndroidManifest.xml ` +
`assets/NOTICE.html.gz:assets/NOTICE.html.gz`,
CommandDeps: []string{"${zip2zip}"},
`assets/NOTICE.html.gz:assets/NOTICE.html.gz &&` +
`${soong_zip} -o $out.config -C $$(dirname ${config}) -f ${config} && ` +
`${merge_zips} $out $out.base $out.config`,
CommandDeps: []string{"${zip2zip}", "${soong_zip}", "${merge_zips}"},
Description: "app bundle",
}, "abi")
}, "abi", "config")
emitApexContentRule = pctx.StaticRule("emitApexContentRule", blueprint.RuleParams{
Command: `rm -f ${out} && touch ${out} && (. ${out}.emit_commands)`,
@ -257,6 +260,36 @@ func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApe
return output.OutputPath
}
func (a *apexBundle) buildBundleConfig(ctx android.ModuleContext) android.OutputPath {
output := android.PathForModuleOut(ctx, "bundle_config.json")
config := struct {
Compression struct {
Uncompressed_glob []string `json:"uncompressed_glob"`
} `json:"compression"`
}{}
config.Compression.Uncompressed_glob = []string{
"apex_payload.img",
"apex_manifest.*",
}
j, err := json.Marshal(config)
if err != nil {
panic(fmt.Errorf("error while marshalling to %q: %#v", output, err))
}
ctx.Build(pctx, android.BuildParams{
Rule: android.WriteFile,
Output: output,
Description: "Bundle Config " + output.String(),
Args: map[string]string{
"content": string(j),
},
})
return output.OutputPath
}
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
var abis []string
for _, target := range ctx.MultiTargets() {
@ -476,13 +509,17 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
Description: "apex proto convert",
})
bundleConfig := a.buildBundleConfig(ctx)
ctx.Build(pctx, android.BuildParams{
Rule: apexBundleRule,
Input: apexProtoFile,
Implicit: bundleConfig,
Output: a.bundleModuleFile,
Description: "apex bundle module",
Args: map[string]string{
"abi": strings.Join(abis, "."),
"config": bundleConfig.String(),
},
})
} else {