diff --git a/android/filegroup.go b/android/filegroup.go index 0aabb6886..bc881ed97 100644 --- a/android/filegroup.go +++ b/android/filegroup.go @@ -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 { diff --git a/apex/apex.go b/apex/apex.go index ba636f1ea..72886ca99 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -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. } diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 188875ac9..c27b072f1 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -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 { diff --git a/cc/cc.go b/cc/cc.go index d34daec9e..fd7a38a12 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -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 diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index 66df10145..764237821 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -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) diff --git a/genrule/genrule.go b/genrule/genrule.go index 87f6392ee..fbda07483 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -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. diff --git a/java/aar.go b/java/aar.go index 15a542e1d..7fc39b6da 100644 --- a/java/aar.go +++ b/java/aar.go @@ -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 { diff --git a/java/app_import.go b/java/app_import.go index ff0f5fe2f..997274c93 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -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 } diff --git a/java/droidstubs.go b/java/droidstubs.go index bdbaf9281..04e6be8d7 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -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) { diff --git a/python/binary.go b/python/binary.go index 85084a4f2..d6750c655 100644 --- a/python/binary.go +++ b/python/binary.go @@ -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} diff --git a/python/test.go b/python/test.go index 782f39f20..7eb913620 100644 --- a/python/test.go +++ b/python/test.go @@ -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) })