Merge "Update usages of min_sdk_version that relies on (kind+level)" am: c8054ec6ac
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2457061 Change-Id: I65855232e3e40985aa10e853f12d579e02cf674e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2128,6 +2128,34 @@ func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
|
|||||||
min_sdk_version: "30",
|
min_sdk_version: "30",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// Skip check for modules compiling against core API surface
|
||||||
|
testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
java_libs: ["libfoo"],
|
||||||
|
min_sdk_version: "29",
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["Foo.java"],
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
// Compile against core API surface
|
||||||
|
sdk_version: "core_current",
|
||||||
|
min_sdk_version: "30",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
||||||
|
13
java/base.go
13
java/base.go
@@ -1845,15 +1845,18 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
|||||||
|
|
||||||
// Implements android.ApexModule
|
// Implements android.ApexModule
|
||||||
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
||||||
sdkSpec := j.MinSdkVersion(ctx)
|
sdkVersionSpec := j.SdkVersion(ctx)
|
||||||
if !sdkSpec.Specified() {
|
minSdkVersionSpec := j.MinSdkVersion(ctx)
|
||||||
|
if !minSdkVersionSpec.Specified() {
|
||||||
return fmt.Errorf("min_sdk_version is not specified")
|
return fmt.Errorf("min_sdk_version is not specified")
|
||||||
}
|
}
|
||||||
if sdkSpec.Kind == android.SdkCore {
|
// If the module is compiling against core (via sdk_version), skip comparison check.
|
||||||
|
if sdkVersionSpec.Kind == android.SdkCore {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if sdkSpec.ApiLevel.GreaterThan(sdkVersion) {
|
minSdkVersion := minSdkVersionSpec.ApiLevel
|
||||||
return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel)
|
if minSdkVersion.GreaterThan(sdkVersion) {
|
||||||
|
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
13
java/java.go
13
java/java.go
@@ -2166,15 +2166,18 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
|||||||
// Implements android.ApexModule
|
// Implements android.ApexModule
|
||||||
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||||
sdkVersion android.ApiLevel) error {
|
sdkVersion android.ApiLevel) error {
|
||||||
sdkSpec := j.MinSdkVersion(ctx)
|
sdkVersionSpec := j.SdkVersion(ctx)
|
||||||
if !sdkSpec.Specified() {
|
minSdkVersionSpec := j.MinSdkVersion(ctx)
|
||||||
|
if !minSdkVersionSpec.Specified() {
|
||||||
return fmt.Errorf("min_sdk_version is not specified")
|
return fmt.Errorf("min_sdk_version is not specified")
|
||||||
}
|
}
|
||||||
if sdkSpec.Kind == android.SdkCore {
|
// If the module is compiling against core (via sdk_version), skip comparison check.
|
||||||
|
if sdkVersionSpec.Kind == android.SdkCore {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if sdkSpec.ApiLevel.GreaterThan(sdkVersion) {
|
minSdkVersion := minSdkVersionSpec.ApiLevel
|
||||||
return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel)
|
if minSdkVersion.GreaterThan(sdkVersion) {
|
||||||
|
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user