Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf9c26c3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I1270e8d0,I61731a5e

* changes:
  Move function PathForVndkRefAbiDump to Prevent unnecessary exports in paths.go
  Change the type of parameter prevVersion to int in sourceAbiDump
parents 7b181b33 f5ed30b2
Loading
Loading
Loading
Loading
+0 −35
Original line number Diff line number Diff line
@@ -1474,41 +1474,6 @@ func pathForModuleOut(ctx ModuleOutPathContext) OutputPath {
	return PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir())
}

// 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 ModuleInstallPathContext, version, fileName string,
	isNdk, isVndk, isGzip bool) OptionalPath {

	currentArchType := ctx.Arch().ArchType
	primaryArchType := ctx.Config().DevicePrimaryArchType()
	archName := currentArchType.String()
	if currentArchType != primaryArchType {
		archName += "_" + primaryArchType.String()
	}

	var dirName string
	if isNdk {
		dirName = "ndk"
	} else if isVndk {
		dirName = "vndk"
	} else {
		dirName = "platform" // opt-in libs
	}

	binderBitness := ctx.DeviceConfig().BinderBitness()

	var ext string
	if isGzip {
		ext = ".lsdump.gz"
	} else {
		ext = ".lsdump"
	}

	return ExistentPathForSource(ctx, "prebuilts", "abi-dumps", dirName,
		version, binderBitness, archName, "source-based",
		fileName+ext)
}

// PathForModuleOut returns a Path representing the paths... under the module's
// output directory.
func PathForModuleOut(ctx ModuleOutPathContext, paths ...string) ModuleOutPath {
+7 −10
Original line number Diff line number Diff line
@@ -920,14 +920,14 @@ func unzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseNam

// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump).
func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
	baseName, prevVersion, exportedHeaderFlags string, diffFlags []string,
	baseName, exportedHeaderFlags string, diffFlags []string, prevVersion int,
	checkAllApis, isLlndk, isNdk, isVndkExt, previousVersionDiff bool) android.OptionalPath {

	var outputFile android.ModuleOutPath
	if prevVersion == "" {
		outputFile = android.PathForModuleOut(ctx, baseName+".abidiff")
	if previousVersionDiff {
		outputFile = android.PathForModuleOut(ctx, baseName+"."+strconv.Itoa(prevVersion)+".abidiff")
	} else {
		outputFile = android.PathForModuleOut(ctx, baseName+"."+prevVersion+".abidiff")
		outputFile = android.PathForModuleOut(ctx, baseName+".abidiff")
	}
	libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))

@@ -946,12 +946,9 @@ func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceD
	if previousVersionDiff {
		// TODO(b/241496591): Remove -advice-only after b/239792343 and b/239790286 are reolved.
		extraFlags = append(extraFlags, "-advice-only")
		errorMessage = "error: Please follow development/vndk/tools/header-checker/README.md to ensure the ABI compatibility between your source code and version " + prevVersion + "."
		// The prevVersion is expected as a string of int, skip it if not.
		if prevVersionInt, err := strconv.Atoi(prevVersion); err == nil {
			sourceVersion := strconv.Itoa(prevVersionInt + 1)
			extraFlags = append(extraFlags, "-target-version", sourceVersion)
		}
		errorMessage = "error: Please follow development/vndk/tools/header-checker/README.md to ensure the ABI compatibility between your source code and version " + strconv.Itoa(prevVersion) + "."
		sourceVersion := prevVersion + 1
		extraFlags = append(extraFlags, "-target-version", strconv.Itoa(sourceVersion))
	} else {
		errorMessage = "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
		extraFlags = append(extraFlags, "-target-version", "current")
+49 −12
Original line number Diff line number Diff line
@@ -1632,13 +1632,48 @@ func (library *libraryDecorator) coverageOutputFilePath() android.OptionalPath {
	return library.coverageOutputFile
}

// 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 android.ModuleInstallPathContext, version, fileName string,
	isNdk, isVndk, isGzip bool) android.OptionalPath {

	currentArchType := ctx.Arch().ArchType
	primaryArchType := ctx.Config().DevicePrimaryArchType()
	archName := currentArchType.String()
	if currentArchType != primaryArchType {
		archName += "_" + primaryArchType.String()
	}

	var dirName string
	if isNdk {
		dirName = "ndk"
	} else if isVndk {
		dirName = "vndk"
	} else {
		dirName = "platform" // opt-in libs
	}

	binderBitness := ctx.DeviceConfig().BinderBitness()

	var ext string
	if isGzip {
		ext = ".lsdump.gz"
	} else {
		ext = ".lsdump"
	}

	return android.ExistentPathForSource(ctx, "prebuilts", "abi-dumps", dirName,
		version, binderBitness, archName, "source-based",
		fileName+ext)
}

