Don't generate intermediate NDK libraries. am: 7fa7b2efd3
am: df66aa3ecf
Change-Id: I2ee3c895c79fec6bb99d18e292cc2f915391c1be
This commit is contained in:
7
cc/cc.go
7
cc/cc.go
@@ -491,6 +491,13 @@ func (c *Module) begin(ctx BaseModuleContext) {
|
|||||||
for _, feature := range c.features {
|
for _, feature := range c.features {
|
||||||
feature.begin(ctx)
|
feature.begin(ctx)
|
||||||
}
|
}
|
||||||
|
if ctx.sdk() {
|
||||||
|
version, err := normalizeNdkApiLevel(ctx.sdkVersion(), ctx.Arch())
|
||||||
|
if err != nil {
|
||||||
|
ctx.PropertyErrorf("sdk_version", err.Error())
|
||||||
|
}
|
||||||
|
c.Properties.Sdk_version = strconv.Itoa(version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) deps(ctx BaseModuleContext) Deps {
|
func (c *Module) deps(ctx BaseModuleContext) Deps {
|
||||||
|
@@ -99,26 +99,16 @@ type stubDecorator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OMG GO
|
// OMG GO
|
||||||
func intMin(a int, b int) int {
|
func intMax(a int, b int) int {
|
||||||
if a < b {
|
if a > b {
|
||||||
return a
|
return a
|
||||||
} else {
|
} else {
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
|
func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (int, error) {
|
||||||
minVersion := 9 // Minimum version supported by the NDK.
|
minVersion := 9 // Minimum version supported by the NDK.
|
||||||
// TODO(danalbert): Use PlatformSdkVersion when possible.
|
|
||||||
// This is an interesting case because for the moment we actually need 24
|
|
||||||
// even though the latest released version in aosp is 23. prebuilts/ndk/r11
|
|
||||||
// has android-24 versions of libraries, and as platform libraries get
|
|
||||||
// migrated the libraries in prebuilts will need to depend on them.
|
|
||||||
//
|
|
||||||
// Once everything is all moved over to the new stuff (when there isn't a
|
|
||||||
// prebuilts/ndk any more) then this should be fixable, but for now I think
|
|
||||||
// it needs to remain as-is.
|
|
||||||
maxVersion := 24
|
|
||||||
firstArchVersions := map[string]int{
|
firstArchVersions := map[string]int{
|
||||||
"arm": 9,
|
"arm": 9,
|
||||||
"arm64": 21,
|
"arm64": 21,
|
||||||
@@ -129,31 +119,49 @@ func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the NDK drops support for a platform version, we don't want to have to
|
// If the NDK drops support for a platform version, we don't want to have to
|
||||||
// fix up every module that was using it as its minimum version. Clip to the
|
// fix up every module that was using it as its SDK version. Clip to the
|
||||||
// supported version here instead.
|
// supported version here instead.
|
||||||
firstVersion, err := strconv.Atoi(c.properties.First_version)
|
version, err := strconv.Atoi(apiLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mctx.ModuleErrorf("Invalid first_version value (must be int): %q",
|
return -1, fmt.Errorf("API level must be an integer (is %q)", apiLevel)
|
||||||
c.properties.First_version)
|
|
||||||
}
|
}
|
||||||
if firstVersion < minVersion {
|
version = intMax(version, minVersion)
|
||||||
firstVersion = minVersion
|
|
||||||
|
archStr := arch.ArchType.String()
|
||||||
|
firstArchVersion, ok := firstArchVersions[archStr]
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Errorf("Arch %q not found in firstArchVersions", archStr))
|
||||||
}
|
}
|
||||||
|
|
||||||
arch := mctx.Arch().ArchType.String()
|
return intMax(version, firstArchVersion), nil
|
||||||
firstArchVersion, ok := firstArchVersions[arch]
|
|
||||||
if !ok {
|
|
||||||
panic(fmt.Errorf("Arch %q not found in firstArchVersions", arch))
|
|
||||||
}
|
}
|
||||||
firstGenVersion := intMin(firstVersion, firstArchVersion)
|
|
||||||
versionStrs := make([]string, maxVersion-firstGenVersion+1)
|
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
|
||||||
for version := firstGenVersion; version <= maxVersion; version++ {
|
// TODO(danalbert): Use PlatformSdkVersion when possible.
|
||||||
versionStrs[version-firstGenVersion] = strconv.Itoa(version)
|
// This is an interesting case because for the moment we actually need 24
|
||||||
|
// even though the latest released version in aosp is 23. prebuilts/ndk/r11
|
||||||
|
// has android-24 versions of libraries, and as platform libraries get
|
||||||
|
// migrated the libraries in prebuilts will need to depend on them.
|
||||||
|
//
|
||||||
|
// Once everything is all moved over to the new stuff (when there isn't a
|
||||||
|
// prebuilts/ndk any more) then this should be fixable, but for now I think
|
||||||
|
// it needs to remain as-is.
|
||||||
|
maxVersion := 24
|
||||||
|
|
||||||
|
firstVersion, err := normalizeNdkApiLevel(c.properties.First_version,
|
||||||
|
mctx.Arch())
|
||||||
|
if err != nil {
|
||||||
|
mctx.PropertyErrorf("first_version", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
versionStrs := make([]string, maxVersion-firstVersion+1)
|
||||||
|
for version := firstVersion; version <= maxVersion; version++ {
|
||||||
|
versionStrs[version-firstVersion] = strconv.Itoa(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
modules := mctx.CreateVariations(versionStrs...)
|
modules := mctx.CreateVariations(versionStrs...)
|
||||||
for i, module := range modules {
|
for i, module := range modules {
|
||||||
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = firstGenVersion + i
|
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = firstVersion + i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user