Merge "Use ApiLevel on min, target and compile Sdk version" into main am: ec222c4dbb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2818082 Change-Id: I0573282b220f8b098b33fcc08d3c9e732f5b38bc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
25
java/base.go
25
java/base.go
@@ -1644,30 +1644,11 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
lintSDKVersion := func(apiLevel android.ApiLevel) int {
|
lintSDKVersion := func(apiLevel android.ApiLevel) android.ApiLevel {
|
||||||
if !apiLevel.IsPreview() {
|
if !apiLevel.IsPreview() {
|
||||||
return apiLevel.FinalInt()
|
return apiLevel
|
||||||
} else {
|
} else {
|
||||||
// When running metalava, we pass --version-codename. When that value
|
return ctx.Config().DefaultAppTargetSdk(ctx)
|
||||||
// is not REL, metalava will add 1 to the --current-version argument.
|
|
||||||
// On old branches, PLATFORM_SDK_VERSION is the latest version (for that
|
|
||||||
// branch) and the codename is REL, except potentially on the most
|
|
||||||
// recent non-master branch. On that branch, it goes through two other
|
|
||||||
// phases before it gets to the phase previously described:
|
|
||||||
// - PLATFORM_SDK_VERSION has not been updated yet, and the codename
|
|
||||||
// is not rel. This happens for most of the internal branch's life
|
|
||||||
// while the branch has been cut but is still under active development.
|
|
||||||
// - PLATFORM_SDK_VERSION has been set, but the codename is still not
|
|
||||||
// REL. This happens briefly during the release process. During this
|
|
||||||
// state the code to add --current-version is commented out, and then
|
|
||||||
// that commenting out is reverted after the codename is set to REL.
|
|
||||||
// On the master branch, the PLATFORM_SDK_VERSION always represents a
|
|
||||||
// prior version and the codename is always non-REL.
|
|
||||||
//
|
|
||||||
// We need to add one here to match metalava adding 1. Technically
|
|
||||||
// this means that in the state described in the second bullet point
|
|
||||||
// above, this number is 1 higher than it should be.
|
|
||||||
return ctx.Config().PlatformSdkVersion().FinalInt() + 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
java/lint.go
15
java/lint.go
@@ -17,7 +17,6 @@ package java
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
@@ -85,9 +84,9 @@ type linter struct {
|
|||||||
classes android.Path
|
classes android.Path
|
||||||
extraLintCheckJars android.Paths
|
extraLintCheckJars android.Paths
|
||||||
library bool
|
library bool
|
||||||
minSdkVersion int
|
minSdkVersion android.ApiLevel
|
||||||
targetSdkVersion int
|
targetSdkVersion android.ApiLevel
|
||||||
compileSdkVersion int
|
compileSdkVersion android.ApiLevel
|
||||||
compileSdkKind android.SdkKind
|
compileSdkKind android.SdkKind
|
||||||
javaLanguageLevel string
|
javaLanguageLevel string
|
||||||
kotlinLanguageLevel string
|
kotlinLanguageLevel string
|
||||||
@@ -358,8 +357,8 @@ func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleB
|
|||||||
Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`).
|
Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`).
|
||||||
Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`).
|
Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`).
|
||||||
Text(`echo " android:versionCode='1' android:versionName='1' >" &&`).
|
Text(`echo " android:versionCode='1' android:versionName='1' >" &&`).
|
||||||
Textf(`echo " <uses-sdk android:minSdkVersion='%d' android:targetSdkVersion='%d'/>" &&`,
|
Textf(`echo " <uses-sdk android:minSdkVersion='%s' android:targetSdkVersion='%s'/>" &&`,
|
||||||
l.minSdkVersion, l.targetSdkVersion).
|
l.minSdkVersion.String(), l.targetSdkVersion.String()).
|
||||||
Text(`echo "</manifest>"`).
|
Text(`echo "</manifest>"`).
|
||||||
Text(") >").Output(manifestPath)
|
Text(") >").Output(manifestPath)
|
||||||
|
|
||||||
@@ -371,7 +370,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.minSdkVersion != l.compileSdkVersion {
|
if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
|
||||||
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
|
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
|
||||||
// Skip lint warning checks for NewApi warnings for libcore where they come from source
|
// Skip lint warning checks for NewApi warnings for libcore where they come from source
|
||||||
// files that reference the API they are adding (b/208656169).
|
// files that reference the API they are adding (b/208656169).
|
||||||
@@ -485,7 +484,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
|||||||
FlagWithOutput("--html ", html).
|
FlagWithOutput("--html ", html).
|
||||||
FlagWithOutput("--text ", text).
|
FlagWithOutput("--text ", text).
|
||||||
FlagWithOutput("--xml ", xml).
|
FlagWithOutput("--xml ", xml).
|
||||||
FlagWithArg("--compile-sdk-version ", strconv.Itoa(l.compileSdkVersion)).
|
FlagWithArg("--compile-sdk-version ", l.compileSdkVersion.String()).
|
||||||
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
|
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
|
||||||
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
|
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
|
||||||
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
|
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
|
||||||
|
Reference in New Issue
Block a user