From bbb546b2da4c99525cdbe5f782c7102ae10bb386 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 9 Apr 2020 00:07:11 +0100 Subject: [PATCH] Extract createJavaImportForStubs() Bug: 153443117 Test: m nothing Change-Id: If74eea675b7ab4aeaa821294f2a137c95f794d4f --- java/sdk_library.go | 74 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index ce3ddcd49..f9fd953cc 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -926,43 +926,7 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte continue } - // Creates a java import for the jar with ".stubs" suffix - props := struct { - Name *string - Soc_specific *bool - Device_specific *bool - Product_specific *bool - System_ext_specific *bool - Sdk_version *string - Libs []string - Jars []string - Prefer *bool - }{} - - props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName())) - props.Sdk_version = scopeProperties.Sdk_version - // 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. - props.Libs = append(module.properties.Libs, scopeProperties.Libs...) - props.Jars = scopeProperties.Jars - - if module.SocSpecific() { - props.Soc_specific = proptools.BoolPtr(true) - } else if module.DeviceSpecific() { - props.Device_specific = proptools.BoolPtr(true) - } else if module.ProductSpecific() { - props.Product_specific = proptools.BoolPtr(true) - } else if module.SystemExtSpecific() { - 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) + module.createJavaImportForStubs(mctx, apiScope, scopeProperties) } javaSdkLibraries := javaSdkLibraries(mctx.Config()) @@ -971,6 +935,42 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte *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 + props := struct { + Name *string + Soc_specific *bool + Device_specific *bool + Product_specific *bool + System_ext_specific *bool + Sdk_version *string + Libs []string + Jars []string + Prefer *bool + }{} + props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName())) + props.Sdk_version = scopeProperties.Sdk_version + // 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. + props.Libs = append(module.properties.Libs, scopeProperties.Libs...) + props.Jars = scopeProperties.Jars + if module.SocSpecific() { + props.Soc_specific = proptools.BoolPtr(true) + } else if module.DeviceSpecific() { + props.Device_specific = proptools.BoolPtr(true) + } else if module.ProductSpecific() { + props.Product_specific = proptools.BoolPtr(true) + } else if module.SystemExtSpecific() { + 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) +} + func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) { for apiScope, scopeProperties := range module.scopeProperties { if len(scopeProperties.Jars) == 0 {