diff options
-rw-r--r-- | android/all_teams.go | 12 | ||||
-rw-r--r-- | android/apex.go | 7 | ||||
-rw-r--r-- | android/module.go | 2 | ||||
-rw-r--r-- | android/package.go | 10 | ||||
-rw-r--r-- | android/singleton.go | 4 | ||||
-rw-r--r-- | android/team.go | 12 | ||||
-rw-r--r-- | apex/apex.go | 5 | ||||
-rw-r--r-- | apex/apex_singleton.go | 12 | ||||
-rw-r--r-- | cc/cc.go | 16 | ||||
-rw-r--r-- | cc/ndk_headers.go | 30 | ||||
-rw-r--r-- | cc/ndk_sysroot.go | 67 | ||||
-rw-r--r-- | java/app.go | 5 |
12 files changed, 136 insertions, 46 deletions
diff --git a/android/all_teams.go b/android/all_teams.go index 3b20107b9..8b55adebd 100644 --- a/android/all_teams.go +++ b/android/all_teams.go @@ -78,19 +78,19 @@ func (t *allTeamsSingleton) GenerateBuildActions(ctx SingletonContext) { t.teams = make(map[string]teamProperties) t.teams_for_mods = make(map[string]moduleTeamAndTestInfo) - ctx.VisitAllModules(func(module Module) { + ctx.VisitAllModuleProxies(func(module ModuleProxy) { bpFile := ctx.BlueprintFile(module) // Package Modules and Team Modules are stored in a map so we can look them up by name for // modules without a team. - if pack, ok := module.(*packageModule); ok { + if pack, ok := OtherModuleProvider(ctx, module, PackageInfoProvider); ok { // Packages don't have names, use the blueprint file as the key. we can't get qualifiedModuleId in t context. pkgKey := bpFile - t.packages[pkgKey] = pack.properties + t.packages[pkgKey] = pack.Properties return } - if team, ok := module.(*teamModule); ok { - t.teams[team.Name()] = team.properties + if team, ok := OtherModuleProvider(ctx, module, TeamInfoProvider); ok { + t.teams[module.Name()] = team.Properties return } @@ -116,7 +116,7 @@ func (t *allTeamsSingleton) GenerateBuildActions(ctx SingletonContext) { testOnly: testModInfo.TestOnly, topLevelTestTarget: testModInfo.TopLevelTarget, kind: ctx.ModuleType(module), - teamName: module.base().Team(), + teamName: OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoKey).Team, } t.teams_for_mods[module.Name()] = entry diff --git a/android/apex.go b/android/apex.go index 91fa2c718..4e92f44f6 100644 --- a/android/apex.go +++ b/android/apex.go @@ -646,6 +646,13 @@ type ApexBundleDepsInfoIntf interface { FullListPath() Path } +type ApexBundleDepsData struct { + Updatable bool + FlatListPath Path +} + +var ApexBundleDepsDataProvider = blueprint.NewProvider[ApexBundleDepsData]() + func (d *ApexBundleDepsInfo) FlatListPath() Path { return d.flatListPath } diff --git a/android/module.go b/android/module.go index 984f0372a..d19648124 100644 --- a/android/module.go +++ b/android/module.go @@ -1940,6 +1940,7 @@ type CommonModuleInfo struct { VintfFragmentModuleNames []string Dists []Dist ExportedToMake bool + Team string } type ApiLevelOrPlatform struct { @@ -2300,6 +2301,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) VintfFragmentModuleNames: m.module.VintfFragmentModuleNames(ctx), Dists: m.Dists(), ExportedToMake: m.ExportedToMake(), + Team: m.Team(), } if mm, ok := m.module.(interface { MinSdkVersion(ctx EarlyModuleContext) ApiLevel diff --git a/android/package.go b/android/package.go index 385326e53..42f17b1d5 100644 --- a/android/package.go +++ b/android/package.go @@ -38,6 +38,12 @@ type packageProperties struct { Default_team *string `android:"path"` } +type PackageInfo struct { + Properties packageProperties +} + +var PackageInfoProvider = blueprint.NewProvider[PackageInfo]() + type packageModule struct { ModuleBase @@ -60,6 +66,10 @@ func (p *packageModule) GenerateBuildActions(ctx blueprint.ModuleContext) { Enabled: true, PrimaryLicensesProperty: p.primaryLicensesProperty, }) + + ctx.SetProvider(PackageInfoProvider, PackageInfo{ + Properties: p.properties, + }) } func (p *packageModule) qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName { diff --git a/android/singleton.go b/android/singleton.go index a03ea74aa..96b10223f 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -290,6 +290,10 @@ func (s *singletonContextAdaptor) ModuleType(module blueprint.Module) string { return s.SingletonContext.ModuleType(getWrappedModule(module)) } +func (s *singletonContextAdaptor) BlueprintFile(module blueprint.Module) string { + return s.SingletonContext.BlueprintFile(getWrappedModule(module)) +} + func (s *singletonContextAdaptor) VisitAllModulesBlueprint(visit func(blueprint.Module)) { s.SingletonContext.VisitAllModules(visit) } diff --git a/android/team.go b/android/team.go index c273dc647..ad37f28c9 100644 --- a/android/team.go +++ b/android/team.go @@ -32,6 +32,12 @@ type teamProperties struct { Trendy_team_id *string `json:"trendy_team_id"` } +type TeamInfo struct { + Properties teamProperties +} + +var TeamInfoProvider = blueprint.NewProvider[TeamInfo]() + type teamModule struct { ModuleBase DefaultableModuleBase @@ -48,7 +54,11 @@ var TestOnlyProviderKey = blueprint.NewProvider[TestModuleInformation]() // Real work is done for the module that depends on us. // If needed, the team can serialize the config to json/proto file as well. -func (t *teamModule) GenerateAndroidBuildActions(ctx ModuleContext) {} +func (t *teamModule) GenerateAndroidBuildActions(ctx ModuleContext) { + SetProvider(ctx, TeamInfoProvider, TeamInfo{ + Properties: t.properties, + }) +} func (t *teamModule) TrendyTeamId(ctx ModuleContext) string { return *t.properties.Trendy_team_id diff --git a/apex/apex.go b/apex/apex.go index 6e4685b1f..4dd3d4cc0 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2258,6 +2258,11 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.enforcePartitionTagOnApexSystemServerJar(ctx) a.verifyNativeImplementationLibs(ctx) + + android.SetProvider(ctx, android.ApexBundleDepsDataProvider, android.ApexBundleDepsData{ + FlatListPath: a.FlatListPath(), + Updatable: a.Updatable(), + }) } // Set prebuiltInfoProvider. This will be used by `apex_prebuiltinfo_singleton` to print out a metadata file diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index a8bd984b2..dabec4930 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -90,11 +90,11 @@ var ( func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) { updatableFlatLists := android.Paths{} - ctx.VisitAllModules(func(module android.Module) { - if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if binaryInfo, ok := android.OtherModuleProvider(ctx, module, android.ApexBundleDepsDataProvider); ok { apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider) - if path := binaryInfo.FlatListPath(); path != nil { - if binaryInfo.Updatable() || apexInfo.Updatable { + if path := binaryInfo.FlatListPath; path != nil { + if binaryInfo.Updatable || apexInfo.Updatable { if strings.HasPrefix(module.String(), "com.android.") { updatableFlatLists = append(updatableFlatLists, path) } @@ -160,11 +160,11 @@ type apexPrebuiltInfo struct { func (a *apexPrebuiltInfo) GenerateBuildActions(ctx android.SingletonContext) { prebuiltInfos := []android.PrebuiltInfo{} - ctx.VisitAllModules(func(m android.Module) { + ctx.VisitAllModuleProxies(func(m android.ModuleProxy) { prebuiltInfo, exists := android.OtherModuleProvider(ctx, m, android.PrebuiltInfoProvider) // Use prebuiltInfoProvider to filter out non apex soong modules. // Use HideFromMake to filter out the unselected variants of a specific apex. - if exists && !m.IsHideFromMake() { + if exists && !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoKey).HideFromMake { prebuiltInfos = append(prebuiltInfos, prebuiltInfo) } }) @@ -93,6 +93,9 @@ type BinaryDecoratorInfo struct{} type LibraryDecoratorInfo struct { ExportIncludeDirs []string InjectBsslHash bool + // Location of the static library in the sysroot. Empty if the library is + // not included in the NDK. + NdkSysrootPath android.Path } type SnapshotInfo struct { @@ -108,9 +111,14 @@ type StubDecoratorInfo struct { AbiDumpPath android.OutputPath HasAbiDump bool AbiDiffPaths android.Paths + InstallPath android.Path } -type ObjectLinkerInfo struct{} +type ObjectLinkerInfo struct { + // Location of the object in the sysroot. Empty if the object is not + // included in the NDK. + NdkSysrootPath android.Path +} type LibraryInfo struct { BuildStubs bool @@ -2343,6 +2351,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { case *libraryDecorator: ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{ InjectBsslHash: Bool(c.linker.(*libraryDecorator).Properties.Inject_bssl_hash), + NdkSysrootPath: c.linker.(*libraryDecorator).ndkSysrootPath, } case *testBinary: ccInfo.LinkerInfo.TestBinaryInfo = &TestBinaryInfo{ @@ -2351,7 +2360,9 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { case *benchmarkDecorator: ccInfo.LinkerInfo.BenchmarkDecoratorInfo = &BenchmarkDecoratorInfo{} case *objectLinker: - ccInfo.LinkerInfo.ObjectLinkerInfo = &ObjectLinkerInfo{} + ccInfo.LinkerInfo.ObjectLinkerInfo = &ObjectLinkerInfo{ + NdkSysrootPath: c.linker.(*objectLinker).ndkSysrootPath, + } case *stubDecorator: ccInfo.LinkerInfo.StubDecoratorInfo = &StubDecoratorInfo{} } @@ -2378,6 +2389,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { HasAbiDump: installer.hasAbiDump, AbiDumpPath: installer.abiDumpPath, AbiDiffPaths: installer.abiDiffPaths, + InstallPath: installer.installPath, } } } diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go index 74819540b..6e26d4c87 100644 --- a/cc/ndk_headers.go +++ b/cc/ndk_headers.go @@ -80,6 +80,20 @@ type headerModule struct { licensePath android.Path } +type NdkHeaderInfo struct { + SrcPaths android.Paths + InstallPaths android.Paths + LicensePath android.Path + // Set to true if the headers installed by this module should skip + // verification. This step ensures that each header is self-contained (can + // be #included alone) and is valid C. This should not be disabled except in + // rare cases. Outside bionic and external, if you're using this option + // you've probably made a mistake. + SkipVerification bool +} + +var NdkHeaderInfoProvider = blueprint.NewProvider[NdkHeaderInfo]() + func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string, to string) android.OutputPath { // Output path is the sysroot base + "usr/include" + to directory + directory component @@ -135,6 +149,13 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { if len(m.installPaths) == 0 { ctx.ModuleErrorf("srcs %q matched zero files", m.properties.Srcs) } + + android.SetProvider(ctx, NdkHeaderInfoProvider, NdkHeaderInfo{ + SrcPaths: m.srcPaths, + InstallPaths: m.installPaths, + LicensePath: m.licensePath, + SkipVerification: Bool(m.properties.Skip_verification), + }) } // ndk_headers installs the sets of ndk headers defined in the srcs property @@ -203,6 +224,8 @@ type preprocessedHeadersModule struct { licensePath android.Path } +var NdkPreprocessedHeaderInfoProvider = blueprint.NewProvider[NdkHeaderInfo]() + func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { if String(m.properties.License) == "" { ctx.PropertyErrorf("license", "field is required") @@ -231,6 +254,13 @@ func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.Modu if len(m.installPaths) == 0 { ctx.ModuleErrorf("srcs %q matched zero files", m.properties.Srcs) } + + android.SetProvider(ctx, NdkPreprocessedHeaderInfoProvider, NdkHeaderInfo{ + SrcPaths: m.srcPaths, + InstallPaths: m.installPaths, + LicensePath: m.licensePath, + SkipVerification: Bool(m.properties.Skip_verification), + }) } // preprocessed_ndk_headers preprocesses all the ndk headers listed in the srcs diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index a5f014b9f..34f6195a5 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go @@ -53,11 +53,12 @@ package cc // TODO(danalbert): Write `ndk_static_library` rule. import ( - "android/soong/android" "fmt" "path/filepath" "strings" + "android/soong/android" + "github.com/google/blueprint" ) @@ -209,57 +210,61 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { var headerCCompatVerificationTimestampPaths android.Paths var installPaths android.Paths var licensePaths android.Paths - ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + + if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled { return } - if m, ok := module.(*headerModule); ok { - headerSrcPaths = append(headerSrcPaths, m.srcPaths...) - headerInstallPaths = append(headerInstallPaths, m.installPaths...) - if !Bool(m.properties.Skip_verification) { - for i, installPath := range m.installPaths { + if m, ok := android.OtherModuleProvider(ctx, module, NdkHeaderInfoProvider); ok { + headerSrcPaths = append(headerSrcPaths, m.SrcPaths...) + headerInstallPaths = append(headerInstallPaths, m.InstallPaths...) + if !m.SkipVerification { + for i, installPath := range m.InstallPaths { headersToVerify = append(headersToVerify, srcDestPair{ - src: m.srcPaths[i], + src: m.SrcPaths[i], dest: installPath, }) } } - installPaths = append(installPaths, m.installPaths...) - licensePaths = append(licensePaths, m.licensePath) + installPaths = append(installPaths, m.InstallPaths...) + licensePaths = append(licensePaths, m.LicensePath) } - if m, ok := module.(*preprocessedHeadersModule); ok { - headerSrcPaths = append(headerSrcPaths, m.srcPaths...) - headerInstallPaths = append(headerInstallPaths, m.installPaths...) - if !Bool(m.properties.Skip_verification) { - for i, installPath := range m.installPaths { + if m, ok := android.OtherModuleProvider(ctx, module, NdkPreprocessedHeaderInfoProvider); ok { + headerSrcPaths = append(headerSrcPaths, m.SrcPaths...) + headerInstallPaths = append(headerInstallPaths, m.InstallPaths...) + if !m.SkipVerification { + for i, installPath := range m.InstallPaths { headersToVerify = append(headersToVerify, srcDestPair{ - src: m.srcPaths[i], + src: m.SrcPaths[i], dest: installPath, }) } } - installPaths = append(installPaths, m.installPaths...) - licensePaths = append(licensePaths, m.licensePath) + installPaths = append(installPaths, m.InstallPaths...) + licensePaths = append(licensePaths, m.LicensePath) } - if m, ok := module.(*Module); ok { - if installer, ok := m.installer.(*stubDecorator); ok && m.library.BuildStubs() { - installPaths = append(installPaths, installer.installPath) + if ccInfo, ok := android.OtherModuleProvider(ctx, module, CcInfoProvider); ok { + if installer := ccInfo.InstallerInfo; installer != nil && installer.StubDecoratorInfo != nil && + ccInfo.LibraryInfo != nil && ccInfo.LibraryInfo.BuildStubs { + installPaths = append(installPaths, installer.StubDecoratorInfo.InstallPath) } - if library, ok := m.linker.(*libraryDecorator); ok { - if library.ndkSysrootPath != nil { - staticLibInstallPaths = append( - staticLibInstallPaths, library.ndkSysrootPath) + if ccInfo.LinkerInfo != nil { + if library := ccInfo.LinkerInfo.LibraryDecoratorInfo; library != nil { + if library.NdkSysrootPath != nil { + staticLibInstallPaths = append( + staticLibInstallPaths, library.NdkSysrootPath) + } } - } - if object, ok := m.linker.(*objectLinker); ok { - if object.ndkSysrootPath != nil { - staticLibInstallPaths = append( - staticLibInstallPaths, object.ndkSysrootPath) + if object := ccInfo.LinkerInfo.ObjectLinkerInfo; object != nil { + if object.NdkSysrootPath != nil { + staticLibInstallPaths = append( + staticLibInstallPaths, object.NdkSysrootPath) + } } } } diff --git a/java/app.go b/java/app.go index 17548e74a..827b23526 100644 --- a/java/app.go +++ b/java/app.go @@ -1124,6 +1124,11 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { android.SetProvider(ctx, JavaInfoProvider, javaInfo) } + android.SetProvider(ctx, android.ApexBundleDepsDataProvider, android.ApexBundleDepsData{ + FlatListPath: a.FlatListPath(), + Updatable: a.Updatable(), + }) + moduleInfoJSON := ctx.ModuleInfoJSON() moduleInfoJSON.Class = []string{"APPS"} if !a.embeddedJniLibs { |