Merge "Remove DistFiles from AndroidMk datastructures" into main
diff --git a/android/androidmk.go b/android/androidmk.go
index d9d78f3..5cb5a66 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -107,8 +107,6 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 0a81fb8..4cdd6a3 100644
--- a/android/androidmk_test.go
+++ b/android/androidmk_test.go
@@ -34,7 +34,6 @@
}
data AndroidMkData
- distFiles TaggedDistFiles
outputFile OptionalPath
}
@@ -73,7 +72,6 @@
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 @@
// 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 @@
return []AndroidMkEntries{
{
Class: "CUSTOM_MODULE",
- DistFiles: m.distFiles,
OutputFile: m.outputFile,
},
}
diff --git a/android/module.go b/android/module.go
index 996c64e..d387c2c 100644
--- a/android/module.go
+++ b/android/module.go
@@ -613,17 +613,6 @@
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 03f229e..b016788 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -244,10 +244,6 @@
entries.Class = "HEADER_LIBRARIES"
}
- if library.distFile != nil {
- entries.DistFiles = android.MakeDefaultDistFiles(library.distFile)
- }
-
library.androidMkWriteExportedFlags(entries)
library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries)
@@ -336,7 +332,6 @@
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 c4791c5..627d5e5 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -104,8 +104,8 @@
// 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 @@
// 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) defaultDistFiles() []android.Path {
+ if binary.defaultDistFile == nil {
+ return nil
+ }
+ return []android.Path{binary.defaultDistFile}
+}
diff --git a/cc/cc.go b/cc/cc.go
index 0e70d48..4b314cd 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -754,6 +754,10 @@
// 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 @@
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 532b7e9..ee7610d 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -419,8 +419,8 @@
// 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 @@
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 @@
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 @@
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 1f0fc07..c21fe56 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -560,6 +560,10 @@
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 bbfca94..95a8beb 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -242,6 +242,10 @@
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 aa82abb..ab50659 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -178,22 +178,24 @@
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) {