diff options
author | 2020-08-06 23:00:37 +0900 | |
---|---|---|
committer | 2020-08-27 23:09:54 +0900 | |
commit | 219141c6bbd234501555e20e8e22f310199bf54c (patch) | |
tree | 485106d2747ca85f993f68c6481906b001813a18 /java/sdk.go | |
parent | 03333d0e2f478aba21c3077dfdb69bd0593eaf3c (diff) |
Introduce BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES
If BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES has a numeric value,
it replaces "current" or "system_current" with the version which
the flag indicates.
Bug: 163009188
Test: BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES=29 m, and then check if every vendor
java module's sdk_version is 29 if its sdk_version was current.
Change-Id: I17b49b8e02caf2d1bc57b91648d4420f3ad9fcb9
Diffstat (limited to 'java/sdk.go')
-rw-r--r-- | java/sdk.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/java/sdk.go b/java/sdk.go index b44cd8e1a..56fa12b3e 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -191,6 +191,26 @@ func (s sdkSpec) prebuiltSdkAvailableForUnbundledBuild() bool { return s.kind != sdkPrivate && s.kind != sdkNone && s.kind != sdkCorePlatform } +func (s sdkSpec) forVendorPartition(ctx android.EarlyModuleContext) sdkSpec { + // If BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES has a numeric value, + // use it instead of "current" for the vendor partition. + currentSdkVersion := ctx.DeviceConfig().CurrentApiLevelForVendorModules() + if currentSdkVersion == "current" { + return s + } + + if s.kind == sdkPublic || s.kind == sdkSystem { + if s.version.isCurrent() { + if i, err := strconv.Atoi(currentSdkVersion); err == nil { + version := sdkVersion(i) + return sdkSpec{s.kind, version, s.raw} + } + panic(fmt.Errorf("BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES must be either \"current\" or a number, but was %q", currentSdkVersion)) + } + } + return s +} + // usePrebuilt determines whether prebuilt SDK should be used for this sdkSpec with the given context. func (s sdkSpec) usePrebuilt(ctx android.EarlyModuleContext) bool { if s.version.isCurrent() { @@ -216,6 +236,10 @@ func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, e if !s.valid() { return s.version, fmt.Errorf("invalid sdk version %q", s.raw) } + + if ctx.DeviceSpecific() || ctx.SocSpecific() { + s = s.forVendorPartition(ctx) + } if s.version.isNumbered() { return s.version, nil } @@ -330,6 +354,10 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep return sdkDep{} } + if ctx.DeviceSpecific() || ctx.SocSpecific() { + sdkVersion = sdkVersion.forVendorPartition(ctx) + } + if !sdkVersion.validateSystemSdk(ctx) { return sdkDep{} } |