Add llndk_stubs property
Prepare for making the relationship between an llndk_library stubs module and the cc_library implementation module explicit by adding an llndk_stubs property. Each cc_library will be updated to point to its llndk_library, and the llndk_library name will be changed to make the .llndk suffix explicit. Then the implicit connection and suffix can be removed. Bug: 170784825 Test: m checkbuild Change-Id: I6b0482a3f286ec29b2e928551aa4317749f2b499
This commit is contained in:
@@ -72,6 +72,7 @@ type AndroidMkEntriesProvider interface {
|
||||
type AndroidMkEntries struct {
|
||||
Class string
|
||||
SubName string
|
||||
OverrideName string
|
||||
DistFiles TaggedDistFiles
|
||||
OutputFile OptionalPath
|
||||
Disabled bool
|
||||
@@ -273,6 +274,9 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
||||
a.EntryMap = make(map[string][]string)
|
||||
amod := mod.(Module).base()
|
||||
name := amod.BaseModuleName()
|
||||
if a.OverrideName != "" {
|
||||
name = a.OverrideName
|
||||
}
|
||||
|
||||
if a.Include == "" {
|
||||
a.Include = "$(BUILD_PREBUILT)"
|
||||
|
@@ -2383,11 +2383,12 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// system libraries.
|
||||
if !am.DirectlyInAnyApex() {
|
||||
// we need a module name for Make
|
||||
name := cc.BaseModuleName() + cc.Properties.SubName
|
||||
if proptools.Bool(a.properties.Use_vendor) {
|
||||
name := cc.ImplementationModuleName(ctx)
|
||||
|
||||
if !proptools.Bool(a.properties.Use_vendor) {
|
||||
// we don't use subName(.vendor) for a "use_vendor: true" apex
|
||||
// which is supposed to be installed in /system
|
||||
name = cc.BaseModuleName()
|
||||
name += cc.Properties.SubName
|
||||
}
|
||||
if !android.InList(name, a.requiredDeps) {
|
||||
a.requiredDeps = append(a.requiredDeps, name)
|
||||
|
@@ -1270,10 +1270,11 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
stubs: { versions: ["29","30"] },
|
||||
llndk_stubs: "libbar.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libbar",
|
||||
name: "libbar.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
`, func(fs map[string][]byte, config android.Config) {
|
||||
|
@@ -33,6 +33,7 @@ var (
|
||||
)
|
||||
|
||||
type AndroidMkContext interface {
|
||||
BaseModuleName() string
|
||||
Target() android.Target
|
||||
subAndroidMk(*android.AndroidMkEntries, interface{})
|
||||
Arch() android.Arch
|
||||
@@ -462,6 +463,7 @@ func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.
|
||||
|
||||
func (c *llndkStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
|
||||
entries.Class = "SHARED_LIBRARIES"
|
||||
entries.OverrideName = c.implementationModuleName(ctx.BaseModuleName())
|
||||
|
||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||
c.libraryDecorator.androidMkWriteExportedFlags(entries)
|
||||
|
10
cc/cc.go
10
cc/cc.go
@@ -1040,6 +1040,16 @@ func (c *Module) HasStubsVariants() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// If this is a stubs library, ImplementationModuleName returns the name of the module that contains
|
||||
// the implementation. If it is an implementation library it returns its own name.
|
||||
func (c *Module) ImplementationModuleName(ctx android.BaseModuleContext) string {
|
||||
name := ctx.OtherModuleName(c)
|
||||
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||
name = versioned.implementationModuleName(name)
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (c *Module) bootstrap() bool {
|
||||
return Bool(c.Properties.Bootstrap)
|
||||
}
|
||||
|
@@ -846,10 +846,11 @@ func TestDoubleLoadbleDep(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
shared_libs: ["libdoubleloadable"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -867,10 +868,11 @@ func TestDoubleLoadbleDep(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
shared_libs: ["libvndksp"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -924,10 +926,11 @@ func TestDoubleLoadbleDep(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
shared_libs: ["libcoreonly"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -1523,10 +1526,11 @@ func TestDoubleLoadableDepError(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
shared_libs: ["libnondoubleloadable"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -1545,10 +1549,11 @@ func TestDoubleLoadableDepError(t *testing.T) {
|
||||
name: "libllndk",
|
||||
no_libcrt: true,
|
||||
shared_libs: ["libnondoubleloadable"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -1617,10 +1622,11 @@ func TestDoubleLoadableDepError(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
shared_libs: ["libcoreonly"],
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
@@ -2361,9 +2367,10 @@ func TestEnforceProductVndkVersion(t *testing.T) {
|
||||
bp := `
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
cc_library {
|
||||
@@ -2564,16 +2571,18 @@ func TestMakeLinkType(t *testing.T) {
|
||||
}
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
cc_library {
|
||||
name: "libllndkprivate",
|
||||
llndk_stubs: "libllndkprivate.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libllndkprivate",
|
||||
name: "libllndkprivate.llndk",
|
||||
vendor_available: false,
|
||||
symbol_file: "",
|
||||
}`
|
||||
@@ -2987,9 +2996,10 @@ func TestLlndkLibrary(t *testing.T) {
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
stubs: { versions: ["1", "2"] },
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
}
|
||||
`)
|
||||
actual := ctx.ModuleVariantsForTests("libllndk.llndk")
|
||||
@@ -3017,9 +3027,14 @@ func TestLlndkHeaders(t *testing.T) {
|
||||
export_include_dirs: ["my_include"],
|
||||
}
|
||||
llndk_library {
|
||||
name: "libllndk",
|
||||
name: "libllndk.llndk",
|
||||
export_llndk_headers: ["libllndk_headers"],
|
||||
}
|
||||
cc_library {
|
||||
name: "libllndk",
|
||||
llndk_stubs: "libllndk.llndk",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libvendor",
|
||||
shared_libs: ["libllndk"],
|
||||
|
@@ -110,6 +110,9 @@ type LibraryProperties struct {
|
||||
|
||||
// Inject boringssl hash into the shared library. This is only intended for use by external/boringssl.
|
||||
Inject_bssl_hash *bool `android:"arch_variant"`
|
||||
|
||||
// If this is an LLNDK library, the name of the equivalent llndk_library module.
|
||||
Llndk_stubs *string
|
||||
}
|
||||
|
||||
type StaticProperties struct {
|
||||
@@ -695,6 +698,8 @@ type versionedInterface interface {
|
||||
stubsVersions(ctx android.BaseMutatorContext) []string
|
||||
setAllStubsVersions([]string)
|
||||
allStubsVersions() []string
|
||||
|
||||
implementationModuleName(name string) string
|
||||
}
|
||||
|
||||
var _ libraryInterface = (*libraryDecorator)(nil)
|
||||
@@ -1205,7 +1210,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
||||
}
|
||||
|
||||
if library.buildStubs() && !library.skipAPIDefine {
|
||||
library.reexportFlags("-D" + versioningMacroName(ctx.baseModuleName()) + "=" + library.stubsVersion())
|
||||
library.reexportFlags("-D" + versioningMacroName(ctx.Module().(*Module).ImplementationModuleName(ctx)) + "=" + library.stubsVersion())
|
||||
}
|
||||
|
||||
library.flagExporter.setProvider(ctx)
|
||||
@@ -1358,6 +1363,10 @@ func (library *libraryDecorator) HeaderOnly() {
|
||||
library.MutatedProperties.BuildStatic = false
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) implementationModuleName(name string) string {
|
||||
return name
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) buildStubs() bool {
|
||||
return library.MutatedProperties.BuildStubs
|
||||
}
|
||||
|
@@ -72,6 +72,8 @@ type llndkStubDecorator struct {
|
||||
movedToApex bool
|
||||
}
|
||||
|
||||
var _ versionedInterface = (*llndkStubDecorator)(nil)
|
||||
|
||||
func (stub *llndkStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
|
||||
flags = stub.baseCompiler.compilerFlags(ctx, flags, deps)
|
||||
return addStubLibraryCompilerFlags(flags)
|
||||
@@ -101,12 +103,14 @@ func (stub *llndkStubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
}
|
||||
|
||||
func (stub *llndkStubDecorator) Name(name string) string {
|
||||
if strings.HasSuffix(name, llndkLibrarySuffix) {
|
||||
return name
|
||||
}
|
||||
return name + llndkLibrarySuffix
|
||||
}
|
||||
|
||||
func (stub *llndkStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
stub.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(),
|
||||
llndkLibrarySuffix)
|
||||
stub.libraryDecorator.libName = stub.implementationModuleName(ctx.ModuleName())
|
||||
return stub.libraryDecorator.linkerFlags(ctx, flags)
|
||||
}
|
||||
|
||||
@@ -133,7 +137,7 @@ func (stub *llndkStubDecorator) processHeaders(ctx ModuleContext, srcHeaderDir s
|
||||
func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
||||
objs Objects) android.Path {
|
||||
|
||||
impl := ctx.GetDirectDepWithTag(ctx.baseModuleName(), llndkImplDep)
|
||||
impl := ctx.GetDirectDepWithTag(stub.implementationModuleName(ctx.ModuleName()), llndkImplDep)
|
||||
if implApexModule, ok := impl.(android.ApexModule); ok {
|
||||
stub.movedToApex = implApexModule.DirectlyInAnyApex()
|
||||
}
|
||||
@@ -167,6 +171,10 @@ func (stub *llndkStubDecorator) nativeCoverage() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (stub *llndkStubDecorator) implementationModuleName(name string) string {
|
||||
return strings.TrimSuffix(name, llndkLibrarySuffix)
|
||||
}
|
||||
|
||||
func (stub *llndkStubDecorator) buildStubs() bool {
|
||||
return true
|
||||
}
|
||||
|
@@ -100,10 +100,16 @@ type stubDecorator struct {
|
||||
unversionedUntil android.ApiLevel
|
||||
}
|
||||
|
||||
var _ versionedInterface = (*stubDecorator)(nil)
|
||||
|
||||
func shouldUseVersionScript(ctx BaseModuleContext, stub *stubDecorator) bool {
|
||||
return stub.apiLevel.GreaterThanOrEqualTo(stub.unversionedUntil)
|
||||
}
|
||||
|
||||
func (stub *stubDecorator) implementationModuleName(name string) string {
|
||||
return strings.TrimSuffix(name, ndkLibrarySuffix)
|
||||
}
|
||||
|
||||
func ndkLibraryVersions(ctx android.BaseMutatorContext, from android.ApiLevel) []string {
|
||||
var versions []android.ApiLevel
|
||||
versionStrs := []string{}
|
||||
|
@@ -172,9 +172,10 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||
stubs: {
|
||||
versions: ["27", "28", "29"],
|
||||
},
|
||||
}
|
||||
llndk_stubs: "libc.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libc",
|
||||
name: "libc.llndk",
|
||||
symbol_file: "",
|
||||
sdk_version: "current",
|
||||
}
|
||||
@@ -193,9 +194,10 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||
"//apex_available:platform",
|
||||
"myapex"
|
||||
],
|
||||
llndk_stubs: "libm.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libm",
|
||||
name: "libm.llndk",
|
||||
symbol_file: "",
|
||||
sdk_version: "current",
|
||||
}
|
||||
@@ -253,9 +255,10 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||
"//apex_available:platform",
|
||||
"myapex"
|
||||
],
|
||||
llndk_stubs: "libdl.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libdl",
|
||||
name: "libdl.llndk",
|
||||
symbol_file: "",
|
||||
sdk_version: "current",
|
||||
}
|
||||
@@ -265,9 +268,10 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
recovery_available: true,
|
||||
llndk_stubs: "libft2.llndk",
|
||||
}
|
||||
llndk_library {
|
||||
name: "libft2",
|
||||
name: "libft2.llndk",
|
||||
symbol_file: "",
|
||||
vendor_available: false,
|
||||
sdk_version: "current",
|
||||
|
10
cc/vndk.go
10
cc/vndk.go
@@ -247,7 +247,7 @@ func vndkSpLibraries(config android.Config) map[string]string {
|
||||
}
|
||||
|
||||
func isLlndkLibrary(baseModuleName string, config android.Config) bool {
|
||||
_, ok := llndkLibraries(config)[baseModuleName]
|
||||
_, ok := llndkLibraries(config)[strings.TrimSuffix(baseModuleName, llndkLibrarySuffix)]
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -290,8 +290,8 @@ func setVndkMustUseVendorVariantListForTest(config android.Config, mustUseVendor
|
||||
|
||||
func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
|
||||
lib := m.linker.(*llndkStubDecorator)
|
||||
name := m.BaseModuleName()
|
||||
filename := m.BaseModuleName() + ".so"
|
||||
name := m.ImplementationModuleName(mctx)
|
||||
filename := name + ".so"
|
||||
|
||||
vndkLibrariesLock.Lock()
|
||||
defer vndkLibrariesLock.Unlock()
|
||||
@@ -834,8 +834,8 @@ func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
|
||||
if m, ok := module.(*Module); ok {
|
||||
if llndk, ok := m.linker.(*llndkStubDecorator); ok {
|
||||
// Skip bionic libs, they are handled in different manner
|
||||
name := m.BaseModuleName()
|
||||
if llndk.movedToApex && !isBionic(m.BaseModuleName()) {
|
||||
name := llndk.implementationModuleName(m.BaseModuleName())
|
||||
if llndk.movedToApex && !isBionic(name) {
|
||||
movedToApexLlndkLibraries[name] = true
|
||||
}
|
||||
}
|
||||
|
@@ -268,6 +268,7 @@ func TestSyspropLibrary(t *testing.T) {
|
||||
system_shared_libs: [],
|
||||
recovery_available: true,
|
||||
host_supported: true,
|
||||
llndk_stubs: "liblog.llndk",
|
||||
}
|
||||
|
||||
cc_binary_host {
|
||||
@@ -276,7 +277,7 @@ func TestSyspropLibrary(t *testing.T) {
|
||||
}
|
||||
|
||||
llndk_library {
|
||||
name: "liblog",
|
||||
name: "liblog.llndk",
|
||||
symbol_file: "",
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user