Expose the minimum supported SDK version to make.
Right now this is hard coded in two places (here and in core/binary.mk). Keep it in one place so it's easier to change. Test: make checkbuild Bug: None Change-Id: I2a2c784d4c667b326f871e6144db92753c16c85f
This commit is contained in:
parent
b90afd09d6
commit
f5415d7cc6
4 changed files with 22 additions and 7 deletions
|
@ -378,6 +378,10 @@ func (c *config) PlatformSdkVersion() string {
|
||||||
return strconv.Itoa(c.PlatformSdkVersionInt())
|
return strconv.Itoa(c.PlatformSdkVersionInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) MinSupportedSdkVersion() int {
|
||||||
|
return 9
|
||||||
|
}
|
||||||
|
|
||||||
// Codenames that are active in the current lunch target.
|
// Codenames that are active in the current lunch target.
|
||||||
func (c *config) PlatformVersionActiveCodenames() []string {
|
func (c *config) PlatformVersionActiveCodenames() []string {
|
||||||
return c.ProductVariables.Platform_version_active_codenames
|
return c.ProductVariables.Platform_version_active_codenames
|
||||||
|
|
|
@ -19,11 +19,20 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterMakeVarsProvider(pctx, androidMakeVarsProvider)
|
||||||
|
}
|
||||||
|
|
||||||
|
func androidMakeVarsProvider(ctx MakeVarsContext) {
|
||||||
|
ctx.Strict("MIN_SUPPORTED_SDK_VERSION", strconv.Itoa(ctx.Config().MinSupportedSdkVersion()))
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Interface for other packages to use to declare make variables
|
// Interface for other packages to use to declare make variables
|
||||||
type MakeVarsContext interface {
|
type MakeVarsContext interface {
|
||||||
|
|
2
cc/cc.go
2
cc/cc.go
|
@ -638,7 +638,7 @@ func (c *Module) begin(ctx BaseModuleContext) {
|
||||||
feature.begin(ctx)
|
feature.begin(ctx)
|
||||||
}
|
}
|
||||||
if ctx.sdk() {
|
if ctx.sdk() {
|
||||||
version, err := normalizeNdkApiLevel(ctx.sdkVersion(), ctx.Arch())
|
version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.PropertyErrorf("sdk_version", err.Error())
|
ctx.PropertyErrorf("sdk_version", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,18 +110,20 @@ func intMax(a int, b int) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (string, error) {
|
func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
|
||||||
|
arch android.Arch) (string, error) {
|
||||||
|
|
||||||
if apiLevel == "current" {
|
if apiLevel == "current" {
|
||||||
return apiLevel, nil
|
return apiLevel, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
minVersion := 9 // Minimum version supported by the NDK.
|
minVersion := ctx.AConfig().MinSupportedSdkVersion()
|
||||||
firstArchVersions := map[android.ArchType]int{
|
firstArchVersions := map[android.ArchType]int{
|
||||||
android.Arm: 9,
|
android.Arm: minVersion,
|
||||||
android.Arm64: 21,
|
android.Arm64: 21,
|
||||||
android.Mips: 9,
|
android.Mips: minVersion,
|
||||||
android.Mips64: 21,
|
android.Mips64: 21,
|
||||||
android.X86: 9,
|
android.X86: minVersion,
|
||||||
android.X86_64: 21,
|
android.X86_64: 21,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +190,7 @@ func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
|
||||||
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
|
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
|
||||||
platformVersion := mctx.AConfig().PlatformSdkVersionInt()
|
platformVersion := mctx.AConfig().PlatformSdkVersionInt()
|
||||||
|
|
||||||
firstSupportedVersion, err := normalizeNdkApiLevel(c.properties.First_version,
|
firstSupportedVersion, err := normalizeNdkApiLevel(mctx, c.properties.First_version,
|
||||||
mctx.Arch())
|
mctx.Arch())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mctx.PropertyErrorf("first_version", err.Error())
|
mctx.PropertyErrorf("first_version", err.Error())
|
||||||
|
|
Loading…
Reference in a new issue