Merge "Support two active sdks in EffectiveVersionString" am: 364c90773e
am: 62f1bbd288
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2464074 Change-Id: I9b129c7a6ade835e6f43c901585987d0f4b9dbad Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -211,7 +211,29 @@ func (s SdkSpec) EffectiveVersionString(ctx EarlyModuleContext) (string, error)
|
|||||||
if !s.ApiLevel.IsPreview() {
|
if !s.ApiLevel.IsPreview() {
|
||||||
return s.ApiLevel.String(), nil
|
return s.ApiLevel.String(), nil
|
||||||
}
|
}
|
||||||
return ctx.Config().DefaultAppTargetSdk(ctx).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 (
|
var (
|
||||||
|
@@ -1005,6 +1005,7 @@ func TestAppSdkVersion(t *testing.T) {
|
|||||||
platformSdkInt int
|
platformSdkInt int
|
||||||
platformSdkCodename string
|
platformSdkCodename string
|
||||||
platformSdkFinal bool
|
platformSdkFinal bool
|
||||||
|
minSdkVersionBp string
|
||||||
expectedMinSdkVersion string
|
expectedMinSdkVersion string
|
||||||
platformApis bool
|
platformApis bool
|
||||||
activeCodenames []string
|
activeCodenames []string
|
||||||
@@ -1052,6 +1053,14 @@ func TestAppSdkVersion(t *testing.T) {
|
|||||||
platformSdkCodename: "S",
|
platformSdkCodename: "S",
|
||||||
activeCodenames: []string{"S"},
|
activeCodenames: []string{"S"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "two active SDKs",
|
||||||
|
sdkVersion: "module_current",
|
||||||
|
minSdkVersionBp: "UpsideDownCake",
|
||||||
|
expectedMinSdkVersion: "UpsideDownCake", // And not VanillaIceCream
|
||||||
|
platformSdkCodename: "VanillaIceCream",
|
||||||
|
activeCodenames: []string{"UpsideDownCake", "VanillaIceCream"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, moduleType := range []string{"android_app", "android_library"} {
|
for _, moduleType := range []string{"android_app", "android_library"} {
|
||||||
@@ -1061,12 +1070,17 @@ func TestAppSdkVersion(t *testing.T) {
|
|||||||
if test.platformApis {
|
if test.platformApis {
|
||||||
platformApiProp = "platform_apis: true,"
|
platformApiProp = "platform_apis: true,"
|
||||||
}
|
}
|
||||||
|
minSdkVersionProp := ""
|
||||||
|
if test.minSdkVersionBp != "" {
|
||||||
|
minSdkVersionProp = fmt.Sprintf(` min_sdk_version: "%s",`, test.minSdkVersionBp)
|
||||||
|
}
|
||||||
bp := fmt.Sprintf(`%s {
|
bp := fmt.Sprintf(`%s {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
sdk_version: "%s",
|
sdk_version: "%s",
|
||||||
%s
|
%s
|
||||||
}`, moduleType, test.sdkVersion, platformApiProp)
|
%s
|
||||||
|
}`, moduleType, test.sdkVersion, platformApiProp, minSdkVersionProp)
|
||||||
|
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForJavaTest,
|
prepareForJavaTest,
|
||||||
|
Reference in New Issue
Block a user