Pass "--container" to aconfig create-cache

Bug: 328823994
Test: unit tests and manual tests locally.

Ignore-AOSP-First: It is easier to detect all the mismatch in internal
master.

Change-Id: I096877015b78786639376b279a9be5d07594d92e
This commit is contained in:
Yu Liu 2024-03-12 22:22:30 +00:00
parent 0c1f5975ac
commit b75ed0f2d8
3 changed files with 48 additions and 8 deletions

View file

@ -137,18 +137,22 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
inputFiles := make([]android.Path, len(declarationFiles))
copy(inputFiles, declarationFiles)
inputFiles = append(inputFiles, valuesFiles...)
args := map[string]string{
"release_version": ctx.Config().ReleaseVersion(),
"package": module.properties.Package,
"declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "),
"values": joinAndPrefix(" --values ", module.properties.Values),
"default-permission": optionalVariable(" --default-permission ", defaultPermission),
}
if len(module.properties.Container) > 0 {
args["container"] = "--container " + module.properties.Container
}
ctx.Build(pctx, android.BuildParams{
Rule: aconfigRule,
Output: intermediateCacheFilePath,
Inputs: inputFiles,
Description: "aconfig_declarations",
Args: map[string]string{
"release_version": ctx.Config().ReleaseVersion(),
"package": module.properties.Package,
"declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "),
"values": joinAndPrefix(" --values ", module.properties.Values),
"default-permission": optionalVariable(" --default-permission ", defaultPermission),
},
Args: args,
})
intermediateDumpFilePath := android.PathForModuleOut(ctx, "intermediate.txt")

View file

@ -69,3 +69,38 @@ func TestAconfigDeclarationsWithExportableUnset(t *testing.T) {
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
android.AssertBoolEquals(t, "exportable", depData.Exportable, false)
}
func TestAconfigDeclarationsWithContainer(t *testing.T) {
bp := `
aconfig_declarations {
name: "module_name",
package: "com.example.package",
container: "com.android.foo",
srcs: [
"foo.aconfig",
],
}
`
result := runTest(t, android.FixtureExpectsNoErrors, bp)
module := result.ModuleForTests("module_name", "")
rule := module.Rule("aconfig")
android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo")
}
func TestAconfigDeclarationsWithoutContainer(t *testing.T) {
bp := `
aconfig_declarations {
name: "module_name",
package: "com.example.package",
srcs: [
"foo.aconfig",
],
}
`
result := runTest(t, android.FixtureExpectsNoErrors, bp)
module := result.ModuleForTests("module_name", "")
rule := module.Rule("aconfig")
android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0)
}

View file

@ -42,6 +42,7 @@ var (
blueprint.RuleParams{
Command: `${aconfig} create-cache` +
` --package ${package}` +
` ${container}` +
` ${declarations}` +
` ${values}` +
` ${default-permission}` +
@ -52,7 +53,7 @@ var (
"${aconfig}",
},
Restat: true,
}, "release_version", "package", "declarations", "values", "default-permission")
}, "release_version", "package", "container", "declarations", "values", "default-permission")
// For create-device-config-sysprops: Generate aconfig flag value map text file
aconfigTextRule = pctx.AndroidStaticRule("aconfig_text",