Merge "Support opt-in ABI checks"

This commit is contained in:
Logan Chien
2019-04-29 17:40:06 +00:00
committed by Gerrit Code Review
5 changed files with 49 additions and 18 deletions

View File

@@ -967,7 +967,7 @@ func pathForModule(ctx ModuleContext) OutputPath {
// PathForVndkRefAbiDump returns an OptionalPath representing the path of the // PathForVndkRefAbiDump returns an OptionalPath representing the path of the
// reference 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, func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string,
isLlndk, isGzip bool) OptionalPath { isLlndkOrNdk, isVndk, isGzip bool) OptionalPath {
arches := ctx.DeviceConfig().Arches() arches := ctx.DeviceConfig().Arches()
if len(arches) == 0 { if len(arches) == 0 {
@@ -980,10 +980,12 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string,
} }
var dirName string var dirName string
if isLlndk { if isLlndkOrNdk {
dirName = "ndk" dirName = "ndk"
} else { } else if isVndk {
dirName = "vndk" dirName = "vndk"
} else {
dirName = "platform" // opt-in libs
} }
binderBitness := ctx.DeviceConfig().BinderBitness() binderBitness := ctx.DeviceConfig().BinderBitness()

View File

@@ -1184,8 +1184,11 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk") fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
} else if fi.class == nativeSharedLib || fi.class == nativeExecutable { } else if fi.class == nativeSharedLib || fi.class == nativeExecutable {
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.builtFile.Base())
if cc, ok := fi.module.(*cc.Module); ok && cc.UnstrippedOutputFile() != nil { if cc, ok := fi.module.(*cc.Module); ok {
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String()) if cc.UnstrippedOutputFile() != nil {
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", cc.UnstrippedOutputFile().String())
}
cc.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
} }
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk") fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
} else { } else {

View File

@@ -145,6 +145,16 @@ func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
} }
} }
func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
if library.sAbiOutputFile.Valid() {
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiOutputFile.String())
if library.sAbiDiff.Valid() && !library.static() {
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
fmt.Fprintln(w, "HEADER_ABI_DIFFS +=", library.sAbiDiff.String())
}
}
}
func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
if library.static() { if library.static() {
ret.Class = "STATIC_LIBRARIES" ret.Class = "STATIC_LIBRARIES"
@@ -169,14 +179,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
ret.DistFile = library.distFile ret.DistFile = library.distFile
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
library.androidMkWriteExportedFlags(w) library.androidMkWriteExportedFlags(w)
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ") library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
if library.sAbiOutputFile.Valid() {
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
if library.sAbiDiff.Valid() && !library.static() {
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
}
}
_, _, ext := splitFileExt(outputFile.Base()) _, _, ext := splitFileExt(outputFile.Base())

View File

@@ -19,6 +19,7 @@ package cc
// is handled in builder.go // is handled in builder.go
import ( import (
"io"
"strconv" "strconv"
"strings" "strings"
@@ -1966,6 +1967,14 @@ func (c *Module) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Srcs = append(dpInfo.Srcs, c.Srcs().Strings()...) dpInfo.Srcs = append(dpInfo.Srcs, c.Srcs().Strings()...)
} }
func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
if c.linker != nil {
if library, ok := c.linker.(*libraryDecorator); ok {
library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
}
}
}
// //
// Defaults // Defaults
// //

View File

@@ -15,6 +15,7 @@
package cc package cc
import ( import (
"io"
"path/filepath" "path/filepath"
"regexp" "regexp"
"sort" "sort"
@@ -96,6 +97,9 @@ type LibraryProperties struct {
// Properties for ABI compatibility checker // Properties for ABI compatibility checker
Header_abi_checker struct { Header_abi_checker struct {
// Enable ABI checks (even if this is not an LLNDK/VNDK lib)
Enabled *bool
// Path to a symbol file that specifies the symbols to be included in the generated // Path to a symbol file that specifies the symbols to be included in the generated
// ABI dump file // ABI dump file
Symbol_file *string `android:"path"` Symbol_file *string `android:"path"`
@@ -421,6 +425,13 @@ func extractExportIncludesFromFlags(flags []string) []string {
return exportedIncludes return exportedIncludes
} }
func (library *libraryDecorator) shouldCreateVndkSourceAbiDump(ctx ModuleContext) bool {
if library.Properties.Header_abi_checker.Enabled != nil {
return Bool(library.Properties.Header_abi_checker.Enabled)
}
return ctx.shouldCreateVndkSourceAbiDump()
}
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
if library.buildStubs() { if library.buildStubs() {
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex") objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
@@ -440,7 +451,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
} }
return Objects{} return Objects{}
} }
if ctx.shouldCreateVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps { if library.shouldCreateVndkSourceAbiDump(ctx) || library.sabi.Properties.CreateSAbiDumps {
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
var SourceAbiFlags []string var SourceAbiFlags []string
for _, dir := range exportIncludeDirs.Strings() { for _, dir := range exportIncludeDirs.Strings() {
@@ -487,6 +498,9 @@ type libraryInterface interface {
// Sets whether a specific variant is static or shared // Sets whether a specific variant is static or shared
setStatic() setStatic()
setShared() setShared()
// Write LOCAL_ADDITIONAL_DEPENDENCIES for ABI diff
androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer)
} }
func (library *libraryDecorator) getLibName(ctx ModuleContext) string { func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
@@ -769,10 +783,10 @@ func (library *libraryDecorator) nativeCoverage() bool {
} }
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path { func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
isLlndk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs) isLlndkOrNdk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs)
refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, false) refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), false)
refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, true) refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndkOrNdk, ctx.isVndk(), true)
if refAbiDumpTextFile.Valid() { if refAbiDumpTextFile.Valid() {
if refAbiDumpGzipFile.Valid() { if refAbiDumpGzipFile.Valid() {
@@ -790,7 +804,7 @@ func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.
} }
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 && library.shouldCreateVndkSourceAbiDump(ctx) {
vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() vndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
if ver := ctx.DeviceConfig().VndkVersion(); ver != "" && ver != "current" { if ver := ctx.DeviceConfig().VndkVersion(); ver != "" && ver != "current" {
vndkVersion = ver vndkVersion = ver