Support text ABI dump file format

This commit adds an option to read ABI reference dump in text file
format directly from `prebuilts/abi-dumps`.  If both the text file and
the gzip format exist, an error will be emitted.

Bug: 78650426
Test: create libexif.lsdump.gz and it works as usual
Test: create libexif.lsdump (decompressed) and it works
Test: touch both libexif.lsdump.gz and libexif.lsdump and it errors
Change-Id: I420a5953fb80855cb5c07e5a4d347fb6709f0340
This commit is contained in:
Logan Chien
2018-07-11 18:10:41 +08:00
parent 5237bed1c4
commit 7eefdc4ed2
2 changed files with 43 additions and 15 deletions

View File

@@ -826,10 +826,15 @@ func pathForModule(ctx ModuleContext) OutputPath {
return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir()) return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir())
} }
// PathForVndkRefDump returns an OptionalPath representing the path of the reference // PathForVndkRefAbiDump returns an OptionalPath representing the path of the
// abi dump for the given module. This is not guaranteed to be valid. // reference abi dump for the given module. This is not guaranteed to be valid.
func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, isLlndk bool) OptionalPath { func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string,
isLlndk, isGzip bool) OptionalPath {
arches := ctx.DeviceConfig().Arches() arches := ctx.DeviceConfig().Arches()
if len(arches) == 0 {
panic("device build with no primary arch")
}
currentArch := ctx.Arch() currentArch := ctx.Arch()
archNameAndVariant := currentArch.ArchType.String() archNameAndVariant := currentArch.ArchType.String()
if currentArch.ArchVariant != "" { if currentArch.ArchVariant != "" {
@@ -843,14 +848,18 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, isLlndk
dirName = "vndk" dirName = "vndk"
} }
if len(arches) == 0 {
panic("device build with no primary arch")
}
binderBitness := ctx.DeviceConfig().BinderBitness() binderBitness := ctx.DeviceConfig().BinderBitness()
ext := ".lsdump.gz"
refDumpFileStr := "prebuilts/abi-dumps/" + dirName + "/" + version + "/" + binderBitness + "/" + var ext string
archNameAndVariant + "/source-based/" + fileName + ext if isGzip {
return ExistentPathForSource(ctx, refDumpFileStr) ext = ".lsdump.gz"
} else {
ext = ".lsdump"
}
return ExistentPathForSource(ctx, "prebuilts", "abi-dumps", dirName,
version, binderBitness, archNameAndVariant, "source-based",
fileName+ext)
} }
// PathForModuleOut returns a Path representing the paths... under the module's // PathForModuleOut returns a Path representing the paths... under the module's

View File

@@ -631,6 +631,27 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
return ret return ret
} }
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
isLlndk := inList(ctx.baseModuleName(), llndkLibraries)
refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, false)
refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, true)
if refAbiDumpTextFile.Valid() {
if refAbiDumpGzipFile.Valid() {
ctx.ModuleErrorf(
"Two reference ABI dump files are found: %q and %q. Please delete the stale one.",
refAbiDumpTextFile, refAbiDumpGzipFile)
return nil
}
return refAbiDumpTextFile.Path()
}
if refAbiDumpGzipFile.Valid() {
return UnzipRefDump(ctx, refAbiDumpGzipFile.Path(), fileName)
}
return nil
}
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 len(objs.sAbiDumpFiles) > 0 && ctx.shouldCreateVndkSourceAbiDump() { if len(objs.sAbiDumpFiles) > 0 && ctx.shouldCreateVndkSourceAbiDump() {
vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() vndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
@@ -649,12 +670,10 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags) library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags)
isLlndk := inList(ctx.baseModuleName(), llndkLibraries) refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk) if refAbiDumpFile != nil {
if refSourceDumpFile.Valid() {
unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName)
library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
unzippedRefDump, fileName, exportedHeaderFlags, ctx.isVndkExt()) refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isVndkExt())
} }
} }
} }