bundle config for apexes are auto-generated am: bd15961043
Change-Id: I1ee190b56f332f2c5be0cb34149f78756c1c1772
This commit is contained in:
@@ -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) {
|
func TestMain(m *testing.M) {
|
||||||
run := func() int {
|
run := func() int {
|
||||||
setUp()
|
setUp()
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package apex
|
package apex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -136,15 +137,17 @@ var (
|
|||||||
})
|
})
|
||||||
|
|
||||||
apexBundleRule = pctx.StaticRule("apexBundleRule", blueprint.RuleParams{
|
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_payload.img:apex/${abi}.img ` +
|
||||||
`apex_manifest.json:root/apex_manifest.json ` +
|
`apex_manifest.json:root/apex_manifest.json ` +
|
||||||
`apex_manifest.pb:root/apex_manifest.pb ` +
|
`apex_manifest.pb:root/apex_manifest.pb ` +
|
||||||
`AndroidManifest.xml:manifest/AndroidManifest.xml ` +
|
`AndroidManifest.xml:manifest/AndroidManifest.xml ` +
|
||||||
`assets/NOTICE.html.gz:assets/NOTICE.html.gz`,
|
`assets/NOTICE.html.gz:assets/NOTICE.html.gz &&` +
|
||||||
CommandDeps: []string{"${zip2zip}"},
|
`${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",
|
Description: "app bundle",
|
||||||
}, "abi")
|
}, "abi", "config")
|
||||||
|
|
||||||
emitApexContentRule = pctx.StaticRule("emitApexContentRule", blueprint.RuleParams{
|
emitApexContentRule = pctx.StaticRule("emitApexContentRule", blueprint.RuleParams{
|
||||||
Command: `rm -f ${out} && touch ${out} && (. ${out}.emit_commands)`,
|
Command: `rm -f ${out} && touch ${out} && (. ${out}.emit_commands)`,
|
||||||
@@ -257,6 +260,36 @@ func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApe
|
|||||||
return output.OutputPath
|
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) {
|
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||||
var abis []string
|
var abis []string
|
||||||
for _, target := range ctx.MultiTargets() {
|
for _, target := range ctx.MultiTargets() {
|
||||||
@@ -476,13 +509,17 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
Description: "apex proto convert",
|
Description: "apex proto convert",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bundleConfig := a.buildBundleConfig(ctx)
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: apexBundleRule,
|
Rule: apexBundleRule,
|
||||||
Input: apexProtoFile,
|
Input: apexProtoFile,
|
||||||
|
Implicit: bundleConfig,
|
||||||
Output: a.bundleModuleFile,
|
Output: a.bundleModuleFile,
|
||||||
Description: "apex bundle module",
|
Description: "apex bundle module",
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"abi": strings.Join(abis, "."),
|
"abi": strings.Join(abis, "."),
|
||||||
|
"config": bundleConfig.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user