Merge "Remove global state from vendor public libraries"

This commit is contained in:
Colin Cross
2021-04-29 16:16:42 +00:00
committed by Gerrit Code Review
10 changed files with 89 additions and 163 deletions

View File

@@ -120,6 +120,9 @@ type LibraryProperties struct {
// If this is an LLNDK library, properties to describe the LLNDK stubs. Will be copied from
// the module pointed to by llndk_stubs if it is set.
Llndk llndkLibraryProperties
// If this is a vendor public library, properties to describe the vendor public library stubs.
Vendor_public_library vendorPublicLibraryProperties
}
// StaticProperties is a properties stanza to affect only attributes of the "static" variants of a
@@ -786,6 +789,13 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
}
return objs
}
if ctx.IsVendorPublicLibrary() {
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Vendor_public_library.Symbol_file), "current", "")
if !Bool(library.Properties.Vendor_public_library.Unversioned) {
library.versionScriptPath = android.OptionalPathForPath(versionScript)
}
return objs
}
if library.buildStubs() {
symbolFile := String(library.Properties.Stubs.Symbol_file)
if symbolFile != "" && !strings.HasSuffix(symbolFile, ".map.txt") {
@@ -883,6 +893,7 @@ type versionedInterface interface {
implementationModuleName(name string) string
hasLLNDKStubs() bool
hasLLNDKHeaders() bool
hasVendorPublicLibrary() bool
}
var _ libraryInterface = (*libraryDecorator)(nil)
@@ -978,6 +989,12 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportHeaderLibHeaders = append([]string(nil), library.Properties.Llndk.Export_llndk_headers...)
return deps
}
if ctx.IsVendorPublicLibrary() {
headers := library.Properties.Vendor_public_library.Export_public_headers
deps.HeaderLibs = append([]string(nil), headers...)
deps.ReexportHeaderLibHeaders = append([]string(nil), headers...)
return deps
}
if library.static() {
// Compare with nil because an empty list needs to be propagated.
@@ -1434,6 +1451,14 @@ func (library *libraryDecorator) link(ctx ModuleContext,
}
}
if ctx.IsVendorPublicLibrary() {
// override the module's export_include_dirs with vendor_public_library.override_export_include_dirs
// if it is set.
if override := library.Properties.Vendor_public_library.Override_export_include_dirs; override != nil {
library.flagExporter.Properties.Export_include_dirs = override
}
}
// Linking this library consists of linking `deps.Objs` (.o files in dependencies
// of this library), together with `objs` (.o files created by compiling this
// library).
@@ -1695,6 +1720,12 @@ func (library *libraryDecorator) hasLLNDKHeaders() bool {
return Bool(library.Properties.Llndk.Llndk_headers)
}
// hasVendorPublicLibrary returns true if this cc_library module has a variant that will build
// vendor public library stubs.
func (library *libraryDecorator) hasVendorPublicLibrary() bool {
return String(library.Properties.Vendor_public_library.Symbol_file) != ""
}
func (library *libraryDecorator) implementationModuleName(name string) string {
return name
}
@@ -1994,11 +2025,12 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
m := mctx.Module().(*Module)
isLLNDK := m.IsLlndk()
isVendorPublicLibrary := m.IsVendorPublicLibrary()
modules := mctx.CreateLocalVariations(variants...)
for i, m := range modules {
if variants[i] != "" || isLLNDK {
if variants[i] != "" || isLLNDK || isVendorPublicLibrary {
// A stubs or LLNDK stubs variant.
c := m.(*Module)
c.sanitize = nil