Merge "java_sdk_library - Use prebuilt/prefer for unbundled app builds" am: 7300095182
Change-Id: I4ccfd4f9ea3271fab429361ca3a8e2b7bd8b012e
This commit is contained in:
@@ -62,6 +62,10 @@ func (p *Prebuilt) Name(name string) string {
|
|||||||
return "prebuilt_" + name
|
return "prebuilt_" + name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Prebuilt) ForcePrefer() {
|
||||||
|
p.properties.Prefer = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
|
||||||
// The below source-related functions and the srcs, src fields are based on an assumption that
|
// The below source-related functions and the srcs, src fields are based on an assumption that
|
||||||
// prebuilt modules have a static source property at the moment. Currently there is only one
|
// prebuilt modules have a static source property at the moment. Currently there is only one
|
||||||
// exception, android_app_import, which chooses a source file depending on the product's DPI
|
// exception, android_app_import, which chooses a source file depending on the product's DPI
|
||||||
|
@@ -265,13 +265,11 @@ func (module *SdkLibrary) getActiveApiScopes() apiScopes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
useBuiltStubs := !ctx.Config().UnbundledBuildUsePrebuiltSdks()
|
|
||||||
for _, apiScope := range module.getActiveApiScopes() {
|
for _, apiScope := range module.getActiveApiScopes() {
|
||||||
// Add dependencies to the stubs library
|
// Add dependencies to the stubs library
|
||||||
if useBuiltStubs {
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsName(apiScope))
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsName(apiScope))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// And the api file
|
||||||
ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,9 +464,6 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc
|
|||||||
Compile_dex *bool
|
Compile_dex *bool
|
||||||
Java_version *string
|
Java_version *string
|
||||||
Product_variables struct {
|
Product_variables struct {
|
||||||
Unbundled_build struct {
|
|
||||||
Enabled *bool
|
|
||||||
}
|
|
||||||
Pdk struct {
|
Pdk struct {
|
||||||
Enabled *bool
|
Enabled *bool
|
||||||
}
|
}
|
||||||
@@ -487,10 +482,6 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc
|
|||||||
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
||||||
props.Installable = proptools.BoolPtr(false)
|
props.Installable = proptools.BoolPtr(false)
|
||||||
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
props.Libs = module.sdkLibraryProperties.Stub_only_libs
|
||||||
// Unbundled apps will use the prebult one from /prebuilts/sdk
|
|
||||||
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
|
||||||
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.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
|
||||||
@@ -651,7 +642,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
|
|||||||
mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps)
|
mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, s sdkSpec) android.Paths {
|
func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) android.Paths {
|
||||||
var ver sdkVersion
|
var ver sdkVersion
|
||||||
var kind sdkKind
|
var kind sdkKind
|
||||||
if s.usePrebuilt(ctx) {
|
if s.usePrebuilt(ctx) {
|
||||||
@@ -665,7 +656,7 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, s sdkSpec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
|
dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
|
||||||
jar := filepath.Join(dir, module.BaseModuleName()+".jar")
|
jar := filepath.Join(dir, baseName+".jar")
|
||||||
jarPath := android.ExistentPathForSource(ctx, jar)
|
jarPath := android.ExistentPathForSource(ctx, jar)
|
||||||
if !jarPath.Valid() {
|
if !jarPath.Valid() {
|
||||||
if ctx.Config().AllowMissingDependencies() {
|
if ctx.Config().AllowMissingDependencies() {
|
||||||
@@ -683,10 +674,9 @@ func (module *SdkLibrary) sdkJars(
|
|||||||
sdkVersion sdkSpec,
|
sdkVersion sdkSpec,
|
||||||
headerJars bool) android.Paths {
|
headerJars bool) android.Paths {
|
||||||
|
|
||||||
// If a specific numeric version has been requested or the build is explicitly configured
|
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
|
||||||
// for it then use prebuilt versions of the sdk.
|
if sdkVersion.version.isNumbered() {
|
||||||
if sdkVersion.version.isNumbered() || ctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
|
||||||
return module.PrebuiltJars(ctx, sdkVersion)
|
|
||||||
} else {
|
} else {
|
||||||
if !sdkVersion.specified() {
|
if !sdkVersion.specified() {
|
||||||
if headerJars {
|
if headerJars {
|
||||||
@@ -899,6 +889,11 @@ func (module *sdkLibraryImport) Name() string {
|
|||||||
|
|
||||||
func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
|
func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
|
||||||
|
|
||||||
|
// If the build is configured to use prebuilts then force this to be preferred.
|
||||||
|
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
|
module.prebuilt.ForcePrefer()
|
||||||
|
}
|
||||||
|
|
||||||
for apiScope, scopeProperties := range module.scopeProperties() {
|
for apiScope, scopeProperties := range module.scopeProperties() {
|
||||||
if len(scopeProperties.Jars) == 0 {
|
if len(scopeProperties.Jars) == 0 {
|
||||||
continue
|
continue
|
||||||
@@ -914,6 +909,7 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
|
|||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
Libs []string
|
Libs []string
|
||||||
Jars []string
|
Jars []string
|
||||||
|
Prefer *bool
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName()))
|
props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName()))
|
||||||
@@ -933,6 +929,12 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
|
|||||||
props.System_ext_specific = proptools.BoolPtr(true)
|
props.System_ext_specific = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the build should use prebuilt sdks then set prefer to true on the stubs library.
|
||||||
|
// That will cause the prebuilt version of the stubs to override the source version.
|
||||||
|
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
|
||||||
|
props.Prefer = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
|
||||||
mctx.CreateModule(ImportFactory, &props)
|
mctx.CreateModule(ImportFactory, &props)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,6 +982,11 @@ func (module *sdkLibraryImport) sdkJars(
|
|||||||
ctx android.BaseModuleContext,
|
ctx android.BaseModuleContext,
|
||||||
sdkVersion sdkSpec) android.Paths {
|
sdkVersion sdkSpec) android.Paths {
|
||||||
|
|
||||||
|
// If a specific numeric version has been requested then use prebuilt versions of the sdk.
|
||||||
|
if sdkVersion.version.isNumbered() {
|
||||||
|
return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
|
||||||
|
}
|
||||||
|
|
||||||
var apiScope *apiScope
|
var apiScope *apiScope
|
||||||
switch sdkVersion.kind {
|
switch sdkVersion.kind {
|
||||||
case sdkSystem:
|
case sdkSystem:
|
||||||
|
Reference in New Issue
Block a user