Merge "Create rule to generate the exportable api files when checkapi is disabled" into main

This commit is contained in:
Treehugger Robot
2024-03-15 23:58:13 +00:00
committed by Gerrit Code Review

View File

@@ -368,7 +368,7 @@ func (d *Droidstubs) ApiFilePath(stubsType StubsType) (ret android.Path, err err
ret, err = nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String()) ret, err = nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String())
} }
if ret == nil && err == nil { if ret == nil && err == nil {
err = fmt.Errorf("stubs srcjar is null for the stub type %s", stubsType.String()) err = fmt.Errorf("api file is null for the stub type %s", stubsType.String())
} }
return ret, err return ret, err
} }
@@ -478,34 +478,41 @@ func (d *Droidstubs) sdkValuesFlags(ctx android.ModuleContext, cmd *android.Rule
} }
func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath, stubsType StubsType, checkApi bool) { func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath, stubsType StubsType, checkApi bool) {
if checkApi || String(d.properties.Api_filename) != "" {
filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--api ", uncheckedApiFile)
apiFileName := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), apiFileName)
cmd.FlagWithOutput("--api ", uncheckedApiFile)
if checkApi || String(d.properties.Api_filename) != "" {
if stubsType == Everything { if stubsType == Everything {
d.apiFile = uncheckedApiFile d.apiFile = uncheckedApiFile
} else if stubsType == Exportable { } else if stubsType == Exportable {
d.exportableApiFile = uncheckedApiFile d.exportableApiFile = uncheckedApiFile
} }
} else if sourceApiFile := proptools.String(d.properties.Check_api.Current.Api_file); sourceApiFile != "" { } else if sourceApiFile := proptools.String(d.properties.Check_api.Current.Api_file); sourceApiFile != "" {
// If check api is disabled then make the source file available for export. if stubsType == Everything {
d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile) // If check api is disabled then make the source file available for export.
d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile)
} else if stubsType == Exportable {
d.exportableApiFile = uncheckedApiFile
}
} }
removedApiFileName := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt")
uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), removedApiFileName)
cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile)
if checkApi || String(d.properties.Removed_api_filename) != "" { if checkApi || String(d.properties.Removed_api_filename) != "" {
filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt")
uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile)
if stubsType == Everything { if stubsType == Everything {
d.removedApiFile = uncheckedRemovedFile d.removedApiFile = uncheckedRemovedFile
} else if stubsType == Exportable { } else if stubsType == Exportable {
d.exportableRemovedApiFile = uncheckedRemovedFile d.exportableRemovedApiFile = uncheckedRemovedFile
} }
} else if sourceRemovedApiFile := proptools.String(d.properties.Check_api.Current.Removed_api_file); sourceRemovedApiFile != "" { } else if sourceRemovedApiFile := proptools.String(d.properties.Check_api.Current.Removed_api_file); sourceRemovedApiFile != "" {
// If check api is disabled then make the source removed api file available for export. if stubsType == Everything {
d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile) // If check api is disabled then make the source removed api file available for export.
d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile)
} else if stubsType == Exportable {
d.exportableRemovedApiFile = uncheckedRemovedFile
}
} }
if stubsDir.Valid() { if stubsDir.Valid() {