Merge "Make sdkDep/decodeSdkDep the source of truth about the sdk"
This commit is contained in:
16
java/aar.go
16
java/aar.go
@@ -188,8 +188,7 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani
|
|||||||
return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips
|
return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
|
func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkDep sdkDep) {
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext)
|
|
||||||
if sdkDep.frameworkResModule != "" {
|
if sdkDep.frameworkResModule != "" {
|
||||||
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
|
||||||
}
|
}
|
||||||
@@ -401,8 +400,9 @@ var _ AndroidLibraryDependency = (*AndroidLibrary)(nil)
|
|||||||
|
|
||||||
func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
a.Module.deps(ctx)
|
a.Module.deps(ctx)
|
||||||
if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(ctx, sdkContext(a))
|
||||||
a.aapt.deps(ctx, sdkContext(a))
|
if sdkDep.hasFrameworkLibs() {
|
||||||
|
a.aapt.deps(ctx, sdkDep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,6 +513,14 @@ func (a *AARImport) targetSdkVersion() string {
|
|||||||
return a.sdkVersion()
|
return a.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AARImport) noFrameworkLibs() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AARImport) noStandardLibs() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var _ AndroidLibraryDependency = (*AARImport)(nil)
|
var _ AndroidLibraryDependency = (*AARImport)(nil)
|
||||||
|
|
||||||
func (a *AARImport) ExportPackage() android.Path {
|
func (a *AARImport) ExportPackage() android.Path {
|
||||||
|
16
java/app.go
16
java/app.go
@@ -159,8 +159,9 @@ func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.PropertyErrorf("stl", "sdk_version must be set in order to use c++_shared")
|
ctx.PropertyErrorf("stl", "sdk_version must be set in order to use c++_shared")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(ctx, sdkContext(a))
|
||||||
a.aapt.deps(ctx, sdkContext(a))
|
if sdkDep.hasFrameworkLibs() {
|
||||||
|
a.aapt.deps(ctx, sdkDep)
|
||||||
}
|
}
|
||||||
|
|
||||||
embedJni := a.shouldEmbedJnis(ctx)
|
embedJni := a.shouldEmbedJnis(ctx)
|
||||||
@@ -180,7 +181,7 @@ func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.usesLibrary.deps(ctx, Bool(a.properties.No_framework_libs))
|
a.usesLibrary.deps(ctx, sdkDep.hasFrameworkLibs())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidApp) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *AndroidApp) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -783,7 +784,7 @@ func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
ctx.AddDependency(ctx.Module(), certificateTag, cert)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.usesLibrary.deps(ctx, false)
|
a.usesLibrary.deps(ctx, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidAppImport) uncompressEmbeddedJniLibs(
|
func (a *AndroidAppImport) uncompressEmbeddedJniLibs(
|
||||||
@@ -937,11 +938,14 @@ type usesLibrary struct {
|
|||||||
usesLibraryProperties UsesLibraryProperties
|
usesLibraryProperties UsesLibraryProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, noFrameworkLibs bool) {
|
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
|
||||||
if !ctx.Config().UnbundledBuild() {
|
if !ctx.Config().UnbundledBuild() {
|
||||||
ctx.AddVariationDependencies(nil, usesLibTag, u.usesLibraryProperties.Uses_libs...)
|
ctx.AddVariationDependencies(nil, usesLibTag, u.usesLibraryProperties.Uses_libs...)
|
||||||
ctx.AddVariationDependencies(nil, usesLibTag, u.presentOptionalUsesLibs(ctx)...)
|
ctx.AddVariationDependencies(nil, usesLibTag, u.presentOptionalUsesLibs(ctx)...)
|
||||||
if !noFrameworkLibs {
|
// Only add these extra dependencies if the module depends on framework libs. This avoids
|
||||||
|
// creating a cyclic dependency:
|
||||||
|
// e.g. framework-res -> org.apache.http.legacy -> ... -> framework-res.
|
||||||
|
if hasFrameworkLibs {
|
||||||
// dexpreopt/dexpreopt.go needs the paths to the dex jars of these libraries in case construct_context.sh needs
|
// dexpreopt/dexpreopt.go needs the paths to the dex jars of these libraries in case construct_context.sh needs
|
||||||
// to pass them to dex2oat. Add them as a dependency so we can determine the path to the dex jar of each
|
// to pass them to dex2oat. Add them as a dependency so we can determine the path to the dex jar of each
|
||||||
// library to dexpreopt.
|
// library to dexpreopt.
|
||||||
|
@@ -538,16 +538,24 @@ func (j *Javadoc) targetSdkVersion() string {
|
|||||||
return j.sdkVersion()
|
return j.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Javadoc) noFrameworkLibs() bool {
|
||||||
|
return Bool(j.properties.No_framework_libs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *Javadoc) noStandardLibs() bool {
|
||||||
|
return Bool(j.properties.No_standard_libs)
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
if !Bool(j.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
if sdkDep.hasStandardLibs() {
|
||||||
if sdkDep.useDefaultLibs {
|
if sdkDep.useDefaultLibs {
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
if ctx.Config().TargetOpenJDK9() {
|
if ctx.Config().TargetOpenJDK9() {
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||||
}
|
}
|
||||||
if !Bool(j.properties.No_framework_libs) {
|
if sdkDep.hasFrameworkLibs() {
|
||||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||||
}
|
}
|
||||||
} else if sdkDep.useModule {
|
} else if sdkDep.useModule {
|
||||||
|
26
java/java.go
26
java/java.go
@@ -440,6 +440,16 @@ type sdkDep struct {
|
|||||||
|
|
||||||
jars android.Paths
|
jars android.Paths
|
||||||
aidl android.OptionalPath
|
aidl android.OptionalPath
|
||||||
|
|
||||||
|
noStandardLibs, noFrameworksLibs bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s sdkDep) hasStandardLibs() bool {
|
||||||
|
return !s.noStandardLibs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s sdkDep) hasFrameworkLibs() bool {
|
||||||
|
return !s.noStandardLibs && !s.noFrameworksLibs
|
||||||
}
|
}
|
||||||
|
|
||||||
type jniLib struct {
|
type jniLib struct {
|
||||||
@@ -476,14 +486,22 @@ func (j *Module) targetSdkVersion() string {
|
|||||||
return j.sdkVersion()
|
return j.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Module) noFrameworkLibs() bool {
|
||||||
|
return Bool(j.properties.No_framework_libs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *Module) noStandardLibs() bool {
|
||||||
|
return Bool(j.properties.No_standard_libs)
|
||||||
|
}
|
||||||
|
|
||||||
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||||
if ctx.Device() {
|
if ctx.Device() {
|
||||||
if !Bool(j.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
if sdkDep.hasStandardLibs() {
|
||||||
if sdkDep.useDefaultLibs {
|
if sdkDep.useDefaultLibs {
|
||||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||||
if !Bool(j.properties.No_framework_libs) {
|
if sdkDep.hasFrameworkLibs() {
|
||||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||||
}
|
}
|
||||||
} else if sdkDep.useModule {
|
} else if sdkDep.useModule {
|
||||||
@@ -913,7 +931,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||||||
flags.processor = strings.Join(deps.processorClasses, ",")
|
flags.processor = strings.Join(deps.processorClasses, ",")
|
||||||
|
|
||||||
if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" &&
|
if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" &&
|
||||||
!Bool(j.properties.No_standard_libs) &&
|
decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() &&
|
||||||
inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) {
|
inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) {
|
||||||
// Give host-side tools a version of OpenJDK's standard libraries
|
// Give host-side tools a version of OpenJDK's standard libraries
|
||||||
// close to what they're targeting. As of Dec 2017, AOSP is only
|
// close to what they're targeting. As of Dec 2017, AOSP is only
|
||||||
|
20
java/sdk.go
20
java/sdk.go
@@ -38,12 +38,18 @@ var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
|||||||
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
||||||
|
|
||||||
type sdkContext interface {
|
type sdkContext interface {
|
||||||
// sdkVersion eturns the sdk_version property of the current module, or an empty string if it is not set.
|
// sdkVersion returns the sdk_version property of the current module, or an empty string if it is not set.
|
||||||
sdkVersion() string
|
sdkVersion() string
|
||||||
// minSdkVersion returns the min_sdk_version property of the current module, or sdkVersion() if it is not set.
|
// minSdkVersion returns the min_sdk_version property of the current module, or sdkVersion() if it is not set.
|
||||||
minSdkVersion() string
|
minSdkVersion() string
|
||||||
// targetSdkVersion returns the target_sdk_version property of the current module, or sdkVersion() if it is not set.
|
// targetSdkVersion returns the target_sdk_version property of the current module, or sdkVersion() if it is not set.
|
||||||
targetSdkVersion() string
|
targetSdkVersion() string
|
||||||
|
|
||||||
|
// Temporarily provide access to the no_standard_libs property (where present).
|
||||||
|
noStandardLibs() bool
|
||||||
|
|
||||||
|
// Temporarily provide access to the no_frameworks_libs property (where present).
|
||||||
|
noFrameworkLibs() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
|
func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string {
|
||||||
@@ -138,6 +144,10 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
|||||||
useFiles: true,
|
useFiles: true,
|
||||||
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
|
jars: android.Paths{jarPath.Path(), lambdaStubsPath},
|
||||||
aidl: android.OptionalPathForPath(aidlPath.Path()),
|
aidl: android.OptionalPathForPath(aidlPath.Path()),
|
||||||
|
|
||||||
|
// Pass values straight through for now to match previous behavior.
|
||||||
|
noStandardLibs: sdkContext.noStandardLibs(),
|
||||||
|
noFrameworksLibs: sdkContext.noFrameworkLibs(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +158,10 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
|||||||
systemModules: m + "_system_modules",
|
systemModules: m + "_system_modules",
|
||||||
frameworkResModule: r,
|
frameworkResModule: r,
|
||||||
aidl: android.OptionalPathForPath(aidl),
|
aidl: android.OptionalPathForPath(aidl),
|
||||||
|
|
||||||
|
// Pass values straight through for now to match previous behavior.
|
||||||
|
noStandardLibs: sdkContext.noStandardLibs(),
|
||||||
|
noFrameworksLibs: sdkContext.noFrameworkLibs(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if m == "core.current.stubs" {
|
if m == "core.current.stubs" {
|
||||||
@@ -182,6 +196,10 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep {
|
|||||||
return sdkDep{
|
return sdkDep{
|
||||||
useDefaultLibs: true,
|
useDefaultLibs: true,
|
||||||
frameworkResModule: "framework-res",
|
frameworkResModule: "framework-res",
|
||||||
|
|
||||||
|
// Pass values straight through for now to match previous behavior.
|
||||||
|
noStandardLibs: sdkContext.noStandardLibs(),
|
||||||
|
noFrameworksLibs: sdkContext.noFrameworkLibs(),
|
||||||
}
|
}
|
||||||
case "current":
|
case "current":
|
||||||
return toModule("android_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
return toModule("android_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx))
|
||||||
|
@@ -159,7 +159,8 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
|
ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
|
||||||
ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
|
ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
|
||||||
|
|
||||||
if !Bool(module.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(ctx, sdkContext(&module.Library))
|
||||||
|
if sdkDep.hasStandardLibs() {
|
||||||
ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
|
ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
|
||||||
ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
|
ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
|
||||||
ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
|
ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
|
||||||
@@ -401,6 +402,8 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc
|
|||||||
}
|
}
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.stubsName(apiScope))
|
props.Name = proptools.StringPtr(module.stubsName(apiScope))
|
||||||
// sources are generated from the droiddoc
|
// sources are generated from the droiddoc
|
||||||
props.Srcs = []string{":" + module.docsName(apiScope)}
|
props.Srcs = []string{":" + module.docsName(apiScope)}
|
||||||
@@ -411,7 +414,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc
|
|||||||
props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
|
props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
|
||||||
}
|
}
|
||||||
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
|
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
|
||||||
props.No_standard_libs = module.Library.Module.properties.No_standard_libs
|
props.No_standard_libs = proptools.BoolPtr(!sdkDep.hasStandardLibs())
|
||||||
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
||||||
props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
|
props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
|
||||||
props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
|
props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
|
||||||
@@ -462,6 +465,8 @@ func (module *SdkLibrary) createDocs(mctx android.LoadHookContext, apiScope apiS
|
|||||||
}
|
}
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.docsName(apiScope))
|
props.Name = proptools.StringPtr(module.docsName(apiScope))
|
||||||
props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
|
props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
|
||||||
props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...)
|
props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...)
|
||||||
@@ -472,7 +477,7 @@ func (module *SdkLibrary) createDocs(mctx android.LoadHookContext, apiScope apiS
|
|||||||
props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
|
props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
|
||||||
props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
|
props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
|
||||||
props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
|
props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
|
||||||
props.No_standard_libs = module.Library.Module.properties.No_standard_libs
|
props.No_standard_libs = proptools.BoolPtr(!sdkDep.hasStandardLibs())
|
||||||
props.Java_version = module.Library.Module.properties.Java_version
|
props.Java_version = module.Library.Module.properties.Java_version
|
||||||
|
|
||||||
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
|
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
|
||||||
@@ -701,7 +706,8 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
|
|||||||
module.createStubsLibrary(mctx, apiScopePublic)
|
module.createStubsLibrary(mctx, apiScopePublic)
|
||||||
module.createDocs(mctx, apiScopePublic)
|
module.createDocs(mctx, apiScopePublic)
|
||||||
|
|
||||||
if !Bool(module.properties.No_standard_libs) {
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
|
if sdkDep.hasStandardLibs() {
|
||||||
// for system API stubs
|
// for system API stubs
|
||||||
module.createStubsLibrary(mctx, apiScopeSystem)
|
module.createStubsLibrary(mctx, apiScopeSystem)
|
||||||
module.createDocs(mctx, apiScopeSystem)
|
module.createDocs(mctx, apiScopeSystem)
|
||||||
|
Reference in New Issue
Block a user