2019-01-10 14:17:55 +08:00
|
|
|
// Copyright 2019 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package java
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
2019-01-10 15:04:25 +08:00
|
|
|
"sort"
|
2019-01-10 14:17:55 +08:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2019-04-19 01:56:44 +08:00
|
|
|
|
2020-01-19 02:33:43 +08:00
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/java/config"
|
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
"github.com/google/blueprint/pathtools"
|
2019-01-10 14:17:55 +08:00
|
|
|
)
|
|
|
|
|
2019-01-10 15:04:25 +08:00
|
|
|
func init() {
|
2019-04-19 01:56:44 +08:00
|
|
|
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
|
|
|
android.RegisterSingletonType("sdk", sdkSingletonFactory)
|
2019-04-19 05:27:12 +08:00
|
|
|
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
|
2019-01-10 15:04:25 +08:00
|
|
|
}
|
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
|
|
|
|
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
2020-04-09 20:29:59 +08:00
|
|
|
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
2019-04-19 05:27:12 +08:00
|
|
|
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
2019-01-10 15:04:25 +08:00
|
|
|
|
2019-01-10 14:17:55 +08:00
|
|
|
type sdkContext interface {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// sdkVersion returns sdkSpec that corresponds to the sdk_version property of the current module
|
|
|
|
sdkVersion() sdkSpec
|
2019-10-11 20:50:28 +08:00
|
|
|
// systemModules returns the system_modules property of the current module, or an empty string if it is not set.
|
|
|
|
systemModules() string
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// minSdkVersion returns sdkSpec that corresponds to the min_sdk_version property of the current module,
|
|
|
|
// or from sdk_version if it is not set.
|
|
|
|
minSdkVersion() sdkSpec
|
|
|
|
// targetSdkVersion returns the sdkSpec that corresponds to the target_sdk_version property of the current module,
|
|
|
|
// or from sdk_version if it is not set.
|
|
|
|
targetSdkVersion() sdkSpec
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
|
2020-03-03 00:58:11 +08:00
|
|
|
func UseApiFingerprint(ctx android.BaseModuleContext) bool {
|
|
|
|
if ctx.Config().UnbundledBuild() &&
|
2020-01-25 07:15:44 +08:00
|
|
|
!ctx.Config().UnbundledBuildUsePrebuiltSdks() &&
|
|
|
|
ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// sdkKind represents a particular category of an SDK spec like public, system, test, etc.
|
|
|
|
type sdkKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
sdkInvalid sdkKind = iota
|
|
|
|
sdkNone
|
|
|
|
sdkCore
|
|
|
|
sdkCorePlatform
|
|
|
|
sdkPublic
|
|
|
|
sdkSystem
|
|
|
|
sdkTest
|
2020-01-30 17:00:15 +08:00
|
|
|
sdkModule
|
2020-02-12 03:36:43 +08:00
|
|
|
sdkSystemServer
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
sdkPrivate
|
|
|
|
)
|
|
|
|
|
|
|
|
// String returns the string representation of this sdkKind
|
|
|
|
func (k sdkKind) String() string {
|
|
|
|
switch k {
|
|
|
|
case sdkPrivate:
|
|
|
|
return "private"
|
|
|
|
case sdkNone:
|
|
|
|
return "none"
|
|
|
|
case sdkPublic:
|
|
|
|
return "public"
|
|
|
|
case sdkSystem:
|
|
|
|
return "system"
|
|
|
|
case sdkTest:
|
|
|
|
return "test"
|
|
|
|
case sdkCore:
|
|
|
|
return "core"
|
|
|
|
case sdkCorePlatform:
|
|
|
|
return "core_platform"
|
2020-01-30 17:00:15 +08:00
|
|
|
case sdkModule:
|
|
|
|
return "module"
|
2020-02-12 03:36:43 +08:00
|
|
|
case sdkSystemServer:
|
|
|
|
return "system_server"
|
2019-01-10 14:17:55 +08:00
|
|
|
default:
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
return "invalid"
|
2020-01-25 07:15:44 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// sdkVersion represents a specific version number of an SDK spec of a particular kind
|
|
|
|
type sdkVersion int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// special version number for a not-yet-frozen SDK
|
|
|
|
sdkVersionCurrent sdkVersion = sdkVersion(android.FutureApiLevel)
|
|
|
|
// special version number to be used for SDK specs where version number doesn't
|
|
|
|
// make sense, e.g. "none", "", etc.
|
|
|
|
sdkVersionNone sdkVersion = sdkVersion(0)
|
|
|
|
)
|
|
|
|
|
|
|
|
// isCurrent checks if the sdkVersion refers to the not-yet-published version of an sdkKind
|
|
|
|
func (v sdkVersion) isCurrent() bool {
|
|
|
|
return v == sdkVersionCurrent
|
|
|
|
}
|
|
|
|
|
|
|
|
// isNumbered checks if the sdkVersion refers to the published (a.k.a numbered) version of an sdkKind
|
|
|
|
func (v sdkVersion) isNumbered() bool {
|
|
|
|
return !v.isCurrent() && v != sdkVersionNone
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns the string representation of this sdkVersion.
|
|
|
|
func (v sdkVersion) String() string {
|
|
|
|
if v.isCurrent() {
|
|
|
|
return "current"
|
|
|
|
} else if v.isNumbered() {
|
|
|
|
return strconv.Itoa(int(v))
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
return "(no version)"
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// asNumberString directly converts the numeric value of this sdk version as a string.
|
|
|
|
// When isNumbered() is true, this method is the same as String(). However, for sdkVersionCurrent
|
|
|
|
// and sdkVersionNone, this returns 10000 and 0 while String() returns "current" and "(no version"),
|
|
|
|
// respectively.
|
|
|
|
func (v sdkVersion) asNumberString() string {
|
|
|
|
return strconv.Itoa(int(v))
|
|
|
|
}
|
|
|
|
|
|
|
|
// sdkSpec represents the kind and the version of an SDK for a module to build against
|
|
|
|
type sdkSpec struct {
|
|
|
|
kind sdkKind
|
|
|
|
version sdkVersion
|
|
|
|
raw string
|
|
|
|
}
|
|
|
|
|
2020-04-09 02:09:30 +08:00
|
|
|
func (s sdkSpec) String() string {
|
|
|
|
return fmt.Sprintf("%s_%s", s.kind, s.version)
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// valid checks if this sdkSpec is well-formed. Note however that true doesn't mean that the
|
|
|
|
// specified SDK actually exists.
|
|
|
|
func (s sdkSpec) valid() bool {
|
|
|
|
return s.kind != sdkInvalid
|
|
|
|
}
|
|
|
|
|
|
|
|
// specified checks if this sdkSpec is well-formed and is not "".
|
|
|
|
func (s sdkSpec) specified() bool {
|
|
|
|
return s.valid() && s.kind != sdkPrivate
|
|
|
|
}
|
|
|
|
|
2020-04-09 02:09:30 +08:00
|
|
|
// whether the API surface is managed and versioned, i.e. has .txt file that
|
|
|
|
// get frozen on SDK freeze and changes get reviewed by API council.
|
|
|
|
func (s sdkSpec) stable() bool {
|
|
|
|
if !s.specified() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
switch s.kind {
|
2020-04-16 00:29:42 +08:00
|
|
|
case sdkNone:
|
|
|
|
// there is nothing to manage and version in this case; de facto stable API.
|
|
|
|
return true
|
2020-04-09 02:09:30 +08:00
|
|
|
case sdkCore, sdkPublic, sdkSystem, sdkModule, sdkSystemServer:
|
|
|
|
return true
|
2020-04-16 00:29:42 +08:00
|
|
|
case sdkCorePlatform, sdkTest, sdkPrivate:
|
2020-04-09 02:09:30 +08:00
|
|
|
return false
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown sdkKind=%v", s.kind))
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// prebuiltSdkAvailableForUnbundledBuilt tells whether this sdkSpec can have a prebuilt SDK
|
|
|
|
// that can be used for unbundled builds.
|
|
|
|
func (s sdkSpec) prebuiltSdkAvailableForUnbundledBuild() bool {
|
|
|
|
// "", "none", and "core_platform" are not available for unbundled build
|
|
|
|
// as we don't/can't have prebuilt stub for the versions
|
|
|
|
return s.kind != sdkPrivate && s.kind != sdkNone && s.kind != sdkCorePlatform
|
|
|
|
}
|
|
|
|
|
|
|
|
// forPdkBuild converts this sdkSpec into another sdkSpec that is for the PDK builds.
|
|
|
|
func (s sdkSpec) forPdkBuild(ctx android.EarlyModuleContext) sdkSpec {
|
|
|
|
// For PDK builds, use the latest SDK version instead of "current" or ""
|
|
|
|
if s.kind == sdkPrivate || s.kind == sdkPublic {
|
|
|
|
kind := s.kind
|
|
|
|
if kind == sdkPrivate {
|
|
|
|
// We don't have prebuilt SDK for private APIs, so use the public SDK
|
|
|
|
// instead. This looks odd, but that's how it has been done.
|
|
|
|
// TODO(b/148271073): investigate the need for this.
|
|
|
|
kind = sdkPublic
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
version := sdkVersion(LatestSdkVersionInt(ctx))
|
|
|
|
return sdkSpec{kind, version, s.raw}
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
return s
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// 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() {
|
|
|
|
// "current" can be built from source and be from prebuilt SDK
|
|
|
|
return ctx.Config().UnbundledBuildUsePrebuiltSdks()
|
|
|
|
} else if s.version.isNumbered() {
|
|
|
|
// sanity check
|
|
|
|
if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest {
|
|
|
|
panic(fmt.Errorf("prebuilt SDK is not not available for sdkKind=%q", s.kind))
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// numbered SDKs are always from prebuilt
|
|
|
|
return true
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// "", "none", "core_platform" fall here
|
|
|
|
return false
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// effectiveVersion converts an sdkSpec into the concrete sdkVersion that the module
|
|
|
|
// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
|
|
|
|
// it returns android.FutureApiLevel(10000).
|
|
|
|
func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, error) {
|
|
|
|
if !s.valid() {
|
|
|
|
return s.version, fmt.Errorf("invalid sdk version %q", s.raw)
|
|
|
|
}
|
|
|
|
if ctx.Config().IsPdkBuild() {
|
|
|
|
s = s.forPdkBuild(ctx)
|
|
|
|
}
|
|
|
|
if s.version.isNumbered() {
|
|
|
|
return s.version, nil
|
2019-01-10 15:04:25 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
return sdkVersion(ctx.Config().DefaultAppTargetSdkInt()), nil
|
|
|
|
}
|
2019-01-10 15:04:25 +08:00
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
// effectiveVersionString converts an sdkSpec into the concrete version string that the module
|
|
|
|
// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
|
|
|
|
// it returns the codename (P, Q, R, etc.)
|
|
|
|
func (s sdkSpec) effectiveVersionString(ctx android.EarlyModuleContext) (string, error) {
|
|
|
|
ver, err := s.effectiveVersion(ctx)
|
|
|
|
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdkInt() {
|
|
|
|
return ctx.Config().DefaultAppTargetSdk(), nil
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
return ver.String(), err
|
|
|
|
}
|
2019-01-10 14:17:55 +08:00
|
|
|
|
2020-05-15 09:05:32 +08:00
|
|
|
func (s sdkSpec) defaultJavaLanguageVersion(ctx android.EarlyModuleContext) javaVersion {
|
|
|
|
sdk, err := s.effectiveVersion(ctx)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "%s", err)
|
|
|
|
}
|
|
|
|
if sdk <= 23 {
|
|
|
|
return JAVA_VERSION_7
|
|
|
|
} else if sdk <= 29 {
|
|
|
|
return JAVA_VERSION_8
|
|
|
|
} else {
|
|
|
|
return JAVA_VERSION_9
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
func sdkSpecFrom(str string) sdkSpec {
|
|
|
|
switch str {
|
|
|
|
// special cases first
|
|
|
|
case "":
|
|
|
|
return sdkSpec{sdkPrivate, sdkVersionNone, str}
|
|
|
|
case "none":
|
|
|
|
return sdkSpec{sdkNone, sdkVersionNone, str}
|
|
|
|
case "core_platform":
|
|
|
|
return sdkSpec{sdkCorePlatform, sdkVersionNone, str}
|
|
|
|
default:
|
|
|
|
// the syntax is [kind_]version
|
|
|
|
sep := strings.LastIndex(str, "_")
|
|
|
|
|
|
|
|
var kindString string
|
|
|
|
if sep == 0 {
|
|
|
|
return sdkSpec{sdkInvalid, sdkVersionNone, str}
|
|
|
|
} else if sep == -1 {
|
|
|
|
kindString = ""
|
2019-01-10 14:17:55 +08:00
|
|
|
} else {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
kindString = str[0:sep]
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
versionString := str[sep+1 : len(str)]
|
|
|
|
|
|
|
|
var kind sdkKind
|
|
|
|
switch kindString {
|
|
|
|
case "":
|
|
|
|
kind = sdkPublic
|
|
|
|
case "core":
|
|
|
|
kind = sdkCore
|
|
|
|
case "system":
|
|
|
|
kind = sdkSystem
|
|
|
|
case "test":
|
|
|
|
kind = sdkTest
|
2020-01-30 17:00:15 +08:00
|
|
|
case "module":
|
|
|
|
kind = sdkModule
|
2020-02-12 03:36:43 +08:00
|
|
|
case "system_server":
|
|
|
|
kind = sdkSystemServer
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
default:
|
|
|
|
return sdkSpec{sdkInvalid, sdkVersionNone, str}
|
|
|
|
}
|
|
|
|
|
|
|
|
var version sdkVersion
|
|
|
|
if versionString == "current" {
|
|
|
|
version = sdkVersionCurrent
|
|
|
|
} else if i, err := strconv.Atoi(versionString); err == nil {
|
|
|
|
version = sdkVersion(i)
|
|
|
|
} else {
|
|
|
|
return sdkSpec{sdkInvalid, sdkVersionNone, str}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sdkSpec{kind, version, str}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-28 12:52:36 +08:00
|
|
|
func (s sdkSpec) validateSystemSdk(ctx android.EarlyModuleContext) bool {
|
|
|
|
// Ensures that the specified system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor/product Java module)
|
|
|
|
// Assuming that BOARD_SYSTEMSDK_VERSIONS := 28 29,
|
|
|
|
// sdk_version of the modules in vendor/product that use system sdk must be either system_28, system_29 or system_current
|
|
|
|
if s.kind != sdkSystem || !s.version.isNumbered() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
allowedVersions := ctx.DeviceConfig().PlatformSystemSdkVersions()
|
|
|
|
if ctx.DeviceSpecific() || ctx.SocSpecific() || (ctx.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
|
|
|
|
systemSdkVersions := ctx.DeviceConfig().SystemSdkVersions()
|
|
|
|
if len(systemSdkVersions) > 0 {
|
|
|
|
allowedVersions = systemSdkVersions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(allowedVersions) > 0 && !android.InList(s.version.String(), allowedVersions) {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
|
|
|
|
s.raw, allowedVersions)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep {
|
|
|
|
sdkVersion := sdkContext.sdkVersion()
|
|
|
|
if !sdkVersion.valid() {
|
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid version %q", sdkVersion.raw)
|
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.Config().IsPdkBuild() {
|
|
|
|
sdkVersion = sdkVersion.forPdkBuild(ctx)
|
|
|
|
}
|
2020-01-28 12:52:36 +08:00
|
|
|
if !sdkVersion.validateSystemSdk(ctx) {
|
|
|
|
return sdkDep{}
|
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
|
|
|
|
if sdkVersion.usePrebuilt(ctx) {
|
|
|
|
dir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), sdkVersion.kind.String())
|
2019-01-10 14:17:55 +08:00
|
|
|
jar := filepath.Join(dir, "android.jar")
|
|
|
|
// There's no aidl for other SDKs yet.
|
|
|
|
// TODO(77525052): Add aidl files for other SDKs too.
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
public_dir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), "public")
|
2019-01-10 14:17:55 +08:00
|
|
|
aidl := filepath.Join(public_dir, "framework.aidl")
|
|
|
|
jarPath := android.ExistentPathForSource(ctx, jar)
|
|
|
|
aidlPath := android.ExistentPathForSource(ctx, aidl)
|
|
|
|
lambdaStubsPath := android.PathForSource(ctx, config.SdkLambdaStubsPath)
|
|
|
|
|
|
|
|
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
|
|
|
|
return sdkDep{
|
|
|
|
invalidVersion: true,
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", sdkVersion.kind, sdkVersion.version.String())},
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !jarPath.Valid() {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.raw, jar)
|
2019-01-10 14:17:55 +08:00
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !aidlPath.Valid() {
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.raw, aidl)
|
2019-01-10 14:17:55 +08:00
|
|
|
return sdkDep{}
|
|
|
|
}
|
|
|
|
|
2020-05-15 09:05:32 +08:00
|
|
|
var systemModules string
|
|
|
|
if sdkVersion.defaultJavaLanguageVersion(ctx).usesJavaModules() {
|
|
|
|
systemModules = "sdk_public_" + sdkVersion.version.String() + "_system_modules"
|
|
|
|
}
|
|
|
|
|
2019-01-10 14:17:55 +08:00
|
|
|
return sdkDep{
|
2020-05-15 09:05:32 +08:00
|
|
|
useFiles: true,
|
|
|
|
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
|
|
|
|
aidl: android.OptionalPathForPath(aidlPath.Path()),
|
|
|
|
systemModules: systemModules,
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-12 03:36:43 +08:00
|
|
|
toModule := func(modules []string, res string, aidl android.Path) sdkDep {
|
2019-10-18 05:23:50 +08:00
|
|
|
return sdkDep{
|
2019-01-10 14:17:55 +08:00
|
|
|
useModule: true,
|
2020-02-12 03:36:43 +08:00
|
|
|
bootclasspath: append(modules, config.DefaultLambdaStubsLibrary),
|
2019-10-18 05:23:50 +08:00
|
|
|
systemModules: "core-current-stubs-system-modules",
|
2020-02-12 03:36:43 +08:00
|
|
|
java9Classpath: modules,
|
|
|
|
frameworkResModule: res,
|
2019-04-19 01:56:44 +08:00
|
|
|
aidl: android.OptionalPathForPath(aidl),
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
switch sdkVersion.kind {
|
|
|
|
case sdkPrivate:
|
2019-01-10 14:17:55 +08:00
|
|
|
return sdkDep{
|
Remove the concept of useDefaultLibs from Soong.
This field in the java/sdk structure was used in two of the many
possible configurations, so it wasn't really a "default". It also
meant that, to understand those configurations, the reader had to know
what was considered the default, which was only possibly by reading
the code in java.go and droiddoc.go which implemented special code
paths when useDefaultLibs was true. By eliminating that setting and
explicitly setting the required values, the code is simpler and easier
to understand.
This change is a straight refactoring, in the sense that the output of
the build should be unchanged.
Regarding the changes to the proguardRaiseTag dependency in java.go:
- This is a noop for anything which had sdkDep.useModule = true prior
to this change, because they all had the same value for
hasFrameworkLibs() and hasStandardLibs().
- This is a noop for anything which had sdkDep.useDefaultLibs = true
prior to this change, because they do not use proguard settings.
- Therefore, it is a noop overall.
- Nevertheless, it is required to make sdkCorePlatform work. Without
this change, such modules would pick up a dependency on framework
libs via the (unused) proguardRaiseTag, which creates a circular
dependency, because this is the sdk_version used when building
framework libs themselves.
Bug: 157640067
Test: m java docs droid
Change-Id: I3a83b5edc1bd48c16b55f6f77e3e710fc8fbd8fa
2020-06-29 18:28:51 +08:00
|
|
|
useModule: true,
|
|
|
|
systemModules: config.LegacyCorePlatformSystemModules,
|
|
|
|
bootclasspath: config.LegacyCorePlatformBootclasspathLibraries,
|
|
|
|
classpath: config.FrameworkLibraries,
|
2019-01-10 14:17:55 +08:00
|
|
|
frameworkResModule: "framework-res",
|
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkNone:
|
2019-10-11 20:50:28 +08:00
|
|
|
systemModules := sdkContext.systemModules()
|
|
|
|
if systemModules == "" {
|
|
|
|
ctx.PropertyErrorf("sdk_version",
|
|
|
|
`system_modules is required to be set to a non-empty value when sdk_version is "none", did you mean sdk_version: "core_platform"?`)
|
|
|
|
} else if systemModules == "none" {
|
2019-10-29 06:10:03 +08:00
|
|
|
return sdkDep{
|
|
|
|
noStandardLibs: true,
|
|
|
|
}
|
2019-10-11 20:50:28 +08:00
|
|
|
}
|
|
|
|
|
2019-06-11 19:31:14 +08:00
|
|
|
return sdkDep{
|
2019-10-29 06:10:03 +08:00
|
|
|
useModule: true,
|
2019-06-11 19:31:14 +08:00
|
|
|
noStandardLibs: true,
|
2019-10-11 20:50:28 +08:00
|
|
|
systemModules: systemModules,
|
2019-10-18 05:23:50 +08:00
|
|
|
bootclasspath: []string{systemModules},
|
2019-06-11 19:31:14 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkCorePlatform:
|
2019-06-12 20:25:22 +08:00
|
|
|
return sdkDep{
|
2020-07-01 20:05:32 +08:00
|
|
|
useModule: true,
|
|
|
|
systemModules: config.LegacyCorePlatformSystemModules,
|
|
|
|
bootclasspath: config.LegacyCorePlatformBootclasspathLibraries,
|
|
|
|
noFrameworksLibs: true,
|
2019-06-12 20:25:22 +08:00
|
|
|
}
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkPublic:
|
2020-02-12 03:36:43 +08:00
|
|
|
return toModule([]string{"android_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkSystem:
|
2020-02-12 03:36:43 +08:00
|
|
|
return toModule([]string{"android_system_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkTest:
|
2020-02-12 03:36:43 +08:00
|
|
|
return toModule([]string{"android_test_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
case sdkCore:
|
2020-07-01 20:17:16 +08:00
|
|
|
return sdkDep{
|
|
|
|
useModule: true,
|
|
|
|
bootclasspath: []string{"core.current.stubs", config.DefaultLambdaStubsLibrary},
|
|
|
|
systemModules: "core-current-stubs-system-modules",
|
|
|
|
noFrameworksLibs: true,
|
|
|
|
}
|
2020-01-30 17:00:15 +08:00
|
|
|
case sdkModule:
|
|
|
|
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
|
2020-04-09 20:29:59 +08:00
|
|
|
return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", nonUpdatableFrameworkAidlPath(ctx))
|
2020-02-12 03:36:43 +08:00
|
|
|
case sdkSystemServer:
|
|
|
|
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
|
2020-03-19 23:23:38 +08:00
|
|
|
return toModule([]string{"android_system_server_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
|
2019-01-10 14:17:55 +08:00
|
|
|
default:
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw))
|
2019-01-10 14:17:55 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-10 15:04:25 +08:00
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
func sdkPreSingletonFactory() android.Singleton {
|
|
|
|
return sdkPreSingleton{}
|
2019-01-10 15:04:25 +08:00
|
|
|
}
|
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
type sdkPreSingleton struct{}
|
2019-01-10 15:04:25 +08:00
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
func (sdkPreSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
2019-01-10 15:04:25 +08:00
|
|
|
sdkJars, err := ctx.GlobWithDeps("prebuilts/sdk/*/public/android.jar", nil)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Errorf("failed to glob prebuilts/sdk/*/public/android.jar: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
var sdkVersions []int
|
|
|
|
for _, sdkJar := range sdkJars {
|
|
|
|
dir := filepath.Base(filepath.Dir(filepath.Dir(sdkJar)))
|
|
|
|
v, err := strconv.Atoi(dir)
|
|
|
|
if scerr, ok := err.(*strconv.NumError); ok && scerr.Err == strconv.ErrSyntax {
|
|
|
|
continue
|
|
|
|
} else if err != nil {
|
|
|
|
ctx.Errorf("invalid sdk jar %q, %s, %v", sdkJar, err.Error())
|
|
|
|
}
|
|
|
|
sdkVersions = append(sdkVersions, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Ints(sdkVersions)
|
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
ctx.Config().Once(sdkVersionsKey, func() interface{} { return sdkVersions })
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-21 01:03:43 +08:00
|
|
|
func LatestSdkVersionInt(ctx android.EarlyModuleContext) int {
|
|
|
|
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
|
|
|
|
latestSdkVersion := 0
|
|
|
|
if len(sdkVersions) > 0 {
|
|
|
|
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
|
|
|
}
|
|
|
|
return latestSdkVersion
|
|
|
|
}
|
|
|
|
|
2019-04-19 01:56:44 +08:00
|
|
|
func sdkSingletonFactory() android.Singleton {
|
|
|
|
return sdkSingleton{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type sdkSingleton struct{}
|
|
|
|
|
|
|
|
func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
2019-04-19 05:27:12 +08:00
|
|
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
2019-04-19 01:56:44 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-04-19 05:27:12 +08:00
|
|
|
createSdkFrameworkAidl(ctx)
|
2020-04-09 20:29:59 +08:00
|
|
|
createNonUpdatableFrameworkAidl(ctx)
|
2019-04-19 05:27:12 +08:00
|
|
|
createAPIFingerprint(ctx)
|
|
|
|
}
|
2019-04-19 01:56:44 +08:00
|
|
|
|
2019-04-19 05:27:12 +08:00
|
|
|
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
|
|
|
|
func createSdkFrameworkAidl(ctx android.SingletonContext) {
|
2019-04-19 01:56:44 +08:00
|
|
|
stubsModules := []string{
|
|
|
|
"android_stubs_current",
|
|
|
|
"android_test_stubs_current",
|
|
|
|
"android_system_stubs_current",
|
|
|
|
}
|
|
|
|
|
2020-04-09 20:29:59 +08:00
|
|
|
combinedAidl := sdkFrameworkAidlPath(ctx)
|
|
|
|
tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp")
|
|
|
|
|
|
|
|
rule := createFrameworkAidl(stubsModules, tempPath, ctx)
|
|
|
|
|
|
|
|
commitChangeForRestat(rule, tempPath, combinedAidl)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a version of framework.aidl for the non-updatable part of the platform.
|
|
|
|
func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) {
|
|
|
|
stubsModules := []string{"android_module_lib_stubs_current"}
|
|
|
|
|
|
|
|
combinedAidl := nonUpdatableFrameworkAidlPath(ctx)
|
|
|
|
tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp")
|
|
|
|
|
|
|
|
rule := createFrameworkAidl(stubsModules, tempPath, ctx)
|
|
|
|
|
|
|
|
commitChangeForRestat(rule, tempPath, combinedAidl)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "framework_non_updatable_aidl", "generate framework_non_updatable.aidl")
|
|
|
|
}
|
|
|
|
|
|
|
|
func createFrameworkAidl(stubsModules []string, path android.OutputPath, ctx android.SingletonContext) *android.RuleBuilder {
|
2019-04-19 01:56:44 +08:00
|
|
|
stubsJars := make([]android.Paths, len(stubsModules))
|
|
|
|
|
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
|
|
|
// Collect dex jar paths for the modules listed above.
|
|
|
|
if j, ok := module.(Dependency); ok {
|
|
|
|
name := ctx.ModuleName(module)
|
|
|
|
if i := android.IndexList(name, stubsModules); i != -1 {
|
|
|
|
stubsJars[i] = j.HeaderJars()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var missingDeps []string
|
|
|
|
|
|
|
|
for i := range stubsJars {
|
|
|
|
if stubsJars[i] == nil {
|
|
|
|
if ctx.Config().AllowMissingDependencies() {
|
|
|
|
missingDeps = append(missingDeps, stubsModules[i])
|
|
|
|
} else {
|
2020-04-09 20:29:59 +08:00
|
|
|
ctx.Errorf("failed to find dex jar path for module %q", stubsModules[i])
|
2019-04-19 01:56:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
rule.MissingDeps(missingDeps)
|
|
|
|
|
|
|
|
var aidls android.Paths
|
|
|
|
for _, jars := range stubsJars {
|
|
|
|
for _, jar := range jars {
|
|
|
|
aidl := android.PathForOutput(ctx, "aidl", pathtools.ReplaceExtension(jar.Base(), "aidl"))
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("rm -f").Output(aidl)
|
|
|
|
rule.Command().
|
2019-07-09 08:08:34 +08:00
|
|
|
BuiltTool(ctx, "sdkparcelables").
|
2019-04-19 01:56:44 +08:00
|
|
|
Input(jar).
|
|
|
|
Output(aidl)
|
|
|
|
|
|
|
|
aidls = append(aidls, aidl)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rule.Command().
|
2020-04-09 20:29:59 +08:00
|
|
|
Text("rm -f").Output(path)
|
2019-04-19 01:56:44 +08:00
|
|
|
rule.Command().
|
|
|
|
Text("cat").
|
|
|
|
Inputs(aidls).
|
|
|
|
Text("| sort -u >").
|
2020-04-09 20:29:59 +08:00
|
|
|
Output(path)
|
2019-04-19 01:56:44 +08:00
|
|
|
|
2020-04-09 20:29:59 +08:00
|
|
|
return rule
|
2019-04-19 01:56:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath {
|
|
|
|
return ctx.Config().Once(sdkFrameworkAidlPathKey, func() interface{} {
|
|
|
|
return android.PathForOutput(ctx, "framework.aidl")
|
|
|
|
}).(android.OutputPath)
|
|
|
|
}
|
|
|
|
|
2020-04-09 20:29:59 +08:00
|
|
|
func nonUpdatableFrameworkAidlPath(ctx android.PathContext) android.OutputPath {
|
|
|
|
return ctx.Config().Once(nonUpdatableFrameworkAidlPathKey, func() interface{} {
|
|
|
|
return android.PathForOutput(ctx, "framework_non_updatable.aidl")
|
|
|
|
}).(android.OutputPath)
|
|
|
|
}
|
|
|
|
|
2019-04-19 05:27:12 +08:00
|
|
|
// Create api_fingerprint.txt
|
|
|
|
func createAPIFingerprint(ctx android.SingletonContext) {
|
2019-04-18 16:25:49 +08:00
|
|
|
out := ApiFingerprintPath(ctx)
|
2019-04-19 05:27:12 +08:00
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("rm -f").Output(out)
|
|
|
|
cmd := rule.Command()
|
|
|
|
|
|
|
|
if ctx.Config().PlatformSdkCodename() == "REL" {
|
|
|
|
cmd.Text("echo REL >").Output(out)
|
|
|
|
} else if ctx.Config().IsPdkBuild() {
|
|
|
|
// TODO: get this from the PDK artifacts?
|
|
|
|
cmd.Text("echo PDK >").Output(out)
|
|
|
|
} else if !ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
|
|
|
in, err := ctx.GlobWithDeps("frameworks/base/api/*current.txt", nil)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Errorf("error globbing API files: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.Text("cat").
|
|
|
|
Inputs(android.PathsForSource(ctx, in)).
|
2019-09-07 05:42:24 +08:00
|
|
|
Text("| md5sum | cut -d' ' -f1 >").
|
2019-04-19 05:27:12 +08:00
|
|
|
Output(out)
|
|
|
|
} else {
|
|
|
|
// Unbundled build
|
|
|
|
// TODO: use a prebuilt api_fingerprint.txt from prebuilts/sdk/current.txt once we have one
|
|
|
|
cmd.Text("echo").
|
|
|
|
Flag(ctx.Config().PlatformPreviewSdkVersion()).
|
|
|
|
Text(">").
|
|
|
|
Output(out)
|
|
|
|
}
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "api_fingerprint", "generate api_fingerprint.txt")
|
|
|
|
}
|
|
|
|
|
2019-04-18 16:25:49 +08:00
|
|
|
func ApiFingerprintPath(ctx android.PathContext) android.OutputPath {
|
2019-04-19 05:27:12 +08:00
|
|
|
return ctx.Config().Once(apiFingerprintPathKey, func() interface{} {
|
|
|
|
return android.PathForOutput(ctx, "api_fingerprint.txt")
|
|
|
|
}).(android.OutputPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func sdkMakeVars(ctx android.MakeVarsContext) {
|
|
|
|
if ctx.Config().UnbundledBuildUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
|
2019-04-19 01:56:44 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
|
2019-04-18 16:25:49 +08:00
|
|
|
ctx.Strict("API_FINGERPRINT", ApiFingerprintPath(ctx).String())
|
2019-01-10 15:04:25 +08:00
|
|
|
}
|