Merge "move CollectDependencyAconfigFiles to android" into main am: 4daed5a026
am: d4efb42433
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2883008 Change-Id: Ie1afa1c155f1750c41b387e65d2c9da1cd081c39 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
46d4218fd0
15 changed files with 106 additions and 89 deletions
|
@ -112,24 +112,6 @@ func optionalVariable(prefix string, value string) string {
|
|||
return sb.String()
|
||||
}
|
||||
|
||||
// Provider published by aconfig_value_set
|
||||
type DeclarationsProviderData struct {
|
||||
Package string
|
||||
Container string
|
||||
IntermediateCacheOutputPath android.WritablePath
|
||||
IntermediateDumpOutputPath android.WritablePath
|
||||
}
|
||||
|
||||
var DeclarationsProviderKey = blueprint.NewProvider[DeclarationsProviderData]()
|
||||
|
||||
// This is used to collect the aconfig declarations info on the transitive closure,
|
||||
// the data is keyed on the container.
|
||||
type TransitiveDeclarationsInfo struct {
|
||||
AconfigFiles map[string]android.Paths
|
||||
}
|
||||
|
||||
var TransitiveDeclarationsInfoProvider = blueprint.NewProvider[TransitiveDeclarationsInfo]()
|
||||
|
||||
func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
|
||||
valuesFiles := make([]android.Path, 0)
|
||||
|
@ -174,7 +156,7 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
|
|||
Description: "aconfig_text",
|
||||
})
|
||||
|
||||
android.SetProvider(ctx, DeclarationsProviderKey, DeclarationsProviderData{
|
||||
android.SetProvider(ctx, android.AconfigDeclarationsProviderKey, android.AconfigDeclarationsProviderData{
|
||||
Package: module.properties.Package,
|
||||
Container: module.properties.Container,
|
||||
IntermediateCacheOutputPath: intermediateCacheFilePath,
|
||||
|
@ -182,51 +164,6 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
|
|||
})
|
||||
|
||||
}
|
||||
func CollectDependencyAconfigFiles(ctx android.ModuleContext, mergedAconfigFiles *map[string]android.Paths) {
|
||||
if *mergedAconfigFiles == nil {
|
||||
*mergedAconfigFiles = make(map[string]android.Paths)
|
||||
}
|
||||
ctx.VisitDirectDeps(func(module android.Module) {
|
||||
if dep, _ := android.OtherModuleProvider(ctx, module, DeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
|
||||
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
|
||||
return
|
||||
}
|
||||
if dep, _ := android.OtherModuleProvider(ctx, module, TransitiveDeclarationsInfoProvider); len(dep.AconfigFiles) > 0 {
|
||||
for container, v := range dep.AconfigFiles {
|
||||
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
for container, aconfigFiles := range *mergedAconfigFiles {
|
||||
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
|
||||
AconfigFiles: *mergedAconfigFiles,
|
||||
})
|
||||
}
|
||||
|
||||
func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths {
|
||||
inputs = android.LastUniquePaths(inputs)
|
||||
if len(inputs) == 1 {
|
||||
return android.Paths{inputs[0]}
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
func SetAconfigFileMkEntries(m *android.ModuleBase, entries *android.AndroidMkEntries, aconfigFiles map[string]android.Paths) {
|
||||
// TODO(b/311155208): The default container here should be system.
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestAconfigDeclarations(t *testing.T) {
|
|||
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
|
||||
|
||||
// Check that the provider has the right contents
|
||||
depData, _ := android.SingletonModuleProvider(result, module, DeclarationsProviderKey)
|
||||
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
|
||||
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
|
||||
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
|
||||
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
|
||||
|
|
|
@ -37,7 +37,7 @@ func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.Si
|
|||
// Find all of the aconfig_declarations modules
|
||||
var cacheFiles android.Paths
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package codegen
|
||||
|
||||
import (
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
|
||||
|
@ -92,7 +91,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorSources(ctx cc.ModuleContext) cc
|
|||
if len(declarationsModules) != 1 {
|
||||
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
|
||||
}
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
|
||||
|
||||
// Figure out the generated file paths. This has to match aconfig's codegen_cpp.rs.
|
||||
this.generatedDir = android.PathForModuleGen(ctx)
|
||||
|
@ -122,7 +121,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContex
|
|||
if len(declarationsModules) != 1 {
|
||||
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
|
||||
}
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
|
||||
|
||||
mode := proptools.StringDefault(this.properties.Mode, "production")
|
||||
if !isModeSupported(mode) {
|
||||
|
|
|
@ -17,7 +17,6 @@ package codegen
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/java"
|
||||
|
||||
|
@ -82,7 +81,7 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
|
|||
if len(declarationsModules) != 1 {
|
||||
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
|
||||
}
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
|
||||
|
||||
// Generate the action to build the srcjar
|
||||
srcJarPath := android.PathForModuleGen(ctx, ctx.ModuleName()+".srcjar")
|
||||
|
|
|
@ -3,7 +3,6 @@ package codegen
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/rust"
|
||||
|
||||
|
@ -65,7 +64,7 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path
|
|||
if len(declarationsModules) != 1 {
|
||||
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
|
||||
}
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], aconfig.DeclarationsProviderKey)
|
||||
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
|
||||
|
||||
mode := proptools.StringDefault(a.Properties.Mode, "production")
|
||||
if !isModeSupported(mode) {
|
||||
|
|
|
@ -30,7 +30,7 @@ func (this *exportedJavaDeclarationsLibrarySingleton) GenerateBuildActions(ctx a
|
|||
// Find all of the aconfig_declarations modules
|
||||
var cacheFiles android.Paths
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, DeclarationsProviderKey)
|
||||
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -62,11 +62,6 @@ var (
|
|||
},
|
||||
}, "cache_files")
|
||||
|
||||
mergeAconfigFilesRule = pctx.AndroidStaticRule("mergeAconfigFilesRule",
|
||||
blueprint.RuleParams{
|
||||
Command: `${aconfig} dump --dedup --format protobuf --out $out $flags`,
|
||||
CommandDeps: []string{"${aconfig}"},
|
||||
}, "flags")
|
||||
// For exported_java_aconfig_library: Generate a JAR from all
|
||||
// java_aconfig_libraries to be consumed by apps built outside the
|
||||
// platform
|
||||
|
|
|
@ -27,6 +27,7 @@ bootstrap_go_package {
|
|||
"androidmk-parser",
|
||||
],
|
||||
srcs: [
|
||||
"aconfig_providers.go",
|
||||
"androidmk.go",
|
||||
"apex.go",
|
||||
"apex_contributions.go",
|
||||
|
|
92
android/aconfig_providers.go
Normal file
92
android/aconfig_providers.go
Normal file
|
@ -0,0 +1,92 @@
|
|||
// Copyright 2023 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package android
|
||||
|
||||
import (
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
var (
|
||||
mergeAconfigFilesRule = pctx.AndroidStaticRule("mergeAconfigFilesRule",
|
||||
blueprint.RuleParams{
|
||||
Command: `${aconfig} dump --dedup --format protobuf --out $out $flags`,
|
||||
CommandDeps: []string{"${aconfig}"},
|
||||
}, "flags")
|
||||
_ = pctx.HostBinToolVariable("aconfig", "aconfig")
|
||||
)
|
||||
|
||||
// Provider published by aconfig_value_set
|
||||
type AconfigDeclarationsProviderData struct {
|
||||
Package string
|
||||
Container string
|
||||
IntermediateCacheOutputPath WritablePath
|
||||
IntermediateDumpOutputPath WritablePath
|
||||
}
|
||||
|
||||
var AconfigDeclarationsProviderKey = blueprint.NewProvider[AconfigDeclarationsProviderData]()
|
||||
|
||||
// This is used to collect the aconfig declarations info on the transitive closure,
|
||||
// the data is keyed on the container.
|
||||
type AconfigTransitiveDeclarationsInfo struct {
|
||||
AconfigFiles map[string]Paths
|
||||
}
|
||||
|
||||
var AconfigTransitiveDeclarationsInfoProvider = blueprint.NewProvider[AconfigTransitiveDeclarationsInfo]()
|
||||
|
||||
func CollectDependencyAconfigFiles(ctx ModuleContext, mergedAconfigFiles *map[string]Paths) {
|
||||
if *mergedAconfigFiles == nil {
|
||||
*mergedAconfigFiles = make(map[string]Paths)
|
||||
}
|
||||
ctx.VisitDirectDeps(func(module Module) {
|
||||
if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
|
||||
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
|
||||
return
|
||||
}
|
||||
if dep, _ := OtherModuleProvider(ctx, module, AconfigTransitiveDeclarationsInfoProvider); len(dep.AconfigFiles) > 0 {
|
||||
for container, v := range dep.AconfigFiles {
|
||||
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
for container, aconfigFiles := range *mergedAconfigFiles {
|
||||
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
|
||||
}
|
||||
|
||||
SetProvider(ctx, AconfigTransitiveDeclarationsInfoProvider, AconfigTransitiveDeclarationsInfo{
|
||||
AconfigFiles: *mergedAconfigFiles,
|
||||
})
|
||||
}
|
||||
|
||||
func mergeAconfigFiles(ctx ModuleContext, inputs Paths) Paths {
|
||||
inputs = LastUniquePaths(inputs)
|
||||
if len(inputs) == 1 {
|
||||
return Paths{inputs[0]}
|
||||
}
|
||||
|
||||
output := PathForModuleOut(ctx, "aconfig_merged.pb")
|
||||
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: mergeAconfigFilesRule,
|
||||
Description: "merge aconfig files",
|
||||
Inputs: inputs,
|
||||
Output: output,
|
||||
Args: map[string]string{
|
||||
"flags": JoinWithPrefix(inputs.Strings(), "--cache "),
|
||||
},
|
||||
})
|
||||
|
||||
return Paths{output}
|
||||
}
|
|
@ -24,7 +24,6 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
|
@ -2272,7 +2271,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||
}
|
||||
|
||||
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
|
||||
dep, _ := android.OtherModuleProvider(ctx, module, aconfig.TransitiveDeclarationsInfoProvider)
|
||||
dep, _ := android.OtherModuleProvider(ctx, module, android.AconfigTransitiveDeclarationsInfoProvider)
|
||||
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
||||
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...)
|
||||
}
|
||||
|
|
3
cc/cc.go
3
cc/cc.go
|
@ -28,7 +28,6 @@ import (
|
|||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/aidl_library"
|
||||
"android/soong/android"
|
||||
"android/soong/cc/config"
|
||||
|
@ -2137,7 +2136,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||
}
|
||||
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: deps.GeneratedSources.Strings()})
|
||||
|
||||
aconfig.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
|
||||
android.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
|
||||
|
||||
c.maybeInstall(ctx, apexInfo)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/testing"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
@ -509,7 +508,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
|
|||
|
||||
var aconfigTextFilePaths android.Paths
|
||||
ctx.VisitDirectDepsWithTag(aconfigDeclarationTag, func(dep android.Module) {
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.DeclarationsProviderKey); ok {
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, android.AconfigDeclarationsProviderKey); ok {
|
||||
aconfigTextFilePaths = append(aconfigTextFilePaths, provider.IntermediateDumpOutputPath)
|
||||
} else {
|
||||
ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/google/blueprint/pathtools"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/dexpreopt"
|
||||
"android/soong/java/config"
|
||||
|
@ -1694,7 +1693,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
|||
|
||||
ctx.CheckbuildFile(outputFile)
|
||||
|
||||
aconfig.CollectDependencyAconfigFiles(ctx, &j.mergedAconfigFiles)
|
||||
android.CollectDependencyAconfigFiles(ctx, &j.mergedAconfigFiles)
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/aconfig"
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
cc_config "android/soong/cc/config"
|
||||
|
@ -1007,7 +1006,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||
android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
|
||||
}
|
||||
|
||||
aconfig.CollectDependencyAconfigFiles(ctx, &mod.mergedAconfigFiles)
|
||||
android.CollectDependencyAconfigFiles(ctx, &mod.mergedAconfigFiles)
|
||||
}
|
||||
|
||||
func (mod *Module) deps(ctx DepsContext) Deps {
|
||||
|
|
Loading…
Reference in a new issue