Merge "apex: make allowed_files prop overridable" into rvc-dev

This commit is contained in:
Jooyung Han
2020-06-22 17:05:58 +00:00
committed by Android (Google) Code Review
3 changed files with 63 additions and 5 deletions

View File

@@ -1031,9 +1031,6 @@ type apexBundleProperties struct {
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
Uses []string
// A txt file containing list of files that are allowed to be included in this APEX.
Allowed_files *string
// package format of this apex variant; could be non-flattened, flattened, or zip.
// imageApex, zipApex or flattened
ApexType apexPackaging `blueprint:"mutated"`
@@ -1106,6 +1103,9 @@ type overridableProperties struct {
// Apex Container Package Name.
// Override value for attribute package:name in AndroidManifest.xml
Package_name string
// A txt file containing list of files that are allowed to be included in this APEX.
Allowed_files *string `android:"path"`
}
type apexPackaging int
@@ -1510,6 +1510,9 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
}
func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
if a.overridableProperties.Allowed_files != nil {
android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
}
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
androidAppTag, a.overridableProperties.Apps...)
}

View File

@@ -4991,6 +4991,61 @@ func TestApexKeysTxt(t *testing.T) {
ensureContains(t, content, `name="myapex.apex" public_key="PRESIGNED" private_key="PRESIGNED" container_certificate="PRESIGNED" container_private_key="PRESIGNED" partition="system"`)
}
func TestAllowedFiles(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
apps: ["app"],
allowed_files: "allowed.txt",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
android_app {
name: "app",
srcs: ["foo/bar/MyClass.java"],
package_name: "foo",
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
}
`, withFiles(map[string][]byte{
"sub/Android.bp": []byte(`
override_apex {
name: "override_myapex",
base: "myapex",
apps: ["override_app"],
allowed_files: ":allowed",
}
// Overridable "path" property should be referenced indirectly
filegroup {
name: "allowed",
srcs: ["allowed.txt"],
}
override_android_app {
name: "override_app",
base: "app",
package_name: "bar",
}
`),
}))
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("diffApexContentRule")
if expected, actual := "allowed.txt", rule.Args["allowed_files_file"]; expected != actual {
t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
}
rule2 := ctx.ModuleForTests("myapex", "android_common_override_myapex_myapex_image").Rule("diffApexContentRule")
if expected, actual := "sub/allowed.txt", rule2.Args["allowed_files_file"]; expected != actual {
t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
}
}
func TestMain(m *testing.M) {
run := func() int {
setUp()

View File

@@ -369,7 +369,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
implicitInputs = append(implicitInputs, a.manifestPbOut)
if a.properties.Allowed_files != nil {
if a.overridableProperties.Allowed_files != nil {
ctx.Build(pctx, android.BuildParams{
Rule: emitApexContentRule,
Implicits: implicitInputs,
@@ -380,7 +380,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
},
})
implicitInputs = append(implicitInputs, imageContentFile)
allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Allowed_files))
allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.overridableProperties.Allowed_files))
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
ctx.Build(pctx, android.BuildParams{