Merge "Move java.sdkSpec to the android package" am: d4fa8fc107 am: 7ff95eca2f am: f19d2d57b3

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1655587

Change-Id: I5c5d25a78c4f51876289dc450874d83c5a9c90b6
This commit is contained in:
Jiyong Park 2021-04-03 13:16:03 +00:00 committed by Automerger Merge Worker
commit 7f61ac4c8b
18 changed files with 515 additions and 486 deletions

View file

@ -67,6 +67,7 @@ bootstrap_go_package {
"rule_builder.go",
"sandbox.go",
"sdk.go",
"sdk_version.go",
"singleton.go",
"singleton_module.go",
"soong_config_modules.go",

View file

@ -31,9 +31,9 @@ const previewAPILevelBase = 9000
// ApiLevelFromUser or ApiLevelOrPanic.
//
// The different *types* of API levels are handled separately. Currently only
// Java has these, and they're managed with the sdkKind enum of the sdkSpec. A
// future cleanup should be to migrate sdkSpec to using ApiLevel instead of its
// sdkVersion int, and to move sdkSpec into this package.
// Java has these, and they're managed with the SdkKind enum of the SdkSpec. A
// future cleanup should be to migrate SdkSpec to using ApiLevel instead of its
// SdkVersion int, and to move SdkSpec into this package.
type ApiLevel struct {
// The string representation of the API level.
value string

311
android/sdk_version.go Normal file
View file

@ -0,0 +1,311 @@
// Copyright 2021 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 android
import (
"fmt"
"strconv"
"strings"
)
type SdkContext interface {
// SdkVersion returns SdkSpec that corresponds to the sdk_version property of the current module
SdkVersion() SdkSpec
// SystemModules returns the system_modules property of the current module, or an empty string if it is not set.
SystemModules() string
// 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
}
// 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
SdkModule
SdkSystemServer
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"
case SdkModule:
return "module-lib"
case SdkSystemServer:
return "system-server"
default:
return "invalid"
}
}
// 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(FutureApiLevelInt)
// 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))
}
return "(no version)"
}
func (v SdkVersion) ApiLevel(ctx EarlyModuleContext) ApiLevel {
return ApiLevelOrPanic(ctx, v.String())
}
// 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
}
func (s SdkSpec) String() string {
return fmt.Sprintf("%s_%s", s.Kind, s.Version)
}
// 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
}
// 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 {
case SdkNone:
// there is nothing to manage and version in this case; de facto stable API.
return true
case SdkCore, SdkPublic, SdkSystem, SdkModule, SdkSystemServer:
return true
case SdkCorePlatform, SdkTest, SdkPrivate:
return false
default:
panic(fmt.Errorf("unknown SdkKind=%v", s.Kind))
}
return false
}
// 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
}
func (s SdkSpec) ForVendorPartition(ctx 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 EarlyModuleContext) bool {
if s.Version.IsCurrent() {
// "current" can be built from source and be from prebuilt SDK
return ctx.Config().AlwaysUsePrebuiltSdks()
} else if s.Version.IsNumbered() {
// validation check
if s.Kind != SdkPublic && s.Kind != SdkSystem && s.Kind != SdkTest && s.Kind != SdkModule {
panic(fmt.Errorf("prebuilt SDK is not not available for SdkKind=%q", s.Kind))
return false
}
// numbered SDKs are always from prebuilt
return true
}
// "", "none", "core_platform" fall here
return false
}
// 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 FutureApiLevel(10000).
func (s SdkSpec) EffectiveVersion(ctx EarlyModuleContext) (SdkVersion, error) {
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
}
return SdkVersion(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt()), nil
}
// 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 EarlyModuleContext) (string, error) {
ver, err := s.EffectiveVersion(ctx)
if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt() {
return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
}
return ver.String(), err
}
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 = ""
} else {
kindString = str[0:sep]
}
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
case "module":
kind = SdkModule
case "system_server":
kind = SdkSystemServer
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}
}
}
func (s SdkSpec) ValidateSystemSdk(ctx 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 && !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
}

View file

