Revert "Enable from-text stub generation in non-sdk java_sdk_library"
Revert submission 2982300-java_api_library_non_sdk Reason for revert: DroidMonitor: Potential culprit for b/357648959 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted changes: /q/submissionid:2982300-java_api_library_non_sdk Change-Id: I5ef7afd9ec3e10ea99f82d02172843ad9b2cfda9
This commit is contained in:
committed by
Gerrit Code Review
parent
062eb663c5
commit
a574cd28a8
@@ -427,10 +427,22 @@ var (
|
||||
apiScopeModuleLib,
|
||||
apiScopeSystemServer,
|
||||
}
|
||||
apiLibraryAdditionalProperties = map[string]string{
|
||||
"legacy.i18n.module.platform.api": "i18n.module.public.api.stubs.source.api.contribution",
|
||||
"stable.i18n.module.platform.api": "i18n.module.public.api.stubs.source.api.contribution",
|
||||
"conscrypt.module.platform.api": "conscrypt.module.public.api.stubs.source.api.contribution",
|
||||
apiLibraryAdditionalProperties = map[string]struct {
|
||||
FullApiSurfaceStubLib string
|
||||
AdditionalApiContribution string
|
||||
}{
|
||||
"legacy.i18n.module.platform.api": {
|
||||
FullApiSurfaceStubLib: "legacy.core.platform.api.stubs",
|
||||
AdditionalApiContribution: "i18n.module.public.api.stubs.source.api.contribution",
|
||||
},
|
||||
"stable.i18n.module.platform.api": {
|
||||
FullApiSurfaceStubLib: "stable.core.platform.api.stubs",
|
||||
AdditionalApiContribution: "i18n.module.public.api.stubs.source.api.contribution",
|
||||
},
|
||||
"conscrypt.module.platform.api": {
|
||||
FullApiSurfaceStubLib: "stable.core.platform.api.stubs",
|
||||
AdditionalApiContribution: "conscrypt.module.public.api.stubs.source.api.contribution",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -638,6 +650,13 @@ type sdkLibraryProperties struct {
|
||||
Legacy_errors_allowed *bool
|
||||
}
|
||||
|
||||
// Determines if the module contributes to any api surfaces.
|
||||
// This property should be set to true only if the module is listed under
|
||||
// frameworks-base-api.bootclasspath in frameworks/base/api/Android.bp.
|
||||
// Otherwise, this property should be set to false.
|
||||
// Defaults to false.
|
||||
Contribute_to_android_api *bool
|
||||
|
||||
// a list of aconfig_declarations module names that the stubs generated in this module
|
||||
// depend on.
|
||||
Aconfig_declarations []string
|
||||
@@ -1732,13 +1751,30 @@ func (module *SdkLibrary) latestIncompatibilitiesModuleName(apiScope *apiScope)
|
||||
return latestPrebuiltApiModuleName(module.distStem()+"-incompatibilities", apiScope)
|
||||
}
|
||||
|
||||
func (module *SdkLibrary) contributesToApiSurface(c android.Config) bool {
|
||||
_, exists := c.GetApiLibraries()[module.Name()]
|
||||
return exists
|
||||
}
|
||||
|
||||
// The listed modules are the special java_sdk_libraries where apiScope.kind do not match the
|
||||
// api surface that the module contribute to. For example, the public droidstubs and java_library
|
||||
// do not contribute to the public api surface, but contributes to the core platform api surface.
|
||||
// This method returns the full api surface stub lib that
|
||||
// the generated java_api_library should depend on.
|
||||
func (module *SdkLibrary) alternativeFullApiSurfaceStubLib() string {
|
||||
if val, ok := apiLibraryAdditionalProperties[module.Name()]; ok {
|
||||
return val.FullApiSurfaceStubLib
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The listed modules' stubs contents do not match the corresponding txt files,
|
||||
// but require additional api contributions to generate the full stubs.
|
||||
// This method returns the name of the additional api contribution module
|
||||
// for corresponding sdk_library modules.
|
||||
func (module *SdkLibrary) apiLibraryAdditionalApiContribution() string {
|
||||
if val, ok := apiLibraryAdditionalProperties[module.Name()]; ok {
|
||||
return val
|
||||
return val.AdditionalApiContribution
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -2033,18 +2069,17 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
||||
mctx.CreateModule(DroidstubsFactory, &props, module.sdkComponentPropertiesForChildLibrary()).(*Droidstubs).CallHookIfAvailable(mctx)
|
||||
}
|
||||
|
||||
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||
func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope, alternativeFullApiSurfaceStub string) {
|
||||
props := struct {
|
||||
Name *string
|
||||
Visibility []string
|
||||
Api_contributions []string
|
||||
Libs []string
|
||||
Static_libs []string
|
||||
System_modules *string
|
||||
Enable_validation *bool
|
||||
Stubs_type *string
|
||||
Sdk_version *string
|
||||
Previous_api *string
|
||||
Name *string
|
||||
Visibility []string
|
||||
Api_contributions []string
|
||||
Libs []string
|
||||
Static_libs []string
|
||||
Full_api_surface_stub *string
|
||||
System_modules *string
|
||||
Enable_validation *bool
|
||||
Stubs_type *string
|
||||
}{}
|
||||
|
||||
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
|
||||
@@ -2068,29 +2103,34 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
|
||||
}
|
||||
|
||||
props.Api_contributions = apiContributions
|
||||
|
||||
// Ensure that stub-annotations is added to the classpath before any other libs
|
||||
props.Libs = []string{"stub-annotations"}
|
||||
props.Libs = append(props.Libs, module.properties.Libs...)
|
||||
props.Libs = append(props.Libs, module.properties.Static_libs...)
|
||||
props.Libs = module.properties.Libs
|
||||
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
|
||||
props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
|
||||
props.Libs = append(props.Libs, "stub-annotations")
|
||||
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
|
||||
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
|
||||
if alternativeFullApiSurfaceStub != "" {
|
||||
props.Full_api_surface_stub = proptools.StringPtr(alternativeFullApiSurfaceStub)
|
||||
}
|
||||
|
||||
// android_module_lib_stubs_current.from-text only comprises api contributions from art, conscrypt and i18n.
|
||||
// Thus, replace with android_module_lib_stubs_current_full.from-text, which comprises every api domains.
|
||||
if apiScope.kind == android.SdkModule {
|
||||
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + "_full.from-text")
|
||||
}
|
||||
|
||||
// java_sdk_library modules that set sdk_version as none does not depend on other api
|
||||
// domains. Therefore, java_api_library created from such modules should not depend on
|
||||
// full_api_surface_stubs but create and compile stubs by the java_api_library module
|
||||
// itself.
|
||||
if module.SdkVersion(mctx).Kind == android.SdkNone {
|
||||
props.Full_api_surface_stub = nil
|
||||
}
|
||||
|
||||
props.System_modules = module.deviceProperties.System_modules
|
||||
props.Enable_validation = proptools.BoolPtr(true)
|
||||
props.Stubs_type = proptools.StringPtr("everything")
|
||||
|
||||
if module.deviceProperties.Sdk_version != nil {
|
||||
props.Sdk_version = module.deviceProperties.Sdk_version
|
||||
}
|
||||
|
||||
if module.compareAgainstLatestApi(apiScope) {
|
||||
// check against the latest released API
|
||||
latestApiFilegroupName := proptools.StringPtr(module.latestApiFilegroupName(apiScope))
|
||||
props.Previous_api = latestApiFilegroupName
|
||||
}
|
||||
|
||||
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
|
||||
}
|
||||
|
||||
@@ -2121,7 +2161,7 @@ func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHook
|
||||
}
|
||||
|
||||
func (module *SdkLibrary) createTopLevelStubsLibrary(
|
||||
mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||
mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
|
||||
|
||||
// Dist the "everything" stubs when the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag is false
|
||||
doDist := !mctx.Config().ReleaseHiddenApiExportableStubs()
|
||||
@@ -2130,7 +2170,7 @@ func (module *SdkLibrary) createTopLevelStubsLibrary(
|
||||
|
||||
// Add the stub compiling java_library/java_api_library as static lib based on build config
|
||||
staticLib := module.sourceStubsLibraryModuleName(apiScope)
|
||||
if mctx.Config().BuildFromTextStub() && module.ModuleBuildFromTextStubs() {
|
||||
if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
|
||||
staticLib = module.apiLibraryModuleName(apiScope)
|
||||
}
|
||||
props.Static_libs = append(props.Static_libs, staticLib)
|
||||
@@ -2173,8 +2213,8 @@ func (module *SdkLibrary) UniqueApexVariations() bool {
|
||||
return module.uniqueApexVariations()
|
||||
}
|
||||
|
||||
func (module *SdkLibrary) ModuleBuildFromTextStubs() bool {
|
||||
return proptools.BoolDefault(module.sdkLibraryProperties.Build_from_text_stub, true)
|
||||
func (module *SdkLibrary) ContributeToApi() bool {
|
||||
return proptools.BoolDefault(module.sdkLibraryProperties.Contribute_to_android_api, false)
|
||||
}
|
||||
|
||||
// Creates the xml file that publicizes the runtime library
|
||||
@@ -2350,10 +2390,16 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
|
||||
module.createStubsLibrary(mctx, scope)
|
||||
module.createExportableStubsLibrary(mctx, scope)
|
||||
|
||||
if mctx.Config().BuildFromTextStub() && module.ModuleBuildFromTextStubs() {
|
||||
module.createApiLibrary(mctx, scope)
|
||||
alternativeFullApiSurfaceStubLib := ""
|
||||
if scope == apiScopePublic {
|
||||
alternativeFullApiSurfaceStubLib = module.alternativeFullApiSurfaceStubLib()
|
||||
}
|
||||
module.createTopLevelStubsLibrary(mctx, scope)
|
||||
contributesToApiSurface := module.contributesToApiSurface(mctx.Config()) || alternativeFullApiSurfaceStubLib != ""
|
||||
if contributesToApiSurface {
|
||||
module.createApiLibrary(mctx, scope, alternativeFullApiSurfaceStubLib)
|
||||
}
|
||||
|
||||
module.createTopLevelStubsLibrary(mctx, scope, contributesToApiSurface)
|
||||
module.createTopLevelExportableStubsLibrary(mctx, scope)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user