Refactor header ABI checker code
- Extract duplicate code into exportedIncludeDirsForAbiCheck. - Convert libraryDecorator.sAbiOutputFile to a local variable. Test: make Bug: 314010764 Change-Id: I99a0352b11347ad363df5645ba8e0faf9bc9a0aa
This commit is contained in:
parent
6954bd2337
commit
af369886e5
2 changed files with 35 additions and 45 deletions
|
@ -854,14 +854,15 @@ func transformObjToDynamicBinary(ctx android.ModuleContext,
|
||||||
// Generate a rule to combine .dump sAbi dump files from multiple source files
|
// Generate a rule to combine .dump sAbi dump files from multiple source files
|
||||||
// into a single .ldump sAbi dump file
|
// into a single .ldump sAbi dump file
|
||||||
func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
|
func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
|
||||||
baseName, exportedHeaderFlags string, symbolFile android.OptionalPath,
|
baseName string, exportedIncludeDirs []string, symbolFile android.OptionalPath,
|
||||||
excludedSymbolVersions, excludedSymbolTags []string,
|
excludedSymbolVersions, excludedSymbolTags []string,
|
||||||
api string) android.OptionalPath {
|
api string) android.Path {
|
||||||
|
|
||||||
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
|
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
|
||||||
|
|
||||||
implicits := android.Paths{soFile}
|
implicits := android.Paths{soFile}
|
||||||
symbolFilterStr := "-so " + soFile.String()
|
symbolFilterStr := "-so " + soFile.String()
|
||||||
|
exportedHeaderFlags := android.JoinWithPrefix(exportedIncludeDirs, "-I")
|
||||||
|
|
||||||
if symbolFile.Valid() {
|
if symbolFile.Valid() {
|
||||||
implicits = append(implicits, symbolFile.Path())
|
implicits = append(implicits, symbolFile.Path())
|
||||||
|
@ -886,13 +887,7 @@ func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
|
||||||
}
|
}
|
||||||
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_LINKER") {
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_LINKER") {
|
||||||
rule = sAbiLinkRE
|
rule = sAbiLinkRE
|
||||||
rbeImplicits := implicits.Strings()
|
rbeImplicits := append(implicits.Strings(), exportedIncludeDirs...)
|
||||||
for _, p := range strings.Split(exportedHeaderFlags, " ") {
|
|
||||||
if len(p) > 2 {
|
|
||||||
// Exclude the -I prefix.
|
|
||||||
rbeImplicits = append(rbeImplicits, p[2:])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args["implicitInputs"] = strings.Join(rbeImplicits, ",")
|
args["implicitInputs"] = strings.Join(rbeImplicits, ",")
|
||||||
}
|
}
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
@ -903,7 +898,7 @@ func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
|
||||||
Implicits: implicits,
|
Implicits: implicits,
|
||||||
Args: args,
|
Args: args,
|
||||||
})
|
})
|
||||||
return android.OptionalPathForPath(outputFile)
|
return outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformAbiDumpToAbiDiff(ctx android.ModuleContext, inputDump, referenceDump android.Path,
|
func transformAbiDumpToAbiDiff(ctx android.ModuleContext, inputDump, referenceDump android.Path,
|
||||||
|
|
|
@ -390,9 +390,6 @@ type libraryDecorator struct {
|
||||||
// Output archive of gcno coverage information files
|
// Output archive of gcno coverage information files
|
||||||
coverageOutputFile android.OptionalPath
|
coverageOutputFile android.OptionalPath
|
||||||
|
|
||||||
// linked Source Abi Dump
|
|
||||||
sAbiOutputFile android.OptionalPath
|
|
||||||
|
|
||||||
// Source Abi Diff
|
// Source Abi Diff
|
||||||
sAbiDiff android.Paths
|
sAbiDiff android.Paths
|
||||||
|
|
||||||
|
@ -756,15 +753,11 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
||||||
return Objects{}
|
return Objects{}
|
||||||
}
|
}
|
||||||
if library.sabi.shouldCreateSourceAbiDump() {
|
if library.sabi.shouldCreateSourceAbiDump() {
|
||||||
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
|
dirs := library.exportedIncludeDirsForAbiCheck(ctx)
|
||||||
var SourceAbiFlags []string
|
flags.SAbiFlags = make([]string, 0, len(dirs))
|
||||||
for _, dir := range exportIncludeDirs.Strings() {
|
for _, dir := range dirs {
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir)
|
||||||
}
|
}
|
||||||
for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes {
|
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude)
|
|
||||||
}
|
|
||||||
flags.SAbiFlags = SourceAbiFlags
|
|
||||||
totalLength := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) +
|
totalLength := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) +
|
||||||
len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs)
|
len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs)
|
||||||
if totalLength > 0 {
|
if totalLength > 0 {
|
||||||
|
@ -1338,6 +1331,12 @@ func (library *libraryDecorator) coverageOutputFilePath() android.OptionalPath {
|
||||||
return library.coverageOutputFile
|
return library.coverageOutputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) exportedIncludeDirsForAbiCheck(ctx ModuleContext) []string {
|
||||||
|
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx).Strings()
|
||||||
|
exportIncludeDirs = append(exportIncludeDirs, library.sabi.Properties.ReexportedIncludes...)
|
||||||
|
return exportIncludeDirs
|
||||||
|
}
|
||||||
|
|
||||||
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
|
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
|
||||||
versionedDumpDir, fileName string) android.OptionalPath {
|
versionedDumpDir, fileName string) android.OptionalPath {
|
||||||
|
|
||||||
|
@ -1384,12 +1383,11 @@ func currRefAbiDumpSdkVersion(ctx ModuleContext) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump).
|
// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump).
|
||||||
func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
|
func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext,
|
||||||
|
sourceDump, referenceDump android.Path,
|
||||||
baseName, nameExt string, isLlndkOrNdk, allowExtensions bool,
|
baseName, nameExt string, isLlndkOrNdk, allowExtensions bool,
|
||||||
sourceVersion, errorMessage string) {
|
sourceVersion, errorMessage string) {
|
||||||
|
|
||||||
sourceDump := library.sAbiOutputFile.Path()
|
|
||||||
|
|
||||||
extraFlags := []string{"-target-version", sourceVersion}
|
extraFlags := []string{"-target-version", sourceVersion}
|
||||||
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
|
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
|
||||||
if Bool(headerAbiChecker.Check_all_apis) {
|
if Bool(headerAbiChecker.Check_all_apis) {
|
||||||
|
@ -1413,26 +1411,29 @@ func (library *libraryDecorator) sourceAbiDiff(ctx android.ModuleContext, refere
|
||||||
baseName, nameExt, extraFlags, errorMessage))
|
baseName, nameExt, extraFlags, errorMessage))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
|
func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext,
|
||||||
|
sourceDump, referenceDump android.Path,
|
||||||
baseName string, isLlndkOrNdk bool, sourceVersion, prevVersion string) {
|
baseName string, isLlndkOrNdk bool, sourceVersion, prevVersion string) {
|
||||||
|
|
||||||
errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/main/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "."
|
errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/main/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "."
|
||||||
|
|
||||||
library.sourceAbiDiff(ctx, referenceDump, baseName, prevVersion,
|
library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, prevVersion,
|
||||||
isLlndkOrNdk, true /* allowExtensions */, sourceVersion, errorMessage)
|
isLlndkOrNdk, true /* allowExtensions */, sourceVersion, errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
|
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext,
|
||||||
|
sourceDump, referenceDump android.Path,
|
||||||
baseName, nameExt string, isLlndkOrNdk bool) {
|
baseName, nameExt string, isLlndkOrNdk bool) {
|
||||||
|
|
||||||
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
|
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
|
||||||
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
|
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
|
||||||
|
|
||||||
library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
|
library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, nameExt,
|
||||||
isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
|
isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
|
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext,
|
||||||
|
sourceDump, referenceDump android.Path,
|
||||||
baseName, nameExt string, refDumpDir string) {
|
baseName, nameExt string, refDumpDir string) {
|
||||||
|
|
||||||
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
|
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
|
||||||
|
@ -1442,33 +1443,26 @@ func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referen
|
||||||
errorMessage += " -products " + ctx.Config().DeviceProduct()
|
errorMessage += " -products " + ctx.Config().DeviceProduct()
|
||||||
}
|
}
|
||||||
|
|
||||||
library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
|
library.sourceAbiDiff(ctx, sourceDump, referenceDump, baseName, nameExt,
|
||||||
false /* isLlndkOrNdk */, false /* allowExtensions */, "current", errorMessage)
|
false /* isLlndkOrNdk */, false /* allowExtensions */, "current", errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
|
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
|
||||||
if library.sabi.shouldCreateSourceAbiDump() {
|
if library.sabi.shouldCreateSourceAbiDump() {
|
||||||
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
|
exportedIncludeDirs := library.exportedIncludeDirsForAbiCheck(ctx)
|
||||||
var SourceAbiFlags []string
|
|
||||||
for _, dir := range exportIncludeDirs.Strings() {
|
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
|
||||||
}
|
|
||||||
for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes {
|
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude)
|
|
||||||
}
|
|
||||||
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
|
|
||||||
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
|
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
|
||||||
currSdkVersion := currRefAbiDumpSdkVersion(ctx)
|
currSdkVersion := currRefAbiDumpSdkVersion(ctx)
|
||||||
currVendorVersion := ctx.Config().VendorApiLevel()
|
currVendorVersion := ctx.Config().VendorApiLevel()
|
||||||
library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
|
sourceDump := transformDumpToLinkedDump(ctx,
|
||||||
|
objs.sAbiDumpFiles, soFile, fileName,
|
||||||
|
exportedIncludeDirs,
|
||||||
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
|
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
|
||||||
headerAbiChecker.Exclude_symbol_versions,
|
headerAbiChecker.Exclude_symbol_versions,
|
||||||
headerAbiChecker.Exclude_symbol_tags,
|
headerAbiChecker.Exclude_symbol_tags,
|
||||||
currSdkVersion)
|
currSdkVersion)
|
||||||
|
|
||||||
for _, tag := range classifySourceAbiDump(ctx) {
|
for _, tag := range classifySourceAbiDump(ctx) {
|
||||||
addLsdumpPath(string(tag) + ":" + library.sAbiOutputFile.String())
|
addLsdumpPath(string(tag) + ":" + sourceDump.String())
|
||||||
|
|
||||||
dumpDirName := tag.dirName()
|
dumpDirName := tag.dirName()
|
||||||
if dumpDirName == "" {
|
if dumpDirName == "" {
|
||||||
continue
|
continue
|
||||||
|
@ -1493,7 +1487,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
|
||||||
prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
|
prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
|
||||||
prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
|
prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
|
||||||
if prevDumpFile.Valid() {
|
if prevDumpFile.Valid() {
|
||||||
library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
|
library.crossVersionAbiDiff(ctx, sourceDump, prevDumpFile.Path(),
|
||||||
fileName, isLlndk || isNdk, currVersion, nameExt+prevVersion)
|
fileName, isLlndk || isNdk, currVersion, nameExt+prevVersion)
|
||||||
}
|
}
|
||||||
// Check against the current version.
|
// Check against the current version.
|
||||||
|
@ -1505,7 +1499,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
|
||||||
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
|
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
|
||||||
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
|
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
|
||||||
if currDumpFile.Valid() {
|
if currDumpFile.Valid() {
|
||||||
library.sameVersionAbiDiff(ctx, currDumpFile.Path(),
|
library.sameVersionAbiDiff(ctx, sourceDump, currDumpFile.Path(),
|
||||||
fileName, nameExt, isLlndk || isNdk)
|
fileName, nameExt, isLlndk || isNdk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1518,7 +1512,8 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
|
||||||
if !optInDumpFile.Valid() {
|
if !optInDumpFile.Valid() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
library.optInAbiDiff(ctx, optInDumpFile.Path(),
|
library.optInAbiDiff(ctx,
|
||||||
|
sourceDump, optInDumpFile.Path(),
|
||||||
fileName, "opt"+strconv.Itoa(i), optInDumpDirPath.String())
|
fileName, "opt"+strconv.Itoa(i), optInDumpDirPath.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue