Merge "apex: make allowed_files prop overridable" into rvc-dev am: d166f79278
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/11931025 Change-Id: I2600c560d596446af255b117abfc07dc1d1f1860
This commit is contained in:
@@ -1020,9 +1020,6 @@ type apexBundleProperties struct {
|
|||||||
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
|
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
|
||||||
Uses []string
|
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.
|
// package format of this apex variant; could be non-flattened, flattened, or zip.
|
||||||
// imageApex, zipApex or flattened
|
// imageApex, zipApex or flattened
|
||||||
ApexType apexPackaging `blueprint:"mutated"`
|
ApexType apexPackaging `blueprint:"mutated"`
|
||||||
@@ -1098,6 +1095,9 @@ type overridableProperties struct {
|
|||||||
// Apex Container Package Name.
|
// Apex Container Package Name.
|
||||||
// Override value for attribute package:name in AndroidManifest.xml
|
// Override value for attribute package:name in AndroidManifest.xml
|
||||||
Package_name string
|
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
|
type apexPackaging int
|
||||||
@@ -1489,6 +1489,9 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) OverridablePropertiesDepsMutator(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(),
|
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
|
||||||
androidAppTag, a.overridableProperties.Apps...)
|
androidAppTag, a.overridableProperties.Apps...)
|
||||||
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
|
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
|
||||||
|
@@ -5398,6 +5398,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"`)
|
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) {
|
func TestMain(m *testing.M) {
|
||||||
run := func() int {
|
run := func() int {
|
||||||
setUp()
|
setUp()
|
||||||
|
@@ -391,7 +391,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
|
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
|
||||||
implicitInputs = append(implicitInputs, a.manifestPbOut)
|
implicitInputs = append(implicitInputs, a.manifestPbOut)
|
||||||
|
|
||||||
if a.properties.Allowed_files != nil {
|
if a.overridableProperties.Allowed_files != nil {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: emitApexContentRule,
|
Rule: emitApexContentRule,
|
||||||
Implicits: implicitInputs,
|
Implicits: implicitInputs,
|
||||||
@@ -402,7 +402,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
implicitInputs = append(implicitInputs, imageContentFile)
|
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")
|
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Reference in New Issue
Block a user