diff options
| -rw-r--r-- | android/androidmk.go | 6 | ||||
| -rw-r--r-- | android/apex.go | 2 | ||||
| -rw-r--r-- | android/arch.go | 24 | ||||
| -rw-r--r-- | android/base_module_context.go | 6 | ||||
| -rw-r--r-- | android/config.go | 11 | ||||
| -rw-r--r-- | android/container.go | 2 | ||||
| -rw-r--r-- | android/gen_notice.go | 67 | ||||
| -rw-r--r-- | android/module.go | 27 | ||||
| -rw-r--r-- | android/notices.go | 18 | ||||
| -rw-r--r-- | android/paths.go | 8 | ||||
| -rw-r--r-- | android/prebuilt.go | 2 | ||||
| -rw-r--r-- | android/singleton.go | 44 | ||||
| -rw-r--r-- | android/visibility.go | 72 | ||||
| -rw-r--r-- | android/visibility_test.go | 5 | ||||
| -rw-r--r-- | apex/apex.go | 6 | ||||
| -rw-r--r-- | apex/prebuilt.go | 5 | ||||
| -rw-r--r-- | cc/cc.go | 2 | ||||
| -rw-r--r-- | cc/library.go | 28 | ||||
| -rw-r--r-- | cc/tidy.go | 10 | ||||
| -rw-r--r-- | dexpreopt/config.go | 4 | ||||
| -rw-r--r-- | filesystem/android_device.go | 54 | ||||
| -rw-r--r-- | filesystem/filesystem.go | 20 | ||||
| -rw-r--r-- | filesystem/system_other.go | 21 | ||||
| -rw-r--r-- | java/app.go | 2 | ||||
| -rw-r--r-- | java/java.go | 9 | ||||
| -rw-r--r-- | java/jdeps.go | 21 | ||||
| -rw-r--r-- | rust/config/OWNERS | 2 | ||||
| -rw-r--r-- | rust/library_test.go | 39 | ||||
| -rw-r--r-- | scripts/microfactory.bash | 9 | ||||
| -rw-r--r-- | ui/build/androidmk_denylist.go | 11 | ||||
| -rw-r--r-- | ui/build/config.go | 19 | ||||
| -rw-r--r-- | ui/build/path.go | 5 |
32 files changed, 370 insertions, 191 deletions
diff --git a/android/androidmk.go b/android/androidmk.go index 6a1701df3..e4366fad2 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -78,6 +78,12 @@ type AndroidMkData struct { Entries AndroidMkEntries } +type AndroidMkDataInfo struct { + Class string +} + +var AndroidMkDataInfoProvider = blueprint.NewProvider[AndroidMkDataInfo]() + type AndroidMkExtraFunc func(w io.Writer, outputFile Path) // Interface for modules to declare their Android.mk outputs. Note that every module needs to diff --git a/android/apex.go b/android/apex.go index 4e92f44f6..39de6de33 100644 --- a/android/apex.go +++ b/android/apex.go @@ -196,7 +196,7 @@ func IsDepInSameApex(ctx BaseModuleContext, module, dep Module) bool { return false } - if !ctx.EqualModules(ctx.Module(), module) { + if !EqualModules(ctx.Module(), module) { if moduleInfo, ok := OtherModuleProvider(ctx, module, DepInSameApexInfoProvider); ok { if !moduleInfo.Checker.OutgoingDepIsInSameApex(depTag) { return false diff --git a/android/arch.go b/android/arch.go index 3cd6e4b7a..d6b297119 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1553,7 +1553,7 @@ func determineBuildOS(config *config) { config.BuildOS = func() OsType { switch runtime.GOOS { case "linux": - if Bool(config.productVariables.HostMusl) { + if Bool(config.productVariables.HostMusl) || runtime.GOARCH == "arm64" { return LinuxMusl } return Linux @@ -1565,11 +1565,25 @@ func determineBuildOS(config *config) { }() config.BuildArch = func() ArchType { - switch runtime.GOARCH { - case "amd64": - return X86_64 + switch runtime.GOOS { + case "linux": + switch runtime.GOARCH { + case "amd64": + return X86_64 + case "arm64": + return Arm64 + default: + panic(fmt.Sprintf("unsupported arch: %s", runtime.GOARCH)) + } + case "darwin": + switch runtime.GOARCH { + case "amd64": + return X86_64 + default: + panic(fmt.Sprintf("unsupported arch: %s", runtime.GOARCH)) + } default: - panic(fmt.Sprintf("unsupported Arch: %s", runtime.GOARCH)) + panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS)) } }() diff --git a/android/base_module_context.go b/android/base_module_context.go index 5e05f547a..d2404fd3e 100644 --- a/android/base_module_context.go +++ b/android/base_module_context.go @@ -34,8 +34,6 @@ type BaseModuleContext interface { blueprintBaseModuleContext() blueprint.BaseModuleContext - EqualModules(m1, m2 Module) bool - // OtherModuleName returns the name of another Module. See BaseModuleContext.ModuleName for more information. // It is intended for use inside the visit functions of Visit* and WalkDeps. OtherModuleName(m blueprint.Module) string @@ -271,8 +269,8 @@ func getWrappedModule(module blueprint.Module) blueprint.Module { return module } -func (b *baseModuleContext) EqualModules(m1, m2 Module) bool { - return b.bp.EqualModules(getWrappedModule(m1), getWrappedModule(m2)) +func EqualModules(m1, m2 Module) bool { + return blueprint.EqualModules(getWrappedModule(m1), getWrappedModule(m2)) } func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string { diff --git a/android/config.go b/android/config.go index 0a1ed98d2..696e7727f 100644 --- a/android/config.go +++ b/android/config.go @@ -814,11 +814,18 @@ func (c *config) HostCcSharedLibPath(ctx PathContext, lib string) Path { func (c *config) PrebuiltOS() string { switch runtime.GOOS { case "linux": - return "linux-x86" + switch runtime.GOARCH { + case "amd64": + return "linux-x86" + case "arm64": + return "linux-arm64" + default: + panic(fmt.Errorf("Unknown GOARCH %s", runtime.GOARCH)) + } case "darwin": return "darwin-x86" default: - panic("Unknown GOOS") + panic(fmt.Errorf("Unknown GOOS %s", runtime.GOOS)) } } diff --git a/android/container.go b/android/container.go index 5dc97d38e..a5aab79bb 100644 --- a/android/container.go +++ b/android/container.go @@ -449,7 +449,7 @@ func generateContainerInfo(ctx ModuleContext) ContainersInfo { } func getContainerModuleInfo(ctx ModuleContext, module Module) (ContainersInfo, bool) { - if ctx.EqualModules(ctx.Module(), module) { + if EqualModules(ctx.Module(), module) { return ctx.getContainersInfo(), true } diff --git a/android/gen_notice.go b/android/gen_notice.go index 9adde9e9b..482b1e006 100644 --- a/android/gen_notice.go +++ b/android/gen_notice.go @@ -19,6 +19,7 @@ import ( "path/filepath" "strings" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -35,34 +36,31 @@ func RegisterGenNoticeBuildComponents(ctx RegistrationContext) { type genNoticeBuildRules struct{} func (s *genNoticeBuildRules) GenerateBuildActions(ctx SingletonContext) { - ctx.VisitAllModules(func(m Module) { - gm, ok := m.(*genNoticeModule) + ctx.VisitAllModuleProxies(func(m ModuleProxy) { + gm, ok := OtherModuleProvider(ctx, m, GenNoticeInfoProvider) if !ok { return } - if len(gm.missing) > 0 { - missingReferencesRule(ctx, gm) + if len(gm.Missing) > 0 { + missingReferencesRule(ctx, m, &gm) return } out := BuildNoticeTextOutputFromLicenseMetadata - if proptools.Bool(gm.properties.Xml) { + if gm.Xml { out = BuildNoticeXmlOutputFromLicenseMetadata - } else if proptools.Bool(gm.properties.Html) { + } else if gm.Html { out = BuildNoticeHtmlOutputFromLicenseMetadata } defaultName := "" - if len(gm.properties.For) > 0 { - defaultName = gm.properties.For[0] + if len(gm.For) > 0 { + defaultName = gm.For[0] } - modules := make([]Module, 0) - for _, name := range gm.properties.For { - mods := ctx.ModuleVariantsFromName(gm, name) + modules := make([]ModuleProxy, 0) + for _, name := range gm.For { + mods := ctx.ModuleVariantsFromName(m, name) for _, mod := range mods { - if mod == nil { - continue - } - if !mod.Enabled(ctx) { // don't depend on variants without build rules + if !OtherModuleProviderOrDefault(ctx, mod, CommonModuleInfoKey).Enabled { // don't depend on variants without build rules continue } modules = append(modules, mod) @@ -71,8 +69,8 @@ func (s *genNoticeBuildRules) GenerateBuildActions(ctx SingletonContext) { if ctx.Failed() { return } - out(ctx, gm.output, ctx.ModuleName(gm), - proptools.StringDefault(gm.properties.ArtifactName, defaultName), + out(ctx, gm.Output, ctx.ModuleName(m), + proptools.StringDefault(gm.ArtifactName, defaultName), []string{ filepath.Join(ctx.Config().OutDir(), "target", "product", ctx.Config().DeviceName()) + "/", ctx.Config().OutDir() + "/", @@ -115,6 +113,22 @@ type genNoticeModule struct { missing []string } +type GenNoticeInfo struct { + // For specifies the modules for which to generate a notice file. + For []string + // ArtifactName specifies the internal name to use for the notice file. + // It appears in the "used by:" list for targets whose entire name is stripped by --strip_prefix. + ArtifactName *string + // Html indicates an html-format file is needed. The default is text. Can be Html or Xml but not both. + Html bool + // Xml indicates an xml-format file is needed. The default is text. Can be Html or Xml but not both. + Xml bool + Output OutputPath + Missing []string +} + +var GenNoticeInfoProvider = blueprint.NewProvider[GenNoticeInfo]() + func (m *genNoticeModule) DepsMutator(ctx BottomUpMutatorContext) { if ctx.ContainsProperty("licenses") { ctx.PropertyErrorf("licenses", "not supported on \"gen_notice\" modules") @@ -176,6 +190,15 @@ func (m *genNoticeModule) GenerateAndroidBuildActions(ctx ModuleContext) { } out := m.getStem() + m.getSuffix() m.output = PathForModuleOut(ctx, out).OutputPath + + SetProvider(ctx, GenNoticeInfoProvider, GenNoticeInfo{ + For: m.properties.For, + ArtifactName: m.properties.ArtifactName, + Xml: proptools.Bool(m.properties.Xml), + Html: proptools.Bool(m.properties.Html), + Output: m.output, + Missing: m.missing, + }) ctx.SetOutputFiles(Paths{m.output}, "") } @@ -205,17 +228,17 @@ func (m *genNoticeModule) AndroidMkEntries() []AndroidMkEntries { } // missingReferencesRule emits an ErrorRule for missing module references. -func missingReferencesRule(ctx BuilderContext, m *genNoticeModule) { - if len(m.missing) < 1 { +func missingReferencesRule(ctx BuilderContext, m ModuleProxy, genInfo *GenNoticeInfo) { + if len(genInfo.Missing) < 1 { panic(fmt.Errorf("missing references rule requested with no missing references")) } ctx.Build(pctx, BuildParams{ Rule: ErrorRule, - Output: m.output, - Description: "notice for " + proptools.StringDefault(m.properties.ArtifactName, "container"), + Output: genInfo.Output, + Description: "notice for " + proptools.StringDefault(genInfo.ArtifactName, "container"), Args: map[string]string{ - "error": m.Name() + " references missing module(s): " + strings.Join(m.missing, ", "), + "error": m.Name() + " references missing module(s): " + strings.Join(genInfo.Missing, ", "), }, }) } diff --git a/android/module.go b/android/module.go index 622399bb6..405573c1b 100644 --- a/android/module.go +++ b/android/module.go @@ -1662,7 +1662,7 @@ func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) { var checkbuildTarget Path var uncheckedModule bool var skipAndroidMkProcessing bool - if ctx.EqualModules(m.module, module) { + if EqualModules(m.module, module) { allInstalledFiles = append(allInstalledFiles, ctx.installFiles...) checkbuildTarget = ctx.checkbuildTarget uncheckedModule = ctx.uncheckedModule @@ -2370,8 +2370,16 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) }) } - if v, ok := m.module.(ModuleMakeVarsProvider); m.Enabled(ctx) && ok { - SetProvider(ctx, ModuleMakeVarsInfoProvider, v.MakeVars(ctx)) + if m.Enabled(ctx) { + if v, ok := m.module.(ModuleMakeVarsProvider); ok { + SetProvider(ctx, ModuleMakeVarsInfoProvider, v.MakeVars(ctx)) + } + + if am, ok := m.module.(AndroidMkDataProvider); ok { + SetProvider(ctx, AndroidMkDataInfoProvider, AndroidMkDataInfo{ + Class: am.AndroidMk().Class, + }) + } } } @@ -2928,7 +2936,6 @@ type OutputFilesProviderModuleContext interface { OtherModuleProviderContext Module() Module GetOutputFiles() OutputFilesInfo - EqualModules(m1, m2 Module) bool } // TODO(b/397766191): Change the signature to take ModuleProxy @@ -2940,7 +2947,7 @@ func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, er } if octx, ok := ctx.(OutputFilesProviderModuleContext); ok { - if octx.EqualModules(octx.Module(), module) { + if EqualModules(octx.Module(), module) { // It is the current module, we can access the srcs through interface if sourceFileProducer, ok := module.(SourceFileProducer); ok { return sourceFileProducer.Srcs(), nil @@ -2967,7 +2974,7 @@ func outputFilesForModuleFromProvider(ctx PathContext, module Module, tag string var outputFiles OutputFilesInfo if mctx, isMctx := ctx.(OutputFilesProviderModuleContext); isMctx { - if !mctx.EqualModules(mctx.Module(), module) { + if !EqualModules(mctx.Module(), module) { outputFiles, _ = OtherModuleProvider(mctx, module, OutputFilesProvider) } else { outputFiles = mctx.GetOutputFiles() @@ -3173,14 +3180,6 @@ type IDEInfo interface { BaseModuleName() string } -// Extract the base module name from the Import name. -// Often the Import name has a prefix "prebuilt_". -// Remove the prefix explicitly if needed -// until we find a better solution to get the Import name. -type IDECustomizedModuleName interface { - IDECustomizedModuleName() string -} - // Collect information for opening IDE project files in java/jdeps.go. type IdeInfo struct { BaseModuleName string `json:"-"` diff --git a/android/notices.go b/android/notices.go index 3c41d924e..dc2290cce 100644 --- a/android/notices.go +++ b/android/notices.go @@ -18,9 +18,11 @@ import ( "fmt" "path/filepath" "strings" + + "github.com/google/blueprint" ) -func modulesOutputDirs(ctx BuilderContext, modules ...Module) []string { +func modulesOutputDirs(ctx BuilderContext, modules ...ModuleProxy) []string { dirs := make([]string, 0, len(modules)) for _, module := range modules { paths, err := outputFilesForModule(ctx, module, "") @@ -41,12 +43,12 @@ type BuilderAndOtherModuleProviderContext interface { OtherModuleProviderContext } -func modulesLicenseMetadata(ctx OtherModuleProviderContext, modules ...Module) Paths { +func modulesLicenseMetadata(ctx OtherModuleProviderContext, modules ...ModuleProxy) Paths { result := make(Paths, 0, len(modules)) mctx, isMctx := ctx.(ModuleContext) for _, module := range modules { var mf Path - if isMctx && mctx.Module() == module { + if isMctx && EqualModules(mctx.Module(), module) { mf = mctx.LicenseMetadataFile() } else { mf = OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider).LicenseMetadataFile @@ -61,12 +63,12 @@ func modulesLicenseMetadata(ctx OtherModuleProviderContext, modules ...Module) P // buildNoticeOutputFromLicenseMetadata writes out a notice file. func buildNoticeOutputFromLicenseMetadata( ctx BuilderAndOtherModuleProviderContext, tool, ruleName string, outputFile WritablePath, - libraryName string, stripPrefix []string, modules ...Module) { + libraryName string, stripPrefix []string, modules ...ModuleProxy) { depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", ".")) rule := NewRuleBuilder(pctx, ctx) if len(modules) == 0 { if mctx, ok := ctx.(ModuleContext); ok { - modules = []Module{mctx.Module()} + modules = []ModuleProxy{{blueprint.CreateModuleProxy(mctx.Module())}} } else { panic(fmt.Errorf("%s %q needs a module to generate the notice for", ruleName, libraryName)) } @@ -97,7 +99,7 @@ func buildNoticeOutputFromLicenseMetadata( // current context module if none given. func BuildNoticeTextOutputFromLicenseMetadata( ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string, - stripPrefix []string, modules ...Module) { + stripPrefix []string, modules ...ModuleProxy) { buildNoticeOutputFromLicenseMetadata(ctx, "textnotice", "text_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...) } @@ -107,7 +109,7 @@ func BuildNoticeTextOutputFromLicenseMetadata( // current context module if none given. func BuildNoticeHtmlOutputFromLicenseMetadata( ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string, - stripPrefix []string, modules ...Module) { + stripPrefix []string, modules ...ModuleProxy) { buildNoticeOutputFromLicenseMetadata(ctx, "htmlnotice", "html_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...) } @@ -117,7 +119,7 @@ func BuildNoticeHtmlOutputFromLicenseMetadata( // current context module if none given. func BuildNoticeXmlOutputFromLicenseMetadata( ctx BuilderAndOtherModuleProviderContext, outputFile WritablePath, ruleName, libraryName string, - stripPrefix []string, modules ...Module) { + stripPrefix []string, modules ...ModuleProxy) { buildNoticeOutputFromLicenseMetadata(ctx, "xmlnotice", "xml_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...) } diff --git a/android/paths.go b/android/paths.go index a944c48db..9c0c9a273 100644 --- a/android/paths.go +++ b/android/paths.go @@ -209,6 +209,10 @@ type ModuleErrorfContext interface { var _ ModuleErrorfContext = blueprint.ModuleContext(nil) +type AddMissingDependenciesContext interface { + AddMissingDependencies([]string) +} + // reportPathError will register an error with the attached context. It // attempts ctx.ModuleErrorf for a better error message first, then falls // back to ctx.Errorf. @@ -220,7 +224,9 @@ func reportPathError(ctx PathContext, err error) { // attempts ctx.ModuleErrorf for a better error message first, then falls // back to ctx.Errorf. func ReportPathErrorf(ctx PathContext, format string, args ...interface{}) { - if mctx, ok := ctx.(ModuleErrorfContext); ok { + if mctx, ok := ctx.(AddMissingDependenciesContext); ok && ctx.Config().AllowMissingDependencies() { + mctx.AddMissingDependencies([]string{fmt.Sprintf(format, args...)}) + } else if mctx, ok := ctx.(ModuleErrorfContext); ok { mctx.ModuleErrorf(format, args...) } else if ectx, ok := ctx.(errorfContext); ok { ectx.Errorf(format, args...) diff --git a/android/prebuilt.go b/android/prebuilt.go index 72735991d..4a94c0bcb 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -412,7 +412,7 @@ func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module { if prebuiltMod != nil { return false } - if ctx.EqualModules(parent, ctx.Module()) { + if EqualModules(parent, ctx.Module()) { // First level: Only recurse if the module is found as a direct dependency. sourceModDepFound = child == module return sourceModDepFound diff --git a/android/singleton.go b/android/singleton.go index 96b10223f..e5f26842a 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -36,7 +36,7 @@ type SingletonContext interface { // ModuleVariantsFromName returns the list of module variants named `name` in the same namespace as `referer` enforcing visibility rules. // Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context. - ModuleVariantsFromName(referer Module, name string) []Module + ModuleVariantsFromName(referer ModuleProxy, name string) []ModuleProxy otherModuleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) @@ -331,7 +331,7 @@ func (s *singletonContextAdaptor) VisitAllModuleVariants(module Module, visit fu } func (s *singletonContextAdaptor) VisitAllModuleVariantProxies(module Module, visit func(proxy ModuleProxy)) { - s.SingletonContext.VisitAllModuleVariantProxies(module, visitProxyAdaptor(visit)) + s.SingletonContext.VisitAllModuleVariantProxies(getWrappedModule(module), visitProxyAdaptor(visit)) } func (s *singletonContextAdaptor) PrimaryModule(module Module) Module { @@ -343,32 +343,30 @@ func (s *singletonContextAdaptor) PrimaryModuleProxy(module ModuleProxy) ModuleP } func (s *singletonContextAdaptor) IsFinalModule(module Module) bool { - return s.SingletonContext.IsFinalModule(module) + return s.SingletonContext.IsFinalModule(getWrappedModule(module)) } -func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name string) []Module { +func (s *singletonContextAdaptor) ModuleVariantsFromName(referer ModuleProxy, name string) []ModuleProxy { // get module reference for visibility enforcement - qualified := createVisibilityModuleReference(s.ModuleName(referer), s.ModuleDir(referer), referer) - - modules := s.SingletonContext.ModuleVariantsFromName(referer, name) - result := make([]Module, 0, len(modules)) - for _, m := range modules { - if module, ok := m.(Module); ok { - // enforce visibility - depName := s.ModuleName(module) - depDir := s.ModuleDir(module) - depQualified := qualifiedModuleName{depDir, depName} - // Targets are always visible to other targets in their own package. - if depQualified.pkg != qualified.name.pkg { - rule := effectiveVisibilityRules(s.Config(), depQualified) - if !rule.matches(qualified) { - s.ModuleErrorf(referer, "module %q references %q which is not visible to this module\nYou may need to add %q to its visibility", - referer.Name(), depQualified, "//"+s.ModuleDir(referer)) - continue - } + qualified := createVisibilityModuleProxyReference(s, s.ModuleName(referer), s.ModuleDir(referer), referer) + + modules := s.SingletonContext.ModuleVariantsFromName(referer.module, name) + result := make([]ModuleProxy, 0, len(modules)) + for _, module := range modules { + // enforce visibility + depName := s.ModuleName(module) + depDir := s.ModuleDir(module) + depQualified := qualifiedModuleName{depDir, depName} + // Targets are always visible to other targets in their own package. + if depQualified.pkg != qualified.name.pkg { + rule := effectiveVisibilityRules(s.Config(), depQualified) + if !rule.matches(qualified) { + s.ModuleErrorf(referer, "module %q references %q which is not visible to this module\nYou may need to add %q to its visibility", + referer.Name(), depQualified, "//"+s.ModuleDir(referer)) + continue } - result = append(result, module) } + result = append(result, ModuleProxy{module}) } return result } diff --git a/android/visibility.go b/android/visibility.go index 4837c7d4b..416a3f15f 100644 --- a/android/visibility.go +++ b/android/visibility.go @@ -58,15 +58,29 @@ const ( var visibilityRuleRegexp = regexp.MustCompile(visibilityRulePattern) type visibilityModuleReference struct { - name qualifiedModuleName - module Module + name qualifiedModuleName + partitionType *string } func createVisibilityModuleReference(name, dir string, module Module) visibilityModuleReference { - return visibilityModuleReference{ - name: createQualifiedModuleName(name, dir), - module: module, + vis := visibilityModuleReference{ + name: createQualifiedModuleName(name, dir), } + if m, ok := module.(PartitionTypeInterface); ok { + pt := m.PartitionType() + vis.partitionType = &pt + } + return vis +} + +func createVisibilityModuleProxyReference(ctx OtherModuleProviderContext, name, dir string, module ModuleProxy) visibilityModuleReference { + vis := visibilityModuleReference{ + name: createQualifiedModuleName(name, dir), + } + if m, ok := OtherModuleProvider(ctx, module, PartitionTypeInfoProvider); ok { + vis.partitionType = &m.PartitionType + } + return vis } // A visibility rule is associated with a module and determines which other modules it is visible @@ -222,9 +236,17 @@ type PartitionTypeInterface interface { PartitionType() string } +type PartitionTypeInfo struct { + // Identifies which partition this is for //visibility:any_system_image (and others) visibility + // checks, and will be used in the future for API surface checks. + PartitionType string +} + +var PartitionTypeInfoProvider = blueprint.NewProvider[PartitionTypeInfo]() + func (r anyPartitionRule) matches(m visibilityModuleReference) bool { - if m2, ok := m.module.(PartitionTypeInterface); ok { - return m2.PartitionType() == r.partitionType + if m.partitionType != nil { + return *m.partitionType == r.partitionType } return false } @@ -647,42 +669,6 @@ func (v *visibilityRuleSet) Strings() []string { return v.rules } -// Get the effective visibility rules, i.e. the actual rules that affect the visibility of the -// property irrespective of where they are defined. -// -// Includes visibility rules specified by package default_visibility and/or on defaults. -// Short hand forms, e.g. //:__subpackages__ are replaced with their full form, e.g. -// //package/containing/rule:__subpackages__. -func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) VisibilityRuleSet { - moduleName := ctx.OtherModuleName(module) - dir := ctx.OtherModuleDir(module) - qualified := qualifiedModuleName{dir, moduleName} - - rule := effectiveVisibilityRules(ctx.Config(), qualified) - - currentModule := createVisibilityModuleReference(moduleName, dir, module) - - // Modules are implicitly visible to other modules in the same package, - // without checking the visibility rules. Here we need to add that visibility - // explicitly. - if !rule.matches(currentModule) { - if len(rule) == 1 { - if _, ok := rule[0].(privateRule); ok { - // If the rule is //visibility:private we can't append another - // visibility to it. Semantically we need to convert it to a package - // visibility rule for the location where the result is used, but since - // modules are implicitly visible within the package we get the same - // result without any rule at all, so just make it an empty list to be - // appended below. - rule = nil - } - } - rule = append(rule, packageRule{dir}) - } - - return &visibilityRuleSet{rule.Strings()} -} - // Clear the default visibility properties so they can be replaced. func clearVisibilityProperties(module Module) { module.base().visibilityPropertyInfo = nil diff --git a/android/visibility_test.go b/android/visibility_test.go index 277be0f65..4acaa02e5 100644 --- a/android/visibility_test.go +++ b/android/visibility_test.go @@ -2112,7 +2112,10 @@ func (j *mockFilesystemModule) DepsMutator(ctx BottomUpMutatorContext) { ctx.AddVariationDependencies(nil, dependencyTag{name: "mockdeps"}, j.properties.Deps...) } -func (p *mockFilesystemModule) GenerateAndroidBuildActions(ModuleContext) { +func (p *mockFilesystemModule) GenerateAndroidBuildActions(ctx ModuleContext) { + SetProvider(ctx, PartitionTypeInfoProvider, PartitionTypeInfo{ + PartitionType: p.PartitionType(), + }) } func (p *mockFilesystemModule) PartitionType() string { diff --git a/apex/apex.go b/apex/apex.go index 4dd3d4cc0..f70076899 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1849,7 +1849,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, return false } depName := ctx.OtherModuleName(child) - if ctx.EqualModules(parent, ctx.Module()) { + if android.EqualModules(parent, ctx.Module()) { switch depTag { case sharedLibTag, jniLibTag: isJniLib := depTag == jniLibTag @@ -2263,6 +2263,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { FlatListPath: a.FlatListPath(), Updatable: a.Updatable(), }) + + android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{a.apexKeysPath}) } // Set prebuiltInfoProvider. This will be used by `apex_prebuiltinfo_singleton` to print out a metadata file @@ -2891,7 +2893,7 @@ func (a *apexBundle) verifyNativeImplementationLibs(ctx android.ModuleContext) { tag := ctx.OtherModuleDependencyTag(child) - if ctx.EqualModules(parent, ctx.Module()) { + if android.EqualModules(parent, ctx.Module()) { if !checkApexTag(tag) { return false } diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 0a970276a..89b0091be 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -21,6 +21,7 @@ import ( "android/soong/android" "android/soong/dexpreopt" + "android/soong/filesystem" "android/soong/java" "android/soong/provenance" @@ -677,6 +678,8 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { } ctx.SetOutputFiles(android.Paths{p.outputApex}, "") + + android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{p.apexKeysPath}) } func (p *Prebuilt) ProvenanceMetaDataFile() android.Path { @@ -873,4 +876,6 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { } ctx.SetOutputFiles(android.Paths{a.outputApex}, "") + + android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{a.apexKeysPath}) } @@ -3713,7 +3713,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { func ShouldUseStubForApex(ctx android.ModuleContext, parent android.Module, dep android.ModuleProxy) bool { inVendorOrProduct := false bootstrap := false - if ctx.EqualModules(ctx.Module(), parent) { + if android.EqualModules(ctx.Module(), parent) { if linkable, ok := parent.(LinkableInterface); !ok { ctx.ModuleErrorf("Not a Linkable module: %q", ctx.ModuleName()) } else { diff --git a/cc/library.go b/cc/library.go index ee7610d08..8a2b6bdbd 100644 --- a/cc/library.go +++ b/cc/library.go @@ -220,6 +220,7 @@ func init() { func RegisterLibraryBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("cc_library_static", LibraryStaticFactory) + ctx.RegisterModuleType("cc_rustlibs_for_make", LibraryMakeRustlibsFactory) ctx.RegisterModuleType("cc_library_shared", LibrarySharedFactory) ctx.RegisterModuleType("cc_library", LibraryFactory) ctx.RegisterModuleType("cc_library_host_static", LibraryHostStaticFactory) @@ -249,6 +250,19 @@ func LibraryStaticFactory() android.Module { return module.Init() } +// cc_rustlibs_for_make creates a static library which bundles together rust_ffi_static +// deps for Make. This should not be depended on in Soong, and is probably not the +// module you need unless you are sure of what you're doing. These should only +// be declared as dependencies in Make. To ensure inclusion, rust_ffi_static modules +// should be declared in the whole_static_libs property. +func LibraryMakeRustlibsFactory() android.Module { + module, library := NewLibrary(android.HostAndDeviceSupported) + library.BuildOnlyStatic() + library.wideStaticlibForMake = true + module.sdkMemberTypes = []android.SdkMemberType{staticLibrarySdkMemberType} + return module.Init() +} + // cc_library_shared creates a shared library for a device and/or host. func LibrarySharedFactory() android.Module { module, library := NewLibrary(android.HostAndDeviceSupported) @@ -437,6 +451,10 @@ type libraryDecorator struct { // Path to the file containing the APIs exported by this library stubsSymbolFilePath android.Path + + // Forces production of the generated Rust staticlib for cc_library_static. + // Intended to be used to provide these generated staticlibs for Make. + wideStaticlibForMake bool } // linkerProps returns the list of properties structs relevant for this library. (For example, if @@ -1055,6 +1073,16 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext, library.objects = library.objects.Append(objs) library.wholeStaticLibsFromPrebuilts = android.CopyOfPaths(deps.WholeStaticLibsFromPrebuilts) + if library.wideStaticlibForMake { + if generatedLib := GenerateRustStaticlib(ctx, deps.RustRlibDeps); generatedLib != nil { + // WholeStaticLibsFromPrebuilts are .a files that get included whole into the resulting staticlib + // so reuse that here for our Rust staticlibs because we don't have individual object files for + // these. + deps.WholeStaticLibsFromPrebuilts = append(deps.WholeStaticLibsFromPrebuilts, generatedLib) + } + + } + fileName := ctx.ModuleName() + staticLibraryExtension outputFile := android.PathForModuleOut(ctx, fileName) builderFlags := flagsToBuilderFlags(flags) diff --git a/cc/tidy.go b/cc/tidy.go index 23736585a..8e7f899a2 100644 --- a/cc/tidy.go +++ b/cc/tidy.go @@ -211,7 +211,7 @@ func TidyPhonySingleton() android.Singleton { type tidyPhonySingleton struct{} // Given a final module, add its tidy/obj phony targets to tidy/objModulesInDirGroup. -func collectTidyObjModuleTargets(ctx android.SingletonContext, module android.Module, +func collectTidyObjModuleTargets(ctx android.SingletonContext, module android.ModuleProxy, tidyModulesInDirGroup, objModulesInDirGroup map[string]map[string]android.Paths) { allObjFileGroups := make(map[string]android.Paths) // variant group name => obj file Paths allTidyFileGroups := make(map[string]android.Paths) // variant group name => tidy file Paths @@ -253,7 +253,7 @@ func (m *tidyPhonySingleton) GenerateBuildActions(ctx android.SingletonContext) objModulesInDirGroup := make(map[string]map[string]android.Paths) // Collect tidy/obj targets from the 'final' modules. - ctx.VisitAllModules(func(module android.Module) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { if ctx.IsFinalModule(module) { collectTidyObjModuleTargets(ctx, module, tidyModulesInDirGroup, objModulesInDirGroup) } @@ -268,7 +268,7 @@ func (m *tidyPhonySingleton) GenerateBuildActions(ctx android.SingletonContext) } // The name for an obj/tidy module variant group phony target is Name_group-obj/tidy, -func objTidyModuleGroupName(module android.Module, group string, suffix string) string { +func objTidyModuleGroupName(module android.ModuleProxy, group string, suffix string) string { if group == "" { return module.Name() + "-" + suffix } @@ -327,7 +327,7 @@ func addToOSGroup(osName string, files android.Paths, allGroups, subsetGroups ma } // Add an all-OS group, with groupName, to include all os-specific phony targets. -func addAllOSGroup(ctx android.SingletonContext, module android.Module, phonyTargetGroups map[string]android.Paths, groupName string, objTidyName string) { +func addAllOSGroup(ctx android.SingletonContext, module android.ModuleProxy, phonyTargetGroups map[string]android.Paths, groupName string, objTidyName string) { if len(phonyTargetGroups) > 0 { var targets android.Paths for group, _ := range phonyTargetGroups { @@ -338,7 +338,7 @@ func addAllOSGroup(ctx android.SingletonContext, module android.Module, phonyTar } // Create one phony targets for each group and add them to the targetGroups. -func genObjTidyPhonyTargets(ctx android.SingletonContext, module android.Module, objTidyName string, fileGroups map[string]android.Paths, targetGroups map[string]android.Path) { +func genObjTidyPhonyTargets(ctx android.SingletonContext, module android.ModuleProxy, objTidyName string, fileGroups map[string]android.Paths, targetGroups map[string]android.Path) { for group, files := range fileGroups { groupName := objTidyModuleGroupName(module, group, objTidyName) ctx.Phony(groupName, files...) diff --git a/dexpreopt/config.go b/dexpreopt/config.go index c5cafb1cf..655ee9b7b 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -510,7 +510,7 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path { var dex2oatModule android.ModuleProxy ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { prebuiltInfo, isPrebuilt := android.OtherModuleProvider(ctx, child, android.PrebuiltModuleInfoProvider) - if ctx.EqualModules(parent, ctx.Module()) && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag { + if android.EqualModules(parent, ctx.Module()) && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag { // Found the source module, or prebuilt module that has replaced the source. dex2oatModule = child if isPrebuilt { @@ -519,7 +519,7 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path { return true // Recurse to check if the source has a prebuilt dependency. } } - if ctx.EqualModules(parent, dex2oatModule) && ctx.OtherModuleDependencyTag(child) == android.PrebuiltDepTag { + if android.EqualModules(parent, dex2oatModule) && ctx.OtherModuleDependencyTag(child) == android.PrebuiltDepTag { if isPrebuilt && prebuiltInfo.UsePrebuilt { dex2oatModule = child // Found a prebuilt that should be used. } diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 31678aa3b..a2fa0f08a 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -175,7 +175,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { allInstalledModules := a.allInstalledModules(ctx) - a.buildTargetFilesZip(ctx) + a.buildTargetFilesZip(ctx, allInstalledModules) a.buildProguardZips(ctx, allInstalledModules) var deps []android.Path @@ -393,7 +393,7 @@ type targetFilesystemZipCopy struct { destSubdir string } -func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) { +func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext, allInstalledModules []android.Module) { targetFilesDir := android.PathForModuleOut(ctx, "target_files_dir") targetFilesZip := android.PathForModuleOut(ctx, "target_files.zip") @@ -497,7 +497,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) { } a.copyImagesToTargetZip(ctx, builder, targetFilesDir) - a.copyMetadataToTargetZip(ctx, builder, targetFilesDir) + a.copyMetadataToTargetZip(ctx, builder, targetFilesDir, allInstalledModules) builder.Command(). BuiltTool("soong_zip"). @@ -549,7 +549,7 @@ func (a *androidDevice) copyImagesToTargetZip(ctx android.ModuleContext, builder } } -func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath) { +func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir android.WritablePath, allInstalledModules []android.Module) { // Create a META/ subdirectory builder.Command().Textf("mkdir -p %s/META", targetFilesDir.String()) if proptools.Bool(a.deviceProps.Ab_ota_updater) { @@ -587,7 +587,22 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build if android.InList(partition, []string{"userdata"}) { continue } - builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/%s", targetFilesDir.String(), a.filesystemConfigNameForTargetFiles(partition)) + if partition != "vendor_ramdisk" { + // vendor_ramdisk will be handled separately. + builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/%s", targetFilesDir.String(), a.filesystemConfigNameForTargetFiles(partition)) + } + if partition == "ramdisk" { + // Create an additional copy at boot_filesystem_config.txt + builder.Command().Textf("cp").Input(fsInfos[partition].FilesystemConfig).Textf(" %s/META/boot_filesystem_config.txt", targetFilesDir.String()) + } + if partition == "system" { + // Create root_filesystem_config from the assembled ROOT/ intermediates directory + a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/ROOT", "root_filesystem_config.txt") + } + if partition == "vendor_ramdisk" { + // Create vendor_boot_filesystem_config from the assembled VENDOR_BOOT/RAMDISK intermediates directory + a.generateFilesystemConfigForTargetFiles(ctx, builder, targetFilesDir.String(), targetFilesDir.String()+"/VENDOR_BOOT/RAMDISK", "vendor_boot_filesystem_config.txt") + } } // Copy ramdisk_node_list if ramdiskNodeList := android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Ramdisk_node_list)); ramdiskNodeList != nil { @@ -597,6 +612,35 @@ func (a *androidDevice) copyMetadataToTargetZip(ctx android.ModuleContext, build if releaseTools := android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Releasetools_extension)); releaseTools != nil { builder.Command().Textf("cp").Input(releaseTools).Textf(" %s/META/", targetFilesDir.String()) } + // apexkeys.txt + var installedApexKeys []android.Path + for _, installedModule := range allInstalledModules { + if info, ok := android.OtherModuleProvider(ctx, installedModule, ApexKeyPathInfoProvider); ok { + installedApexKeys = append(installedApexKeys, info.ApexKeyPath) + } + } + installedApexKeys = android.SortedUniquePaths(installedApexKeys) // Sort by keypath to match make + builder.Command().Text("cat").Inputs(installedApexKeys).Textf(" >> %s/META/apexkeys.txt", targetFilesDir.String()) + +} + +type ApexKeyPathInfo struct { + ApexKeyPath android.Path +} + +var ApexKeyPathInfoProvider = blueprint.NewProvider[ApexKeyPathInfo]() + +func (a *androidDevice) generateFilesystemConfigForTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir, stagingDir, filename string) { + fsConfigOut := android.PathForModuleOut(ctx, filename) + ctx.Build(pctx, android.BuildParams{ + Rule: fsConfigRule, + Output: fsConfigOut, + Args: map[string]string{ + "rootDir": stagingDir, + "prefix": "", + }, + }) + builder.Command().Textf("cp").Input(fsConfigOut).Textf(" %s/META/", targetFilesDir) } // Filenames for the partition specific fs_config files. diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index d4ea6a34c..725786897 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -474,11 +474,7 @@ type FullInstallPathInfo struct { var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]() -type FilesystemDefaultsInfo struct { - // Identifies which partition this is for //visibility:any_system_image (and others) visibility - // checks, and will be used in the future for API surface checks. - PartitionType string -} +type FilesystemDefaultsInfo struct{} var FilesystemDefaultsInfoProvider = blueprint.NewProvider[FilesystemDefaultsInfo]() @@ -696,6 +692,10 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { android.SetProvider(ctx, FilesystemProvider, fsInfo) + android.SetProvider(ctx, android.PartitionTypeInfoProvider, android.PartitionTypeInfo{ + PartitionType: f.PartitionType(), + }) + f.fileListFile = fileListFile if proptools.Bool(f.properties.Unchecked_module) { @@ -822,11 +822,12 @@ func validatePartitionType(ctx android.ModuleContext, p partition) { } ctx.VisitDirectDepsProxyWithTag(android.DefaultsDepTag, func(m android.ModuleProxy) { - if fdm, ok := android.OtherModuleProvider(ctx, m, FilesystemDefaultsInfoProvider); ok { - if p.PartitionType() != fdm.PartitionType { + if _, ok := android.OtherModuleProvider(ctx, m, FilesystemDefaultsInfoProvider); ok { + partitionInfo := android.OtherModuleProviderOrDefault(ctx, m, android.PartitionTypeInfoProvider) + if p.PartitionType() != partitionInfo.PartitionType { ctx.PropertyErrorf("partition_type", "%s doesn't match with the partition type %s of the filesystem default module %s", - p.PartitionType(), fdm.PartitionType, m.Name()) + p.PartitionType(), partitionInfo.PartitionType, m.Name()) } } }) @@ -1413,7 +1414,8 @@ var _ partition = (*filesystemDefaults)(nil) func (f *filesystemDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { validatePartitionType(ctx, f) - android.SetProvider(ctx, FilesystemDefaultsInfoProvider, FilesystemDefaultsInfo{ + android.SetProvider(ctx, FilesystemDefaultsInfoProvider, FilesystemDefaultsInfo{}) + android.SetProvider(ctx, android.PartitionTypeInfoProvider, android.PartitionTypeInfo{ PartitionType: f.PartitionType(), }) } diff --git a/filesystem/system_other.go b/filesystem/system_other.go index 5309e9012..cbfd78b5b 100644 --- a/filesystem/system_other.go +++ b/filesystem/system_other.go @@ -172,9 +172,10 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext builder.Build("build_system_other_hermetic", "build system other") fsInfo := FilesystemInfo{ - Output: output, - OutputHermetic: outputHermetic, - RootDir: stagingDir, + Output: output, + OutputHermetic: outputHermetic, + RootDir: stagingDir, + FilesystemConfig: m.generateFilesystemConfig(ctx, stagingDir, stagingDirTimestamp), } android.SetProvider(ctx, FilesystemProvider, fsInfo) @@ -183,6 +184,20 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext ctx.CheckbuildFile(output) } +func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path { + out := android.PathForModuleOut(ctx, "filesystem_config.txt") + ctx.Build(pctx, android.BuildParams{ + Rule: fsConfigRule, + Input: stagingDirTimestamp, // assemble the staging directory + Output: out, + Args: map[string]string{ + "rootDir": stagingDir.String(), + "prefix": "system/", + }, + }) + return out +} + func (f *systemOtherImage) propFileForHermeticImg(ctx android.ModuleContext, builder *android.RuleBuilder, inputPropFile android.Path) android.Path { propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop") builder.Command().Textf("cat").Input(inputPropFile).Flag(">").Output(propFilePinnedTimestamp). diff --git a/java/app.go b/java/app.go index 827b23526..c2aa8a474 100644 --- a/java/app.go +++ b/java/app.go @@ -1175,7 +1175,7 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface, apkInApex := ctx.Module().(android.ApexModule).NotInPlatform() childLinkable, _ := android.OtherModuleProvider(ctx, child, cc.LinkableInfoProvider) parentIsLinkable := false - if ctx.EqualModules(ctx.Module(), parent) { + if android.EqualModules(ctx.Module(), parent) { parentLinkable, _ := ctx.Module().(cc.LinkableInterface) parentIsLinkable = parentLinkable != nil } else { diff --git a/java/java.go b/java/java.go index 38361bfa7..c1e4f8ca0 100644 --- a/java/java.go +++ b/java/java.go @@ -3363,21 +3363,12 @@ func (j *Import) UseProfileGuidedDexpreopt() bool { // Add compile time check for interface implementation var _ android.IDEInfo = (*Import)(nil) -var _ android.IDECustomizedModuleName = (*Import)(nil) // Collect information for opening IDE project files in java/jdeps.go. - func (j *Import) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Jars = append(dpInfo.Jars, j.combinedImplementationFile.String()) } -func (j *Import) IDECustomizedModuleName() string { - // TODO(b/113562217): Extract the base module name from the Import name, often the Import name - // has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better - // solution to get the Import name. - return android.RemoveOptionalPrebuiltPrefix(j.Name()) -} - var _ android.PrebuiltInterface = (*Import)(nil) func (j *Import) IsInstallable() bool { diff --git a/java/jdeps.go b/java/jdeps.go index 07f8c4378..4711dc1a4 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -45,13 +45,13 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont // (b/204397180) Generate module_bp_java_deps.json by default. moduleInfos := make(map[string]android.IdeInfo) - ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled(ctx) { + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled { return } // Prevent including both prebuilts and matching source modules when one replaces the other. - if !android.IsModulePreferred(module) { + if !android.IsModulePreferredProxy(ctx, module) { return } @@ -60,9 +60,11 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont return } name := ideInfoProvider.BaseModuleName - ideModuleNameProvider, ok := module.(android.IDECustomizedModuleName) - if ok { - name = ideModuleNameProvider.IDECustomizedModuleName() + if info, ok := android.OtherModuleProvider(ctx, module, JavaLibraryInfoProvider); ok && info.Prebuilt { + // TODO(b/113562217): Extract the base module name from the Import name, often the Import name + // has a prefix "prebuilt_". Remove the prefix explicitly if needed until we find a better + // solution to get the Import name. + name = android.RemoveOptionalPrebuiltPrefix(module.Name()) } dpInfo := moduleInfos[name] @@ -70,13 +72,12 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont dpInfo.Paths = []string{ctx.ModuleDir(module)} moduleInfos[name] = dpInfo - mkProvider, ok := module.(android.AndroidMkDataProvider) + mkProvider, ok := android.OtherModuleProvider(ctx, module, android.AndroidMkDataInfoProvider) if !ok { return } - data := mkProvider.AndroidMk() - if data.Class != "" { - dpInfo.Classes = append(dpInfo.Classes, data.Class) + if mkProvider.Class != "" { + dpInfo.Classes = append(dpInfo.Classes, mkProvider.Class) } if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { diff --git a/rust/config/OWNERS b/rust/config/OWNERS index dfff87354..e4bf5e60c 100644 --- a/rust/config/OWNERS +++ b/rust/config/OWNERS @@ -1,2 +1,2 @@ -per-file global.go = srhines@google.com, chh@google.com, pirama@google.com, yikong@google.com +per-file global.go = srhines@google.com, pirama@google.com, yikong@google.com diff --git a/rust/library_test.go b/rust/library_test.go index 6db95253f..6cc4f2517 100644 --- a/rust/library_test.go +++ b/rust/library_test.go @@ -426,6 +426,45 @@ func TestRustFFIExportedIncludes(t *testing.T) { android.AssertStringDoesContain(t, "cFlags for lib module", libfooStatic.Args["cFlags"], " -Irust_includes ") } +// Make sure cc_rustlibs_for_make has the expected behavior, and that +// cc_library_static does as well. +// This is here instead of cc/library_test.go because the test needs to +// define a rust_ffi module which can't be done in soong-cc to avoid the +// circular dependency. +func TestCCRustlibsForMake(t *testing.T) { + t.Parallel() + result := testRust(t, ` + rust_ffi_static { + name: "libbar", + srcs: ["foo.rs"], + crate_name: "bar", + export_include_dirs: ["rust_includes"], + host_supported: true, + } + + cc_rustlibs_for_make { + name: "libmakerustlibs", + whole_static_libs: ["libbar"], + } + + cc_library_static { + name: "libccstatic", + whole_static_libs: ["libbar"], + } + `) + + libmakerustlibs := result.ModuleForTests(t, "libmakerustlibs", "android_arm64_armv8-a_static").MaybeRule("rustc") + libccstatic := result.ModuleForTests(t, "libccstatic", "android_arm64_armv8-a_static").MaybeRule("rustc") + + if libmakerustlibs.Output == nil { + t.Errorf("cc_rustlibs_for_make is not generating a Rust staticlib when it should") + } + + if libccstatic.Output != nil { + t.Errorf("cc_library_static is generating a Rust staticlib when it should not") + } +} + func TestRustVersionScript(t *testing.T) { ctx := testRust(t, ` rust_library { diff --git a/scripts/microfactory.bash b/scripts/microfactory.bash index ce4a0e48a..49988fa29 100644 --- a/scripts/microfactory.bash +++ b/scripts/microfactory.bash @@ -23,7 +23,14 @@ # Ensure GOROOT is set to the in-tree version. case $(uname) in Linux) - export GOROOT="${TOP}/prebuilts/go/linux-x86/" + case $(uname -m) in + x86_64) + export GOROOT="${TOP}/prebuilts/go/linux-x86/" + ;; + aarch64) + export GOROOT="${TOP}/prebuilts/go/linux-arm64/" + ;; + esac ;; Darwin) export GOROOT="${TOP}/prebuilts/go/darwin-x86/" diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go index 640a82d9a..cd49ec876 100644 --- a/ui/build/androidmk_denylist.go +++ b/ui/build/androidmk_denylist.go @@ -70,8 +70,8 @@ func blockAndroidMks(ctx Context, androidMks []string) { } } -// The Android.mk files in these directories are for NDK build system. -var external_ndk_androidmks []string = []string{ +var external_androidmks []string = []string{ + // The Android.mk files in these directories are for NDK build system. "external/fmtlib/", "external/google-breakpad/", "external/googletest/", @@ -83,6 +83,9 @@ var external_ndk_androidmks []string = []string{ "external/vulkan-validation-layers/", "external/walt/", "external/webp/", + // These directories hold the published Android SDK, used in Unbundled Gradle builds. + "prebuilts/fullsdk-darwin", + "prebuilts/fullsdk-linux", } var art_androidmks = []string{ @@ -90,8 +93,8 @@ var art_androidmks = []string{ } func ignoreSomeAndroidMks(androidMks []string) (filtered []string) { - ignore_androidmks := make([]string, 0, len(external_ndk_androidmks)+len(art_androidmks)) - ignore_androidmks = append(ignore_androidmks, external_ndk_androidmks...) + ignore_androidmks := make([]string, 0, len(external_androidmks)+len(art_androidmks)) + ignore_androidmks = append(ignore_androidmks, external_androidmks...) ignore_androidmks = append(ignore_androidmks, art_androidmks...) shouldKeep := func(androidmk string) bool { diff --git a/ui/build/config.go b/ui/build/config.go index a4f778d74..94b07811d 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -1117,11 +1117,18 @@ func (c *configImpl) ApiSurfacesOutDir() string { func (c *configImpl) PrebuiltOS() string { switch runtime.GOOS { case "linux": - return "linux-x86" + switch runtime.GOARCH { + case "amd64": + return "linux-x86" + case "arm64": + return "linux-arm64" + default: + panic(fmt.Errorf("Unknown GOARCH %s", runtime.GOARCH)) + } case "darwin": return "darwin-x86" default: - panic("Unknown GOOS") + panic(fmt.Errorf("Unknown GOOS %s", runtime.GOOS)) } } @@ -1711,13 +1718,7 @@ func (c *configImpl) hostCrossOut() string { } func (c *configImpl) HostPrebuiltTag() string { - if runtime.GOOS == "linux" { - return "linux-x86" - } else if runtime.GOOS == "darwin" { - return "darwin-x86" - } else { - panic("Unsupported OS") - } + return c.PrebuiltOS() } func (c *configImpl) KatiBin() string { diff --git a/ui/build/path.go b/ui/build/path.go index cc1d7e9c2..b92d79959 100644 --- a/ui/build/path.go +++ b/ui/build/path.go @@ -20,7 +20,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "strings" "github.com/google/blueprint/microfactory" @@ -122,7 +121,7 @@ func SetupLitePath(ctx Context, config Config, tmpDir string) { myPath, _ = filepath.Abs(myPath) // Set up the checked-in prebuilts path directory for the current host OS. - prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86") + prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + config.PrebuiltOS()) myPath = prebuiltsPath + string(os.PathListSeparator) + myPath // Set $PATH to be the directories containing the host tool symlinks, and @@ -258,7 +257,7 @@ func SetupPath(ctx Context, config Config) { // We put some prebuilts in $PATH, since it's infeasible to add dependencies // for all of them. - prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86") + prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + config.PrebuiltOS()) myPath = prebuiltsPath + string(os.PathListSeparator) + myPath // Replace the $PATH variable with the path_interposer symlinks, and |