diff options
author | 2023-03-03 21:20:36 +0000 | |
---|---|---|
committer | 2023-03-20 16:51:32 +0000 | |
commit | e773739787394e9632043749e88ca6cfd5a40a67 (patch) | |
tree | c069277b81df80f608af7f97b33e62c3e0d18ff8 /java/base.go | |
parent | 3015e38a5f0d466dd850fd0a77648844a1364efc (diff) |
Update min_sdk_version from SdkSpec to ApiLevel
min_sdk_version signifies device version and does not need an sdkKind to
describe it fully. Update the type and cleanup existing usages. As a
side benefit, we also get better error handling since users can no
longer enter something like `public_30` as a valid min_sdk_version in bp
files
Will do a similar cleanup for targetSdkVersion and maxSdkVersion in a
followup CL
Test: m nothing
Test: no change in ninja files (this should be a no-op)
Bug: 208456999
Change-Id: Ie6ae7e267d093c5e4787e82685daaca1021d202e
Diffstat (limited to 'java/base.go')
-rw-r--r-- | java/base.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/java/base.go b/java/base.go index 85f4a5e06..75ec16d6f 100644 --- a/java/base.go +++ b/java/base.go @@ -489,7 +489,7 @@ type Module struct { hideApexVariantFromMake bool sdkVersion android.SdkSpec - minSdkVersion android.SdkSpec + minSdkVersion android.ApiLevel maxSdkVersion android.SdkSpec sourceExtensions []string @@ -665,11 +665,11 @@ func (j *Module) SystemModules() string { return proptools.String(j.deviceProperties.System_modules) } -func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { +func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { if j.deviceProperties.Min_sdk_version != nil { - return android.SdkSpecFrom(ctx, *j.deviceProperties.Min_sdk_version) + return android.ApiLevelFrom(ctx, *j.deviceProperties.Min_sdk_version) } - return j.SdkVersion(ctx) + return j.SdkVersion(ctx).ApiLevel } func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { @@ -685,7 +685,7 @@ func (j *Module) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) } func (j *Module) MinSdkVersionString() string { - return j.minSdkVersion.Raw + return j.minSdkVersion.String() } func (j *Module) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { @@ -881,7 +881,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt j.ignoredAidlPermissionList = android.PathsForModuleSrcExcludes(ctx, exceptions, nil) } - aidlMinSdkVersion := j.MinSdkVersion(ctx).ApiLevel.String() + aidlMinSdkVersion := j.MinSdkVersion(ctx).String() flags = append(flags, "--min_sdk_version="+aidlMinSdkVersion) return strings.Join(flags, " "), deps @@ -1542,9 +1542,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } if ctx.Device() { - lintSDKVersion := func(sdkSpec android.SdkSpec) int { - if v := sdkSpec.ApiLevel; !v.IsPreview() { - return v.FinalInt() + lintSDKVersion := func(apiLevel android.ApiLevel) int { + if !apiLevel.IsPreview() { + return apiLevel.FinalInt() } else { // When running metalava, we pass --version-codename. When that value // is not REL, metalava will add 1 to the --current-version argument. @@ -1575,8 +1575,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...) j.linter.classes = j.implementationJarFile j.linter.minSdkVersion = lintSDKVersion(j.MinSdkVersion(ctx)) - j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx)) - j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx)) + j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx).ApiLevel) + j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx).ApiLevel) j.linter.compileSdkKind = j.SdkVersion(ctx).Kind j.linter.javaLanguageLevel = flags.javaVersion.String() j.linter.kotlinLanguageLevel = "1.3" @@ -1846,15 +1846,14 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu // Implements android.ApexModule func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { sdkVersionSpec := j.SdkVersion(ctx) - minSdkVersionSpec := j.MinSdkVersion(ctx) - if !minSdkVersionSpec.Specified() { + minSdkVersion := j.MinSdkVersion(ctx) + if !minSdkVersion.Specified() { return fmt.Errorf("min_sdk_version is not specified") } // If the module is compiling against core (via sdk_version), skip comparison check. if sdkVersionSpec.Kind == android.SdkCore { return nil } - minSdkVersion := minSdkVersionSpec.ApiLevel if minSdkVersion.GreaterThan(sdkVersion) { return fmt.Errorf("newer SDK(%v)", minSdkVersion) } |