Don't generate intermediate NDK libraries.

am: 7fa7b2efd3

Change-Id: I049ab976019bf085943cc4cf0bceb68e0c6ef59b
This commit is contained in:
Dan Albert 2016-08-08 18:44:14 +00:00 committed by android-build-merger
commit df66aa3ecf
2 changed files with 43 additions and 28 deletions

View file

@ -491,6 +491,13 @@ func (c *Module) begin(ctx BaseModuleContext) {
for _, feature := range c.features {
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 {

View file

@ -99,26 +99,16 @@ type stubDecorator struct {
}
// OMG GO
func intMin(a int, b int) int {
if a < b {
func intMax(a int, b int) int {
if a > b {
return a
} else {
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.
// 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{
"arm": 9,
"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
// 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.
firstVersion, err := strconv.Atoi(c.properties.First_version)
version, err := strconv.Atoi(apiLevel)
if err != nil {
mctx.ModuleErrorf("Invalid first_version value (must be int): %q",
c.properties.First_version)
return -1, fmt.Errorf("API level must be an integer (is %q)", apiLevel)
}
if firstVersion < minVersion {
firstVersion = minVersion
version = intMax(version, 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()
firstArchVersion, ok := firstArchVersions[arch]
if !ok {
panic(fmt.Errorf("Arch %q not found in firstArchVersions", arch))
return intMax(version, firstArchVersion), nil
}
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
// 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
firstVersion, err := normalizeNdkApiLevel(c.properties.First_version,
mctx.Arch())
if err != nil {
mctx.PropertyErrorf("first_version", err.Error())
}
firstGenVersion := intMin(firstVersion, firstArchVersion)
versionStrs := make([]string, maxVersion-firstGenVersion+1)
for version := firstGenVersion; version <= maxVersion; version++ {
versionStrs[version-firstGenVersion] = strconv.Itoa(version)
versionStrs := make([]string, maxVersion-firstVersion+1)
for version := firstVersion; version <= maxVersion; version++ {
versionStrs[version-firstVersion] = strconv.Itoa(version)
}
modules := mctx.CreateVariations(versionStrs...)
for i, module := range modules {
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = firstGenVersion + i
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = firstVersion + i
}
}