diff options
author | 2025-02-24 16:18:18 -0800 | |
---|---|---|
committer | 2025-02-24 19:04:46 -0800 | |
commit | d143f3e35485b8ad9f5be0bede0f030874025240 (patch) | |
tree | 4beb9463f2f21737bf1d99aa4e550bd9dd26c92a | |
parent | 324d19b8b5a20678586d4e8e4b894a2bba70a2ae (diff) |
Remove DistFiles from AndroidMk datastructures
The code that collects dists also supports getting them from
OutputFiles. Switch the few remaining usages of AndroidMk-based
disted files over to OutputFiles, and remove DistFiles from the
AndroidMk datastructures.
This should allow us to clean up more AndroidMk code in a followup
cl.
Bug: 398938465
Test: Confirmed that the ninja files for "m nothing dist" don't change after this cl.
Change-Id: I9eaed21018ef73ec36276556e7daa7201b272009
-rw-r--r-- | android/androidmk.go | 23 | ||||
-rw-r--r-- | android/androidmk_test.go | 8 | ||||
-rw-r--r-- | android/module.go | 11 | ||||
-rw-r--r-- | cc/androidmk.go | 5 | ||||
-rw-r--r-- | cc/binary.go | 15 | ||||
-rw-r--r-- | cc/cc.go | 8 | ||||
-rw-r--r-- | cc/library.go | 17 | ||||
-rw-r--r-- | cc/ndk_library.go | 4 | ||||
-rw-r--r-- | cc/object.go | 4 | ||||
-rw-r--r-- | sdk/sdk.go | 10 |
10 files changed, 48 insertions, 57 deletions
diff --git a/android/androidmk.go b/android/androidmk.go index d9d78f349..5cb5a66bc 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -107,8 +107,6 @@ type AndroidMkEntries struct { SubName string // If set, this value overrides the base module name. SubName is still appended. OverrideName string - // Dist files to output - DistFiles TaggedDistFiles // The output file for Kati to process and/or install. If absent, the module is skipped. OutputFile OptionalPath // If true, the module is skipped and does not appear on the final Android-<product name>.mk @@ -360,15 +358,9 @@ func (a *AndroidMkEntries) getDistContributions(mod Module) *distContributions { // Start with an empty (nil) set. var availableTaggedDists TaggedDistFiles - // Then merge in any that are provided explicitly by the module. - if a.DistFiles != nil { - // Merge the DistFiles into the set. - availableTaggedDists = availableTaggedDists.merge(a.DistFiles) - } - // If no paths have been provided for the DefaultDistTag and the output file is // valid then add that as the default dist path. - if _, ok := availableTaggedDists[DefaultDistTag]; !ok && a.OutputFile.Valid() { + if a.OutputFile.Valid() { availableTaggedDists = availableTaggedDists.addPathsForTag(DefaultDistTag, a.OutputFile.Path()) } @@ -1295,8 +1287,6 @@ type AndroidMkInfo struct { SubName string // If set, this value overrides the base module name. SubName is still appended. OverrideName string - // Dist files to output - DistFiles TaggedDistFiles // The output file for Kati to process and/or install. If absent, the module is skipped. OutputFile OptionalPath // If true, the module is skipped and does not appear on the final Android-<product name>.mk @@ -1682,15 +1672,9 @@ func (a *AndroidMkInfo) getDistContributions(ctx fillInEntriesContext, mod Modul // Start with an empty (nil) set. var availableTaggedDists TaggedDistFiles - // Then merge in any that are provided explicitly by the module. - if a.DistFiles != nil { - // Merge the DistFiles into the set. - availableTaggedDists = availableTaggedDists.merge(a.DistFiles) - } - // If no paths have been provided for the DefaultDistTag and the output file is // valid then add that as the default dist path. - if _, ok := availableTaggedDists[DefaultDistTag]; !ok && a.OutputFile.Valid() { + if a.OutputFile.Valid() { availableTaggedDists = availableTaggedDists.addPathsForTag(DefaultDistTag, a.OutputFile.Path()) } @@ -1815,9 +1799,8 @@ func deepCopyAndroidMkInfo(mkinfo *AndroidMkInfo) AndroidMkInfo { Class: mkinfo.Class, SubName: mkinfo.SubName, OverrideName: mkinfo.OverrideName, - // There is no modification on DistFiles or OutputFile, so no need to + // There is no modification on OutputFile, so no need to // make their deep copy. - DistFiles: mkinfo.DistFiles, OutputFile: mkinfo.OutputFile, Disabled: mkinfo.Disabled, Include: mkinfo.Include, diff --git a/android/androidmk_test.go b/android/androidmk_test.go index 0a81fb8bf..4cdd6a37b 100644 --- a/android/androidmk_test.go +++ b/android/androidmk_test.go @@ -34,7 +34,6 @@ type customModule struct { } data AndroidMkData - distFiles TaggedDistFiles outputFile OptionalPath } @@ -73,7 +72,6 @@ func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) { path := PathForTesting("default-dist.out") defaultDistPaths = Paths{path} m.setOutputFiles(ctx, defaultDistPaths) - m.distFiles = MakeDefaultDistFiles(path) case defaultDistFiles_Tagged: // Module types that set AndroidMkEntry.DistFiles to the result of calling @@ -84,11 +82,6 @@ func (m *customModule) GenerateAndroidBuildActions(ctx ModuleContext) { // will be the same as empty-string-tag output. defaultDistPaths = PathsForTesting("one.out") m.setOutputFiles(ctx, defaultDistPaths) - - // This must be called after setting defaultDistPaths/outputFile as - // GenerateTaggedDistFiles calls into outputFiles property which may use - // those fields. - m.distFiles = m.GenerateTaggedDistFiles(ctx) } } @@ -113,7 +106,6 @@ func (m *customModule) AndroidMkEntries() []AndroidMkEntries { return []AndroidMkEntries{ { Class: "CUSTOM_MODULE", - DistFiles: m.distFiles, OutputFile: m.outputFile, }, } diff --git a/android/module.go b/android/module.go index 996c64e52..d387c2cf3 100644 --- a/android/module.go +++ b/android/module.go @@ -613,17 +613,6 @@ func (t TaggedDistFiles) merge(other TaggedDistFiles) TaggedDistFiles { return t } -func MakeDefaultDistFiles(paths ...Path) TaggedDistFiles { - for _, p := range paths { - if p == nil { - panic("The path to a dist file cannot be nil.") - } - } - - // The default OutputFile tag is the empty "" string. - return TaggedDistFiles{DefaultDistTag: paths} -} - type hostAndDeviceProperties struct { // If set to true, build a variant of the module for the host. Defaults to false. Host_supported *bool diff --git a/cc/androidmk.go b/cc/androidmk.go index 03f229ef4..b016788ee 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -244,10 +244,6 @@ func (library *libraryDecorator) prepareAndroidMKProviderInfo(config android.Con entries.Class = "HEADER_LIBRARIES" } - if library.distFile != nil { - entries.DistFiles = android.MakeDefaultDistFiles(library.distFile) - } - library.androidMkWriteExportedFlags(entries) library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries) @@ -336,7 +332,6 @@ func (binary *binaryDecorator) prepareAndroidMKProviderInfo(config android.Confi ctx.subAndroidMk(config, entries, binary.baseInstaller) entries.Class = "EXECUTABLES" - entries.DistFiles = binary.distFiles entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String()) if len(binary.symlinks) > 0 { entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...) diff --git a/cc/binary.go b/cc/binary.go index c4791c519..627d5e560 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -104,8 +104,8 @@ type binaryDecorator struct { // Output archive of gcno coverage information coverageOutputFile android.OptionalPath - // Location of the files that should be copied to dist dir when requested - distFiles android.TaggedDistFiles + // Location of the file that should be copied to dist dir when no explicit tag is requested + defaultDistFile android.Path // Action command lines to run directly after the binary is installed. For example, // may be used to symlink runtime dependencies (such as bionic) alongside installation. @@ -385,11 +385,11 @@ func (binary *binaryDecorator) link(ctx ModuleContext, // When dist'ing a library or binary that has use_version_lib set, always // distribute the stamped version, even for the device. versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName) - binary.distFiles = android.MakeDefaultDistFiles(versionedOutputFile) + binary.defaultDistFile = versionedOutputFile if binary.stripper.NeedsStrip(ctx) { out := android.PathForModuleOut(ctx, "versioned-stripped", fileName) - binary.distFiles = android.MakeDefaultDistFiles(out) + binary.defaultDistFile = out binary.stripper.StripExecutableOrSharedLib(ctx, versionedOutputFile, out, stripFlags) } @@ -575,3 +575,10 @@ func (binary *binaryDecorator) verifyHostBionicLinker(ctx ModuleContext, in, lin }, }) } + +func (binary *binaryDecorator) defaultDistFiles() []android.Path { + if binary.defaultDistFile == nil { + return nil + } + return []android.Path{binary.defaultDistFile} +} @@ -754,6 +754,10 @@ type linker interface { // Get the deps that have been explicitly specified in the properties. linkerSpecifiedDeps(ctx android.ConfigurableEvaluatorContext, module *Module, specifiedDeps specifiedDeps) specifiedDeps + // Gets a list of files that will be disted when using the dist property without specifying + // an output file tag. + defaultDistFiles() []android.Path + moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) } @@ -2423,6 +2427,10 @@ func (c *Module) setOutputFiles(ctx ModuleContext) { if c.linker != nil { ctx.SetOutputFiles(android.PathsIfNonNil(c.linker.unstrippedOutputFilePath()), "unstripped") ctx.SetOutputFiles(android.PathsIfNonNil(c.linker.strippedAllOutputFilePath()), "stripped_all") + defaultDistFiles := c.linker.defaultDistFiles() + if len(defaultDistFiles) > 0 { + ctx.SetOutputFiles(defaultDistFiles, android.DefaultDistTag) + } } } diff --git a/cc/library.go b/cc/library.go index 532b7e9aa..ee7610d08 100644 --- a/cc/library.go +++ b/cc/library.go @@ -419,8 +419,8 @@ type libraryDecorator struct { // Location of the linked, stripped library for shared libraries, strip: "all" strippedAllOutputFile android.Path - // Location of the file that should be copied to dist dir when requested - distFile android.Path + // Location of the file that should be copied to dist dir when no explicit tag is requested + defaultDistFile android.Path versionScriptPath android.OptionalPath @@ -1066,7 +1066,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext, library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) } else { versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName) - library.distFile = versionedOutputFile + library.defaultDistFile = versionedOutputFile library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) } } @@ -1206,11 +1206,11 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) } else { versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName) - library.distFile = versionedOutputFile + library.defaultDistFile = versionedOutputFile if library.stripper.NeedsStrip(ctx) { out := android.PathForModuleOut(ctx, "versioned-stripped", fileName) - library.distFile = out + library.defaultDistFile = out library.stripper.StripExecutableOrSharedLib(ctx, versionedOutputFile, out, stripFlags) } @@ -2090,6 +2090,13 @@ func (library *libraryDecorator) overriddenModules() []string { return library.Properties.Overrides } +func (library *libraryDecorator) defaultDistFiles() []android.Path { + if library.defaultDistFile == nil { + return nil + } + return []android.Path{library.defaultDistFile} +} + var _ overridable = (*libraryDecorator)(nil) var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList") diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 1f0fc0764..c21fe564b 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -560,6 +560,10 @@ func (stub *stubDecorator) nativeCoverage() bool { return false } +func (stub *stubDecorator) defaultDistFiles() []android.Path { + return nil +} + // Returns the install path for unversioned NDK libraries (currently only static // libraries). func getUnversionedLibraryInstallPath(ctx ModuleContext) android.OutputPath { diff --git a/cc/object.go b/cc/object.go index bbfca94c5..95a8beb52 100644 --- a/cc/object.go +++ b/cc/object.go @@ -242,6 +242,10 @@ func (object *objectLinker) isCrt() bool { return Bool(object.Properties.Crt) } +func (object *objectLinker) defaultDistFiles() []android.Path { + return nil +} + func (object *objectLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) { object.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON) moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"} diff --git a/sdk/sdk.go b/sdk/sdk.go index aa82abbb4..ab50659cd 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -178,22 +178,24 @@ func (s *sdk) GenerateAndroidBuildActions(ctx android.ModuleContext) { s.buildSnapshot(ctx, sdkVariants) } + if s.snapshotFile.Valid() != s.infoFile.Valid() { + panic(fmt.Sprintf("Snapshot (%q) and info file (%q) should both be set or neither should be set.", s.snapshotFile, s.infoFile)) + } + if s.snapshotFile.Valid() { ctx.SetOutputFiles([]android.Path{s.snapshotFile.Path()}, "") + ctx.SetOutputFiles([]android.Path{s.snapshotFile.Path(), s.infoFile.Path()}, android.DefaultDistTag) } } func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries { - if !s.snapshotFile.Valid() != !s.infoFile.Valid() { - panic("Snapshot (%q) and info file (%q) should both be set or neither should be set.") - } else if !s.snapshotFile.Valid() { + if !s.snapshotFile.Valid() { return []android.AndroidMkEntries{} } return []android.AndroidMkEntries{android.AndroidMkEntries{ Class: "FAKE", OutputFile: s.snapshotFile, - DistFiles: android.MakeDefaultDistFiles(s.snapshotFile.Path(), s.infoFile.Path()), Include: "$(BUILD_PHONY_PACKAGE)", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |