Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b848b01 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Extract createJavaImportForStubs()" into rvc-dev

parents 317bf115 f6155721
Loading
Loading
Loading
Loading
+37 −37
Original line number Diff line number Diff line
@@ -912,6 +912,16 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
			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
	props := struct {
		Name                *string
@@ -924,14 +934,12 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
		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() {
@@ -941,22 +949,14 @@ func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookConte
	} 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())
	javaSdkLibrariesLock.Lock()
	defer javaSdkLibrariesLock.Unlock()
	*javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
}

func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
	for apiScope, scopeProperties := range module.scopeProperties {
		if len(scopeProperties.Jars) == 0 {