@ -950,6 +950,10 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
if v := m.MinSdkVersion(); v != "" {
toMinSdkVersion = v
}
} else if m, ok := to.(interface{ MinSdkVersionString() string }); ok {
if v := m.MinSdkVersionString(); v != "" {
toMinSdkVersion = v
}
}
depInfos[to.Name()] = android.ApexModuleDepInfo{

View file

@ -163,7 +163,7 @@ func (a *aapt) IsRROEnforced(ctx android.BaseModuleContext) bool {
a.aaptProperties.RROEnforcedForDependent
}
func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext,
func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkContext,
manifestPath android.Path) (compileFlags, linkFlags []string, linkDeps android.Paths,
resDirs, overlayDirs []globbedResourceDir, rroDirs []rroDir, resZips android.Paths) {
@ -218,7 +218,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext,
linkDeps = append(linkDeps, assetDeps...)
// SDK version flags
minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersionString(ctx)
minSdkVersion, err := sdkContext.MinSdkVersion().EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
@ -266,7 +266,7 @@ var extractAssetsRule = pctx.AndroidStaticRule("extractAssets",
CommandDeps: []string{"${config.Zip2ZipCmd}"},
})
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext,
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkContext,
classLoaderContexts dexpreopt.ClassLoaderContextMap, extraLinkFlags ...string) {
transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assetPackages, libDeps, libFlags :=
@ -397,7 +397,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext,
}
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) (
func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) (
transitiveStaticLibs, transitiveStaticLibManifests android.Paths, staticRRODirs []rroDir, assets, deps android.Paths, flags []string) {
var sharedLibs android.Paths
@ -498,7 +498,7 @@ var _ AndroidLibraryDependency = (*AndroidLibrary)(nil)
func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
a.Module.deps(ctx)
sdkDep := decodeSdkDep(ctx, sdkContext(a))
sdkDep := decodeSdkDep(ctx, android.SdkContext(a))
if sdkDep.hasFrameworkLibs() {
a.aapt.deps(ctx, sdkDep)
}
@ -507,7 +507,7 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.aapt.isLibrary = true
a.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
a.aapt.buildActions(ctx, sdkContext(a), a.classLoaderContexts)
a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts)
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
@ -625,23 +625,23 @@ func (a *AARImport) OutputFiles(tag string) (android.Paths, error) {
}
}
func (a *AARImport) sdkVersion() sdkSpec {
return sdkSpecFrom(String(a.properties.Sdk_version))
func (a *AARImport) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom(String(a.properties.Sdk_version))
}
func (a *AARImport) systemModules() string {
func (a *AARImport) SystemModules() string {
return ""
}
func (a *AARImport) minSdkVersion() sdkSpec {
func (a *AARImport) MinSdkVersion() android.SdkSpec {
if a.properties.Min_sdk_version != nil {
return sdkSpecFrom(*a.properties.Min_sdk_version)
return android.SdkSpecFrom(*a.properties.Min_sdk_version)
}
return a.sdkVersion()
return a.SdkVersion()
}
func (a *AARImport) targetSdkVersion() sdkSpec {
return a.sdkVersion()
func (a *AARImport) TargetSdkVersion() android.SdkSpec {
return a.SdkVersion()
}
func (a *AARImport) javaVersion() string {
@ -700,7 +700,7 @@ func (a *AARImport) JacocoReportClassesFile() android.Path {
func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
if !ctx.Config().AlwaysUsePrebuiltSdks() {
sdkDep := decodeSdkDep(ctx, sdkContext(a))
sdkDep := decodeSdkDep(ctx, android.SdkContext(a))
if sdkDep.useModule && sdkDep.frameworkResModule != "" {
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
}
@ -780,7 +780,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
linkDeps = append(linkDeps, a.manifest)
transitiveStaticLibs, staticLibManifests, staticRRODirs, transitiveAssets, libDeps, libFlags :=
aaptLibs(ctx, sdkContext(a), nil)
aaptLibs(ctx, android.SdkContext(a), nil)
_ = staticLibManifests
_ = staticRRODirs

View file

@ -43,7 +43,7 @@ var manifestMergerRule = pctx.AndroidStaticRule("manifestMerger",
"args", "libs")
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext,
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext android.SdkContext,
classLoaderContexts dexpreopt.ClassLoaderContextMap, isLibrary, useEmbeddedNativeLibs, usesNonSdkApis,
useEmbeddedDex, hasNoCode bool, loggingParent string) android.Path {
@ -51,7 +51,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
if isLibrary {
args = append(args, "--library")
} else {
minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersion(ctx)
minSdkVersion, err := sdkContext.MinSdkVersion().EffectiveVersion(ctx)
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}
@ -87,7 +87,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
args = append(args, "--logging-parent", loggingParent)
}
var deps android.Paths
targetSdkVersion, err := sdkContext.targetSdkVersion().effectiveVersionString(ctx)
targetSdkVersion, err := sdkContext.TargetSdkVersion().EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
}
@ -96,7 +96,7 @@ func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext
deps = append(deps, ApiFingerprintPath(ctx))
}
minSdkVersion, err := sdkContext.minSdkVersion().effectiveVersionString(ctx)
minSdkVersion, err := sdkContext.MinSdkVersion().EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid minSdkVersion: %s", err)
}

View file

@ -106,7 +106,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
if len(library.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
}
entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion().raw)
entries.SetString("LOCAL_SDK_VERSION", library.SdkVersion().Raw)
entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
@ -255,7 +255,7 @@ func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
entries.SetString("LOCAL_SDK_VERSION", prebuilt.SdkVersion().Raw)
},
},
}}

View file

