From eeff222655c12768693ea47f527c2bd0392380d3 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Tue, 19 Mar 2024 23:07:34 +0000 Subject: [PATCH] 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. (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b75ed0f2d8c4d13924573fd065c9706475aac17b) Merged-In: I096877015b78786639376b279a9be5d07594d92e Change-Id: I096877015b78786639376b279a9be5d07594d92e --- aconfig/aconfig_declarations.go | 18 ++++++++------ aconfig/aconfig_declarations_test.go | 35 ++++++++++++++++++++++++++++ aconfig/init.go | 3 ++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index 392e8193a..d29e3122d 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -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") diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go index 1fe3c862a..5201fedb1 100644 --- a/aconfig/aconfig_declarations_test.go +++ b/aconfig/aconfig_declarations_test.go @@ -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) +} diff --git a/aconfig/init.go b/aconfig/init.go index 4625128e4..46554676b 100644 --- a/aconfig/init.go +++ b/aconfig/init.go @@ -28,6 +28,7 @@ var ( blueprint.RuleParams{ Command: `${aconfig} create-cache` + ` --package ${package}` + + ` ${container}` + ` ${declarations}` + ` ${values}` + ` ${default-permission}` + @@ -38,7 +39,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",