java_sdk_library_import: Propagate prefer to child modules am: 38b5785e3f

Change-Id: Ida8134f076911902c08e0656e54fd04395c793f6
This commit is contained in:
Paul Duffin 2020-05-13 21:58:24 +00:00 committed by Automerger Merge Worker
commit b08ba780c5
2 changed files with 12 additions and 7 deletions

View file

@ -69,6 +69,10 @@ func (p *Prebuilt) ForcePrefer() {
p.properties.Prefer = proptools.BoolPtr(true) p.properties.Prefer = proptools.BoolPtr(true)
} }
func (p *Prebuilt) Prefer() bool {
return proptools.Bool(p.properties.Prefer)
}
// 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

View file

@ -1448,22 +1448,23 @@ func (module *sdkLibraryImport) createJavaImportForStubs(mctx android.Defaultabl
} else if module.SystemExtSpecific() { } else if module.SystemExtSpecific() {
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. // The imports are preferred if the java_sdk_library_import is preferred.
// That will cause the prebuilt version of the stubs to override the source version. props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
props.Prefer = proptools.BoolPtr(true)
}
mctx.CreateModule(ImportFactory, &props) mctx.CreateModule(ImportFactory, &props)
} }
func (module *sdkLibraryImport) createPrebuiltStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) { func (module *sdkLibraryImport) createPrebuiltStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
props := struct { props := struct {
Name *string Name *string
Srcs []string Srcs []string
Prefer *bool
}{} }{}
props.Name = proptools.StringPtr(module.stubsSourceModuleName(apiScope)) props.Name = proptools.StringPtr(module.stubsSourceModuleName(apiScope))
props.Srcs = scopeProperties.Stub_srcs props.Srcs = scopeProperties.Stub_srcs
mctx.CreateModule(PrebuiltStubsSourcesFactory, &props) mctx.CreateModule(PrebuiltStubsSourcesFactory, &props)
// The stubs source is preferred if the java_sdk_library_import is preferred.
props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
} }
func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) { func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {