Merge "Use module-lib system modules when building from prebuilts"

This commit is contained in:
Paul Duffin
2021-11-03 15:32:42 +00:00
committed by Gerrit Code Review
5 changed files with 59 additions and 11 deletions

View File

@@ -177,6 +177,10 @@ var FirstPackedRelocationsVersion = uncheckedFinalApiLevel(23)
// libandroid_support.
var FirstNonLibAndroidSupportVersion = uncheckedFinalApiLevel(21)
// LastWithoutModuleLibCoreSystemModules is the last API level where prebuilts/sdk does not contain
// a core-for-system-modules.jar for the module-lib API scope.
var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31)
// If the `raw` input is the codename of an API level has been finalized, this
// function returns the API level number associated with that API level. If the
// input is *not* a finalized codename, the input is returned unmodified.
@@ -236,6 +240,27 @@ func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) {
return apiLevel, nil
}
// ApiLevelForTest returns an ApiLevel constructed from the supplied raw string.
//
// This only supports "current" and numeric levels, code names are not supported.
func ApiLevelForTest(raw string) ApiLevel {
if raw == "" {
panic("API level string must be non-empty")
}
if raw == "current" {
return FutureApiLevel
}
asInt, err := strconv.Atoi(raw)
if err != nil {
panic(fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", raw))
}
apiLevel := uncheckedFinalApiLevel(asInt)
return apiLevel
}
// Converts an API level string `raw` into an ApiLevel in the same method as
// `ApiLevelFromUser`, but the input is assumed to have no errors and any errors
// will panic instead of returning an error.