Merge "Populate baseline_file values."

This commit is contained in:
Jaewoong Jung 2021-03-11 15:04:52 +00:00 committed by Gerrit Code Review
commit 48b8df14be
2 changed files with 16 additions and 6 deletions

View File

@ -248,9 +248,9 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
}
// Create incompatibilities tracking files for all modules, if we have a "next" api.
incompatibilities := make(map[string]bool)
if nextApiDir := String(p.properties.Next_api_dir); nextApiDir != "" {
files := getPrebuiltFilesInSubdir(mctx, nextApiDir, "api/*incompatibilities.txt")
incompatibilities := make(map[string]bool)
for _, f := range files {
localPath := strings.TrimPrefix(f, mydir)
module, _, scope := parseApiFilePath(mctx, localPath)
@ -266,11 +266,11 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
incompatibilities[referencedModule+"."+scope] = true
}
// Create empty incompatibilities files for remaining modules
for _, k := range android.SortedStringKeys(m) {
if _, ok := incompatibilities[k]; !ok {
createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest"))
}
}
// Create empty incompatibilities files for remaining modules
for _, k := range android.SortedStringKeys(m) {
if _, ok := incompatibilities[k]; !ok {
createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest"))
}
}
}

View File

@ -452,6 +452,7 @@ type sdkLibraryProperties struct {
// that references the latest released API and remove API specification files.
// * API specification filegroup -> <dist-stem>.api.<scope>.latest
// * Removed API specification filegroup -> <dist-stem>-removed.api.<scope>.latest
// * API incompatibilities baseline filegroup -> <dist-stem>-incompatibilities.api.<scope>.latest
Dist_stem *string
// A compatibility mode that allows historical API-tracking files to not exist.
@ -1059,6 +1060,9 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
if m := android.SrcIsModule(module.latestRemovedApiFilegroupName(apiScope)); !ctx.OtherModuleExists(m) {
missingApiModules = append(missingApiModules, m)
}
if m := android.SrcIsModule(module.latestIncompatibilitiesFilegroupName(apiScope)); !ctx.OtherModuleExists(m) {
missingApiModules = append(missingApiModules, m)
}
}
if len(missingApiModules) != 0 && !module.sdkLibraryProperties.Unsafe_ignore_missing_latest_api {
m := module.Name() + " is missing tracking files for previously released library versions.\n"
@ -1165,6 +1169,10 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri
return ":" + module.distStem() + "-removed.api." + apiScope.name + ".latest"
}
func (module *SdkLibrary) latestIncompatibilitiesFilegroupName(apiScope *apiScope) string {
return ":" + module.distStem() + "-incompatibilities.api." + apiScope.name + ".latest"
}
func childModuleVisibility(childVisibility []string) []string {
if childVisibility == nil {
// No child visibility set. The child will use the visibility of the sdk_library.
@ -1389,6 +1397,8 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
props.Check_api.Last_released.Api_file = latestApiFilegroupName
props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
module.latestRemovedApiFilegroupName(apiScope))
props.Check_api.Last_released.Baseline_file = proptools.StringPtr(
module.latestIncompatibilitiesFilegroupName(apiScope))
if proptools.Bool(module.sdkLibraryProperties.Api_lint.Enabled) {
// Enable api lint.