@ -213,16 +213,16 @@ func (c Certificate) AndroidMkString() string {
func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
a.Module.deps(ctx)
if String(a.appProperties.Stl) == "c++_shared" && !a.sdkVersion().specified() {
if String(a.appProperties.Stl) == "c++_shared" && !a.SdkVersion().Specified() {
ctx.PropertyErrorf("stl", "sdk_version must be set in order to use c++_shared")
}
sdkDep := decodeSdkDep(ctx, sdkContext(a))
sdkDep := decodeSdkDep(ctx, android.SdkContext(a))
if sdkDep.hasFrameworkLibs() {
a.aapt.deps(ctx, sdkDep)
}
usesSDK := a.sdkVersion().specified() && a.sdkVersion().kind != sdkCorePlatform
usesSDK := a.SdkVersion().Specified() && a.SdkVersion().Kind != android.SdkCorePlatform
if usesSDK && Bool(a.appProperties.Jni_uses_sdk_apis) {
ctx.PropertyErrorf("jni_uses_sdk_apis",
@ -279,14 +279,14 @@ func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
if a.Updatable() {
if !a.sdkVersion().stable() {
ctx.PropertyErrorf("sdk_version", "Updatable apps must use stable SDKs, found %v", a.sdkVersion())
if !a.SdkVersion().Stable() {
ctx.PropertyErrorf("sdk_version", "Updatable apps must use stable SDKs, found %v", a.SdkVersion())
}
if String(a.deviceProperties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable apps must set min_sdk_version.")
}
if minSdkVersion, err := a.minSdkVersion().effectiveVersion(ctx); err == nil {
if minSdkVersion, err := a.MinSdkVersion().EffectiveVersion(ctx); err == nil {
a.checkJniLibsSdkVersion(ctx, minSdkVersion)
android.CheckMinSdkVersion(a, ctx, minSdkVersion.ApiLevel(ctx))
} else {
@ -304,7 +304,7 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
// because, sdk_version is overridden by min_sdk_version (if set as smaller)
// and sdkLinkType is checked with dependencies so we can be sure that the whole dependency tree
// will meet the requirements.
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion sdkVersion) {
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.SdkVersion) {
// It's enough to check direct JNI deps' sdk_version because all transitive deps from JNI deps are checked in cc.checkLinkType()
ctx.VisitDirectDeps(func(m android.Module) {
if !IsJniDepTag(ctx.OtherModuleDependencyTag(m)) {
@ -312,9 +312,9 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer
}
dep, _ := m.(*cc.Module)
// The domain of cc.sdk_version is "current" and <number>
// We can rely on sdkSpec to convert it to <number> so that "current" is handled
// properly regardless of sdk finalization.
jniSdkVersion, err := sdkSpecFrom(dep.SdkVersion()).effectiveVersion(ctx)
// We can rely on android.SdkSpec to convert it to <number> so that "current" is
// handled properly regardless of sdk finalization.
jniSdkVersion, err := android.SdkSpecFrom(dep.SdkVersion()).EffectiveVersion(ctx)
if err != nil || minSdkVersion < jniSdkVersion {
ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)",
dep.SdkVersion(), minSdkVersion, ctx.ModuleName())
@ -327,9 +327,9 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer
// Returns true if the native libraries should be stored in the APK uncompressed and the
// extractNativeLibs application flag should be set to false in the manifest.
func (a *AndroidApp) useEmbeddedNativeLibs(ctx android.ModuleContext) bool {
minSdkVersion, err := a.minSdkVersion().effectiveVersion(ctx)
minSdkVersion, err := a.MinSdkVersion().EffectiveVersion(ctx)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.minSdkVersion(), err)
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.MinSdkVersion(), err)
}
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
@ -419,7 +419,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
a.aapt.splitNames = a.appProperties.Package_splits
a.aapt.LoggingParent = String(a.overridableAppProperties.Logging_parent)
a.aapt.buildActions(ctx, sdkContext(a), a.classLoaderContexts, aaptLinkFlags...)
a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts, aaptLinkFlags...)
// apps manifests are handled by aapt, don't let Module see them
a.properties.Manifest = nil
@ -720,8 +720,8 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
type appDepsInterface interface {
sdkVersion() sdkSpec
minSdkVersion() sdkSpec
SdkVersion() android.SdkSpec
MinSdkVersion() android.SdkSpec
RequiresStableAPIs(ctx android.BaseModuleContext) bool
}
@ -734,8 +734,8 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface,
seenModulePaths := make(map[string]bool)
if checkNativeSdkVersion {
checkNativeSdkVersion = app.sdkVersion().specified() &&
app.sdkVersion().kind != sdkCorePlatform && !app.RequiresStableAPIs(ctx)
checkNativeSdkVersion = app.SdkVersion().Specified() &&
app.SdkVersion().Kind != android.SdkCorePlatform && !app.RequiresStableAPIs(ctx)
}
ctx.WalkDeps(func(module android.Module, parent android.Module) bool {
@ -829,6 +829,10 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) {
if v := m.MinSdkVersion(); v != "" {
toMinSdkVersion = v
}
} else if m, ok := to.(interface{ MinSdkVersionString() string }); ok {
if v := m.MinSdkVersionString(); v != "" {
toMinSdkVersion = v
}
}
depsInfo[depName] = android.ApexModuleDepInfo{
To: depName,
@ -840,7 +844,7 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) {
return true
})
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(), depsInfo)
a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersionString(), depsInfo)
}
func (a *AndroidApp) Updatable() bool {

View file

@ -394,12 +394,12 @@ func (a *AndroidAppImport) DepIsInSameApex(_ android.BaseModuleContext, _ androi
return false
}
func (a *AndroidAppImport) sdkVersion() sdkSpec {
return sdkSpecFrom("")
func (a *AndroidAppImport) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom("")
}
func (a *AndroidAppImport) minSdkVersion() sdkSpec {
return sdkSpecFrom("")
func (a *AndroidAppImport) MinSdkVersion() android.SdkSpec {
return android.SdkSpecFrom("")
}
var _ android.ApexModule = (*AndroidAppImport)(nil)

View file

@ -373,11 +373,11 @@ type Module struct {
}
func (j *Module) CheckStableSdkVersion() error {
sdkVersion := j.sdkVersion()
if sdkVersion.stable() {
sdkVersion := j.SdkVersion()
if sdkVersion.Stable() {
return nil
}
if sdkVersion.kind == sdkCorePlatform {
if sdkVersion.Kind == android.SdkCorePlatform {
if useLegacyCorePlatformApiByName(j.BaseModuleName()) {
return fmt.Errorf("non stable SDK %v - uses legacy core platform", sdkVersion)
} else {
@ -392,8 +392,8 @@ func (j *Module) CheckStableSdkVersion() error {
// checkSdkVersions enforces restrictions around SDK dependencies.
func (j *Module) checkSdkVersions(ctx android.ModuleContext) {
if j.RequiresStableAPIs(ctx) {
if sc, ok := ctx.Module().(sdkContext); ok {
if !sc.sdkVersion().specified() {
if sc, ok := ctx.Module().(android.SdkContext); ok {
if !sc.SdkVersion().Specified() {
ctx.PropertyErrorf("sdk_version",
"sdk_version must have a value when the module is located at vendor or product(only if PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is set).")
}
@ -416,9 +416,9 @@ func (j *Module) checkSdkVersions(ctx android.ModuleContext) {
}
func (j *Module) checkPlatformAPI(ctx android.ModuleContext) {
if sc, ok := ctx.Module().(sdkContext); ok {
if sc, ok := ctx.Module().(android.SdkContext); ok {
usePlatformAPI := proptools.Bool(j.deviceProperties.Platform_apis)
sdkVersionSpecified := sc.sdkVersion().specified()
sdkVersionSpecified := sc.SdkVersion().Specified()
if usePlatformAPI && sdkVersionSpecified {
ctx.PropertyErrorf("platform_apis", "platform_apis must be false when sdk_version is not empty.")
} else if !usePlatformAPI && !sdkVersionSpecified {
@ -512,30 +512,30 @@ func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool {
return false
}
func (j *Module) sdkVersion() sdkSpec {
return sdkSpecFrom(String(j.deviceProperties.Sdk_version))
func (j *Module) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom(String(j.deviceProperties.Sdk_version))
}
func (j *Module) systemModules() string {
func (j *Module) SystemModules() string {
return proptools.String(j.deviceProperties.System_modules)
}
func (j *Module) minSdkVersion() sdkSpec {
func (j *Module) MinSdkVersion() android.SdkSpec {
if j.deviceProperties.Min_sdk_version != nil {
return sdkSpecFrom(*j.deviceProperties.Min_sdk_version)
return android.SdkSpecFrom(*j.deviceProperties.Min_sdk_version)
}
return j.sdkVersion()
return j.SdkVersion()
}
func (j *Module) targetSdkVersion() sdkSpec {
func (j *Module) TargetSdkVersion() android.SdkSpec {
if j.deviceProperties.Target_sdk_version != nil {
return sdkSpecFrom(*j.deviceProperties.Target_sdk_version)
return android.SdkSpecFrom(*j.deviceProperties.Target_sdk_version)
}
return j.sdkVersion()
return j.SdkVersion()
}
func (j *Module) MinSdkVersion() string {
return j.minSdkVersion().version.String()
func (j *Module) MinSdkVersionString() string {
return j.MinSdkVersion().Version.String()
}
func (j *Module) AvailableFor(what string) bool {
@ -552,7 +552,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
j.linter.deps(ctx)
sdkDeps(ctx, sdkContext(j), j.dexer)
sdkDeps(ctx, android.SdkContext(j), j.dexer)
if j.deviceProperties.SyspropPublicStub != "" {
// This is a sysprop implementation library that has a corresponding sysprop public
@ -702,7 +702,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
var flags javaBuilderFlags
// javaVersion flag.
flags.javaVersion = getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
flags.javaVersion = getJavaVersion(ctx, String(j.properties.Java_version), android.SdkContext(j))
if ctx.Config().RunErrorProne() {
if config.ErrorProneClasspath == nil && ctx.Config().TestProductVariables == nil {
@ -731,7 +731,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.processors = android.FirstUniqueStrings(flags.processors)
if len(flags.bootClasspath) == 0 && ctx.Host() && !flags.javaVersion.usesJavaModules() &&
decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() {
decodeSdkDep(ctx, android.SdkContext(j)).hasStandardLibs() {
// Give host-side tools a version of OpenJDK's standard libraries
// close to what they're targeting. As of Dec 2017, AOSP is only
// bundling OpenJDK 8 and 9, so nothing < 8 is available.
@ -1209,7 +1209,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
// Dex compilation
var dexOutputFile android.OutputPath
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(), outputFile, jarName)
if ctx.Failed() {
return
}
@ -1254,8 +1254,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
if ctx.Device() {
lintSDKVersionString := func(sdkSpec sdkSpec) string {
if v := sdkSpec.version; v.isNumbered() {
lintSDKVersionString := func(sdkSpec android.SdkSpec) string {
if v := sdkSpec.Version; v.IsNumbered() {
return v.String()
} else {
return ctx.Config().DefaultAppTargetSdk(ctx).String()
@ -1267,9 +1267,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.linter.srcJars = srcJars
j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...)
j.linter.classes = j.implementationJarFile
j.linter.minSdkVersion = lintSDKVersionString(j.minSdkVersion())
j.linter.targetSdkVersion = lintSDKVersionString(j.targetSdkVersion())
j.linter.compileSdkVersion = lintSDKVersionString(j.sdkVersion())
j.linter.minSdkVersion = lintSDKVersionString(j.MinSdkVersion())
j.linter.targetSdkVersion = lintSDKVersionString(j.TargetSdkVersion())
j.linter.compileSdkVersion = lintSDKVersionString(j.SdkVersion())
j.linter.javaLanguageLevel = flags.javaVersion.String()
j.linter.kotlinLanguageLevel = "1.3"
if !apexInfo.IsForPlatform() && ctx.Config().UnbundledBuildApps() {
@ -1471,14 +1471,14 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
// Implements android.ApexModule
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
sdkVersion android.ApiLevel) error {
sdkSpec := j.minSdkVersion()
if !sdkSpec.specified() {
sdkSpec := j.MinSdkVersion()
if !sdkSpec.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
if sdkSpec.kind == sdkCore {
if sdkSpec.Kind == android.SdkCore {
return nil
}
ver, err := sdkSpec.effectiveVersion(ctx)
ver, err := sdkSpec.EffectiveVersion(ctx)
if err != nil {
return err
}
@ -1576,24 +1576,24 @@ func (m *Module) getSdkLinkType(name string) (ret sdkLinkType, stubs bool) {
return linkType, true
}
ver := m.sdkVersion()
switch ver.kind {
case sdkCore:
ver := m.SdkVersion()
switch ver.Kind {
case android.SdkCore:
return javaCore, false
case sdkSystem:
case android.SdkSystem:
return javaSystem, false
case sdkPublic:
case android.SdkPublic:
return javaSdk, false
case sdkModule:
case android.SdkModule:
return javaModule, false
case sdkSystemServer:
case android.SdkSystemServer:
return javaSystemServer, false
case sdkPrivate, sdkNone, sdkCorePlatform, sdkTest:
case android.SdkPrivate, android.SdkNone, android.SdkCorePlatform, android.SdkTest:
return javaPlatform, false
}
if !ver.valid() {
panic(fmt.Errorf("sdk_version is invalid. got %q", ver.raw))
if !ver.Valid() {
panic(fmt.Errorf("sdk_version is invalid. got %q", ver.Raw))
}
return javaSdk, false
}
@ -1625,7 +1625,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
var deps deps
if ctx.Device() {
sdkDep := decodeSdkDep(ctx, sdkContext(j))
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
if sdkDep.invalidVersion {
ctx.AddMissingDependencies(sdkDep.bootclasspath)
ctx.AddMissingDependencies(sdkDep.java9Classpath)
@ -1656,7 +1656,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
if dep, ok := module.(SdkLibraryDependency); ok {
switch tag {
case libTag:
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion())...)
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}

View file

@ -157,7 +157,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
}, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir",
"r8Flags", "zipFlags"}, []string{"implicits"})
func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion sdkSpec) []string {
func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) []string {
flags := d.dexProperties.Dxflags
// Translate all the DX flags to D8 ones until all the build files have been migrated
// to D8 flags. See: b/69377755
@ -174,12 +174,12 @@ func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion sdkSpec)
"--verbose")
}
effectiveVersion, err := minSdkVersion.effectiveVersion(ctx)
effectiveVersion, err := minSdkVersion.EffectiveVersion(ctx)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "%s", err)
}
flags = append(flags, "--min-api "+effectiveVersion.asNumberString())
flags = append(flags, "--min-api "+effectiveVersion.AsNumberString())
return flags
}
@ -266,7 +266,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
return r8Flags, r8Deps
}
func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, minSdkVersion sdkSpec,
func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, minSdkVersion android.SdkSpec,
classesJar android.Path, jarName string) android.OutputPath {
// Compile classes.jar into classes.dex and then javalib.jar

View file

@ -265,25 +265,25 @@ func JavadocHostFactory() android.Module {
var _ android.OutputFileProducer = (*Javadoc)(nil)
func (j *Javadoc) sdkVersion() sdkSpec {
return sdkSpecFrom(String(j.properties.Sdk_version))
func (j *Javadoc) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom(String(j.properties.Sdk_version))
}
func (j *Javadoc) systemModules() string {
func (j *Javadoc) SystemModules() string {
return proptools.String(j.properties.System_modules)
}
func (j *Javadoc) minSdkVersion() sdkSpec {
return j.sdkVersion()
func (j *Javadoc) MinSdkVersion() android.SdkSpec {
return j.SdkVersion()
}
func (j *Javadoc) targetSdkVersion() sdkSpec {
return j.sdkVersion()
func (j *Javadoc) TargetSdkVersion() android.SdkSpec {
return j.SdkVersion()
}
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
sdkDep := decodeSdkDep(ctx, sdkContext(j))
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
if sdkDep.useModule {
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
@ -361,7 +361,7 @@ func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
var deps deps
sdkDep := decodeSdkDep(ctx, sdkContext(j))
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
if sdkDep.invalidVersion {
ctx.AddMissingDependencies(sdkDep.bootclasspath)
ctx.AddMissingDependencies(sdkDep.java9Classpath)
@ -390,7 +390,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
}
case libTag:
if dep, ok := module.(SdkLibraryDependency); ok {
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion())...)
} else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
deps.classpath = append(deps.classpath, dep.HeaderJars...)
@ -555,7 +555,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, j.srcJars)
javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), android.SdkContext(j))
cmd := javadocSystemModulesCmd(ctx, rule, j.srcFiles, outDir, srcJarDir, srcJarList,
deps.systemModules, deps.classpath, j.sourcepaths)

View file

@ -474,7 +474,7 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
deps := d.Javadoc.collectDeps(ctx)
javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), sdkContext(d))
javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), android.SdkContext(d))
// Create rule for metalava

View file

@ -304,7 +304,7 @@ type jniLib struct {
unstrippedFile android.Path
}
func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext sdkContext, d dexer) {
func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext android.SdkContext, d dexer) {
sdkDep := decodeSdkDep(ctx, sdkContext)
if sdkDep.useModule {
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
@ -352,11 +352,11 @@ func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer
}
}
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) javaVersion {
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext android.SdkContext) javaVersion {
if javaVersion != "" {
return normalizeJavaVersion(ctx, javaVersion)
} else if ctx.Device() {
return sdkContext.sdkVersion().defaultJavaLanguageVersion(ctx)
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion())
} else {
return JAVA_VERSION_9
}
@ -1132,31 +1132,31 @@ type Import struct {
hideApexVariantFromMake bool
}
func (j *Import) sdkVersion() sdkSpec {
return sdkSpecFrom(String(j.properties.Sdk_version))
func (j *Import) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom(String(j.properties.Sdk_version))
}
func (j *Import) makeSdkVersion() string {
return j.sdkVersion().raw
return j.SdkVersion().Raw
}
func (j *Import) systemModules() string {
func (j *Import) SystemModules() string {
return "none"
}
func (j *Import) minSdkVersion() sdkSpec {
func (j *Import) MinSdkVersion() android.SdkSpec {
if j.properties.Min_sdk_version != nil {
return sdkSpecFrom(*j.properties.Min_sdk_version)
return android.SdkSpecFrom(*j.properties.Min_sdk_version)
}
return j.sdkVersion()
return j.SdkVersion()
}
func (j *Import) targetSdkVersion() sdkSpec {
return j.sdkVersion()
func (j *Import) TargetSdkVersion() android.SdkSpec {
return j.SdkVersion()
}
func (j *Import) MinSdkVersion() string {
return j.minSdkVersion().version.String()
func (j *Import) MinSdkVersionString() string {
return j.MinSdkVersion().Version.String()
}
func (j *Import) Prebuilt() *android.Prebuilt {
@ -1187,7 +1187,7 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
if ctx.Device() && Bool(j.dexProperties.Compile_dex) {
sdkDeps(ctx, sdkContext(j), j.dexer)
sdkDeps(ctx, android.SdkContext(j), j.dexer)
}
}
@ -1230,7 +1230,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} else if dep, ok := module.(SdkLibraryDependency); ok {
switch tag {
case libTag:
flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion())...)
}
}
@ -1272,7 +1272,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt_apex %q", deapexerModule.Name())
}
} else if Bool(j.dexProperties.Compile_dex) {
sdkDep := decodeSdkDep(ctx, sdkContext(j))
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
if sdkDep.invalidVersion {
ctx.AddMissingDependencies(sdkDep.bootclasspath)
ctx.AddMissingDependencies(sdkDep.java9Classpath)
@ -1291,7 +1291,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
var dexOutputFile android.OutputPath
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(), outputFile, jarName)
if ctx.Failed() {
return
}
@ -1359,14 +1359,14 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
// Implements android.ApexModule
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
sdkVersion android.ApiLevel) error {
sdkSpec := j.minSdkVersion()
if !sdkSpec.specified() {
sdkSpec := j.MinSdkVersion()
if !sdkSpec.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
if sdkSpec.kind == sdkCore {
if sdkSpec.Kind == android.SdkCore {
return nil
}
ver, err := sdkSpec.effectiveVersion(ctx)
ver, err := sdkSpec.EffectiveVersion(ctx)
if err != nil {
return err
}

View file

@ -91,7 +91,7 @@ type RuntimeResourceOverlayModule interface {
}
func (r *RuntimeResourceOverlay) DepsMutator(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, sdkContext(r))
sdkDep := decodeSdkDep(ctx, android.SdkContext(r))
if sdkDep.hasFrameworkLibs() {
r.aapt.deps(ctx, sdkDep)
}
@ -141,23 +141,23 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC
ctx.InstallFile(r.installDir, r.outputFile.Base(), r.outputFile)
}
func (r *RuntimeResourceOverlay) sdkVersion() sdkSpec {
return sdkSpecFrom(String(r.properties.Sdk_version))
func (r *RuntimeResourceOverlay) SdkVersion() android.SdkSpec {
return android.SdkSpecFrom(String(r.properties.Sdk_version))
}
func (r *RuntimeResourceOverlay) systemModules() string {
func (r *RuntimeResourceOverlay) SystemModules() string {
return ""
}
func (r *RuntimeResourceOverlay) minSdkVersion() sdkSpec {
func (r *RuntimeResourceOverlay) MinSdkVersion() android.SdkSpec {
if r.properties.Min_sdk_version != nil {
return sdkSpecFrom(*r.properties.Min_sdk_version)
return android.SdkSpecFrom(*r.properties.Min_sdk_version)
}
return r.sdkVersion()
return r.SdkVersion()
}
func (r *RuntimeResourceOverlay) targetSdkVersion() sdkSpec {
return r.sdkVersion()
func (r *RuntimeResourceOverlay) TargetSdkVersion() android.SdkSpec {
return r.SdkVersion()
}
func (r *RuntimeResourceOverlay) Certificate() Certificate {

View file

@ -19,7 +19,6 @@ import (
"path/filepath"
"sort"
"strconv"
"strings"
"android/soong/android"
"android/soong/java/config"
@ -38,19 +37,6 @@ var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
type sdkContext interface {
// sdkVersion returns sdkSpec that corresponds to the sdk_version property of the current module
sdkVersion() sdkSpec
// systemModules returns the system_modules property of the current module, or an empty string if it is not set.
systemModules() string
// 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
}
func UseApiFingerprint(ctx android.BaseModuleContext) bool {
if ctx.Config().UnbundledBuild() &&
!ctx.Config().AlwaysUsePrebuiltSdks() &&
@ -60,209 +46,8 @@ func UseApiFingerprint(ctx android.BaseModuleContext) bool {
return false
}
// 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
sdkModule
sdkSystemServer
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"
case sdkModule:
return "module-lib"
case sdkSystemServer:
return "system-server"
default:
return "invalid"
}
}
// 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.FutureApiLevelInt)
// 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))
}
return "(no version)"
}
func (v sdkVersion) ApiLevel(ctx android.EarlyModuleContext) android.ApiLevel {
return android.ApiLevelOrPanic(ctx, v.String())
}
// 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
}
func (s sdkSpec) String() string {
return fmt.Sprintf("%s_%s", s.kind, s.version)
}
// 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
}
// 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 {
case sdkNone:
// there is nothing to manage and version in this case; de facto stable API.
return true
case sdkCore, sdkPublic, sdkSystem, sdkModule, sdkSystemServer:
return true
case sdkCorePlatform, sdkTest, sdkPrivate:
return false
default:
panic(fmt.Errorf("unknown sdkKind=%v", s.kind))
}
return false
}
// 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
}
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() {
// "current" can be built from source and be from prebuilt SDK
return ctx.Config().AlwaysUsePrebuiltSdks()
} else if s.version.isNumbered() {
// validation check
if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest && s.kind != sdkModule {
panic(fmt.Errorf("prebuilt SDK is not not available for sdkKind=%q", s.kind))
return false
}
// numbered SDKs are always from prebuilt
return true
}
// "", "none", "core_platform" fall here
return false
}
// 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.DeviceSpecific() || ctx.SocSpecific() {
s = s.forVendorPartition(ctx)
}
if s.version.isNumbered() {
return s.version, nil
}
return sdkVersion(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt()), nil
}
// 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().DefaultAppTargetSdk(ctx).FinalOrFutureInt() {
return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
}
return ver.String(), err
}
func (s sdkSpec) defaultJavaLanguageVersion(ctx android.EarlyModuleContext) javaVersion {
sdk, err := s.effectiveVersion(ctx)
func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpec) javaVersion {
sdk, err := s.EffectiveVersion(ctx)
if err != nil {
ctx.PropertyErrorf("sdk_version", "%s", err)
}
@ -275,103 +60,27 @@ func (s sdkSpec) defaultJavaLanguageVersion(ctx android.EarlyModuleContext) java
}
}
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 = ""
} else {
kindString = str[0:sep]
}
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
case "module":
kind = sdkModule
case "system_server":
kind = sdkSystemServer
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}
}
}
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
}
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep {
sdkVersion := sdkContext.sdkVersion()
if !sdkVersion.valid() {
ctx.PropertyErrorf("sdk_version", "invalid version %q", sdkVersion.raw)
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) sdkDep {
sdkVersion := sdkContext.SdkVersion()
if !sdkVersion.Valid() {
ctx.PropertyErrorf("sdk_version", "invalid version %q", sdkVersion.Raw)
return sdkDep{}
}
if ctx.DeviceSpecific() || ctx.SocSpecific() {
sdkVersion = sdkVersion.forVendorPartition(ctx)
sdkVersion = sdkVersion.ForVendorPartition(ctx)
}
if !sdkVersion.validateSystemSdk(ctx) {
if !sdkVersion.ValidateSystemSdk(ctx) {
return sdkDep{}
}
if sdkVersion.usePrebuilt(ctx) {
dir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), sdkVersion.kind.String())
if sdkVersion.UsePrebuilt(ctx) {
dir := filepath.Join("prebuilts", "sdk", sdkVersion.Version.String(), sdkVersion.Kind.String())
jar := filepath.Join(dir, "android.jar")
// There's no aidl for other SDKs yet.
// TODO(77525052): Add aidl files for other SDKs too.
publicDir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), "public")
publicDir := filepath.Join("prebuilts", "sdk", sdkVersion.Version.String(), "public")
aidl := filepath.Join(publicDir, "framework.aidl")
jarPath := android.ExistentPathForSource(ctx, jar)
aidlPath := android.ExistentPathForSource(ctx, aidl)
@ -380,23 +89,23 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
return sdkDep{
invalidVersion: true,
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", sdkVersion.kind, sdkVersion.version.String())},
bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", sdkVersion.Kind, sdkVersion.Version.String())},
}
}
if !jarPath.Valid() {
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.raw, jar)
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.Raw, jar)
return sdkDep{}
}
if !aidlPath.Valid() {
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.raw, aidl)
ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdkVersion.Raw, aidl)
return sdkDep{}
}
var systemModules string
if sdkVersion.defaultJavaLanguageVersion(ctx).usesJavaModules() {
systemModules = "sdk_public_" + sdkVersion.version.String() + "_system_modules"
if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() {
systemModules = "sdk_public_" + sdkVersion.Version.String() + "_system_modules"
}
return sdkDep{
@ -418,8 +127,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
}
}
switch sdkVersion.kind {
case sdkPrivate:
switch sdkVersion.Kind {
case android.SdkPrivate:
return sdkDep{
useModule: true,
systemModules: corePlatformSystemModules(ctx),
@ -427,8 +136,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
classpath: config.FrameworkLibraries,
frameworkResModule: "framework-res",
}
case sdkNone:
systemModules := sdkContext.systemModules()
case android.SdkNone:
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"?`)
@ -444,34 +153,34 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
systemModules: systemModules,
bootclasspath: []string{systemModules},
}
case sdkCorePlatform:
case android.SdkCorePlatform:
return sdkDep{
useModule: true,
systemModules: corePlatformSystemModules(ctx),
bootclasspath: corePlatformBootclasspathLibraries(ctx),
noFrameworksLibs: true,
}
case sdkPublic:
case android.SdkPublic:
return toModule([]string{"android_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
case sdkSystem:
case android.SdkSystem:
return toModule([]string{"android_system_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
case sdkTest:
case android.SdkTest:
return toModule([]string{"android_test_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
case sdkCore:
case android.SdkCore:
return sdkDep{
useModule: true,
bootclasspath: []string{"core.current.stubs", config.DefaultLambdaStubsLibrary},
systemModules: "core-current-stubs-system-modules",
noFrameworksLibs: true,
}
case sdkModule:
case android.SdkModule:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", nonUpdatableFrameworkAidlPath(ctx))
case sdkSystemServer:
case android.SdkSystemServer:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules
return toModule([]string{"android_system_server_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
default:
panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw))
panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw))
}
}

View file

@ -814,22 +814,22 @@ func (c *commonToSdkLibraryAndImport) findClosestScopePath(scope *apiScope) *sco
return nil
}
func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
if sdkVersion.version.isNumbered() {
if sdkVersion.Version.IsNumbered() {
return PrebuiltJars(ctx, c.moduleBase.BaseModuleName(), sdkVersion)
}
var apiScope *apiScope
switch sdkVersion.kind {
case sdkSystem:
switch sdkVersion.Kind {
case android.SdkSystem:
apiScope = apiScopeSystem
case sdkModule:
case android.SdkModule:
apiScope = apiScopeModuleLib
case sdkTest:
case android.SdkTest:
apiScope = apiScopeTest
case sdkSystemServer:
case android.SdkSystemServer:
apiScope = apiScopeSystemServer
default:
apiScope = apiScopePublic
@ -932,14 +932,14 @@ type SdkLibraryDependency interface {
//
// These are turbine generated jars so they only change if the externals of the
// class changes but it does not contain and implementation or JavaDoc.
SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths
SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
// Get the implementation jars appropriate for the supplied sdk version.
//
// These are either the implementation jar for the whole sdk library or the implementation
// jars for the stubs. The latter should only be needed when generating JavaDoc as otherwise
// they are identical to the corresponding header jars.
SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths
SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
}
type SdkLibrary struct {
@ -1147,7 +1147,7 @@ func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.EarlyModuleCont
return proptools.String(scopeProperties.Sdk_version)
}
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
sdkDep := decodeSdkDep(mctx, android.SdkContext(&module.Library))
if sdkDep.hasStandardLibs() {
// If building against a standard sdk then use the sdk version appropriate for the scope.
return apiScope.sdkVersion
@ -1465,17 +1465,17 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
mctx.CreateModule(sdkLibraryXmlFactory, &props)
}
func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) android.Paths {
var ver sdkVersion
var kind sdkKind
if s.usePrebuilt(ctx) {
ver = s.version
kind = s.kind
func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s android.SdkSpec) android.Paths {
var ver android.SdkVersion
var kind android.SdkKind
if s.UsePrebuilt(ctx) {
ver = s.Version
kind = s.Kind
} else {
// We don't have prebuilt SDK for the specific sdkVersion.
// Instead of breaking the build, fallback to use "system_current"
ver = sdkVersionCurrent
kind = sdkSystem
ver = android.SdkVersionCurrent
kind = android.SdkSystem
}
dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
@ -1485,7 +1485,7 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and
if ctx.Config().AllowMissingDependencies() {
return android.Paths{android.PathForSource(ctx, jar)}
} else {
ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", s.raw, jar)
ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", s.Raw, jar)
}
return nil
}
@ -1502,13 +1502,13 @@ func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) boo
return len(otherApexInfo.InApexes) > 0 && reflect.DeepEqual(apexInfo.InApexes, otherApexInfo.InApexes)
}
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
// If the client doesn't set sdk_version, but if this library prefers stubs over
// the impl library, let's provide the widest API surface possible. To do so,
// force override sdk_version to module_current so that the closest possible API
// surface could be found in selectHeaderJarsForSdkVersion
if module.defaultsToStubs() && !sdkVersion.specified() {
sdkVersion = sdkSpecFrom("module_current")
if module.defaultsToStubs() && !sdkVersion.Specified() {
sdkVersion = android.SdkSpecFrom("module_current")
}
// Only provide access to the implementation library if it is actually built.
@ -1518,7 +1518,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS
// Only allow access to the implementation library in the following condition:
// * No sdk_version specified on the referencing module.
// * The referencing module is in the same apex as this.
if sdkVersion.kind == sdkPrivate || withinSameApexesAs(ctx, module) {
if sdkVersion.Kind == android.SdkPrivate || withinSameApexesAs(ctx, module) {
if headerJars {
return module.HeaderJars()
} else {
@ -1531,12 +1531,12 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS
}
// to satisfy SdkLibraryDependency interface
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
return module.sdkJars(ctx, sdkVersion, true /*headerJars*/)
}
// to satisfy SdkLibraryDependency interface
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
return module.sdkJars(ctx, sdkVersion, false /*headerJars*/)
}
@ -1568,7 +1568,7 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
// If this builds against standard libraries (i.e. is not part of the core libraries)
// then assume it provides both system and test apis.
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
sdkDep := decodeSdkDep(mctx, android.SdkContext(&module.Library))
hasSystemAndTestApis := sdkDep.hasStandardLibs()
module.sdkLibraryProperties.Generate_system_and_test_apis = hasSystemAndTestApis
@ -2069,7 +2069,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
}
}
func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
// For consistency with SdkLibrary make the implementation jar available to libraries that
// are within the same APEX.
@ -2086,13 +2086,13 @@ func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersio
}
// to satisfy SdkLibraryDependency interface
func (module *SdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
func (module *SdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
// This module is just a wrapper for the prebuilt stubs.
return module.sdkJars(ctx, sdkVersion, true)
}
// to satisfy SdkLibraryDependency interface
func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
// This module is just a wrapper for the stubs.
return module.sdkJars(ctx, sdkVersion, false)
}

View file

@ -371,6 +371,6 @@ func TestMinSdkVersionIsForwarded(t *testing.T) {
android.AssertStringEquals(t, "min_sdk_version forwarding to cc module", "29", propFromCc)
javaModule := result.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library)
propFromJava := javaModule.MinSdkVersion()
propFromJava := javaModule.MinSdkVersionString()
android.AssertStringEquals(t, "min_sdk_version forwarding to java module", "30", propFromJava)
}