use version mutator for CRT
Move the CRT objects into the version mutator and retire the ndk_api mutator. Test: no change to build.ninja or Android-${TARGET_PRODUCT}.mk Change-Id: Ibbbde323e3e0e8e4702dda4f3828a49786280118
This commit is contained in:
6
cc/cc.go
6
cc/cc.go
@@ -45,7 +45,6 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
||||||
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
||||||
ctx.BottomUp("link", LinkageMutator).Parallel()
|
ctx.BottomUp("link", LinkageMutator).Parallel()
|
||||||
ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
|
|
||||||
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
||||||
ctx.BottomUp("version_selector", versionSelectorMutator).Parallel()
|
ctx.BottomUp("version_selector", versionSelectorMutator).Parallel()
|
||||||
ctx.BottomUp("version", versionMutator).Parallel()
|
ctx.BottomUp("version", versionMutator).Parallel()
|
||||||
@@ -1688,7 +1687,7 @@ func GetCrtVariations(ctx android.BottomUpMutatorContext,
|
|||||||
if m.UseSdk() {
|
if m.UseSdk() {
|
||||||
return []blueprint.Variation{
|
return []blueprint.Variation{
|
||||||
{Mutator: "sdk", Variation: "sdk"},
|
{Mutator: "sdk", Variation: "sdk"},
|
||||||
{Mutator: "ndk_api", Variation: m.SdkVersion()},
|
{Mutator: "version", Variation: m.SdkVersion()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []blueprint.Variation{
|
return []blueprint.Variation{
|
||||||
@@ -1954,11 +1953,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
actx.AddDependency(c, depTag, gen)
|
actx.AddDependency(c, depTag, gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
|
|
||||||
|
|
||||||
vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
|
vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
|
||||||
|
|
||||||
crtVariations := GetCrtVariations(ctx, c)
|
crtVariations := GetCrtVariations(ctx, c)
|
||||||
|
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
|
||||||
if deps.CrtBegin != "" {
|
if deps.CrtBegin != "" {
|
||||||
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
|
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
|
||||||
rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
|
rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
|
||||||
|
@@ -1611,6 +1611,21 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
|
|||||||
mctx.CreateAliasVariation("latest", latestVersion)
|
mctx.CreateAliasVariation("latest", latestVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createPerApiVersionVariations(mctx android.BottomUpMutatorContext, minSdkVersion string) {
|
||||||
|
from, err := nativeApiLevelFromUser(mctx, minSdkVersion)
|
||||||
|
if err != nil {
|
||||||
|
mctx.PropertyErrorf("min_sdk_version", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
versionStrs := ndkLibraryVersions(mctx, from)
|
||||||
|
modules := mctx.CreateLocalVariations(versionStrs...)
|
||||||
|
|
||||||
|
for i, module := range modules {
|
||||||
|
module.(*Module).Properties.Sdk_version = StringPtr(versionStrs[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CanBeOrLinkAgainstVersionVariants(module interface {
|
func CanBeOrLinkAgainstVersionVariants(module interface {
|
||||||
Host() bool
|
Host() bool
|
||||||
InRamdisk() bool
|
InRamdisk() bool
|
||||||
@@ -1646,6 +1661,23 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if compiler, ok := c.linker.(*stubDecorator); ok {
|
||||||
|
if mctx.Os() != android.Android {
|
||||||
|
// These modules are always android.DeviceEnabled only, but
|
||||||
|
// those include Fuchsia devices, which we don't support.
|
||||||
|
mctx.Module().Disable()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
firstVersion, err := nativeApiLevelFromUser(mctx,
|
||||||
|
String(compiler.properties.First_version))
|
||||||
|
if err != nil {
|
||||||
|
mctx.PropertyErrorf("first_version", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.SetAllStubsVersions(ndkLibraryVersions(mctx, firstVersion))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 && !library.UseSdk() {
|
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 && !library.UseSdk() {
|
||||||
@@ -1659,7 +1691,6 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
library.SetAllStubsVersions(versions)
|
library.SetAllStubsVersions(versions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1668,6 +1699,16 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
func versionMutator(mctx android.BottomUpMutatorContext) {
|
func versionMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
||||||
createVersionVariations(mctx, library.AllStubsVersions())
|
createVersionVariations(mctx, library.AllStubsVersions())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if m, ok := mctx.Module().(*Module); ok {
|
||||||
|
if m.SplitPerApiLevel() && m.IsSdkVariant() {
|
||||||
|
if mctx.Os() != android.Android {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
createPerApiVersionVariations(mctx, m.MinSdkVersion())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -118,53 +118,6 @@ func ndkLibraryVersions(ctx android.BottomUpMutatorContext, from android.ApiLeve
|
|||||||
return versionStrs
|
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), android.ApiLevelOrPanic(ctx, versionStrs[i]))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NdkApiMutator(ctx android.BottomUpMutatorContext) {
|
|
||||||
if m, ok := ctx.Module().(*Module); ok {
|
|
||||||
if m.Enabled() {
|
|
||||||
if compiler, ok := m.compiler.(*stubDecorator); ok {
|
|
||||||
if ctx.Os() != android.Android {
|
|
||||||
// These modules are always android.DeviceEnabled only, but
|
|
||||||
// those include Fuchsia devices, which we don't support.
|
|
||||||
ctx.Module().Disable()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
firstVersion, err := nativeApiLevelFromUser(ctx,
|
|
||||||
String(compiler.properties.First_version))
|
|
||||||
if err != nil {
|
|
||||||
ctx.PropertyErrorf("first_version", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.SetAllStubsVersions(ndkLibraryVersions(ctx, firstVersion))
|
|
||||||
} else if m.SplitPerApiLevel() && m.IsSdkVariant() {
|
|
||||||
if ctx.Os() != android.Android {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
from, err := nativeApiLevelFromUser(ctx, m.MinSdkVersion())
|
|
||||||
if err != nil {
|
|
||||||
ctx.PropertyErrorf("min_sdk_version", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
generatePerApiVariants(ctx, from,
|
|
||||||
func(m *Module, version android.ApiLevel) {
|
|
||||||
m.Properties.Sdk_version = StringPtr(version.String())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
||||||
this.apiLevel = nativeApiLevelOrPanic(ctx, this.stubsVersion())
|
this.apiLevel = nativeApiLevelOrPanic(ctx, this.stubsVersion())
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user