versioning macro is exported from prebuilt stubs as well
This change fixes a bug that the versioning macro (__LIBNAME_API__) is
omitted for prebuilts providing a stub.
Bug: 175166063
Test: m nothing
Change-Id: I1cce5ab58ef245622861200ec0d8b0f84e3178ed
diff --git a/cc/library.go b/cc/library.go
index 06b9905..71b1f45 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1274,9 +1274,7 @@
}
// Add stub-related flags if this library is a stub library.
- if library.buildStubs() && !library.skipAPIDefine {
- library.reexportFlags("-D" + versioningMacroName(ctx.Module().(*Module).ImplementationModuleName(ctx)) + "=" + library.stubsVersion())
- }
+ library.exportVersioningMacroIfNeeded(ctx)
// Propagate a Provider containing information about exported flags, deps, and include paths.
library.flagExporter.setProvider(ctx)
@@ -1284,6 +1282,14 @@
return out
}
+func (library *libraryDecorator) exportVersioningMacroIfNeeded(ctx android.BaseModuleContext) {
+ if library.buildStubs() && !library.skipAPIDefine {
+ name := versioningMacroName(ctx.Module().(*Module).ImplementationModuleName(ctx))
+ ver := library.stubsVersion()
+ library.reexportFlags("-D" + name + "=" + ver)
+ }
+}
+
// buildStatic returns true if this library should be built as a static library.
func (library *libraryDecorator) buildStatic() bool {
return library.MutatedProperties.BuildStatic &&
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 37df4ba..05be8d8 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"path/filepath"
+ "strings"
)
func init() {
@@ -117,6 +118,8 @@
return nil
}
+ p.libraryDecorator.exportVersioningMacroIfNeeded(ctx)
+
in := android.PathForModuleSrc(ctx, srcs[0])
if p.static() {
@@ -220,6 +223,11 @@
p.properties.Srcs = nil
}
+// Implements versionedInterface
+func (p *prebuiltLibraryLinker) implementationModuleName(name string) string {
+ return strings.TrimPrefix(name, "prebuilt_")
+}
+
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
module, library := NewLibrary(hod)
module.compiler = nil