From 83c415f9553be10b3ac3c6227203c9387c6c1769 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Wed, 11 Jul 2018 15:27:36 +0800 Subject: [PATCH 1/3] Remove isSourceDump from PathForVndkRefAbiDump() This commit removes `isSourceDump` from `PathForVndkRefAbiDump()` because the binary dump paths are not being used at all. Test: lunch aosp_arm64_ab-userdebug && make Change-Id: I7a6bb9053a6b052590fb1152982949fee897df8d --- android/paths.go | 14 +++----------- cc/library.go | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/android/paths.go b/android/paths.go index af2f9567a..f478bddb6 100644 --- a/android/paths.go +++ b/android/paths.go @@ -828,23 +828,14 @@ func pathForModule(ctx ModuleContext) OutputPath { // PathForVndkRefDump returns an OptionalPath representing the path of the reference // abi dump for the given module. This is not guaranteed to be valid. -func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNdk, isSourceDump bool) OptionalPath { +func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNdk bool) OptionalPath { arches := ctx.DeviceConfig().Arches() currentArch := ctx.Arch() archNameAndVariant := currentArch.ArchType.String() if currentArch.ArchVariant != "" { archNameAndVariant += "_" + currentArch.ArchVariant } - var sourceOrBinaryDir string var vndkOrNdkDir string - var ext string - if isSourceDump { - ext = ".lsdump.gz" - sourceOrBinaryDir = "source-based" - } else { - ext = ".bdump.gz" - sourceOrBinaryDir = "binary-based" - } if vndkOrNdk { vndkOrNdkDir = "vndk" } else { @@ -854,8 +845,9 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNd panic("device build with no primary arch") } binderBitness := ctx.DeviceConfig().BinderBitness() + ext := ".lsdump.gz" refDumpFileStr := "prebuilts/abi-dumps/" + vndkOrNdkDir + "/" + version + "/" + binderBitness + "/" + - archNameAndVariant + "/" + sourceOrBinaryDir + "/" + fileName + ext + archNameAndVariant + "/source-based/" + fileName + ext return ExistentPathForSource(ctx, refDumpFileStr) } diff --git a/cc/library.go b/cc/library.go index e92cf9d1f..377be410a 100644 --- a/cc/library.go +++ b/cc/library.go @@ -649,7 +649,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags) - refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, vndkVsNdk(ctx), true) + refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, vndkVsNdk(ctx)) if refSourceDumpFile.Valid() { unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName) library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), From 5237bed1c4645212dd8c1858629af03b59d980a8 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Wed, 11 Jul 2018 17:15:57 +0800 Subject: [PATCH 2/3] Remove vndkVsNdk() This commmit removes `vndkVsNdk()`, which is essentially `!inList(ctx.baseModuleName(), llndkLibraries)`. Test: lunch aosp_arm64_ab-userdebug && make Change-Id: I8e2352f302df30057997944678f176f4550d3f75 --- android/paths.go | 14 ++++++++------ cc/library.go | 10 ++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/android/paths.go b/android/paths.go index f478bddb6..f321a4b46 100644 --- a/android/paths.go +++ b/android/paths.go @@ -828,25 +828,27 @@ func pathForModule(ctx ModuleContext) OutputPath { // PathForVndkRefDump returns an OptionalPath representing the path of the reference // abi dump for the given module. This is not guaranteed to be valid. -func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNdk bool) OptionalPath { +func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, isLlndk bool) OptionalPath { arches := ctx.DeviceConfig().Arches() currentArch := ctx.Arch() archNameAndVariant := currentArch.ArchType.String() if currentArch.ArchVariant != "" { archNameAndVariant += "_" + currentArch.ArchVariant } - var vndkOrNdkDir string - if vndkOrNdk { - vndkOrNdkDir = "vndk" + + var dirName string + if isLlndk { + dirName = "ndk" } else { - vndkOrNdkDir = "ndk" + dirName = "vndk" } + if len(arches) == 0 { panic("device build with no primary arch") } binderBitness := ctx.DeviceConfig().BinderBitness() ext := ".lsdump.gz" - refDumpFileStr := "prebuilts/abi-dumps/" + vndkOrNdkDir + "/" + version + "/" + binderBitness + "/" + + refDumpFileStr := "prebuilts/abi-dumps/" + dirName + "/" + version + "/" + binderBitness + "/" + archNameAndVariant + "/source-based/" + fileName + ext return ExistentPathForSource(ctx, refDumpFileStr) } diff --git a/cc/library.go b/cc/library.go index 377be410a..dcd9576e7 100644 --- a/cc/library.go +++ b/cc/library.go @@ -649,7 +649,8 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags) - refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, vndkVsNdk(ctx)) + isLlndk := inList(ctx.baseModuleName(), llndkLibraries) + refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk) if refSourceDumpFile.Valid() { unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName) library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), @@ -658,13 +659,6 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec } } -func vndkVsNdk(ctx ModuleContext) bool { - if inList(ctx.baseModuleName(), llndkLibraries) { - return false - } - return true -} - func (library *libraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { From 7eefdc4ed29286de3e643fb3da58a2eb0d0975e7 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Wed, 11 Jul 2018 18:10:41 +0800 Subject: [PATCH 3/3] 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 --- android/paths.go | 29 +++++++++++++++++++---------- cc/library.go | 29 ++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/android/paths.go b/android/paths.go index f321a4b46..31c5977ee 100644 --- a/android/paths.go +++ b/android/paths.go @@ -826,10 +826,15 @@ func pathForModule(ctx ModuleContext) OutputPath { return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir()) } -// PathForVndkRefDump returns an OptionalPath representing the path of the reference -// abi dump for the given module. This is not guaranteed to be valid. -func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, isLlndk bool) OptionalPath { +// PathForVndkRefAbiDump returns an OptionalPath representing the path of the +// reference abi dump for the given module. This is not guaranteed to be valid. +func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, + isLlndk, isGzip bool) OptionalPath { + arches := ctx.DeviceConfig().Arches() + if len(arches) == 0 { + panic("device build with no primary arch") + } currentArch := ctx.Arch() archNameAndVariant := currentArch.ArchType.String() if currentArch.ArchVariant != "" { @@ -843,14 +848,18 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, isLlndk dirName = "vndk" } - if len(arches) == 0 { - panic("device build with no primary arch") - } binderBitness := ctx.DeviceConfig().BinderBitness() - ext := ".lsdump.gz" - refDumpFileStr := "prebuilts/abi-dumps/" + dirName + "/" + version + "/" + binderBitness + "/" + - archNameAndVariant + "/source-based/" + fileName + ext - return ExistentPathForSource(ctx, refDumpFileStr) + + var ext string + if isGzip { + 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 diff --git a/cc/library.go b/cc/library.go index dcd9576e7..5da36dc66 100644 --- a/cc/library.go +++ b/cc/library.go @@ -631,6 +631,27 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, 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) { if len(objs.sAbiDumpFiles) > 0 && ctx.shouldCreateVndkSourceAbiDump() { vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() @@ -649,12 +670,10 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags) - isLlndk := inList(ctx.baseModuleName(), llndkLibraries) - refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk) - if refSourceDumpFile.Valid() { - unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName) + refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName) + if refAbiDumpFile != nil { library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), - unzippedRefDump, fileName, exportedHeaderFlags, ctx.isVndkExt()) + refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isVndkExt()) } } }