Merge changes from topic "revert-2457063-EKFSKANQWZ" am: cd05792d06
am: d3d9c4ae59
am: 12992d3db9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2499159 Change-Id: I952f4fc41b91be9e3bd8145be9fe1d81abe2642c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
f4149e51ce
22 changed files with 111 additions and 197 deletions
|
@ -847,7 +847,7 @@ type WalkPayloadDepsFunc func(ctx ModuleContext, do PayloadDepsCallback)
|
|||
// ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks
|
||||
type ModuleWithMinSdkVersionCheck interface {
|
||||
Module
|
||||
MinSdkVersion(ctx EarlyModuleContext) ApiLevel
|
||||
MinSdkVersion(ctx EarlyModuleContext) SdkSpec
|
||||
CheckMinSdkVersion(ctx ModuleContext)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ type ApiLevel struct {
|
|||
}
|
||||
|
||||
func (this ApiLevel) FinalInt() int {
|
||||
if this.IsInvalid() {
|
||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
||||
}
|
||||
if this.IsPreview() {
|
||||
panic("Requested a final int from a non-final ApiLevel")
|
||||
} else {
|
||||
|
@ -66,9 +63,6 @@ func (this ApiLevel) FinalInt() int {
|
|||
}
|
||||
|
||||
func (this ApiLevel) FinalOrFutureInt() int {
|
||||
if this.IsInvalid() {
|
||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
||||
}
|
||||
if this.IsPreview() {
|
||||
return FutureApiLevelInt
|
||||
} else {
|
||||
|
@ -82,9 +76,6 @@ func (this ApiLevel) FinalOrFutureInt() int {
|
|||
// - preview codenames -> preview base (9000) + index
|
||||
// - otherwise -> cast to int
|
||||
func (this ApiLevel) FinalOrPreviewInt() int {
|
||||
if this.IsInvalid() {
|
||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
||||
}
|
||||
if this.IsCurrent() {
|
||||
return this.number
|
||||
}
|
||||
|
@ -106,11 +97,6 @@ func (this ApiLevel) IsPreview() bool {
|
|||
return this.isPreview
|
||||
}
|
||||
|
||||
// Returns true if the raw api level string is invalid
|
||||
func (this ApiLevel) IsInvalid() bool {
|
||||
return this.EqualTo(InvalidApiLevel)
|
||||
}
|
||||
|
||||
// Returns true if this is the unfinalized "current" API level. This means
|
||||
// different things across Java and native. Java APIs do not use explicit
|
||||
// codenames, so all non-final codenames are grouped into "current". For native
|
||||
|
@ -127,72 +113,6 @@ func (this ApiLevel) IsNone() bool {
|
|||
return this.number == -1
|
||||
}
|
||||
|
||||
// Returns true if an app is compiling against private apis.
|
||||
// e.g. if sdk_version = "" in Android.bp, then the ApiLevel of that "sdk" is at PrivateApiLevel.
|
||||
func (this ApiLevel) IsPrivate() bool {
|
||||
return this.number == PrivateApiLevel.number
|
||||
}
|
||||
|
||||
// EffectiveVersion converts an ApiLevel into the concrete ApiLevel that the module should use. For
|
||||
// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns
|
||||
// FutureApiLevel(10000).
|
||||
func (l ApiLevel) EffectiveVersion(ctx EarlyModuleContext) (ApiLevel, error) {
|
||||
if l.EqualTo(InvalidApiLevel) {
|
||||
return l, fmt.Errorf("invalid version in sdk_version %q", l.value)
|
||||
}
|
||||
if !l.IsPreview() {
|
||||
return l, nil
|
||||
}
|
||||
ret := ctx.Config().DefaultAppTargetSdk(ctx)
|
||||
if ret.IsPreview() {
|
||||
return FutureApiLevel, nil
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// EffectiveVersionString converts an SdkSpec into the concrete version string that the module
|
||||
// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
|
||||
// it returns the codename (P, Q, R, etc.)
|
||||
func (l ApiLevel) EffectiveVersionString(ctx EarlyModuleContext) (string, error) {
|
||||
if l.EqualTo(InvalidApiLevel) {
|
||||
return l.value, fmt.Errorf("invalid version in sdk_version %q", l.value)
|
||||
}
|
||||
if !l.IsPreview() {
|
||||
return l.String(), nil
|
||||
}
|
||||
// Determine the default sdk
|
||||
ret := ctx.Config().DefaultAppTargetSdk(ctx)
|
||||
if !ret.IsPreview() {
|
||||
// If the default sdk has been finalized, return that
|
||||
return ret.String(), nil
|
||||
}
|
||||
// There can be more than one active in-development sdks
|
||||
// If an app is targeting an active sdk, but not the default one, return the requested active sdk.
|
||||
// e.g.
|
||||
// SETUP
|
||||
// In-development: UpsideDownCake, VanillaIceCream
|
||||
// Default: VanillaIceCream
|
||||
// Android.bp
|
||||
// min_sdk_version: `UpsideDownCake`
|
||||
// RETURN
|
||||
// UpsideDownCake and not VanillaIceCream
|
||||
for _, preview := range ctx.Config().PreviewApiLevels() {
|
||||
if l.String() == preview.String() {
|
||||
return preview.String(), nil
|
||||
}
|
||||
}
|
||||
// Otherwise return the default one
|
||||
return ret.String(), nil
|
||||
}
|
||||
|
||||
// Specified returns true if the module is targeting a recognzized api_level.
|
||||
// It returns false if either
|
||||
// 1. min_sdk_version is not an int or a recognized codename
|
||||
// 2. both min_sdk_version and sdk_version are empty. In this case, MinSdkVersion() defaults to SdkSpecPrivate.ApiLevel
|
||||
func (this ApiLevel) Specified() bool {
|
||||
return !this.IsInvalid() && !this.IsPrivate()
|
||||
}
|
||||
|
||||
// Returns -1 if the current API level is less than the argument, 0 if they
|
||||
// are equal, and 1 if it is greater than the argument.
|
||||
func (this ApiLevel) CompareTo(other ApiLevel) int {
|
||||
|
@ -246,19 +166,6 @@ var NoneApiLevel = ApiLevel{
|
|||
isPreview: true,
|
||||
}
|
||||
|
||||
// Sentinel ApiLevel to validate that an apiLevel is either an int or a recognized codename.
|
||||
var InvalidApiLevel = NewInvalidApiLevel("invalid")
|
||||
|
||||
// Returns an apiLevel object at the same level as InvalidApiLevel.
|
||||
// The object contains the raw string provied in bp file, and can be used for error handling.
|
||||
func NewInvalidApiLevel(raw string) ApiLevel {
|
||||
return ApiLevel{
|
||||
value: raw,
|
||||
number: -2, // One less than NoneApiLevel
|
||||
isPreview: true,
|
||||
}
|
||||
}
|
||||
|
||||
// The first version that introduced 64-bit ABIs.
|
||||
var FirstLp64Version = uncheckedFinalApiLevel(21)
|
||||
|
||||
|
@ -297,16 +204,6 @@ func ReplaceFinalizedCodenames(config Config, raw string) string {
|
|||
return strconv.Itoa(num)
|
||||
}
|
||||
|
||||
// ApiLevelFrom converts the given string `raw` to an ApiLevel.
|
||||
// If `raw` is invalid (empty string, unrecognized codename etc.) it returns an invalid ApiLevel
|
||||
func ApiLevelFrom(ctx PathContext, raw string) ApiLevel {
|
||||
ret, err := ApiLevelFromUser(ctx, raw)
|
||||
if err != nil {
|
||||
return NewInvalidApiLevel(raw)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// ApiLevelFromUser converts the given string `raw` to an ApiLevel, possibly returning an error.
|
||||
//
|
||||
// `raw` must be non-empty. Passing an empty string results in a panic.
|
||||
|
|
|
@ -52,15 +52,6 @@ var StringDefault = proptools.StringDefault
|
|||
// FutureApiLevelInt is a placeholder constant for unreleased API levels.
|
||||
const FutureApiLevelInt = 10000
|
||||
|
||||
// PrivateApiLevel represents the api level of SdkSpecPrivate (sdk_version: "")
|
||||
// This api_level exists to differentiate user-provided "" from "current" sdk_version
|
||||
// The differentiation is necessary to enable different validation rules for these two possible values.
|
||||
var PrivateApiLevel = ApiLevel{
|
||||
value: "current", // The value is current since aidl expects `current` as the default (TestAidlFlagsWithMinSdkVersion)
|
||||
number: FutureApiLevelInt + 1, // This is used to differentiate it from FutureApiLevel
|
||||
isPreview: true,
|
||||
}
|
||||
|
||||
// FutureApiLevel represents unreleased API levels.
|
||||
var FutureApiLevel = ApiLevel{
|
||||
value: "current",
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
// minApiLevelForSdkSnapshot provides access to the min_sdk_version for MinApiLevelForSdkSnapshot
|
||||
type minApiLevelForSdkSnapshot interface {
|
||||
MinSdkVersion(ctx EarlyModuleContext) ApiLevel
|
||||
MinSdkVersion(ctx EarlyModuleContext) SdkSpec
|
||||
}
|
||||
|
||||
// MinApiLevelForSdkSnapshot returns the ApiLevel of the min_sdk_version of the supplied module.
|
||||
|
@ -34,7 +34,7 @@ type minApiLevelForSdkSnapshot interface {
|
|||
func MinApiLevelForSdkSnapshot(ctx EarlyModuleContext, module Module) ApiLevel {
|
||||
minApiLevel := NoneApiLevel
|
||||
if m, ok := module.(minApiLevelForSdkSnapshot); ok {
|
||||
minApiLevel = m.MinSdkVersion(ctx)
|
||||
minApiLevel = m.MinSdkVersion(ctx).ApiLevel
|
||||
}
|
||||
if minApiLevel == NoneApiLevel {
|
||||
// The default min API level is 1.
|
||||
|
|
|
@ -25,9 +25,9 @@ type SdkContext interface {
|
|||
SdkVersion(ctx EarlyModuleContext) SdkSpec
|
||||
// SystemModules returns the system_modules property of the current module, or an empty string if it is not set.
|
||||
SystemModules() string
|
||||
// MinSdkVersion returns ApiLevel that corresponds to the min_sdk_version property of the current module,
|
||||
// MinSdkVersion returns SdkSpec that corresponds to the min_sdk_version property of the current module,
|
||||
// or from sdk_version if it is not set.
|
||||
MinSdkVersion(ctx EarlyModuleContext) ApiLevel
|
||||
MinSdkVersion(ctx EarlyModuleContext) SdkSpec
|
||||
// ReplaceMaxSdkVersionPlaceholder returns SdkSpec to replace the maxSdkVersion property of permission and
|
||||
// uses-permission tags if it is set.
|
||||
ReplaceMaxSdkVersionPlaceholder(ctx EarlyModuleContext) SdkSpec
|
||||
|
@ -187,7 +187,14 @@ func (s SdkSpec) EffectiveVersion(ctx EarlyModuleContext) (ApiLevel, error) {
|
|||
if ctx.DeviceSpecific() || ctx.SocSpecific() {
|
||||
s = s.ForVendorPartition(ctx)
|
||||
}
|
||||
return s.ApiLevel.EffectiveVersion(ctx)
|
||||
if !s.ApiLevel.IsPreview() {
|
||||
return s.ApiLevel, nil
|
||||
}
|
||||
ret := ctx.Config().DefaultAppTargetSdk(ctx)
|
||||
if ret.IsPreview() {
|
||||
return FutureApiLevel, nil
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// EffectiveVersionString converts an SdkSpec into the concrete version string that the module
|
||||
|
@ -201,12 +208,37 @@ func (s SdkSpec) EffectiveVersionString(ctx EarlyModuleContext) (string, error)
|
|||
if ctx.DeviceSpecific() || ctx.SocSpecific() {
|
||||
s = s.ForVendorPartition(ctx)
|
||||
}
|
||||
return s.ApiLevel.EffectiveVersionString(ctx)
|
||||
if !s.ApiLevel.IsPreview() {
|
||||
return s.ApiLevel.String(), nil
|
||||
}
|
||||
// Determine the default sdk
|
||||
ret := ctx.Config().DefaultAppTargetSdk(ctx)
|
||||
if !ret.IsPreview() {
|
||||
// If the default sdk has been finalized, return that
|
||||
return ret.String(), nil
|
||||
}
|
||||
// There can be more than one active in-development sdks
|
||||
// If an app is targeting an active sdk, but not the default one, return the requested active sdk.
|
||||
// e.g.
|
||||
// SETUP
|
||||
// In-development: UpsideDownCake, VanillaIceCream
|
||||
// Default: VanillaIceCream
|
||||
// Android.bp
|
||||
// min_sdk_version: `UpsideDownCake`
|
||||
// RETURN
|
||||
// UpsideDownCake and not VanillaIceCream
|
||||
for _, preview := range ctx.Config().PreviewApiLevels() {
|
||||
if s.ApiLevel.String() == preview.String() {
|
||||
return preview.String(), nil
|
||||
}
|
||||
}
|
||||
// Otherwise return the default one
|
||||
return ret.String(), nil
|
||||
}
|
||||
|
||||
var (
|
||||
SdkSpecNone = SdkSpec{SdkNone, NoneApiLevel, "(no version)"}
|
||||
SdkSpecPrivate = SdkSpec{SdkPrivate, PrivateApiLevel, ""}
|
||||
SdkSpecPrivate = SdkSpec{SdkPrivate, FutureApiLevel, ""}
|
||||
SdkSpecCorePlatform = SdkSpec{SdkCorePlatform, FutureApiLevel, "core_platform"}
|
||||
)
|
||||
|
||||
|
@ -229,7 +261,7 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
|
|||
|
||||
var kindString string
|
||||
if sep == 0 {
|
||||
return SdkSpec{SdkInvalid, NewInvalidApiLevel(str), str}
|
||||
return SdkSpec{SdkInvalid, NoneApiLevel, str}
|
||||
} else if sep == -1 {
|
||||
kindString = ""
|
||||
} else {
|
||||
|
@ -257,7 +289,7 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
|
|||
|
||||
apiLevel, err := ApiLevelFromUserWithConfig(config, versionString)
|
||||
if err != nil {
|
||||
return SdkSpec{SdkInvalid, NewInvalidApiLevel(versionString), str}
|
||||
return SdkSpec{SdkInvalid, apiLevel, str}
|
||||
}
|
||||
return SdkSpec{kind, apiLevel, str}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@ func TestSdkSpecFrom(t *testing.T) {
|
|||
},
|
||||
{
|
||||
input: "_",
|
||||
expected: "invalid__",
|
||||
expected: "invalid_(no version)",
|
||||
},
|
||||
{
|
||||
input: "_31",
|
||||
expected: "invalid__31",
|
||||
expected: "invalid_(no version)",
|
||||
},
|
||||
{
|
||||
input: "system_R",
|
||||
|
|
|
@ -2946,8 +2946,12 @@ func (a *apexBundle) minSdkVersionValue(ctx android.EarlyModuleContext) string {
|
|||
}
|
||||
|
||||
// Returns apex's min_sdk_version SdkSpec, honoring overrides
|
||||
func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
return a.minSdkVersion(ctx)
|
||||
func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
return android.SdkSpec{
|
||||
Kind: android.SdkNone,
|
||||
ApiLevel: a.minSdkVersion(ctx),
|
||||
Raw: a.minSdkVersionValue(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// Returns apex's min_sdk_version ApiLevel, honoring overrides
|
||||
|
|
|
@ -1063,10 +1063,10 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
|
|||
} else {
|
||||
toMinSdkVersion := "(no version)"
|
||||
if m, ok := to.(interface {
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
}); ok {
|
||||
if v := m.MinSdkVersion(ctx); !v.IsNone() {
|
||||
toMinSdkVersion = v.String()
|
||||
if v := m.MinSdkVersion(ctx); !v.ApiLevel.IsNone() {
|
||||
toMinSdkVersion = v.ApiLevel.String()
|
||||
}
|
||||
} else if m, ok := to.(interface{ MinSdkVersion() string }); ok {
|
||||
// TODO(b/175678607) eliminate the use of MinSdkVersion returning
|
||||
|
@ -1087,7 +1087,7 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
|
|||
return !externalDep
|
||||
})
|
||||
|
||||
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(ctx).String(), depInfos)
|
||||
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(ctx).Raw, depInfos)
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: android.Phony,
|
||||
|
|
12
java/aar.go
12
java/aar.go
|
@ -220,12 +220,12 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte
|
|||
linkDeps = append(linkDeps, assetDeps...)
|
||||
|
||||
// Returns the effective version for {min|target}_sdk_version
|
||||
effectiveVersionString := func(sdkVersion android.SdkSpec, minSdkVersion android.ApiLevel) string {
|
||||
effectiveVersionString := func(sdkVersion android.SdkSpec, minSdkVersion android.SdkSpec) string {
|
||||
// If {min|target}_sdk_version is current, use sdk_version to determine the effective level
|
||||
// This is necessary for vendor modules.
|
||||
// The effective version does not _only_ depend on {min|target}_sdk_version(level),
|
||||
// but also on the sdk_version (kind+level)
|
||||
if minSdkVersion.IsCurrent() {
|
||||
if minSdkVersion.ApiLevel.IsCurrent() {
|
||||
ret, err := sdkVersion.EffectiveVersionString(ctx)
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf("invalid sdk_version: %s", err)
|
||||
|
@ -689,7 +689,7 @@ type AARImport struct {
|
|||
jniPackages android.Paths
|
||||
|
||||
sdkVersion android.SdkSpec
|
||||
minSdkVersion android.ApiLevel
|
||||
minSdkVersion android.SdkSpec
|
||||
}
|
||||
|
||||
var _ android.OutputFileProducer = (*AARImport)(nil)
|
||||
|
@ -714,11 +714,11 @@ func (a *AARImport) SystemModules() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
if a.properties.Min_sdk_version != nil {
|
||||
return android.ApiLevelFrom(ctx, *a.properties.Min_sdk_version)
|
||||
return android.SdkSpecFrom(ctx, *a.properties.Min_sdk_version)
|
||||
}
|
||||
return a.SdkVersion(ctx).ApiLevel
|
||||
return a.SdkVersion(ctx)
|
||||
}
|
||||
|
||||
func (a *AARImport) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
|
|
14
java/app.go
14
java/app.go
|
@ -752,7 +752,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
|
||||
type appDepsInterface interface {
|
||||
SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
RequiresStableAPIs(ctx android.BaseModuleContext) bool
|
||||
}
|
||||
|
||||
|
@ -865,10 +865,10 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) {
|
|||
} else {
|
||||
toMinSdkVersion := "(no version)"
|
||||
if m, ok := to.(interface {
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
}); ok {
|
||||
if v := m.MinSdkVersion(ctx); !v.IsNone() {
|
||||
toMinSdkVersion = v.String()
|
||||
if v := m.MinSdkVersion(ctx); !v.ApiLevel.IsNone() {
|
||||
toMinSdkVersion = v.ApiLevel.String()
|
||||
}
|
||||
} else if m, ok := to.(interface{ MinSdkVersion() string }); ok {
|
||||
// TODO(b/175678607) eliminate the use of MinSdkVersion returning
|
||||
|
@ -1524,9 +1524,9 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||
manifestValues := &manifestValueAttribute{}
|
||||
// TODO(b/274474008 ): Directly convert deviceProperties.Min_sdk_version in bp2build
|
||||
// MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set
|
||||
minSdkVersion := a.MinSdkVersion(ctx)
|
||||
if !minSdkVersion.IsPreview() && !minSdkVersion.IsInvalid() {
|
||||
minSdkStr, err := minSdkVersion.EffectiveVersionString(ctx)
|
||||
minSdkSpec := a.MinSdkVersion(ctx)
|
||||
if !minSdkSpec.ApiLevel.IsPreview() && minSdkSpec.Valid() {
|
||||
minSdkStr, err := minSdkSpec.EffectiveVersionString(ctx)
|
||||
if err == nil {
|
||||
manifestValues.MinSdkVersion = &minSdkStr
|
||||
}
|
||||
|
|
|
@ -426,8 +426,8 @@ func (a *AndroidAppImport) SdkVersion(ctx android.EarlyModuleContext) android.Sd
|
|||
return android.SdkSpecPrivate
|
||||
}
|
||||
|
||||
func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
return android.SdkSpecPrivate.ApiLevel
|
||||
func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
return android.SdkSpecPrivate
|
||||
}
|
||||
|
||||
func (a *AndroidAppImport) LintDepSets() LintDepSets {
|
||||
|
|
27
java/base.go
27
java/base.go
|
@ -489,7 +489,7 @@ type Module struct {
|
|||
hideApexVariantFromMake bool
|
||||
|
||||
sdkVersion android.SdkSpec
|
||||
minSdkVersion android.ApiLevel
|
||||
minSdkVersion android.SdkSpec
|
||||
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.ApiLevel {
|
||||
func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
if j.deviceProperties.Min_sdk_version != nil {
|
||||
return android.ApiLevelFrom(ctx, *j.deviceProperties.Min_sdk_version)
|
||||
return android.SdkSpecFrom(ctx, *j.deviceProperties.Min_sdk_version)
|
||||
}
|
||||
return j.SdkVersion(ctx).ApiLevel
|
||||
return j.SdkVersion(ctx)
|
||||
}
|
||||
|
||||
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.String()
|
||||
return j.minSdkVersion.Raw
|
||||
}
|
||||
|
||||
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).String()
|
||||
aidlMinSdkVersion := j.MinSdkVersion(ctx).ApiLevel.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(apiLevel android.ApiLevel) int {
|
||||
if !apiLevel.IsPreview() {
|
||||
return apiLevel.FinalInt()
|
||||
lintSDKVersion := func(sdkSpec android.SdkSpec) int {
|
||||
if v := sdkSpec.ApiLevel; !v.IsPreview() {
|
||||
return v.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).ApiLevel)
|
||||
j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx).ApiLevel)
|
||||
j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx))
|
||||
j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx))
|
||||
j.linter.compileSdkKind = j.SdkVersion(ctx).Kind
|
||||
j.linter.javaLanguageLevel = flags.javaVersion.String()
|
||||
j.linter.kotlinLanguageLevel = "1.3"
|
||||
|
@ -1846,14 +1846,15 @@ 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)
|
||||
minSdkVersion := j.MinSdkVersion(ctx)
|
||||
if !minSdkVersion.Specified() {
|
||||
minSdkVersionSpec := j.MinSdkVersion(ctx)
|
||||
if !minSdkVersionSpec.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)
|
||||
}
|
||||
|
|
|
@ -130,13 +130,13 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars
|
|||
if s, ok := m.(*SdkLibrary); ok {
|
||||
// TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
|
||||
if s.minSdkVersion.Specified() {
|
||||
if s.minSdkVersion.IsCurrent() {
|
||||
if s.minSdkVersion.ApiLevel.IsCurrent() {
|
||||
jar.minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||
} else {
|
||||
jar.minSdkVersion = s.minSdkVersion.String()
|
||||
jar.minSdkVersion = s.minSdkVersion.ApiLevel.String()
|
||||
}
|
||||
}
|
||||
if s.maxSdkVersion.ApiLevel.Specified() {
|
||||
if s.maxSdkVersion.Specified() {
|
||||
if s.maxSdkVersion.ApiLevel.IsCurrent() {
|
||||
jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
|
||||
} else {
|
||||
|
|
|
@ -343,7 +343,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
|
|||
type compileDexParams struct {
|
||||
flags javaBuilderFlags
|
||||
sdkVersion android.SdkSpec
|
||||
minSdkVersion android.ApiLevel
|
||||
minSdkVersion android.SdkSpec
|
||||
classesJar android.Path
|
||||
jarName string
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ func (j *Javadoc) SystemModules() string {
|
|||
return proptools.String(j.properties.System_modules)
|
||||
}
|
||||
|
||||
func (j *Javadoc) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
return j.SdkVersion(ctx).ApiLevel
|
||||
func (j *Javadoc) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
return j.SdkVersion(ctx)
|
||||
}
|
||||
|
||||
func (j *Javadoc) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
|
@ -304,7 +304,7 @@ func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Op
|
|||
flags = append(flags, "-I"+src.String())
|
||||
}
|
||||
|
||||
minSdkVersion := j.MinSdkVersion(ctx).FinalOrFutureInt()
|
||||
minSdkVersion := j.MinSdkVersion(ctx).ApiLevel.FinalOrFutureInt()
|
||||
flags = append(flags, fmt.Sprintf("--min_sdk_version=%v", minSdkVersion))
|
||||
|
||||
return strings.Join(flags, " "), deps
|
||||
|
|
|
@ -73,7 +73,7 @@ type hiddenAPIModule interface {
|
|||
android.Module
|
||||
hiddenAPIIntf
|
||||
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
|
||||
MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
|
||||
}
|
||||
|
||||
type hiddenAPIIntf interface {
|
||||
|
@ -157,7 +157,7 @@ func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android
|
|||
// Create a copy of the dex jar which has been encoded with hiddenapi flags.
|
||||
flagsCSV := hiddenAPISingletonPaths(ctx).flags
|
||||
outputDir := android.PathForModuleOut(ctx, "hiddenapi").OutputPath
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.NoneApiLevel, outputDir)
|
||||
encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.SdkSpecNone, outputDir)
|
||||
|
||||
// Use the encoded dex jar from here onwards.
|
||||
return encodedDex
|
||||
|
@ -253,7 +253,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr
|
|||
// The encode dex rule requires unzipping, encoding and rezipping the classes.dex files along with
|
||||
// all the resources from the input jar. It also ensures that if it was uncompressed in the input
|
||||
// it stays uncompressed in the output.
|
||||
func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.ApiLevel, outputDir android.OutputPath) android.OutputPath {
|
||||
func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.SdkSpec, outputDir android.OutputPath) android.OutputPath {
|
||||
|
||||
// The output file has the same name as the input file and is in the output directory.
|
||||
output := outputDir.Join(ctx, dexInput.Base())
|
||||
|
@ -283,7 +283,7 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Pa
|
|||
|
||||
// If the library is targeted for Q and/or R then make sure that they do not
|
||||
// have any S+ flags encoded as that will break the runtime.
|
||||
minApiLevel := minSdkVersion
|
||||
minApiLevel := minSdkVersion.ApiLevel
|
||||
if !minApiLevel.IsNone() {
|
||||
if minApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, "R")) {
|
||||
hiddenapiFlags = hiddenapiFlags + " --max-hiddenapi-level=max-target-r"
|
||||
|
|
|
@ -1278,7 +1278,7 @@ type bootDexInfo struct {
|
|||
uncompressDex bool
|
||||
|
||||
// The minimum sdk version that the dex jar will be used on.
|
||||
minSdkVersion android.ApiLevel
|
||||
minSdkVersion android.SdkSpec
|
||||
}
|
||||
|
||||
// bootDexInfoByModule is a map from module name (as returned by module.Name()) to the boot dex
|
||||
|
|
15
java/java.go
15
java/java.go
|
@ -811,7 +811,7 @@ func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberCo
|
|||
// If the min_sdk_version was set then add the canonical representation of the API level to the
|
||||
// snapshot.
|
||||
if j.deviceProperties.Min_sdk_version != nil {
|
||||
canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.String())
|
||||
canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String())
|
||||
p.MinSdkVersion = proptools.StringPtr(canonical)
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1873,7 @@ type Import struct {
|
|||
hideApexVariantFromMake bool
|
||||
|
||||
sdkVersion android.SdkSpec
|
||||
minSdkVersion android.ApiLevel
|
||||
minSdkVersion android.SdkSpec
|
||||
}
|
||||
|
||||
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
|
||||
|
@ -1890,11 +1890,11 @@ func (j *Import) SystemModules() string {
|
|||
return "none"
|
||||
}
|
||||
|
||||
func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
if j.properties.Min_sdk_version != nil {
|
||||
return android.ApiLevelFrom(ctx, *j.properties.Min_sdk_version)
|
||||
return android.SdkSpecFrom(ctx, *j.properties.Min_sdk_version)
|
||||
}
|
||||
return j.SdkVersion(ctx).ApiLevel
|
||||
return j.SdkVersion(ctx)
|
||||
}
|
||||
|
||||
func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
|
@ -2160,14 +2160,15 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
|||
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||
sdkVersion android.ApiLevel) error {
|
||||
sdkVersionSpec := j.SdkVersion(ctx)
|
||||
minSdkVersion := j.MinSdkVersion(ctx)
|
||||
if !minSdkVersion.Specified() {
|
||||
minSdkVersionSpec := j.MinSdkVersion(ctx)
|
||||
if !minSdkVersionSpec.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)
|
||||
}
|
||||
|
|
|
@ -175,11 +175,11 @@ func (r *RuntimeResourceOverlay) SystemModules() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (r *RuntimeResourceOverlay) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
func (r *RuntimeResourceOverlay) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
if r.properties.Min_sdk_version != nil {
|
||||
return android.ApiLevelFrom(ctx, *r.properties.Min_sdk_version)
|
||||
return android.SdkSpecFrom(ctx, *r.properties.Min_sdk_version)
|
||||
}
|
||||
return r.SdkVersion(ctx).ApiLevel
|
||||
return r.SdkVersion(ctx)
|
||||
}
|
||||
|
||||
func (r *RuntimeResourceOverlay) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
|
|
|
@ -1231,7 +1231,7 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext)
|
|||
var _ android.ModuleWithMinSdkVersionCheck = (*SdkLibrary)(nil)
|
||||
|
||||
func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) {
|
||||
android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.ModuleContext, do android.PayloadDepsCallback) {
|
||||
android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx).ApiLevel, func(c android.ModuleContext, do android.PayloadDepsCallback) {
|
||||
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
|
||||
isExternal := !module.depIsInSameApex(ctx, child)
|
||||
if am, ok := child.(android.ApexModule); ok {
|
||||
|
@ -1775,7 +1775,7 @@ func (module *SdkLibrary) UniqueApexVariations() bool {
|
|||
|
||||
// Creates the xml file that publicizes the runtime library
|
||||
func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
|
||||
moduleMinApiLevel := module.Library.MinSdkVersion(mctx)
|
||||
moduleMinApiLevel := module.Library.MinSdkVersion(mctx).ApiLevel
|
||||
var moduleMinApiLevelStr = moduleMinApiLevel.String()
|
||||
if moduleMinApiLevel == android.NoneApiLevel {
|
||||
moduleMinApiLevelStr = "current"
|
||||
|
@ -2414,8 +2414,8 @@ func (module *SdkLibraryImport) UniqueApexVariations() bool {
|
|||
}
|
||||
|
||||
// MinSdkVersion - Implements hiddenAPIModule
|
||||
func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
|
||||
return android.NoneApiLevel
|
||||
func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
|
||||
return android.SdkSpecNone
|
||||
}
|
||||
|
||||
var _ hiddenAPIModule = (*SdkLibraryImport)(nil)
|
||||
|
|
|
@ -839,7 +839,6 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
|||
compile_dex: true,
|
||||
public: {enabled: true},
|
||||
permitted_packages: ["mysdklibrary"],
|
||||
min_sdk_version: "current",
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
|
|
|
@ -319,7 +319,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
|
|||
targetBuildRelease := s.targetBuildRelease(ctx)
|
||||
targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name)
|
||||
if err != nil {
|
||||
targetApiLevel = android.InvalidApiLevel
|
||||
targetApiLevel = android.FutureApiLevel
|
||||
}
|
||||
|
||||
// Aggregate all the sdkMemberVariantDep instances from all the sdk variants.
|
||||
|
@ -357,12 +357,6 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
|
|||
// If the minApiLevel of the member is greater than the target API level then exclude it from
|
||||
// this snapshot.
|
||||
exclude := memberVariantDep.minApiLevel.GreaterThan(targetApiLevel)
|
||||
// Always include host variants (e.g. host tools) in the snapshot.
|
||||
// Host variants should not be guarded by a min_sdk_version check. In fact, host variants
|
||||
// do not have a `min_sdk_version`.
|
||||
if memberVariantDep.Host() {
|
||||
exclude = false
|
||||
}
|
||||
|
||||
addMember(name, export, exclude)
|
||||
|
||||
|
@ -1269,11 +1263,6 @@ type sdkMemberVariantDep struct {
|
|||
minApiLevel android.ApiLevel
|
||||
}
|
||||
|
||||
// Host returns true if the sdk member is a host variant (e.g. host tool)
|
||||
func (s *sdkMemberVariantDep) Host() bool {
|
||||
return s.variant.Target().Os.Class == android.Host
|
||||
}
|
||||
|
||||
var _ android.SdkMember = (*sdkMember)(nil)
|
||||
|
||||
// sdkMember groups all the variants of a specific member module together along with the name of the
|
||||
|
|
Loading…
Reference in a new issue