func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
	// The logic must be consistent with classifySourceAbiDump.
	isNdk := ctx.isNdk(ctx.Config())
	isVndk := ctx.useVndk() && ctx.isVndk()

	refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isVndk, false)
	refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isVndk, true)
	refAbiDumpTextFile := pathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isVndk, false)
	refAbiDumpGzipFile := pathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isVndk, true)

	if refAbiDumpTextFile.Valid() {
		if refAbiDumpGzipFile.Valid() {
@@ -1655,12 +1690,12 @@ func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.
	return nil
}

func prevDumpRefVersion(ctx ModuleContext) string {
func prevDumpRefVersion(ctx ModuleContext) int {
	sdkVersionInt := ctx.Config().PlatformSdkVersion().FinalInt()
	sdkVersionStr := ctx.Config().PlatformSdkVersion().String()

	if ctx.Config().PlatformSdkFinal() {
		return strconv.Itoa(sdkVersionInt - 1)
		return sdkVersionInt - 1
	} else {
		var dirName string

@@ -1676,9 +1711,9 @@ func prevDumpRefVersion(ctx ModuleContext) string {
		// This situation could be identified by checking the existence of the PLATFORM_SDK_VERION dump directory.
		refDumpDir := android.ExistentPathForSource(ctx, "prebuilts", "abi-dumps", dirName, sdkVersionStr)
		if refDumpDir.Valid() {
			return sdkVersionStr
			return sdkVersionInt
		} else {
			return strconv.Itoa(sdkVersionInt - 1)
			return sdkVersionInt - 1
		}
	}
}
@@ -1686,7 +1721,7 @@ func prevDumpRefVersion(ctx ModuleContext) string {
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
	if library.sabi.shouldCreateSourceAbiDump() {
		var version string
		var prevVersion string
		var prevVersion int

		if ctx.useVndk() {
			// For modules linking against vndk, follow its vndk version
@@ -1718,12 +1753,13 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec

		addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())

		if prevVersion != "" {
			prevRefAbiDumpFile := getRefAbiDumpFile(ctx, prevVersion, fileName)
		// If NDK or PLATFORM library, check against previous version ABI.
		if !ctx.useVndk() {
			prevRefAbiDumpFile := getRefAbiDumpFile(ctx, strconv.Itoa(prevVersion), fileName)
			if prevRefAbiDumpFile != nil {
				library.prevSAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
					prevRefAbiDumpFile, fileName, prevVersion, exportedHeaderFlags,
					library.Properties.Header_abi_checker.Diff_flags,
					prevRefAbiDumpFile, fileName, exportedHeaderFlags,
					library.Properties.Header_abi_checker.Diff_flags, prevVersion,
					Bool(library.Properties.Header_abi_checker.Check_all_apis),
					ctx.IsLlndk(), ctx.isNdk(ctx.Config()), ctx.IsVndkExt(), true)
			}
@@ -1732,8 +1768,9 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
		refAbiDumpFile := getRefAbiDumpFile(ctx, version, fileName)
		if refAbiDumpFile != nil {
			library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
				refAbiDumpFile, fileName, "", exportedHeaderFlags,
				refAbiDumpFile, fileName, exportedHeaderFlags,
				library.Properties.Header_abi_checker.Diff_flags,
				/* unused if not previousVersionDiff */ 0,
				Bool(library.Properties.Header_abi_checker.Check_all_apis),
				ctx.IsLlndk(), ctx.isNdk(ctx.Config()), ctx.IsVndkExt(), false)
		}