java_sdk_library: Add framework-modules naming scheme

Matches the naming scheme used by the separate manually created modules
that will be replaced by java_sdk_library's automatically created
components. This will simplify conversion to java_sdk_library as it
will allow developers to concentrate on getting the conversion correct
without also having to worry about name changes. It will also allow the
conversions to be parallelized as many of the references to the
components are in places where conflicts are likely.

Test: m nothing
Bug: 155480189
Change-Id: Ic859a61de155b3e582c17f6ab5e9298f5f4e709a
This commit is contained in:
Paul Duffin 2020-05-08 15:36:30 +01:00
parent dd9d0740fa
commit 6c9c5fc4bc

View file

@ -471,8 +471,9 @@ func (paths *scopePaths) extractStubsSourceAndApiInfoFromApiStubsProvider(dep an
type commonToSdkLibraryAndImportProperties struct {
// The naming scheme to use for the components that this module creates.
//
// If not specified then it defaults to "default", which is currently the only
// allowable value.
// If not specified then it defaults to "default". The other allowable value is
// "framework-modules" which matches the scheme currently used by framework modules
// for the equivalent components represented as separate Soong modules.
//
// This is a temporary mechanism to simplify conversion from separate modules for each
// component that follow a different naming pattern to the default one.
@ -503,6 +504,8 @@ func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android
switch schemeProperty {
case "default":
c.namingScheme = &defaultNamingScheme{}
case "framework-modules":
c.namingScheme = &frameworkModulesNamingScheme{}
default:
ctx.PropertyErrorf("naming_scheme", "expected 'default' but was %q", schemeProperty)
return false
@ -1198,6 +1201,31 @@ func (s *defaultNamingScheme) apiModuleName(scope *apiScope, baseName string) st
var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil)
type frameworkModulesNamingScheme struct {
}
func (s *frameworkModulesNamingScheme) moduleSuffix(scope *apiScope) string {
suffix := scope.name
if scope == apiScopeModuleLib {
suffix = "module_libs_"
}
return suffix
}
func (s *frameworkModulesNamingScheme) stubsLibraryModuleName(scope *apiScope, baseName string) string {
return fmt.Sprintf("%s-stubs-%sapi", baseName, s.moduleSuffix(scope))
}
func (s *frameworkModulesNamingScheme) stubsSourceModuleName(scope *apiScope, baseName string) string {
return fmt.Sprintf("%s-stubs-srcs-%sapi", baseName, s.moduleSuffix(scope))
}
func (s *frameworkModulesNamingScheme) apiModuleName(scope *apiScope, baseName string) string {
return fmt.Sprintf("%s-api-%sapi", baseName, s.moduleSuffix(scope))
}
var _ sdkLibraryComponentNamingScheme = (*frameworkModulesNamingScheme)(nil)
// java_sdk_library is a special Java library that provides optional platform APIs to apps.
// In practice, it can be viewed as a combination of several modules: 1) stubs library that clients
// are linked against to, 2) droiddoc module that internally generates API stubs source files,