Merge "Properly package aconfig files for vendor partition" into main

This commit is contained in:
Yu Liu 2023-12-14 19:14:11 +00:00 committed by Gerrit Code Review
commit a1df1a5937
5 changed files with 76 additions and 13 deletions

View file

@ -230,3 +230,12 @@ func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.
return android.Paths{output}
}
func SetAconfigFileMkEntries(m *android.ModuleBase, entries *android.AndroidMkEntries, aconfigFiles map[string]android.Paths) {
if m.InstallInVendor() {
entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles["vendor"])
} else {
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles[""])
}
}

View file

@ -104,3 +104,61 @@ func testIncorrectCCCodegenModeHelper(t *testing.T, bpMode string, err string) {
}
`, bpMode))
}
func TestAndroidMkCcLibrary(t *testing.T) {
bp := `
aconfig_declarations {
name: "my_aconfig_declarations_foo",
package: "com.example.package",
srcs: ["foo.aconfig"],
container: "vendor",
}
cc_aconfig_library {
name: "my_cc_aconfig_library_foo",
aconfig_declarations: "my_aconfig_declarations_foo",
vendor_available: true,
}
aconfig_declarations {
name: "my_aconfig_declarations_bar",
package: "com.example.package",
srcs: ["bar.aconfig"],
}
cc_aconfig_library {
name: "my_cc_aconfig_library_bar",
aconfig_declarations: "my_aconfig_declarations_bar",
vendor_available: true,
}
cc_library {
name: "my_cc_library",
srcs: [
"src/foo.cc",
],
static_libs: [
"my_cc_aconfig_library_foo",
"my_cc_aconfig_library_bar",
],
vendor: true,
}
cc_library {
name: "server_configurable_flags",
srcs: ["server_configurable_flags.cc"],
}
`
result := android.GroupFixturePreparers(
PrepareForTestWithAconfigBuildComponents,
cc.PrepareForTestWithCcDefaultModules).
ExtendWithErrorHandler(android.FixtureExpectsNoErrors).RunTestWithBp(t, bp)
module := result.ModuleForTests("my_cc_library", "android_arm64_armv8-a_shared").Module()
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"]
android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 1, len(makeVar))
android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb")
}

View file

@ -15,6 +15,7 @@
package cc
import (
"android/soong/aconfig"
"github.com/google/blueprint/proptools"
"fmt"
@ -133,8 +134,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetString("SOONG_SDK_VARIANT_MODULES",
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
}
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", c.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{

View file

@ -19,6 +19,7 @@ import (
"io"
"strings"
"android/soong/aconfig"
"android/soong/android"
"github.com/google/blueprint/proptools"
@ -128,9 +129,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
if library.dexpreopter.configPath != nil {
entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
}
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", library.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
},
},
})
@ -307,8 +306,7 @@ func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
if len(binary.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
}
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", binary.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
@ -461,8 +459,7 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
if app.Name() != "framework-res" {
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", app.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
}
},
},
@ -540,8 +537,7 @@ func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", a.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
})
return entriesList

View file

@ -17,6 +17,7 @@ package rust
import (
"path/filepath"
"android/soong/aconfig"
"android/soong/android"
)
@ -66,8 +67,7 @@ func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
if mod.UseVndk() {
entries.SetBool("LOCAL_USE_VNDK", true)
}
// TODO(b/311155208): The container here should be system.
entries.SetPaths("LOCAL_ACONFIG_FILES", mod.mergedAconfigFiles[""])
aconfig.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
},
},
}