Merge aconfig files per-module am: d788b3e6cb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2860765 Change-Id: Ie43ca8826156ff580618cdeda0337db270a82e62 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -126,7 +126,7 @@ var DeclarationsProviderKey = blueprint.NewProvider(DeclarationsProviderData{})
|
|||||||
// This is used to collect the aconfig declarations info on the transitive closure,
|
// This is used to collect the aconfig declarations info on the transitive closure,
|
||||||
// the data is keyed on the container.
|
// the data is keyed on the container.
|
||||||
type TransitiveDeclarationsInfo struct {
|
type TransitiveDeclarationsInfo struct {
|
||||||
AconfigFiles map[string]*android.DepSet[android.Path]
|
AconfigFiles map[string]android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
var TransitiveDeclarationsInfoProvider = blueprint.NewProvider(TransitiveDeclarationsInfo{})
|
var TransitiveDeclarationsInfoProvider = blueprint.NewProvider(TransitiveDeclarationsInfo{})
|
||||||
@@ -177,40 +177,49 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
func CollectDependencyAconfigFiles(ctx android.ModuleContext, mergedAconfigFiles *map[string]android.Paths) {
|
||||||
func CollectTransitiveAconfigFiles(ctx android.ModuleContext, transitiveAconfigFiles *map[string]*android.DepSet[android.Path]) {
|
if *mergedAconfigFiles == nil {
|
||||||
if *transitiveAconfigFiles == nil {
|
*mergedAconfigFiles = make(map[string]android.Paths)
|
||||||
*transitiveAconfigFiles = make(map[string]*android.DepSet[android.Path])
|
|
||||||
}
|
}
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
if dep := ctx.OtherModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData); dep.IntermediatePath != nil {
|
if dep := ctx.OtherModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData); dep.IntermediatePath != nil {
|
||||||
aconfigMap := make(map[string]*android.DepSet[android.Path])
|
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediatePath)
|
||||||
aconfigMap[dep.Container] = android.NewDepSet(android.POSTORDER, []android.Path{dep.IntermediatePath}, nil)
|
|
||||||
mergeTransitiveAconfigFiles(aconfigMap, *transitiveAconfigFiles)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if dep := ctx.OtherModuleProvider(module, TransitiveDeclarationsInfoProvider).(TransitiveDeclarationsInfo); len(dep.AconfigFiles) > 0 {
|
if dep := ctx.OtherModuleProvider(module, TransitiveDeclarationsInfoProvider).(TransitiveDeclarationsInfo); len(dep.AconfigFiles) > 0 {
|
||||||
mergeTransitiveAconfigFiles(dep.AconfigFiles, *transitiveAconfigFiles)
|
for container, v := range dep.AconfigFiles {
|
||||||
|
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for container, aconfigFiles := range *mergedAconfigFiles {
|
||||||
|
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
|
||||||
|
}
|
||||||
|
|
||||||
ctx.SetProvider(TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
|
ctx.SetProvider(TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
|
||||||
AconfigFiles: *transitiveAconfigFiles,
|
AconfigFiles: *mergedAconfigFiles,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeTransitiveAconfigFiles(from, to map[string]*android.DepSet[android.Path]) {
|
func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths {
|
||||||
for fromKey, fromValue := range from {
|
if len(inputs) == 1 {
|
||||||
if fromValue == nil {
|
return android.Paths{inputs[0]}
|
||||||
continue
|
|
||||||
}
|
|
||||||
toValue, ok := to[fromKey]
|
|
||||||
if !ok {
|
|
||||||
to[fromKey] = fromValue
|
|
||||||
} else {
|
|
||||||
to[fromKey] = android.NewDepSet(android.POSTORDER, toValue.ToList(), []*android.DepSet[android.Path]{fromValue})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output := android.PathForModuleOut(ctx, "aconfig_merged.pb")
|
||||||
|
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: mergeAconfigFilesRule,
|
||||||
|
Description: "merge aconfig files",
|
||||||
|
Inputs: inputs,
|
||||||
|
Output: output,
|
||||||
|
Args: map[string]string{
|
||||||
|
"flags": android.JoinWithPrefix(inputs.Strings(), "--cache "),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return android.Paths{output}
|
||||||
}
|
}
|
||||||
|
|
||||||
type bazelAconfigDeclarationsAttributes struct {
|
type bazelAconfigDeclarationsAttributes struct {
|
||||||
|
@@ -60,9 +60,8 @@ func runJavaAndroidMkTest(t *testing.T, bp string) {
|
|||||||
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
|
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
|
||||||
|
|
||||||
makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"]
|
makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"]
|
||||||
android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 2, len(makeVar))
|
android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 1, len(makeVar))
|
||||||
android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb")
|
android.EnsureListContainsSuffix(t, makeVar, "android_common/aconfig_merged.pb")
|
||||||
android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_bar/intermediate.pb")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAndroidMkJavaLibrary(t *testing.T) {
|
func TestAndroidMkJavaLibrary(t *testing.T) {
|
||||||
|
@@ -48,6 +48,12 @@ var (
|
|||||||
"${aconfig}",
|
"${aconfig}",
|
||||||
},
|
},
|
||||||
}, "cache_files")
|
}, "cache_files")
|
||||||
|
|
||||||
|
mergeAconfigFilesRule = pctx.AndroidStaticRule("mergeAconfigFilesRule",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: `${aconfig} dump --dedup --format protobuf --out $out $flags`,
|
||||||
|
CommandDeps: []string{"${aconfig}"},
|
||||||
|
}, "flags")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@@ -2394,7 +2394,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
|
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
|
||||||
dep := ctx.OtherModuleProvider(module, aconfig.TransitiveDeclarationsInfoProvider).(aconfig.TransitiveDeclarationsInfo)
|
dep := ctx.OtherModuleProvider(module, aconfig.TransitiveDeclarationsInfoProvider).(aconfig.TransitiveDeclarationsInfo)
|
||||||
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
||||||
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()].ToList()...)
|
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11103,7 +11103,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
t.Fatalf("Expected 3 commands, got %d in:\n%s", len(aconfigArgs), s)
|
t.Fatalf("Expected 3 commands, got %d in:\n%s", len(aconfigArgs), s)
|
||||||
}
|
}
|
||||||
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
|
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
|
||||||
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_bar/intermediate.pb")
|
android.EnsureListContainsSuffix(t, aconfigArgs, "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/aconfig_merged.pb")
|
||||||
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_baz/intermediate.pb")
|
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_baz/intermediate.pb")
|
||||||
|
|
||||||
buildParams := combineAconfigRule.BuildParams
|
buildParams := combineAconfigRule.BuildParams
|
||||||
@@ -11111,7 +11111,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
|
|||||||
t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
|
t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
|
||||||
}
|
}
|
||||||
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
|
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
|
||||||
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_bar/intermediate.pb")
|
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/aconfig_merged.pb")
|
||||||
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_baz/intermediate.pb")
|
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_baz/intermediate.pb")
|
||||||
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
|
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@ bootstrap_go_package {
|
|||||||
name: "soong-bp2build",
|
name: "soong-bp2build",
|
||||||
pkgPath: "android/soong/bp2build",
|
pkgPath: "android/soong/bp2build",
|
||||||
srcs: [
|
srcs: [
|
||||||
"aconfig_conversion_test.go",
|
|
||||||
"androidbp_to_build_templates.go",
|
"androidbp_to_build_templates.go",
|
||||||
"bp2build.go",
|
"bp2build.go",
|
||||||
"bp2build_product_config.go",
|
"bp2build_product_config.go",
|
||||||
@@ -43,6 +42,7 @@ bootstrap_go_package {
|
|||||||
testSrcs: [
|
testSrcs: [
|
||||||
"go_conversion_test.go",
|
"go_conversion_test.go",
|
||||||
"aar_conversion_test.go",
|
"aar_conversion_test.go",
|
||||||
|
"aconfig_conversion_test.go",
|
||||||
"aidl_library_conversion_test.go",
|
"aidl_library_conversion_test.go",
|
||||||
"android_app_certificate_conversion_test.go",
|
"android_app_certificate_conversion_test.go",
|
||||||
"android_app_conversion_test.go",
|
"android_app_conversion_test.go",
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package bp2build
|
package bp2build
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"android/soong/aconfig/codegen"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/aconfig"
|
"android/soong/aconfig"
|
||||||
@@ -25,6 +26,7 @@ import (
|
|||||||
|
|
||||||
func registerAconfigModuleTypes(ctx android.RegistrationContext) {
|
func registerAconfigModuleTypes(ctx android.RegistrationContext) {
|
||||||
aconfig.RegisterBuildComponents(ctx)
|
aconfig.RegisterBuildComponents(ctx)
|
||||||
|
codegen.RegisterBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||||
ctx.RegisterModuleType("java_library", java.LibraryFactory)
|
ctx.RegisterModuleType("java_library", java.LibraryFactory)
|
||||||
}
|
}
|
||||||
|
@@ -134,7 +134,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
|
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
|
||||||
}
|
}
|
||||||
// TODO(b/311155208): The container here should be system.
|
// TODO(b/311155208): The container here should be system.
|
||||||
entries.SetOptionalPaths("LOCAL_ACONFIG_FILES", c.getTransitiveAconfigFiles(""))
|
entries.SetPaths("LOCAL_ACONFIG_FILES", c.mergedAconfigFiles[""])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
||||||
|
8
cc/cc.go
8
cc/cc.go
@@ -928,7 +928,7 @@ type Module struct {
|
|||||||
hideApexVariantFromMake bool
|
hideApexVariantFromMake bool
|
||||||
|
|
||||||
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
|
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
|
||||||
transitiveAconfigFiles map[string]*android.DepSet[android.Path]
|
mergedAconfigFiles map[string]android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) AddJSONData(d *map[string]interface{}) {
|
func (c *Module) AddJSONData(d *map[string]interface{}) {
|
||||||
@@ -2324,7 +2324,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
|
ctx.SetProvider(blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
|
||||||
|
|
||||||
aconfig.CollectTransitiveAconfigFiles(ctx, &c.transitiveAconfigFiles)
|
aconfig.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
|
||||||
|
|
||||||
c.maybeInstall(ctx, apexInfo)
|
c.maybeInstall(ctx, apexInfo)
|
||||||
}
|
}
|
||||||
@@ -2345,10 +2345,6 @@ func (c *Module) maybeUnhideFromMake() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) getTransitiveAconfigFiles(container string) []android.Path {
|
|
||||||
return c.transitiveAconfigFiles[container].ToList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// maybeInstall is called at the end of both GenerateAndroidBuildActions and
|
// maybeInstall is called at the end of both GenerateAndroidBuildActions and
|
||||||
// ProcessBazelQueryResponse to run the install hooks for installable modules,
|
// ProcessBazelQueryResponse to run the install hooks for installable modules,
|
||||||
// like binaries and tests.
|
// like binaries and tests.
|
||||||
|
@@ -129,7 +129,8 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
|
entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
|
||||||
}
|
}
|
||||||
// TODO(b/311155208): The container here should be system.
|
// TODO(b/311155208): The container here should be system.
|
||||||
entries.SetOptionalPaths("LOCAL_ACONFIG_FILES", library.getTransitiveAconfigFiles(""))
|
|
||||||
|
entries.SetPaths("LOCAL_ACONFIG_FILES", library.mergedAconfigFiles[""])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -307,7 +308,7 @@ func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
|
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
|
||||||
}
|
}
|
||||||
// TODO(b/311155208): The container here should be system.
|
// TODO(b/311155208): The container here should be system.
|
||||||
entries.SetOptionalPaths("LOCAL_ACONFIG_FILES", binary.getTransitiveAconfigFiles(""))
|
entries.SetPaths("LOCAL_ACONFIG_FILES", binary.mergedAconfigFiles[""])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
ExtraFooters: []android.AndroidMkExtraFootersFunc{
|
||||||
@@ -461,7 +462,7 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
|
|
||||||
if app.Name() != "framework-res" {
|
if app.Name() != "framework-res" {
|
||||||
// TODO(b/311155208): The container here should be system.
|
// TODO(b/311155208): The container here should be system.
|
||||||
entries.SetOptionalPaths("LOCAL_ACONFIG_FILES", app.getTransitiveAconfigFiles(""))
|
entries.SetPaths("LOCAL_ACONFIG_FILES", app.mergedAconfigFiles[""])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -540,7 +541,7 @@ func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
|||||||
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
|
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
|
||||||
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
|
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
|
||||||
// TODO(b/311155208): The container here should be system.
|
// TODO(b/311155208): The container here should be system.
|
||||||
entries.SetOptionalPaths("LOCAL_ACONFIG_FILES", a.getTransitiveAconfigFiles(""))
|
entries.SetPaths("LOCAL_ACONFIG_FILES", a.mergedAconfigFiles[""])
|
||||||
})
|
})
|
||||||
|
|
||||||
return entriesList
|
return entriesList
|
||||||
|
12
java/base.go
12
java/base.go
@@ -22,9 +22,9 @@ import (
|
|||||||
|
|
||||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||||
|
|
||||||
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/pathtools"
|
"github.com/google/blueprint/pathtools"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
"github.com/google/blueprint"
|
|
||||||
|
|
||||||
"android/soong/aconfig"
|
"android/soong/aconfig"
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -514,8 +514,8 @@ type Module struct {
|
|||||||
// or the module should override Stem().
|
// or the module should override Stem().
|
||||||
stem string
|
stem string
|
||||||
|
|
||||||
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
|
// Single aconfig "cache file" merged from this module and all dependencies.
|
||||||
transitiveAconfigFiles map[string]*android.DepSet[android.Path]
|
mergedAconfigFiles map[string]android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
|
||||||
@@ -1721,7 +1721,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
|||||||
|
|
||||||
ctx.CheckbuildFile(outputFile)
|
ctx.CheckbuildFile(outputFile)
|
||||||
|
|
||||||
aconfig.CollectTransitiveAconfigFiles(ctx, &j.transitiveAconfigFiles)
|
aconfig.CollectDependencyAconfigFiles(ctx, &j.mergedAconfigFiles)
|
||||||
|
|
||||||
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||||
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||||
@@ -2078,10 +2078,6 @@ func (j *Module) IsInstallable() bool {
|
|||||||
return Bool(j.properties.Installable)
|
return Bool(j.properties.Installable)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) getTransitiveAconfigFiles(container string) []android.Path {
|
|
||||||
return j.transitiveAconfigFiles[container].ToList()
|
|
||||||
}
|
|
||||||
|
|
||||||
type sdkLinkType int
|
type sdkLinkType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user