Extract createJavaImportForStubs()
Bug: 153443117 Test: m nothing Change-Id: If74eea675b7ab4aeaa821294f2a137c95f794d4f
This commit is contained in:
@@ -926,43 +926,7 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a java import for the jar with ".stubs" suffix
|
module.createJavaImportForStubs(mctx, apiScope, scopeProperties)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
||||||
@@ -971,6 +935,42 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
|
|||||||
*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
|
*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) {
|
func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for apiScope, scopeProperties := range module.scopeProperties {
|
for apiScope, scopeProperties := range module.scopeProperties {
|
||||||
if len(scopeProperties.Jars) == 0 {
|
if len(scopeProperties.Jars) == 0 {
|
||||||
|
Reference in New Issue
Block a user