Merge "respect "apex_name:" for "apex" module" am: 852116a061 am: a13f0727b9 am: d4b98c58ad

am: 0e429b76c5

Change-Id: Ibb99aa5f044f5688b37ab8c53b8921527b830d6b
This commit is contained in:
Jooyung Han 2019-09-29 17:48:50 -07:00 committed by android-build-merger
commit ac4cf06f1c
2 changed files with 65 additions and 25 deletions

View File

@ -47,13 +47,15 @@ var (
Description: "fs_config ${out}",
}, "ro_paths", "exec_paths")
injectApexDependency = pctx.StaticRule("injectApexDependency", blueprint.RuleParams{
apexManifestRule = pctx.StaticRule("apexManifestRule", blueprint.RuleParams{
Command: `rm -f $out && ${jsonmodify} $in ` +
`-a provideNativeLibs ${provideNativeLibs} ` +
`-a requireNativeLibs ${requireNativeLibs} -o $out`,
`-a requireNativeLibs ${requireNativeLibs} ` +
`${opt} ` +
`-o $out`,
CommandDeps: []string{"${jsonmodify}"},
Description: "Inject dependency into ${out}",
}, "provideNativeLibs", "requireNativeLibs")
Description: "prepare ${out}",
}, "provideNativeLibs", "requireNativeLibs", "opt")
// TODO(b/113233103): make sure that file_contexts is sane, i.e., validate
// against the binary policy using sefcontext_compiler -p <policy>.
@ -1222,18 +1224,28 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.installDir = android.PathForModuleInstall(ctx, "apex")
a.filesInfo = filesInfo
// prepare apex_manifest.json
a.manifestOut = android.PathForModuleOut(ctx, "apex_manifest.json")
// put dependency({provide|require}NativeLibs) in apex_manifest.json
manifestSrc := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
// put dependency({provide|require}NativeLibs) in apex_manifest.json
provideNativeLibs = android.SortedUniqueStrings(provideNativeLibs)
requireNativeLibs = android.SortedUniqueStrings(android.RemoveListFromList(requireNativeLibs, provideNativeLibs))
// apex name can be overridden
optCommands := []string{}
if a.properties.Apex_name != nil {
optCommands = append(optCommands, "-v name "+*a.properties.Apex_name)
}
ctx.Build(pctx, android.BuildParams{
Rule: injectApexDependency,
Rule: apexManifestRule,
Input: manifestSrc,
Output: a.manifestOut,
Args: map[string]string{
"provideNativeLibs": strings.Join(provideNativeLibs, " "),
"requireNativeLibs": strings.Join(requireNativeLibs, " "),
"opt": strings.Join(optCommands, " "),
},
})
@ -1447,6 +1459,12 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap
optFlags = append(optFlags, "--no_hashtree")
}
if a.properties.Apex_name != nil {
// If apex_name is set, apexer can skip checking if key name matches with apex name.
// Note that apex_manifest is also mended.
optFlags = append(optFlags, "--do_not_check_keyname")
}
ctx.Build(pctx, android.BuildParams{
Rule: apexRule,
Implicits: implicitInputs,

View File

@ -771,9 +771,9 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
// Ensure that runtime_libs dep in included
ensureContains(t, copyCmds, "image.apex/lib64/libbar.so")
injectRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("injectApexDependency")
ensureListEmpty(t, names(injectRule.Args["provideNativeLibs"]))
ensureListContains(t, names(injectRule.Args["requireNativeLibs"]), "libfoo.so")
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule")
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libfoo.so")
}
@ -821,11 +821,11 @@ func TestApexDependencyToLLNDK(t *testing.T) {
// Ensure that LLNDK dep is not included
ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
injectRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("injectApexDependency")
ensureListEmpty(t, names(injectRule.Args["provideNativeLibs"]))
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexManifestRule")
ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
// Ensure that LLNDK dep is required
ensureListContains(t, names(injectRule.Args["requireNativeLibs"]), "libbar.so")
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
}
@ -1582,34 +1582,56 @@ func TestDependenciesInApexManifest(t *testing.T) {
}
`)
var injectRule android.TestingBuildParams
var apexManifestRule android.TestingBuildParams
var provideNativeLibs, requireNativeLibs []string
injectRule = ctx.ModuleForTests("myapex_nodep", "android_common_myapex_nodep").Rule("injectApexDependency")
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
apexManifestRule = ctx.ModuleForTests("myapex_nodep", "android_common_myapex_nodep").Rule("apexManifestRule")
provideNativeLibs = names(apexManifestRule.Args["provideNativeLibs"])
requireNativeLibs = names(apexManifestRule.Args["requireNativeLibs"])
ensureListEmpty(t, provideNativeLibs)
ensureListEmpty(t, requireNativeLibs)
injectRule = ctx.ModuleForTests("myapex_dep", "android_common_myapex_dep").Rule("injectApexDependency")
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
apexManifestRule = ctx.ModuleForTests("myapex_dep", "android_common_myapex_dep").Rule("apexManifestRule")
provideNativeLibs = names(apexManifestRule.Args["provideNativeLibs"])
requireNativeLibs = names(apexManifestRule.Args["requireNativeLibs"])
ensureListEmpty(t, provideNativeLibs)
ensureListContains(t, requireNativeLibs, "libfoo.so")
injectRule = ctx.ModuleForTests("myapex_provider", "android_common_myapex_provider").Rule("injectApexDependency")
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
apexManifestRule = ctx.ModuleForTests("myapex_provider", "android_common_myapex_provider").Rule("apexManifestRule")
provideNativeLibs = names(apexManifestRule.Args["provideNativeLibs"])
requireNativeLibs = names(apexManifestRule.Args["requireNativeLibs"])
ensureListContains(t, provideNativeLibs, "libfoo.so")
ensureListEmpty(t, requireNativeLibs)
injectRule = ctx.ModuleForTests("myapex_selfcontained", "android_common_myapex_selfcontained").Rule("injectApexDependency")
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
apexManifestRule = ctx.ModuleForTests("myapex_selfcontained", "android_common_myapex_selfcontained").Rule("apexManifestRule")
provideNativeLibs = names(apexManifestRule.Args["provideNativeLibs"])
requireNativeLibs = names(apexManifestRule.Args["requireNativeLibs"])
ensureListContains(t, provideNativeLibs, "libfoo.so")
ensureListEmpty(t, requireNativeLibs)
}
func TestApexName(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
apex_name: "com.android.myapex",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
`)
module := ctx.ModuleForTests("myapex", "android_common_myapex")
apexManifestRule := module.Rule("apexManifestRule")
ensureContains(t, apexManifestRule.Args["opt"], "-v name com.android.myapex")
apexRule := module.Rule("apexRule")
ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname")
}
func TestNonTestApex(t *testing.T) {
ctx, _ := testApex(t, `
apex {