Add dist support to Soong
When dist'ing a library or binary that has use_version_lib set, always
distribute the stamped version, even for the device.
Test: m test_build_version_test dist
Change-Id: I2995ec516b1d182ce18f099aeaa4d186ffbcf01f
diff --git a/cc/library.go b/cc/library.go
index abaa6c4..a9d63f9 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -267,6 +267,9 @@
// Location of the linked, unstripped library for shared libraries
unstrippedOutputFile android.Path
+ // Location of the file that should be copied to dist dir when requested
+ distFile android.OptionalPath
+
versionScriptPath android.ModuleGenPath
// Decorated interafaces
@@ -542,10 +545,16 @@
outputFile := android.PathForModuleOut(ctx, fileName)
builderFlags := flagsToBuilderFlags(flags)
- if Bool(library.baseLinker.Properties.Use_version_lib) && ctx.Host() {
- versionedOutputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
- library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ if Bool(library.baseLinker.Properties.Use_version_lib) {
+ if ctx.Host() {
+ versionedOutputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ } else {
+ versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
+ library.distFile = android.OptionalPathForPath(versionedOutputFile)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ }
}
TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
@@ -619,10 +628,23 @@
library.unstrippedOutputFile = outputFile
- if Bool(library.baseLinker.Properties.Use_version_lib) && ctx.Host() {
- versionedOutputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
- library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ if Bool(library.baseLinker.Properties.Use_version_lib) {
+ if ctx.Host() {
+ versionedOutputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ } else {
+ versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
+ library.distFile = android.OptionalPathForPath(versionedOutputFile)
+
+ if library.stripper.needsStrip(ctx) {
+ out := android.PathForModuleOut(ctx, "versioned-stripped", fileName)
+ library.distFile = android.OptionalPathForPath(out)
+ library.stripper.strip(ctx, versionedOutputFile, out, builderFlags)
+ }
+
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ }
}
sharedLibs := deps.SharedLibs