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
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"}