From ceaa5328f046b89ea20ebe8fd48ed32a78e1f548 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 28 Sep 2021 16:37:50 -0700 Subject: [PATCH] Export SOONG_CC_API_XML to Make outside androidmk This relands Ie0a945d879de4f99ce76d005aea8041719c244f7 with a fix to prevent building XMl files for multiple variants of a library. The SOONG_CC_API_XML values are needed for modules that are not exported to Make, export them from a singleton that covers all modules instead of an AndroidMkProvider that may not be called for some modules. Bug: 193819970 Test: forrest Change-Id: I54710c00901976a736e88126f406e02b1f3c3586 --- cc/androidmk.go | 3 --- cc/library.go | 8 +++++++- cc/stub_library.go | 12 ++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cc/androidmk.go b/cc/androidmk.go index cd52363e8..e95d5a793 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -294,9 +294,6 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries if library.buildStubs() { entries.SetBool("LOCAL_NO_NOTICE_FILE", true) } - if library.apiListCoverageXmlPath.String() != "" { - entries.SetString("SOONG_CC_API_XML", "$(SOONG_CC_API_XML) "+library.apiListCoverageXmlPath.String()) - } }) } // If a library providing a stub is included in an APEX, the private APIs of the library diff --git a/cc/library.go b/cc/library.go index de9d01ede..5306d5cbb 100644 --- a/cc/library.go +++ b/cc/library.go @@ -956,7 +956,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa nativeAbiResult.versionScript) // Parse symbol file to get API list for coverage - if library.stubsVersion() == "current" && ctx.PrimaryArch() { + if library.stubsVersion() == "current" && ctx.PrimaryArch() && !ctx.inRecovery() && !ctx.inProduct() && !ctx.inVendor() { library.apiListCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile) } @@ -1035,6 +1035,8 @@ type libraryInterface interface { androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) availableFor(string) bool + + getAPIListCoverageXMLPath() android.ModuleOutPath } type versionedInterface interface { @@ -1971,6 +1973,10 @@ func (library *libraryDecorator) makeUninstallable(mod *Module) { mod.ModuleBase.MakeUninstallable() } +func (library *libraryDecorator) getAPIListCoverageXMLPath() android.ModuleOutPath { + return library.apiListCoverageXmlPath +} + var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList") // versioningMacroNamesList returns a singleton map, where keys are "version macro names", diff --git a/cc/stub_library.go b/cc/stub_library.go index 1722c8096..76da782ee 100644 --- a/cc/stub_library.go +++ b/cc/stub_library.go @@ -15,6 +15,7 @@ package cc import ( + "sort" "strings" "android/soong/android" @@ -27,6 +28,8 @@ func init() { type stubLibraries struct { stubLibraryMap map[string]bool + + apiListCoverageXmlPaths []string } // Check if the module defines stub, or itself is stub @@ -53,6 +56,11 @@ func (s *stubLibraries) GenerateBuildActions(ctx android.SingletonContext) { s.stubLibraryMap[name] = true } } + if m.library != nil { + if p := m.library.getAPIListCoverageXMLPath().String(); p != "" { + s.apiListCoverageXmlPaths = append(s.apiListCoverageXmlPaths, p) + } + } } }) } @@ -66,4 +74,8 @@ func stubLibrariesSingleton() android.Singleton { func (s *stubLibraries) MakeVars(ctx android.MakeVarsContext) { // Convert stub library file names into Makefile variable. ctx.Strict("STUB_LIBRARIES", strings.Join(android.SortedStringKeys(s.stubLibraryMap), " ")) + + // Export the list of API XML files to Make. + sort.Strings(s.apiListCoverageXmlPaths) + ctx.Strict("SOONG_CC_API_XML", strings.Join(s.apiListCoverageXmlPaths, " ")) }