Allow `first_version: "current"` in ndk_library.
am: 90f7a4dcab
Change-Id: I7141ce08ce3fbc9506a8d05db33d8a61a84ace8d
This commit is contained in:
commit
e7754d3f27
2
cc/cc.go
2
cc/cc.go
|
@ -497,7 +497,7 @@ func (c *Module) begin(ctx BaseModuleContext) {
|
|||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version", err.Error())
|
||||
}
|
||||
c.Properties.Sdk_version = strconv.Itoa(version)
|
||||
c.Properties.Sdk_version = version
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,11 @@ func intMax(a int, b int) int {
|
|||
}
|
||||
}
|
||||
|
||||
func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (int, error) {
|
||||
func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (string, error) {
|
||||
if apiLevel == "current" {
|
||||
return apiLevel, nil
|
||||
}
|
||||
|
||||
minVersion := 9 // Minimum version supported by the NDK.
|
||||
firstArchVersions := map[string]int{
|
||||
"arm": 9,
|
||||
|
@ -125,7 +129,7 @@ func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (int, error) {
|
|||
// supported version here instead.
|
||||
version, err := strconv.Atoi(apiLevel)
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf("API level must be an integer (is %q)", apiLevel)
|
||||
return "", fmt.Errorf("API level must be an integer (is %q)", apiLevel)
|
||||
}
|
||||
version = intMax(version, minVersion)
|
||||
|
||||
|
@ -135,20 +139,35 @@ func normalizeNdkApiLevel(apiLevel string, arch android.Arch) (int, error) {
|
|||
panic(fmt.Errorf("Arch %q not found in firstArchVersions", archStr))
|
||||
}
|
||||
|
||||
return intMax(version, firstArchVersion), nil
|
||||
return strconv.Itoa(intMax(version, firstArchVersion)), nil
|
||||
}
|
||||
|
||||
func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int) (int, error) {
|
||||
if firstSupportedVersion == "current" {
|
||||
return platformVersion + 1, nil
|
||||
}
|
||||
|
||||
return strconv.Atoi(firstSupportedVersion)
|
||||
}
|
||||
|
||||
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
|
||||
maxVersion := mctx.AConfig().PlatformSdkVersionInt()
|
||||
platformVersion := mctx.AConfig().PlatformSdkVersionInt()
|
||||
|
||||
firstVersion, err := normalizeNdkApiLevel(c.properties.First_version,
|
||||
firstSupportedVersion, err := normalizeNdkApiLevel(c.properties.First_version,
|
||||
mctx.Arch())
|
||||
if err != nil {
|
||||
mctx.PropertyErrorf("first_version", err.Error())
|
||||
}
|
||||
|
||||
firstGenVersion, err := getFirstGeneratedVersion(firstSupportedVersion, platformVersion)
|
||||
if err != nil {
|
||||
// In theory this is impossible because we've already run this through
|
||||
// normalizeNdkApiLevel above.
|
||||
mctx.PropertyErrorf("first_version", err.Error())
|
||||
}
|
||||
|
||||
var versionStrs []string
|
||||
for version := firstVersion; version <= maxVersion; version++ {
|
||||
for version := firstGenVersion; version <= platformVersion; version++ {
|
||||
versionStrs = append(versionStrs, strconv.Itoa(version))
|
||||
}
|
||||
versionStrs = append(versionStrs, "current")
|
||||
|
|
Loading…
Reference in New Issue