Merge changes Id33bf640,I4d67b9b9 am: 8c56183fb7
am: b17e061ae9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1663139 Change-Id: I0128e2d5bf70a7cce8b16b78a62434c819b09de4
This commit is contained in:
@@ -55,7 +55,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
|
||||
}
|
||||
if minSdkVersion >= 23 {
|
||||
if minSdkVersion.FinalOrFutureInt() >= 23 {
|
||||
args = append(args, fmt.Sprintf("--extract-native-libs=%v", !useEmbeddedNativeLibs))
|
||||
} else if useEmbeddedNativeLibs {
|
||||
ctx.ModuleErrorf("module attempted to store uncompressed native libraries, but minSdkVersion=%d doesn't support it",
|
||||
|
@@ -288,7 +288,7 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
||||
|
||||
if minSdkVersion, err := a.MinSdkVersion().EffectiveVersion(ctx); err == nil {
|
||||
a.checkJniLibsSdkVersion(ctx, minSdkVersion)
|
||||
android.CheckMinSdkVersion(a, ctx, minSdkVersion.ApiLevel(ctx))
|
||||
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
|
||||
} else {
|
||||
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
|
||||
}
|
||||
@@ -304,7 +304,7 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
|
||||
// because, sdk_version is overridden by min_sdk_version (if set as smaller)
|
||||
// and sdkLinkType is checked with dependencies so we can be sure that the whole dependency tree
|
||||
// will meet the requirements.
|
||||
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.SdkVersion) {
|
||||
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) {
|
||||
// It's enough to check direct JNI deps' sdk_version because all transitive deps from JNI deps are checked in cc.checkLinkType()
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
if !IsJniDepTag(ctx.OtherModuleDependencyTag(m)) {
|
||||
@@ -315,7 +315,7 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer
|
||||
// We can rely on android.SdkSpec to convert it to <number> so that "current" is
|
||||
// handled properly regardless of sdk finalization.
|
||||
jniSdkVersion, err := android.SdkSpecFrom(dep.SdkVersion()).EffectiveVersion(ctx)
|
||||
if err != nil || minSdkVersion < jniSdkVersion {
|
||||
if err != nil || minSdkVersion.LessThan(jniSdkVersion) {
|
||||
ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)",
|
||||
dep.SdkVersion(), minSdkVersion, ctx.ModuleName())
|
||||
return
|
||||
@@ -333,7 +333,7 @@ func (a *AndroidApp) useEmbeddedNativeLibs(ctx android.ModuleContext) bool {
|
||||
}
|
||||
|
||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||
return (minSdkVersion >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
|
||||
return (minSdkVersion.FinalOrFutureInt() >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
|
||||
!apexInfo.IsForPlatform()
|
||||
}
|
||||
|
||||
|
@@ -535,7 +535,7 @@ func (j *Module) TargetSdkVersion() android.SdkSpec {
|
||||
}
|
||||
|
||||
func (j *Module) MinSdkVersionString() string {
|
||||
return j.MinSdkVersion().Version.String()
|
||||
return j.MinSdkVersion().ApiLevel.String()
|
||||
}
|
||||
|
||||
func (j *Module) AvailableFor(what string) bool {
|
||||
@@ -1255,7 +1255,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||
|
||||
if ctx.Device() {
|
||||
lintSDKVersionString := func(sdkSpec android.SdkSpec) string {
|
||||
if v := sdkSpec.Version; v.IsNumbered() {
|
||||
if v := sdkSpec.ApiLevel; !v.IsPreview() {
|
||||
return v.String()
|
||||
} else {
|
||||
return ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||
@@ -1482,7 +1482,7 @@ func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ver.ApiLevel(ctx).GreaterThan(sdkVersion) {
|
||||
if ver.GreaterThan(sdkVersion) {
|
||||
return fmt.Errorf("newer SDK(%v)", ver)
|
||||
}
|
||||
return nil
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package java
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
@@ -179,7 +180,7 @@ func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.
|
||||
ctx.PropertyErrorf("min_sdk_version", "%s", err)
|
||||
}
|
||||
|
||||
flags = append(flags, "--min-api "+effectiveVersion.AsNumberString())
|
||||
flags = append(flags, "--min-api "+strconv.Itoa(effectiveVersion.FinalOrFutureInt()))
|
||||
return flags
|
||||
}
|
||||
|
||||
|
@@ -1156,7 +1156,7 @@ func (j *Import) TargetSdkVersion() android.SdkSpec {
|
||||
}
|
||||
|
||||
func (j *Import) MinSdkVersionString() string {
|
||||
return j.MinSdkVersion().Version.String()
|
||||
return j.MinSdkVersion().ApiLevel.String()
|
||||
}
|
||||
|
||||
func (j *Import) Prebuilt() *android.Prebuilt {
|
||||
@@ -1370,7 +1370,7 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ver.ApiLevel(ctx).GreaterThan(sdkVersion) {
|
||||
if ver.GreaterThan(sdkVersion) {
|
||||
return fmt.Errorf("newer SDK(%v)", ver)
|
||||
}
|
||||
return nil
|
||||
|
12
java/sdk.go
12
java/sdk.go
@@ -51,9 +51,9 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version", "%s", err)
|
||||
}
|
||||
if sdk <= 23 {
|
||||
if sdk.FinalOrFutureInt() <= 23 {
|
||||
return JAVA_VERSION_7
|
||||
} else if sdk <= 29 {
|
||||
} else if sdk.FinalOrFutureInt() <= 29 {
|
||||
return JAVA_VERSION_8
|
||||
} else {
|
||||
return JAVA_VERSION_9
|
||||
@@ -76,11 +76,11 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
}
|
||||
|
||||
if sdkVersion.UsePrebuilt(ctx) {
|
||||
dir := filepath.Join("prebuilts", "sdk", sdkVersion.Version.String(), sdkVersion.Kind.String())
|
||||
dir := filepath.Join("prebuilts", "sdk", sdkVersion.ApiLevel.String(), sdkVersion.Kind.String())
|
||||
jar := filepath.Join(dir, "android.jar")
|
||||
// There's no aidl for other SDKs yet.
|
||||
// TODO(77525052): Add aidl files for other SDKs too.
|
||||
publicDir := filepath.Join("prebuilts", "sdk", sdkVersion.Version.String(), "public")
|
||||
publicDir := filepath.Join("prebuilts", "sdk", sdkVersion.ApiLevel.String(), "public")
|
||||
aidl := filepath.Join(publicDir, "framework.aidl")
|
||||
jarPath := android.ExistentPathForSource(ctx, jar)
|
||||
aidlPath := android.ExistentPathForSource(ctx, aidl)
|
||||
@@ -89,7 +89,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
||||
return sdkDep{
|
||||
invalidVersion: true,
|
||||
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", sdkVersion.Kind, sdkVersion.Version.String())},
|
||||
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", sdkVersion.Kind, sdkVersion.ApiLevel.String())},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
|
||||
var systemModules string
|
||||
if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() {
|
||||
systemModules = "sdk_public_" + sdkVersion.Version.String() + "_system_modules"
|
||||
systemModules = "sdk_public_" + sdkVersion.ApiLevel.String() + "_system_modules"
|
||||
}
|
||||
|
||||
return sdkDep{
|
||||
|
@@ -817,7 +817,7 @@ func (c *commonToSdkLibraryAndImport) findClosestScopePath(scope *apiScope) *sco
|
||||
func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
||||
|
||||
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
|
||||
if sdkVersion.Version.IsNumbered() {
|
||||
if !sdkVersion.ApiLevel.IsPreview() {
|
||||
return PrebuiltJars(ctx, c.moduleBase.BaseModuleName(), sdkVersion)
|
||||
}
|
||||
|
||||
@@ -1466,15 +1466,15 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
|
||||
}
|
||||
|
||||
func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s android.SdkSpec) android.Paths {
|
||||
var ver android.SdkVersion
|
||||
var ver android.ApiLevel
|
||||
var kind android.SdkKind
|
||||
if s.UsePrebuilt(ctx) {
|
||||
ver = s.Version
|
||||
ver = s.ApiLevel
|
||||
kind = s.Kind
|
||||
} else {
|
||||
// We don't have prebuilt SDK for the specific sdkVersion.
|
||||
// Instead of breaking the build, fallback to use "system_current"
|
||||
ver = android.SdkVersionCurrent
|
||||
ver = android.FutureApiLevel
|
||||
kind = android.SdkSystem
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user