diff options
author | 2025-03-03 09:10:01 +0100 | |
---|---|---|
committer | 2025-03-04 09:14:15 +0100 | |
commit | 7ceaad1de07ddc61a6c31c09e50cd396eb905442 (patch) | |
tree | 0e0052aa2a2329229365e1b9b531c36fab8c13df /java/prebuilt_apis.go | |
parent | 4a153bca753c38778e9ad960377ef8ab154f316e (diff) |
Always allow mixing old and new SDK version formats
The SDK is changing its versioning scheme from the old single integer
API level to the new major.minor format.
Remove the now obsolete allow_incremental_platform_api property of
prebuilt_apis.
Update soong to allow a mix of the old and new formats.
Bug: 397644338
Test: croot build/soong && go test ./java
Test: lunch sdk-next-eng && m sdk dist
Ignore-AOSP-First: minor SDK development takes place on internal main
Change-Id: Ie169addb97bb1c45fb254f9a7922a623cda94289
Diffstat (limited to 'java/prebuilt_apis.go')
-rw-r--r-- | java/prebuilt_apis.go | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go index 527e479f2..31f149ea9 100644 --- a/java/prebuilt_apis.go +++ b/java/prebuilt_apis.go @@ -55,11 +55,6 @@ type prebuiltApisProperties struct { // If set to true, compile dex for java_import modules. Defaults to false. Imports_compile_dex *bool - - // If set to true, allow incremental platform API of the form MM.m where MM is the major release - // version corresponding to the API level/SDK_INT and m is an incremental release version - // (e.g. API changes associated with QPR). Defaults to false. - Allow_incremental_platform_api *bool } type prebuiltApis struct { @@ -97,28 +92,28 @@ func parsePrebuiltPath(ctx android.LoadHookContext, p string) (module string, ve } // parseFinalizedPrebuiltPath is like parsePrebuiltPath, but verifies the version is numeric (a finalized version). -func parseFinalizedPrebuiltPath(ctx android.LoadHookContext, p string, allowIncremental bool) (module string, version int, release int, scope string) { +func parseFinalizedPrebuiltPath(ctx android.LoadHookContext, p string) (module string, version int, release int, scope string) { module, v, scope := parsePrebuiltPath(ctx, p) - if allowIncremental { - parts := strings.Split(v, ".") - if len(parts) != 2 { - ctx.ModuleErrorf("Found unexpected version '%v' for incremental prebuilts - expect MM.m format for incremental API with both major (MM) an minor (m) revision.", v) - return - } + + // assume a major.minor version code + parts := strings.Split(v, ".") + if len(parts) == 2 { sdk, sdk_err := strconv.Atoi(parts[0]) qpr, qpr_err := strconv.Atoi(parts[1]) if sdk_err != nil || qpr_err != nil { - ctx.ModuleErrorf("Unable to read version number for incremental prebuilt api '%v'", v) + ctx.ModuleErrorf("Unable to read major.minor version for prebuilt api '%v'", v) return } version = sdk release = qpr return } + + // assume a legacy integer only api level release = 0 version, err := strconv.Atoi(v) if err != nil { - ctx.ModuleErrorf("Found finalized API files in non-numeric dir '%v'", v) + ctx.ModuleErrorf("Unable to read API level for prebuilt api '%v'", v) return } return @@ -279,12 +274,11 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) { } // Create modules for all (<module>, <scope, <version>) triplets, - allowIncremental := proptools.BoolDefault(p.properties.Allow_incremental_platform_api, false) for _, f := range apiLevelFiles { - module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental) - if allowIncremental { - incrementalVersion := strconv.Itoa(version) + "." + strconv.Itoa(release) - createApiModule(mctx, PrebuiltApiModuleName(module, scope, incrementalVersion), f) + module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f) + if release != 0 { + majorDotMinorVersion := strconv.Itoa(version) + "." + strconv.Itoa(release) + createApiModule(mctx, PrebuiltApiModuleName(module, scope, majorDotMinorVersion), f) } else { createApiModule(mctx, PrebuiltApiModuleName(module, scope, strconv.Itoa(version)), f) } @@ -300,7 +294,7 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) { getLatest := func(files []string, isExtensionApiFile bool) map[string]latestApiInfo { m := make(map[string]latestApiInfo) for _, f := range files { - module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental) + module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f) if strings.HasSuffix(module, "incompatibilities") { continue } |