Extract createJavaImportForStubs()

Bug: 153443117
Test: m nothing
Change-Id: If74eea675b7ab4aeaa821294f2a137c95f794d4f
This commit is contained in:
Paul Duffin
2020-04-09 00:07:11 +01:00
parent dd46f71493
commit bbb546b2da

View File

@@ -926,6 +926,16 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
continue continue
} }
module.createJavaImportForStubs(mctx, apiScope, scopeProperties)
}
javaSdkLibraries := javaSdkLibraries(mctx.Config())
javaSdkLibrariesLock.Lock()
defer javaSdkLibrariesLock.Unlock()
*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
}
func (module *sdkLibraryImport) createJavaImportForStubs(mctx android.LoadHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
// Creates a java import for the jar with ".stubs" suffix // Creates a java import for the jar with ".stubs" suffix
props := struct { props := struct {
Name *string Name *string
@@ -938,14 +948,12 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
Jars []string Jars []string
Prefer *bool Prefer *bool
}{} }{}
props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName())) props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName()))
props.Sdk_version = scopeProperties.Sdk_version props.Sdk_version = scopeProperties.Sdk_version
// Prepend any of the libs from the legacy public properties to the libs for each of the // Prepend any of the libs from the legacy public properties to the libs for each of the
// scopes to avoid having to duplicate them in each scope. // scopes to avoid having to duplicate them in each scope.
props.Libs = append(module.properties.Libs, scopeProperties.Libs...) props.Libs = append(module.properties.Libs, scopeProperties.Libs...)
props.Jars = scopeProperties.Jars props.Jars = scopeProperties.Jars
if module.SocSpecific() { if module.SocSpecific() {
props.Soc_specific = proptools.BoolPtr(true) props.Soc_specific = proptools.BoolPtr(true)
} else if module.DeviceSpecific() { } else if module.DeviceSpecific() {
@@ -955,20 +963,12 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
} 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. // 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. // That will cause the prebuilt version of the stubs to override the source version.
if mctx.Config().UnbundledBuildUsePrebuiltSdks() { if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
props.Prefer = proptools.BoolPtr(true) props.Prefer = proptools.BoolPtr(true)
} }
mctx.CreateModule(ImportFactory, &props) mctx.CreateModule(ImportFactory, &props)
}
javaSdkLibraries := javaSdkLibraries(mctx.Config())
javaSdkLibrariesLock.Lock()
defer javaSdkLibrariesLock.Unlock()
*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
} }
func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) { func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {