Use version mutator for NDK
The ndk_api mutator is similar to the version mutator. Move the ndk_library ndk_api variations into the version mutator instead, which will help later when consolidating the stubs handling between NDK, LLDNK and Apex libraries. Test: No change to build.ninja or Android-${TARGET_PRODUCT}.mk Change-Id: I51417cf669265762c15f7289e1dc186d017ef4a9
This commit is contained in:
parent
8e21aa54eb
commit
5ec407b594
|
@ -442,6 +442,11 @@ func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.
|
|||
entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
|
||||
entries.Class = "SHARED_LIBRARIES"
|
||||
|
||||
if !c.buildStubs() {
|
||||
entries.Disabled = true
|
||||
return
|
||||
}
|
||||
|
||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||
path, file := filepath.Split(c.installPath.String())
|
||||
stem, suffix, _ := android.SplitFileExt(file)
|
||||
|
|
4
cc/cc.go
4
cc/cc.go
|
@ -1978,13 +1978,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
|
||||
ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version}
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "ndk_api", Variation: version},
|
||||
{Mutator: "version", Variation: version},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, ndkStubDepTag, variantNdkLibs...)
|
||||
|
||||
ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version}
|
||||
actx.AddVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "ndk_api", Variation: version},
|
||||
{Mutator: "version", Variation: version},
|
||||
{Mutator: "link", Variation: "shared"},
|
||||
}, ndkLateStubDepTag, variantLateNdkLibs...)
|
||||
|
||||
|
|
|
@ -355,6 +355,8 @@ type libraryDecorator struct {
|
|||
useCoreVariant bool
|
||||
checkSameCoreVariant bool
|
||||
|
||||
skipAPIDefine bool
|
||||
|
||||
// Decorated interfaces
|
||||
*baseCompiler
|
||||
*baseLinker
|
||||
|
@ -1197,7 +1199,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||
library.addExportedGeneratedHeaders(library.baseCompiler.pathDeps...)
|
||||
}
|
||||
|
||||
if library.buildStubs() {
|
||||
if library.buildStubs() && !library.skipAPIDefine {
|
||||
library.reexportFlags("-D" + versioningMacroName(ctx.baseModuleName()) + "=" + library.stubsVersion())
|
||||
}
|
||||
|
||||
|
@ -1613,16 +1615,14 @@ func CanBeOrLinkAgainstVersionVariants(module interface {
|
|||
Host() bool
|
||||
InRamdisk() bool
|
||||
InRecovery() bool
|
||||
UseSdk() bool
|
||||
}) bool {
|
||||
return !module.Host() && !module.InRamdisk() && !module.InRecovery() && !module.UseSdk()
|
||||
return !module.Host() && !module.InRamdisk() && !module.InRecovery()
|
||||
}
|
||||
|
||||
func CanBeVersionVariant(module interface {
|
||||
Host() bool
|
||||
InRamdisk() bool
|
||||
InRecovery() bool
|
||||
UseSdk() bool
|
||||
CcLibraryInterface() bool
|
||||
Shared() bool
|
||||
Static() bool
|
||||
|
@ -1648,7 +1648,7 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 && !library.UseSdk() {
|
||||
versions := library.StubsVersions()
|
||||
normalizeVersions(mctx, versions)
|
||||
if mctx.Failed() {
|
||||
|
|
|
@ -80,9 +80,6 @@ type libraryProperties struct {
|
|||
// https://github.com/android-ndk/ndk/issues/265.
|
||||
Unversioned_until *string
|
||||
|
||||
// Use via apiLevel on the stubDecorator.
|
||||
ApiLevel string `blueprint:"mutated"`
|
||||
|
||||
// True if this API is not yet ready to be shipped in the NDK. It will be
|
||||
// available in the platform for testing, but will be excluded from the
|
||||
// sysroot provided to the NDK proper.
|
||||
|
@ -107,9 +104,7 @@ func shouldUseVersionScript(ctx BaseModuleContext, stub *stubDecorator) bool {
|
|||
return stub.apiLevel.GreaterThanOrEqualTo(stub.unversionedUntil)
|
||||
}
|
||||
|
||||
func generatePerApiVariants(ctx android.BottomUpMutatorContext, m *Module,
|
||||
from android.ApiLevel, perSplit func(*Module, android.ApiLevel)) {
|
||||
|
||||
func ndkLibraryVersions(ctx android.BottomUpMutatorContext, from android.ApiLevel) []string {
|
||||
var versions []android.ApiLevel
|
||||
versionStrs := []string{}
|
||||
for _, version := range ctx.Config().AllSupportedApiLevels() {
|
||||
|
@ -118,12 +113,20 @@ func generatePerApiVariants(ctx android.BottomUpMutatorContext, m *Module,
|
|||
versionStrs = append(versionStrs, version.String())
|
||||
}
|
||||
}
|
||||
versions = append(versions, android.FutureApiLevel)
|
||||
versionStrs = append(versionStrs, android.FutureApiLevel.String())
|
||||
|
||||
return versionStrs
|
||||
}
|
||||
|
||||
func generatePerApiVariants(ctx android.BottomUpMutatorContext,
|
||||
from android.ApiLevel, perSplit func(*Module, android.ApiLevel)) {
|
||||
|
||||
versionStrs := ndkLibraryVersions(ctx, from)
|
||||
modules := ctx.CreateVariations(versionStrs...)
|
||||
|
||||
for i, module := range modules {
|
||||
perSplit(module.(*Module), versions[i])
|
||||
perSplit(module.(*Module), android.ApiLevelOrPanic(ctx, versionStrs[i]))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,11 +146,7 @@ func NdkApiMutator(ctx android.BottomUpMutatorContext) {
|
|||
ctx.PropertyErrorf("first_version", err.Error())
|
||||
return
|
||||
}
|
||||
generatePerApiVariants(ctx, m, firstVersion,
|
||||
func(m *Module, version android.ApiLevel) {
|
||||
m.compiler.(*stubDecorator).properties.ApiLevel =
|
||||
version.String()
|
||||
})
|
||||
m.SetAllStubsVersions(ndkLibraryVersions(ctx, firstVersion))
|
||||
} else if m.SplitPerApiLevel() && m.IsSdkVariant() {
|
||||
if ctx.Os() != android.Android {
|
||||
return
|
||||
|
@ -157,7 +156,7 @@ func NdkApiMutator(ctx android.BottomUpMutatorContext) {
|
|||
ctx.PropertyErrorf("min_sdk_version", err.Error())
|
||||
return
|
||||
}
|
||||
generatePerApiVariants(ctx, m, from,
|
||||
generatePerApiVariants(ctx, from,
|
||||
func(m *Module, version android.ApiLevel) {
|
||||
m.Properties.Sdk_version = StringPtr(version.String())
|
||||
})
|
||||
|
@ -167,7 +166,7 @@ func NdkApiMutator(ctx android.BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
||||
this.apiLevel = nativeApiLevelOrPanic(ctx, this.properties.ApiLevel)
|
||||
this.apiLevel = nativeApiLevelOrPanic(ctx, this.stubsVersion())
|
||||
|
||||
var err error
|
||||
this.firstVersion, err = nativeApiLevelFromUser(ctx,
|
||||
|
@ -280,6 +279,11 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
|
|||
ctx.PropertyErrorf("symbol_file", "must end with .map.txt")
|
||||
}
|
||||
|
||||
if !c.buildStubs() {
|
||||
// NDK libraries have no implementation variant, nothing to do
|
||||
return Objects{}
|
||||
}
|
||||
|
||||
if !c.initializeProperties(ctx) {
|
||||
// Emits its own errors, so we don't need to.
|
||||
return Objects{}
|
||||
|
@ -311,12 +315,18 @@ func (stub *stubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|||
func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
||||
objs Objects) android.Path {
|
||||
|
||||
if !stub.buildStubs() {
|
||||
// NDK libraries have no implementation variant, nothing to do
|
||||
return nil
|
||||
}
|
||||
|
||||
if shouldUseVersionScript(ctx, stub) {
|
||||
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
|
||||
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
|
||||
flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
|
||||
}
|
||||
|
||||
stub.libraryDecorator.skipAPIDefine = true
|
||||
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||
}
|
||||
|
||||
if m, ok := module.(*Module); ok {
|
||||
if installer, ok := m.installer.(*stubDecorator); ok {
|
||||
if installer, ok := m.installer.(*stubDecorator); ok && m.BuildStubs() {
|
||||
if ctx.Config().ExcludeDraftNdkApis() &&
|
||||
installer.properties.Draft {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue