Merge "fix: comparison between min_sdk_version" am: 91913e3e07

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1743953

Change-Id: I25972204c1f00ab438d28663d56ddde104c78555
This commit is contained in:
Jooyung Han 2021-06-23 17:20:08 +00:00 committed by Automerger Merge Worker
commit bdafb79af7
3 changed files with 34 additions and 12 deletions

View file

@ -1695,6 +1695,36 @@ func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
expectNoLink("libx", "shared_apex10000", "libz", "shared")
}
func TestApexMinSdkVersion_SupportsCodeNames_JavaLibs(t *testing.T) {
testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
java_libs: ["libx"],
min_sdk_version: "S",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_library {
name: "libx",
srcs: ["a.java"],
apex_available: [ "myapex" ],
sdk_version: "current",
min_sdk_version: "S", // should be okay
}
`,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Platform_version_active_codenames = []string{"S"}
variables.Platform_sdk_codename = proptools.StringPtr("S")
}),
)
}
func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) {
ctx := testApex(t, `
apex {

View file

@ -1513,12 +1513,8 @@ func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
if sdkSpec.Kind == android.SdkCore {
return nil
}
ver, err := sdkSpec.EffectiveVersion(ctx)
if err != nil {
return err
}
if ver.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", ver)
if sdkSpec.ApiLevel.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel)
}
return nil
}

View file

@ -1416,12 +1416,8 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
if sdkSpec.Kind == android.SdkCore {
return nil
}
ver, err := sdkSpec.EffectiveVersion(ctx)
if err != nil {
return err
}
if ver.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", ver)
if sdkSpec.ApiLevel.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", sdkSpec.ApiLevel)
}
return nil
}