Remove global state from vendor public libraries
Remove the global list of vendor public library modules used to rewrite
dependencies from the vendor module to the stubs for system modules,
and replace it with building the stubs directly in the system variant
of the vendor module.
Bug: 178231622
Test: vendor_public_library_test.go
Change-Id: I826e69ffd507d7e85fa3d4d85b5157428c642143
diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go
index 394e322..65a2b0c 100644
--- a/cc/vendor_public_library.go
+++ b/cc/vendor_public_library.go
@@ -14,26 +14,10 @@
package cc
-import (
- "strings"
- "sync"
-
- "android/soong/android"
-)
-
var (
vendorPublicLibrarySuffix = ".vendorpublic"
-
- vendorPublicLibrariesKey = android.NewOnceKey("vendorPublicLibraries")
- vendorPublicLibrariesLock sync.Mutex
)
-func vendorPublicLibraries(config android.Config) *[]string {
- return config.Once(vendorPublicLibrariesKey, func() interface{} {
- return &[]string{}
- }).(*[]string)
-}
-
// Creates a stub shared library for a vendor public library. Vendor public libraries
// are vendor libraries (owned by them and installed to /vendor partition) that are
// exposed to Android apps via JNI. The libraries are made public by being listed in
@@ -64,105 +48,9 @@
// list of header libs to re-export include directories from.
Export_public_headers []string `android:"arch_variant"`
-}
-type vendorPublicLibraryStubDecorator struct {
- *libraryDecorator
-
- Properties vendorPublicLibraryProperties
-
- versionScriptPath android.ModuleGenPath
-}
-
-func (stub *vendorPublicLibraryStubDecorator) Name(name string) string {
- return name + vendorPublicLibrarySuffix
-}
-
-func (stub *vendorPublicLibraryStubDecorator) compilerInit(ctx BaseModuleContext) {
- stub.baseCompiler.compilerInit(ctx)
-
- name := ctx.baseModuleName()
- if strings.HasSuffix(name, vendorPublicLibrarySuffix) {
- ctx.PropertyErrorf("name", "Do not append %q manually, just use the base name", vendorPublicLibrarySuffix)
- }
-
- vendorPublicLibrariesLock.Lock()
- defer vendorPublicLibrariesLock.Unlock()
- vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
- for _, lib := range *vendorPublicLibraries {
- if lib == name {
- return
- }
- }
- *vendorPublicLibraries = append(*vendorPublicLibraries, name)
-}
-
-func (stub *vendorPublicLibraryStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
- flags = stub.baseCompiler.compilerFlags(ctx, flags, deps)
- return addStubLibraryCompilerFlags(flags)
-}
-
-func (stub *vendorPublicLibraryStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
- objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), "current", "")
- stub.versionScriptPath = versionScript
- return objs
-}
-
-func (stub *vendorPublicLibraryStubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
- headers := stub.Properties.Export_public_headers
- deps.HeaderLibs = append(deps.HeaderLibs, headers...)
- deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders, headers...)
- return deps
-}
-
-func (stub *vendorPublicLibraryStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
- stub.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), vendorPublicLibrarySuffix)
- return stub.libraryDecorator.linkerFlags(ctx, flags)
-}
-
-func (stub *vendorPublicLibraryStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
- objs Objects) android.Path {
- if !Bool(stub.Properties.Unversioned) {
- linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
- flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
- flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
- }
- return stub.libraryDecorator.link(ctx, flags, deps, objs)
-}
-
-// vendor_public_library creates a stub shared library for a vendor public
-// library. This stub library is a build-time only artifact that provides
-// symbols that are exposed from a vendor public library. Example:
-//
-// vendor_public_library {
-// name: "libfoo",
-// symbol_file: "libfoo.map.txt",
-// export_public_headers: ["libfoo_headers"],
-// }
-func vendorPublicLibraryFactory() android.Module {
- module, library := NewLibrary(android.DeviceSupported)
- library.BuildOnlyShared()
- module.stl = nil
- module.sanitize = nil
- library.disableStripping()
-
- stub := &vendorPublicLibraryStubDecorator{
- libraryDecorator: library,
- }
- module.compiler = stub
- module.linker = stub
- module.installer = nil
-
- module.AddProperties(
- &stub.Properties,
- &module.VendorProperties,
- &library.MutatedProperties,
- &library.flagExporter.Properties)
-
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
- return module
-}
-
-func init() {
- android.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
+ // list of directories relative to the Blueprints file that willbe added to the include path
+ // (using -I) for any module that links against the LLNDK variant of this module, replacing
+ // any that were listed outside the llndk clause.
+ Override_export_include_dirs []string
}