Support for incremetal platform prebuilt APIs
This change provides support for prebuilt incremental platform API (i.e.
API changes associated with a QPR, as opposed to a major dessert
releas).
This feature is provided via the existing prebuilt_apis module with the
introduction of a new attribute:
allow_incremental_platform_api
While typical platform prebuilt APIs are presumed to be under a
directory structure that follows the pattern:
<version>/<scope>/<module>.jar
<version>/<scope>/api/<module>.txt
Where <version> is limited to a single integer signifying the API level.
For modules where allow_incremental_platform_api is set to 'true' (false
by default) the pattern is the same, however <version> is presumed to be
of the form MM.m, where MM aligns with the existing API level and m
signifies the incremental release (e.g. QPR).
Bug: b/280790094
Test: platform build check with both incremental & non-incremental API
cd build/soong && go test ./java
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:eee6995093485497bc29cdce01c2a86765ffb4eb)
Change-Id: I67e293006ccfa210d0dcc0a294db894632f1b6cb
diff --git a/android/api_levels.go b/android/api_levels.go
index 44c8640..3f538c0 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -19,6 +19,7 @@
"encoding/json"
"fmt"
"strconv"
+ "strings"
)
func init() {
@@ -237,6 +238,14 @@
}
}
+func uncheckedFinalIncrementalApiLevel(num int, increment int) ApiLevel {
+ return ApiLevel{
+ value: strconv.Itoa(num) + "." + strconv.Itoa(increment),
+ number: num,
+ isPreview: false,
+ }
+}
+
var NoneApiLevel = ApiLevel{
value: "(no version)",
// Not 0 because we don't want this to compare equal with the first preview.
@@ -371,6 +380,22 @@
return FutureApiLevel
}
+ if strings.Contains(raw, ".") {
+ // Check prebuilt incremental API format MM.m for major (API level) and minor (incremental) revisions
+ parts := strings.Split(raw, ".")
+ if len(parts) != 2 {
+ panic(fmt.Errorf("Found unexpected version '%s' for incremental API - expect MM.m format for incremental API with both major (MM) an minor (m) revision.", raw))
+ }
+ sdk, sdk_err := strconv.Atoi(parts[0])
+ qpr, qpr_err := strconv.Atoi(parts[1])
+ if sdk_err != nil || qpr_err != nil {
+ panic(fmt.Errorf("Unable to read version number for incremental api '%s'", raw))
+ }
+
+ apiLevel := uncheckedFinalIncrementalApiLevel(sdk, qpr)
+ return apiLevel
+ }
+
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))