Propagate aconfig providers for more modules.

Bug: 308625757
Test: manual
Change-Id: Iaf6d45a4259f1c6c34476c34c431344283ae2830
This commit is contained in:
LaMont Jones 2024-01-09 22:47:39 +00:00
parent acae2d7656
commit afe7baf47d
11 changed files with 76 additions and 0 deletions

View file

@ -55,6 +55,9 @@ type fileGroup struct {
DefaultableModuleBase
properties fileGroupProperties
srcs Paths
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
mergedAconfigFiles map[string]Paths
}
var _ SourceFileProducer = (*fileGroup)(nil)
@ -93,6 +96,7 @@ func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
}
SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
CollectDependencyAconfigFiles(ctx, &fg.mergedAconfigFiles)
}
func (fg *fileGroup) Srcs() Paths {

View file

@ -480,6 +480,9 @@ type apexBundle struct {
javaApisUsedByModuleFile android.ModuleOutPath
aconfigFiles []android.Path
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
}
// apexFileClass represents a type of file that can be included in APEX.
@ -2356,6 +2359,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return
}
}
android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
////////////////////////////////////////////////////////////////////////////////////////////
// 3) some fields in apexBundle struct are configured
@ -2515,6 +2519,9 @@ func BundleFactory() android.Module {
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
}
// apex_defaults provides defaultable properties to other apex modules.
@ -2537,6 +2544,10 @@ type OverrideApex struct {
android.OverrideModuleBase
}
func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
}
func (o *OverrideApex) GenerateAndroidBuildActions(_ android.ModuleContext) {
// All the overrides happen in the base module.
}

View file

@ -483,6 +483,9 @@ type Prebuilt struct {
inputApex android.Path
provenanceMetaDataFile android.OutputPath
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
}
type ApexFileProperties struct {
@ -837,6 +840,8 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *Prebuilt) ProvenanceMetaDataFile() android.OutputPath {

View file

@ -1994,6 +1994,10 @@ func (c *Module) stubLibraryMultipleApexViolation(ctx android.ModuleContext) boo
return false
}
func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
}
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// Handle the case of a test module split by `test_per_src` mutator.
//
@ -4075,6 +4079,9 @@ type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
android.ApexModuleBase
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
mergedAconfigFiles map[string]android.Paths
}
// cc_defaults provides a set of properties that can be inherited by other cc

View file

@ -155,6 +155,9 @@ type PrebuiltEtc struct {
additionalDependencies *android.Paths
makeClass string
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
mergedAconfigFiles map[string]android.Paths
}
type Defaults struct {
@ -365,6 +368,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
symlinks: p.properties.Symlinks,
}
p.addInstallRules(ctx, ip)
android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
type installProperties struct {
@ -433,11 +437,16 @@ func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
if p.additionalDependencies != nil {
entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
}
android.SetAconfigFileMkEntries(p.AndroidModuleBase(), entries, p.mergedAconfigFiles)
},
},
}}
}
func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
return &p.ModuleBase
}
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
p.installDirBase = dirBase
p.AddProperties(&p.properties)

View file

@ -184,6 +184,9 @@ type Module struct {
subName string
subDir string
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
mergedAconfigFiles map[string]android.Paths
}
type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask
@ -610,6 +613,24 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
g.outputDeps = android.Paths{phonyFile}
}
android.CollectDependencyAconfigFiles(ctx, &g.mergedAconfigFiles)
}
func (g *Module) AndroidMkEntries() []android.AndroidMkEntries {
ret := android.AndroidMkEntries{
OutputFile: android.OptionalPathForPath(g.outputFiles[0]),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
android.SetAconfigFileMkEntries(g.AndroidModuleBase(), entries, g.mergedAconfigFiles)
},
},
}
return []android.AndroidMkEntries{ret}
}
func (g *Module) AndroidModuleBase() *android.ModuleBase {
return &g.ModuleBase
}
// Collect information for opening IDE project files in java/jdeps.go.

View file

@ -980,6 +980,9 @@ type AARImport struct {
sdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
}
var _ android.OutputFileProducer = (*AARImport)(nil)
@ -1274,6 +1277,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: a.jniPackages,
})
android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
}
func (a *AARImport) HeaderJars() android.Paths {

View file

@ -86,6 +86,9 @@ type AndroidAppImport struct {
hideApexVariantFromMake bool
provenanceMetaDataFile android.OutputPath
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
}
type AndroidAppImportProperties struct {
@ -377,6 +380,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
artifactPath := android.PathForModuleSrc(ctx, *a.properties.Apk)
a.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, artifactPath, a.installPath)
}
android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
// TODO: androidmk converter jni libs
}

View file

@ -89,6 +89,9 @@ type Droidstubs struct {
metadataZip android.WritablePath
metadataDir android.WritablePath
// Single aconfig "cache file" merged from this module and all dependencies.
mergedAconfigFiles map[string]android.Paths
exportableApiFile android.WritablePath
exportableRemovedApiFile android.WritablePath
exportableNullabilityWarningsFile android.WritablePath
@ -1255,6 +1258,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
}
func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {

View file

@ -71,6 +71,9 @@ type PythonBinaryModule struct {
installedDest android.Path
androidMkSharedLibs []string
// Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
mergedAconfigFiles map[string]android.Paths
}
var _ android.AndroidMkEntriesProvider = (*PythonBinaryModule)(nil)
@ -103,6 +106,7 @@ func (p *PythonBinaryModule) GenerateAndroidBuildActions(ctx android.ModuleConte
p.buildBinary(ctx)
p.installedDest = ctx.InstallFile(installDir(ctx, "bin", "", ""),
p.installSource.Base(), p.installSource)
android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
@ -166,6 +170,7 @@ func (p *PythonBinaryModule) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetString("LOCAL_MODULE_STEM", stem)
entries.AddStrings("LOCAL_SHARED_LIBRARIES", p.androidMkSharedLibs...)
entries.SetBool("LOCAL_CHECK_ELF_FILES", false)
android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
})
return []android.AndroidMkEntries{entries}

View file

@ -149,6 +149,7 @@ func (p *PythonTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext
// just use buildBinary() so that the binary is not installed into the location
// it would be for regular binaries.
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
p.buildBinary(ctx)
var configs []tradefed.Option
@ -228,6 +229,7 @@ func (p *PythonTestModule) AndroidMkEntries() []android.AndroidMkEntries {
}
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
p.testProperties.Test_options.SetAndroidMkEntries(entries)
})