diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/aconfig_providers.go | 4 | ||||
-rw-r--r-- | android/all_teams.go | 5 | ||||
-rw-r--r-- | android/androidmk.go | 14 | ||||
-rw-r--r-- | android/build_prop.go | 2 | ||||
-rw-r--r-- | android/compliance_metadata.go | 6 | ||||
-rw-r--r-- | android/config.go | 16 | ||||
-rw-r--r-- | android/config_test.go | 7 | ||||
-rw-r--r-- | android/container.go | 169 | ||||
-rw-r--r-- | android/deapexer.go | 6 | ||||
-rw-r--r-- | android/license_metadata.go | 10 | ||||
-rw-r--r-- | android/logtags.go | 2 | ||||
-rw-r--r-- | android/makevars.go | 2 | ||||
-rw-r--r-- | android/module.go | 39 | ||||
-rw-r--r-- | android/prebuilt.go | 16 | ||||
-rw-r--r-- | android/prebuilt_test.go | 6 | ||||
-rw-r--r-- | android/provider.go | 22 | ||||
-rw-r--r-- | android/singleton.go | 4 | ||||
-rw-r--r-- | android/test_suites.go | 2 | ||||
-rw-r--r-- | android/testing.go | 14 | ||||
-rw-r--r-- | android/variable.go | 5 |
20 files changed, 224 insertions, 127 deletions
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go index a47e80f03..f0675dd5b 100644 --- a/android/aconfig_providers.go +++ b/android/aconfig_providers.go @@ -141,7 +141,7 @@ func aconfigUpdateAndroidBuildActions(ctx ModuleContext) { } func aconfigUpdateAndroidMkData(ctx fillInEntriesContext, mod Module, data *AndroidMkData) { - info, ok := SingletonModuleProvider(ctx, mod, AconfigPropagatingProviderKey) + info, ok := OtherModuleProvider(ctx, mod, AconfigPropagatingProviderKey) // If there is no aconfigPropagatingProvider, or there are no AconfigFiles, then we are done. if !ok || len(info.AconfigFiles) == 0 { return @@ -172,7 +172,7 @@ func aconfigUpdateAndroidMkEntries(ctx fillInEntriesContext, mod Module, entries if len(*entries) == 0 { return } - info, ok := SingletonModuleProvider(ctx, mod, AconfigPropagatingProviderKey) + info, ok := OtherModuleProvider(ctx, mod, AconfigPropagatingProviderKey) if !ok || len(info.AconfigFiles) == 0 { return } diff --git a/android/all_teams.go b/android/all_teams.go index d4bf7d0c4..e3c2e70bd 100644 --- a/android/all_teams.go +++ b/android/all_teams.go @@ -1,9 +1,10 @@ package android import ( - "android/soong/android/team_proto" "path/filepath" + "android/soong/android/team_proto" + "google.golang.org/protobuf/proto" ) @@ -93,7 +94,7 @@ func (t *allTeamsSingleton) GenerateBuildActions(ctx SingletonContext) { } testModInfo := TestModuleInformation{} - if tmi, ok := SingletonModuleProvider(ctx, module, TestOnlyProviderKey); ok { + if tmi, ok := OtherModuleProvider(ctx, module, TestOnlyProviderKey); ok { testModInfo = tmi } diff --git a/android/androidmk.go b/android/androidmk.go index 9699ce5b8..f88a2265a 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -170,7 +170,7 @@ type androidMkExtraEntriesContext struct { } func (a *androidMkExtraEntriesContext) Provider(provider blueprint.AnyProviderKey) (any, bool) { - return a.ctx.moduleProvider(a.mod, provider) + return a.ctx.otherModuleProvider(a.mod, provider) } type AndroidMkExtraEntriesFunc func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) @@ -497,7 +497,7 @@ type fillInEntriesContext interface { ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string Config() Config - moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) + otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) ModuleType(module blueprint.Module) string OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) } @@ -633,11 +633,11 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint } } - if licenseMetadata, ok := SingletonModuleProvider(ctx, mod, LicenseMetadataProvider); ok { + if licenseMetadata, ok := OtherModuleProvider(ctx, mod, LicenseMetadataProvider); ok { a.SetPath("LOCAL_SOONG_LICENSE_METADATA", licenseMetadata.LicenseMetadataPath) } - if _, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { + if _, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { a.SetBool("LOCAL_SOONG_MODULE_INFO_JSON", true) } @@ -861,6 +861,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs * } data := provider.AndroidMk() + if data.Include == "" { data.Include = "$(BUILD_PREBUILT)" } @@ -907,6 +908,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs * case "*phony.PhonyRule": // writes phony deps and acts like `.PHONY` case "*selinux.selinuxContextsModule": // license properties written case "*sysprop.syspropLibrary": // license properties written + case "*vintf.vintfCompatibilityMatrixRule": // use case like phony default: if !ctx.Config().IsEnvFalse("ANDROID_REQUIRE_LICENSES") { return fmt.Errorf("custom make rules not allowed for %q (%q) module %q", ctx.ModuleType(mod), reflect.TypeOf(mod), ctx.ModuleName(mod)) @@ -918,7 +920,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs * } if !data.Entries.disabled() { - if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { + if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { *moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON) } } @@ -960,7 +962,7 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleIn } if len(entriesList) > 0 && !entriesList[0].disabled() { - if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { + if moduleInfoJSON, ok := OtherModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok { *moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON) } } diff --git a/android/build_prop.go b/android/build_prop.go index b127755c8..13d59f9f5 100644 --- a/android/build_prop.go +++ b/android/build_prop.go @@ -56,7 +56,7 @@ func (p *buildPropModule) stem() string { } func (p *buildPropModule) propFiles(ctx ModuleContext) Paths { - partition := p.PartitionTag(ctx.DeviceConfig()) + partition := p.partition(ctx.DeviceConfig()) if partition == "system" { return ctx.Config().SystemPropFiles(ctx) } else if partition == "system_ext" { diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go index 6ea66541a..5cdd3020f 100644 --- a/android/compliance_metadata.go +++ b/android/compliance_metadata.go @@ -160,7 +160,7 @@ var ( // buildComplianceMetadataProvider starts with the ModuleContext.ComplianceMetadataInfo() and fills in more common metadata // for different module types without accessing their private fields but through android.Module interface // and public/private fields of package android. The final metadata is stored to a module's ComplianceMetadataProvider. -func buildComplianceMetadataProvider(ctx ModuleContext, m *ModuleBase) { +func buildComplianceMetadataProvider(ctx *moduleContext, m *ModuleBase) { complianceMetadataInfo := ctx.ComplianceMetadataInfo() complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.NAME, m.Name()) complianceMetadataInfo.SetStringValue(ComplianceMetadataProp.PACKAGE, ctx.ModuleDir()) @@ -186,7 +186,7 @@ func buildComplianceMetadataProvider(ctx ModuleContext, m *ModuleBase) { } var installed InstallPaths - installed = append(installed, m.module.FilesToInstall()...) + installed = append(installed, ctx.installFiles...) installed = append(installed, m.katiInstalls.InstallPaths()...) installed = append(installed, m.katiSymlinks.InstallPaths()...) installed = append(installed, m.katiInitRcInstalls.InstallPaths()...) @@ -267,7 +267,7 @@ func (c *complianceMetadataSingleton) GenerateBuildActions(ctx SingletonContext) writerToCsv(csvWriter, metadata) return } - if provider, ok := ctx.moduleProvider(module, ComplianceMetadataProvider); ok { + if provider, ok := ctx.otherModuleProvider(module, ComplianceMetadataProvider); ok { metadataInfo := provider.(*ComplianceMetadataInfo) rowId = rowId + 1 metadata := []string{strconv.Itoa(rowId)} diff --git a/android/config.go b/android/config.go index d13e5ab3f..d6d76a4a0 100644 --- a/android/config.go +++ b/android/config.go @@ -2053,3 +2053,19 @@ func (c *config) ProductPropFiles(ctx PathContext) Paths { func (c *config) EnableUffdGc() string { return String(c.productVariables.EnableUffdGc) } + +func (c *config) DeviceFrameworkCompatibilityMatrixFile() []string { + return c.productVariables.DeviceFrameworkCompatibilityMatrixFile +} + +func (c *config) DeviceProductCompatibilityMatrixFile() []string { + return c.productVariables.DeviceProductCompatibilityMatrixFile +} + +func (c *config) BoardAvbEnable() bool { + return Bool(c.productVariables.BoardAvbEnable) +} + +func (c *config) BoardAvbSystemAddHashtreeFooterArgs() []string { + return c.productVariables.BoardAvbSystemAddHashtreeFooterArgs +} diff --git a/android/config_test.go b/android/config_test.go index ca7c7f8b4..773216844 100644 --- a/android/config_test.go +++ b/android/config_test.go @@ -150,12 +150,7 @@ func TestReleaseAconfigExtraReleaseConfigs(t *testing.T) { for _, tc := range testCases { fixture := GroupFixturePreparers( - FixtureModifyProductVariables(func(vars FixtureProductVariables) { - if vars.BuildFlags == nil { - vars.BuildFlags = make(map[string]string) - } - vars.BuildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"] = tc.flag - }), + PrepareForTestWithBuildFlag("RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS", tc.flag), ) actual := fixture.RunTest(t).Config.ReleaseAconfigExtraReleaseConfigs() AssertArrayString(t, tc.name, tc.expected, actual) diff --git a/android/container.go b/android/container.go index c4fdd9c91..05897dd6c 100644 --- a/android/container.go +++ b/android/container.go @@ -21,12 +21,22 @@ import ( "github.com/google/blueprint" ) +// ---------------------------------------------------------------------------- +// Start of the definitions of exception functions and the lookup table. +// +// Functions cannot be used as a value passed in providers, because functions are not +// hashable. As a workaround, the [exceptionHandleFuncLabel] enum values are passed using providers, +// and the corresponding functions are called from [exceptionHandleFunctionsTable] map. +// ---------------------------------------------------------------------------- + +type exceptionHandleFunc func(ModuleContext, Module, Module) bool + type StubsAvailableModule interface { IsStubsModule() bool } // Returns true if the dependency module is a stubs module -var depIsStubsModule = func(_ ModuleContext, _, dep Module) bool { +var depIsStubsModule exceptionHandleFunc = func(_ ModuleContext, _, dep Module) bool { if stubsModule, ok := dep.(StubsAvailableModule); ok { return stubsModule.IsStubsModule() } @@ -41,13 +51,76 @@ const ( checkStubs exceptionHandleFuncLabel = iota ) -// Functions cannot be used as a value passed in providers, because functions are not -// hashable. As a workaround, the exceptionHandleFunc enum values are passed using providers, -// and the corresponding functions are called from this map. -var exceptionHandleFunctionsTable = map[exceptionHandleFuncLabel]func(ModuleContext, Module, Module) bool{ +var exceptionHandleFunctionsTable = map[exceptionHandleFuncLabel]exceptionHandleFunc{ checkStubs: depIsStubsModule, } +// ---------------------------------------------------------------------------- +// Start of the definitions of container determination functions. +// +// Similar to the above section, below defines the functions used to determine +// the container of each modules. +// ---------------------------------------------------------------------------- + +type containerBoundaryFunc func(mctx ModuleContext) bool + +var vendorContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { + m, ok := mctx.Module().(ImageInterface) + return mctx.Module().InstallInVendor() || (ok && m.VendorVariantNeeded(mctx)) +} + +var systemContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { + module := mctx.Module() + + return !module.InstallInTestcases() && + !module.InstallInData() && + !module.InstallInRamdisk() && + !module.InstallInVendorRamdisk() && + !module.InstallInDebugRamdisk() && + !module.InstallInRecovery() && + !module.InstallInVendor() && + !module.InstallInOdm() && + !module.InstallInProduct() && + determineModuleKind(module.base(), mctx.blueprintBaseModuleContext()) == platformModule +} + +var productContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { + m, ok := mctx.Module().(ImageInterface) + return mctx.Module().InstallInProduct() || (ok && m.ProductVariantNeeded(mctx)) +} + +var apexContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { + _, ok := ModuleProvider(mctx, AllApexInfoProvider) + return ok +} + +var ctsContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool { + props := mctx.Module().GetProperties() + for _, prop := range props { + val := reflect.ValueOf(prop).Elem() + if val.Kind() == reflect.Struct { + testSuites := val.FieldByName("Test_suites") + if testSuites.IsValid() && testSuites.Kind() == reflect.Slice && slices.Contains(testSuites.Interface().([]string), "cts") { + return true + } + } + } + return false +} + +// Map of [*container] to the [containerBoundaryFunc] +var containerBoundaryFunctionsTable = map[*container]containerBoundaryFunc{ + VendorContainer: vendorContainerBoundaryFunc, + SystemContainer: systemContainerBoundaryFunc, + ProductContainer: productContainerBoundaryFunc, + ApexContainer: apexContainerBoundaryFunc, + CtsContainer: ctsContainerBoundaryFunc, +} + +// ---------------------------------------------------------------------------- +// End of the definitions of container determination functions. +// ---------------------------------------------------------------------------- + type InstallableModule interface { EnforceApiContainerChecks() bool } @@ -77,6 +150,7 @@ var ( name: VendorVariation, restricted: nil, } + SystemContainer = &container{ name: "system", restricted: []restriction{ @@ -90,6 +164,7 @@ var ( }, }, } + ProductContainer = &container{ name: ProductVariation, restricted: []restriction{ @@ -102,8 +177,10 @@ var ( }, }, } + ApexContainer = initializeApexContainer() - CtsContainer = &container{ + + CtsContainer = &container{ name: "cts", restricted: []restriction{ { @@ -116,6 +193,14 @@ var ( }, }, } + + allContainers = []*container{ + VendorContainer, + SystemContainer, + ProductContainer, + ApexContainer, + CtsContainer, + } ) func initializeApexContainer() *container { @@ -155,68 +240,38 @@ func (c *ContainersInfo) BelongingContainers() []*container { return c.belongingContainers } -var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]() +func (c *ContainersInfo) ApexNames() (ret []string) { + for _, apex := range c.belongingApexes { + ret = append(ret, apex.InApexModules...) + } + slices.Sort(ret) + return ret +} -// Determines if the module can be installed in the system partition or not. -// Logic is identical to that of modulePartition(...) defined in paths.go -func installInSystemPartition(ctx ModuleContext) bool { - module := ctx.Module() - return !module.InstallInTestcases() && - !module.InstallInData() && - !module.InstallInRamdisk() && - !module.InstallInVendorRamdisk() && - !module.InstallInDebugRamdisk() && - !module.InstallInRecovery() && - !module.InstallInVendor() && - !module.InstallInOdm() && - !module.InstallInProduct() && - determineModuleKind(module.base(), ctx.blueprintBaseModuleContext()) == platformModule +// Returns true if any of the apex the module belongs to is updatable. +func (c *ContainersInfo) UpdatableApex() bool { + for _, apex := range c.belongingApexes { + if apex.Updatable { + return true + } + } + return false } +var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]() + func generateContainerInfo(ctx ModuleContext) ContainersInfo { - inSystem := installInSystemPartition(ctx) - inProduct := ctx.Module().InstallInProduct() - inVendor := ctx.Module().InstallInVendor() - inCts := false - inApex := false - - if m, ok := ctx.Module().(ImageInterface); ok { - inProduct = inProduct || m.ProductVariantNeeded(ctx) - inVendor = inVendor || m.VendorVariantNeeded(ctx) - } + var containers []*container - props := ctx.Module().GetProperties() - for _, prop := range props { - val := reflect.ValueOf(prop).Elem() - if val.Kind() == reflect.Struct { - testSuites := val.FieldByName("Test_suites") - if testSuites.IsValid() && testSuites.Kind() == reflect.Slice && slices.Contains(testSuites.Interface().([]string), "cts") { - inCts = true - } + for _, cnt := range allContainers { + if containerBoundaryFunctionsTable[cnt](ctx) { + containers = append(containers, cnt) } } var belongingApexes []ApexInfo if apexInfo, ok := ModuleProvider(ctx, AllApexInfoProvider); ok { belongingApexes = apexInfo.ApexInfos - inApex = true - } - - containers := []*container{} - if inSystem { - containers = append(containers, SystemContainer) - } - if inProduct { - containers = append(containers, ProductContainer) - } - if inVendor { - containers = append(containers, VendorContainer) - } - if inCts { - containers = append(containers, CtsContainer) - } - if inApex { - containers = append(containers, ApexContainer) } return ContainersInfo{ diff --git a/android/deapexer.go b/android/deapexer.go index 61ae64ea5..dcae3e46d 100644 --- a/android/deapexer.go +++ b/android/deapexer.go @@ -181,7 +181,11 @@ func FindDeapexerProviderForModule(ctx ModuleContext) (*DeapexerInfo, error) { // An err has been found. Do not visit further. return } - c, _ := OtherModuleProvider(ctx, m, DeapexerProvider) + c, ok := OtherModuleProvider(ctx, m, DeapexerProvider) + if !ok { + ctx.ModuleErrorf("Expected all deps with DeapexerTag to have a DeapexerProvider, but module %q did not", m.Name()) + return + } p := &c if di != nil { // If two DeapexerInfo providers have been found then check if they are diff --git a/android/license_metadata.go b/android/license_metadata.go index 8056189fc..c12a01c4c 100644 --- a/android/license_metadata.go +++ b/android/license_metadata.go @@ -33,7 +33,7 @@ var ( }, "args") ) -func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { +func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath) { base := ctx.Module().base() if !base.Enabled(ctx) { @@ -52,8 +52,8 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { // Only pass the last installed file to isContainerFromFileExtensions so a *.zip file in test data // doesn't mark the whole module as a container. var installFiles InstallPaths - if len(base.installFiles) > 0 { - installFiles = InstallPaths{base.installFiles[len(base.installFiles)-1]} + if len(ctx.installFiles) > 0 { + installFiles = InstallPaths{ctx.installFiles[len(ctx.installFiles)-1]} } isContainer := isContainerFromFileExtensions(installFiles, outputFiles) @@ -92,7 +92,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { allDepMetadataArgs = append(allDepMetadataArgs, info.LicenseMetadataPath.String()+depAnnotations) - if depInstallFiles := dep.base().installFiles; len(depInstallFiles) > 0 { + if depInstallFiles := ModuleFilesToInstall(ctx, dep); len(depInstallFiles) > 0 { allDepOutputFiles = append(allDepOutputFiles, depInstallFiles.Paths()...) } else if depOutputFiles, err := outputFilesForModule(ctx, dep, ""); err == nil { depOutputFiles = PathsIfNonNil(depOutputFiles...) @@ -162,7 +162,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { // Installed files args = append(args, - JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(base.installFiles.Strings()), "-i ")) + JoinWithPrefix(proptools.NinjaAndShellEscapeListIncludingSpaces(ctx.installFiles.Strings()), "-i ")) if isContainer { args = append(args, "--is_container") diff --git a/android/logtags.go b/android/logtags.go index d11cccf4f..7929057ff 100644 --- a/android/logtags.go +++ b/android/logtags.go @@ -42,7 +42,7 @@ func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) { if !module.ExportedToMake() { return } - if logtagsInfo, ok := SingletonModuleProvider(ctx, module, LogtagsProviderKey); ok { + if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok { allLogtags = append(allLogtags, logtagsInfo.Logtags...) } }) diff --git a/android/makevars.go b/android/makevars.go index f92f4581e..ff43cc5ab 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -94,7 +94,7 @@ type MakeVarsContext interface { ModuleDir(module blueprint.Module) string ModuleSubDir(module blueprint.Module) string ModuleType(module blueprint.Module) string - moduleProvider(module blueprint.Module, key blueprint.AnyProviderKey) (any, bool) + otherModuleProvider(module blueprint.Module, key blueprint.AnyProviderKey) (any, bool) BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) diff --git a/android/module.go b/android/module.go index e161959ab..9f06045de 100644 --- a/android/module.go +++ b/android/module.go @@ -113,7 +113,6 @@ type Module interface { TargetRequiredModuleNames() []string VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string - FilesToInstall() InstallPaths PackagingSpecs() []PackagingSpec // TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive @@ -764,6 +763,14 @@ func InitCommonOSAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupport m.base().commonProperties.CreateCommonOSVariant = true } +func ModuleFilesToInstall(ctx OtherModuleProviderContext, m blueprint.Module) InstallPaths { + var filesToInstall InstallPaths + if info, ok := OtherModuleProvider(ctx, m, InstallFilesProvider); ok { + filesToInstall = info.InstallFiles + } + return filesToInstall +} + // A ModuleBase object contains the properties that are common to all Android // modules. It should be included as an anonymous field in every module // struct definition. InitAndroidModule should then be called from the module's @@ -836,7 +843,6 @@ type ModuleBase struct { primaryLicensesProperty applicableLicensesProperty noAddressSanitizer bool - installFiles InstallPaths installFilesDepSet *DepSet[InstallPath] checkbuildFiles Paths packagingSpecs []PackagingSpec @@ -1491,10 +1497,6 @@ func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool { return IsInstallDepNeededTag(tag) } -func (m *ModuleBase) FilesToInstall() InstallPaths { - return m.installFiles -} - func (m *ModuleBase) PackagingSpecs() []PackagingSpec { return m.packagingSpecs } @@ -1634,12 +1636,16 @@ func (m *ModuleBase) SetLicenseInstallMap(installMap []string) { m.licenseInstallMap = append(m.licenseInstallMap, installMap...) } -func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) { +func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { var allInstalledFiles InstallPaths var allCheckbuildFiles Paths ctx.VisitAllModuleVariants(func(module Module) { a := module.base() - allInstalledFiles = append(allInstalledFiles, a.installFiles...) + if a == m { + allInstalledFiles = append(allInstalledFiles, ctx.installFiles...) + } else { + allInstalledFiles = append(allInstalledFiles, ModuleFilesToInstall(ctx, module)...) + } // A module's -checkbuild phony targets should // not be created if the module is not exported to make. // Those could depend on the build target and fail to compile @@ -1782,6 +1788,12 @@ func (m *ModuleBase) archModuleContextFactory(ctx archModuleContextFactoryContex } +type InstallFilesInfo struct { + InstallFiles InstallPaths +} + +var InstallFilesProvider = blueprint.NewProvider[InstallFilesInfo]() + func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) { ctx := &moduleContext{ module: m.module, @@ -1940,7 +1952,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) restored := false if incrementalAnalysis && cacheKey != nil { - restored = ctx.bp.RestoreBuildActions(cacheKey, incrementalModule) + restored = ctx.bp.RestoreBuildActions(cacheKey) } if !restored { @@ -1963,12 +1975,15 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) return } - m.installFiles = append(m.installFiles, ctx.installFiles...) m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...) m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...) m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...) m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...) m.testData = append(m.testData, ctx.testData...) + + SetProvider(ctx, InstallFilesProvider, InstallFilesInfo{ + InstallFiles: ctx.installFiles, + }) } else if ctx.Config().AllowMissingDependencies() { // If the module is not enabled it will not create any build rules, nothing will call // ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled @@ -1984,7 +1999,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) } } - m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, m.installFiles, dependencyInstallFiles) + m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles) m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs) buildLicenseMetadata(ctx, m.licenseMetadataFile) @@ -2538,7 +2553,7 @@ func outputFilesForModuleFromProvider(ctx PathContext, module blueprint.Module, fromProperty = true } } else if cta, isCta := ctx.(*singletonContextAdaptor); isCta { - providerData, _ := cta.moduleProvider(module, OutputFilesProvider) + providerData, _ := cta.otherModuleProvider(module, OutputFilesProvider) outputFiles, _ = providerData.(OutputFilesInfo) } else { return nil, fmt.Errorf("unsupported context %q in method outputFilesForModuleFromProvider", reflect.TypeOf(ctx)) diff --git a/android/prebuilt.go b/android/prebuilt.go index 9c8c13093..fd5a6eaee 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -244,6 +244,8 @@ func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier Pr p.srcsPropertyName = srcsPropertyName } +// InitPrebuiltModule is the same as InitPrebuiltModuleWithSrcSupplier, but uses the +// provided list of strings property as the source provider. func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) { if srcs == nil { panic(fmt.Errorf("srcs must not be nil")) @@ -256,6 +258,20 @@ func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) { InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs") } +// InitConfigurablePrebuiltModule is the same as InitPrebuiltModule, but uses a +// Configurable list of strings property instead of a regular list of strings. +func InitConfigurablePrebuiltModule(module PrebuiltInterface, srcs *proptools.Configurable[[]string]) { + if srcs == nil { + panic(fmt.Errorf("srcs must not be nil")) + } + + srcsSupplier := func(ctx BaseModuleContext, _ Module) []string { + return srcs.GetOrDefault(ctx, nil) + } + + InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs") +} + func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface{}, srcField string) { srcPropsValue := reflect.ValueOf(srcProps).Elem() srcStructField, _ := srcPropsValue.Type().FieldByName(srcField) diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index 6e4fc0c2f..5e4af0ba5 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -574,11 +574,7 @@ func newOverrideSourceModule() Module { func TestPrebuiltErrorCannotListBothSourceAndPrebuiltInContributions(t *testing.T) { selectMainlineModuleContritbutions := GroupFixturePreparers( - FixtureModifyProductVariables(func(variables FixtureProductVariables) { - variables.BuildFlags = map[string]string{ - "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_apex_contributions", - } - }), + PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_apex_contributions"), ) testPrebuiltErrorWithFixture(t, `Found duplicate variations of the same module in apex_contributions: foo and prebuilt_foo. Please remove one of these`, ` source { diff --git a/android/provider.go b/android/provider.go index 3b9c5d2ba..327f224f7 100644 --- a/android/provider.go +++ b/android/provider.go @@ -14,6 +14,8 @@ var _ OtherModuleProviderContext = BaseModuleContext(nil) var _ OtherModuleProviderContext = ModuleContext(nil) var _ OtherModuleProviderContext = BottomUpMutatorContext(nil) var _ OtherModuleProviderContext = TopDownMutatorContext(nil) +var _ OtherModuleProviderContext = SingletonContext(nil) +var _ OtherModuleProviderContext = (*TestContext)(nil) // OtherModuleProvider reads the provider for the given module. If the provider has been set the value is // returned and the boolean is true. If it has not been set the zero value of the provider's type is returned @@ -56,26 +58,6 @@ func ModuleProvider[K any](ctx ModuleProviderContext, provider blueprint.Provide return value.(K), ok } -type SingletonModuleProviderContext interface { - moduleProvider(blueprint.Module, blueprint.AnyProviderKey) (any, bool) -} - -var _ SingletonModuleProviderContext = SingletonContext(nil) -var _ SingletonModuleProviderContext = (*TestContext)(nil) - -// SingletonModuleProvider wraps blueprint.SingletonModuleProvider to provide a type-safe method to retrieve the value -// of the given provider from a module using a SingletonContext. If the provider has not been set the first return -// value will be the zero value of the provider's type, and the second return value will be false. If the provider has -// been set the second return value will be true. -func SingletonModuleProvider[K any](ctx SingletonModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) (K, bool) { - value, ok := ctx.moduleProvider(module, provider) - if !ok { - var k K - return k, false - } - return value.(K), ok -} - // SetProviderContext is a helper interface that is a subset of ModuleContext, BottomUpMutatorContext, or // TopDownMutatorContext for use in SetProvider. type SetProviderContext interface { diff --git a/android/singleton.go b/android/singleton.go index d364384e2..92264d2e3 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -35,7 +35,7 @@ type SingletonContext interface { // Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context. ModuleVariantsFromName(referer Module, name string) []Module - moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) + otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) ModuleErrorf(module blueprint.Module, format string, args ...interface{}) Errorf(format string, args ...interface{}) @@ -279,7 +279,7 @@ func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name st return result } -func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) { +func (s *singletonContextAdaptor) otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) { return s.SingletonContext.ModuleProvider(module, provider) } diff --git a/android/test_suites.go b/android/test_suites.go index ff75f26bb..c0dc17ebd 100644 --- a/android/test_suites.go +++ b/android/test_suites.go @@ -47,7 +47,7 @@ func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) { files[testSuite] = make(map[string]InstallPaths) } name := ctx.ModuleName(m) - files[testSuite][name] = append(files[testSuite][name], tsm.FilesToInstall()...) + files[testSuite][name] = append(files[testSuite][name], ModuleFilesToInstall(ctx, tsm)...) } } }) diff --git a/android/testing.go b/android/testing.go index 3a6643941..79d0c9b41 100644 --- a/android/testing.go +++ b/android/testing.go @@ -179,6 +179,16 @@ var PrepareForTestDisallowNonExistentPaths = FixtureModifyConfig(func(config Con config.TestAllowNonExistentPaths = false }) +// PrepareForTestWithBuildFlag returns a FixturePreparer that sets the given flag to the given value. +func PrepareForTestWithBuildFlag(flag, value string) FixturePreparer { + return FixtureModifyProductVariables(func(variables FixtureProductVariables) { + if variables.BuildFlags == nil { + variables.BuildFlags = make(map[string]string) + } + variables.BuildFlags[flag] = value + }) +} + func NewTestArchContext(config Config) *TestContext { ctx := NewTestContext(config) ctx.preDeps = append(ctx.preDeps, registerArchMutator) @@ -207,7 +217,7 @@ func (ctx *TestContext) HardCodedPreArchMutators(f RegisterMutatorFunc) { ctx.PreArchMutators(f) } -func (ctx *TestContext) moduleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) { +func (ctx *TestContext) otherModuleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) { return ctx.Context.ModuleProvider(m, p) } @@ -225,7 +235,7 @@ func (ctx *TestContext) FinalDepsMutators(f RegisterMutatorFunc) { func (ctx *TestContext) OtherModuleProviderAdaptor() OtherModuleProviderContext { return NewOtherModuleProviderAdaptor(func(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) { - return ctx.moduleProvider(module, provider) + return ctx.otherModuleProvider(module, provider) }) } diff --git a/android/variable.go b/android/variable.go index 4025607d9..c14143748 100644 --- a/android/variable.go +++ b/android/variable.go @@ -513,6 +513,11 @@ type ProductVariables struct { ProductPropFiles []string `json:",omitempty"` EnableUffdGc *string `json:",omitempty"` + + BoardAvbEnable *bool `json:",omitempty"` + BoardAvbSystemAddHashtreeFooterArgs []string `json:",omitempty"` + DeviceFrameworkCompatibilityMatrixFile []string `json:",omitempty"` + DeviceProductCompatibilityMatrixFile []string `json:",omitempty"` } type PartitionQualifiedVariablesType struct { |