summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hsin-Yi Chen <hsinyichen@google.com> 2024-04-14 19:08:17 +0800
committer Hsin-Yi Chen <hsinyichen@google.com> 2024-04-25 17:57:29 +0800
commit98da02128ce0411ccebec65de140f317e0c3efd6 (patch)
tree5a8e6d5787e6e6f3ddd62c6a0dfbaa688c634521
parentc0df1afc072373446e204ff3e471abb25dd9175c (diff)
Split APEX ABI dumps from implementation ABI dumps
This commit adds a rule that builds APEX ABI dumps separately from the implementation libraries' ABI dumps. The rule takes the export_include_dirs and the symbol_file of the stubs as parameters. The dump paths are tagged with "APEX" in lsdump_paths.txt. The script updating the prebuilt reference dumps can differentiate the APEX dumps from the opt-in dumps tagged with "PLATFORM". This commit also adds an ABI diff rule. Soong compares the APEX ABI dumps with the reference dumps in version 35. It compares the implementation dumps with the reference dumps in old versions. Bug: 333532038 Test: make Change-Id: I76902a8e3b7d0e96a5ad756f493924371cd7ad3c
-rw-r--r--cc/library.go50
-rw-r--r--cc/sabi.go11
2 files changed, 50 insertions, 11 deletions
diff --git a/cc/library.go b/cc/library.go
index 5b2480906..44bbdfcaf 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1261,6 +1261,18 @@ func (library *libraryDecorator) linkLlndkSAbiDumpFiles(ctx ModuleContext,
"34")
}
+func (library *libraryDecorator) linkApexSAbiDumpFiles(ctx ModuleContext,
+ deps PathDeps, sAbiDumpFiles android.Paths, soFile android.Path, libFileName string,
+ excludeSymbolVersions, excludeSymbolTags []string, sdkVersion string) android.Path {
+ return transformDumpToLinkedDump(ctx,
+ sAbiDumpFiles, soFile, libFileName+".apex",
+ library.exportedIncludeDirsForAbiCheck(ctx),
+ android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file),
+ append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
+ append([]string{"platform-only"}, excludeSymbolTags...),
+ sdkVersion)
+}
+
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
versionedDumpDir, fileName string) android.OptionalPath {
@@ -1276,21 +1288,21 @@ func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
}
// Return the previous and current SDK versions for cross-version ABI diff.
-func crossVersionAbiDiffSdkVersions(ctx ModuleContext, dumpDir string) (string, string) {
+func crossVersionAbiDiffSdkVersions(ctx ModuleContext, dumpDir string) (int, int) {
sdkVersionInt := ctx.Config().PlatformSdkVersion().FinalInt()
- sdkVersionStr := ctx.Config().PlatformSdkVersion().String()
if ctx.Config().PlatformSdkFinal() {
- return strconv.Itoa(sdkVersionInt - 1), sdkVersionStr
+ return sdkVersionInt - 1, sdkVersionInt
} else {
// The platform SDK version can be upgraded before finalization while the corresponding abi dumps hasn't
// been generated. Thus the Cross-Version Check chooses PLATFORM_SDK_VERION - 1 as previous version.
// This situation could be identified by checking the existence of the PLATFORM_SDK_VERION dump directory.
- versionedDumpDir := android.ExistentPathForSource(ctx, dumpDir, sdkVersionStr)
+ versionedDumpDir := android.ExistentPathForSource(ctx,
+ dumpDir, ctx.Config().PlatformSdkVersion().String())
if versionedDumpDir.Valid() {
- return sdkVersionStr, strconv.Itoa(sdkVersionInt + 1)
+ return sdkVersionInt, sdkVersionInt + 1
} else {
- return strconv.Itoa(sdkVersionInt - 1), sdkVersionStr
+ return sdkVersionInt - 1, sdkVersionInt
}
}
}
@@ -1387,7 +1399,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
headerAbiChecker.Exclude_symbol_tags,
currSdkVersion)
- var llndkDump android.Path
+ var llndkDump, apexVariantDump android.Path
tags := classifySourceAbiDump(ctx)
for _, tag := range tags {
if tag == llndkLsdumpTag {
@@ -1399,6 +1411,15 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
headerAbiChecker.Exclude_symbol_tags)
}
addLsdumpPath(string(tag) + ":" + llndkDump.String())
+ } else if tag == apexLsdumpTag {
+ if apexVariantDump == nil {
+ apexVariantDump = library.linkApexSAbiDumpFiles(ctx,
+ deps, objs.sAbiDumpFiles, soFile, fileName,
+ headerAbiChecker.Exclude_symbol_versions,
+ headerAbiChecker.Exclude_symbol_tags,
+ currSdkVersion)
+ }
+ addLsdumpPath(string(tag) + ":" + apexVariantDump.String())
} else {
addLsdumpPath(string(tag) + ":" + implDump.String())
}
@@ -1412,11 +1433,14 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
}
dumpDir := filepath.Join("prebuilts", "abi-dumps", dumpDirName)
isLlndk := (tag == llndkLsdumpTag)
+ isApex := (tag == apexLsdumpTag)
isNdk := (tag == ndkLsdumpTag)
binderBitness := ctx.DeviceConfig().BinderBitness()
nameExt := ""
if isLlndk {
nameExt = "llndk"
+ } else if isApex {
+ nameExt = "apex"
}
// Check against the previous version.
var prevVersion, currVersion string
@@ -1430,7 +1454,13 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
sourceDump = llndkDump
}
} else {
- prevVersion, currVersion = crossVersionAbiDiffSdkVersions(ctx, dumpDir)
+ prevVersionInt, currVersionInt := crossVersionAbiDiffSdkVersions(ctx, dumpDir)
+ prevVersion = strconv.Itoa(prevVersionInt)
+ currVersion = strconv.Itoa(currVersionInt)
+ // APEX dumps are generated by different rules after trunk stable.
+ if isApex && prevVersionInt > 34 {
+ sourceDump = apexVariantDump
+ }
}
prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
@@ -1447,6 +1477,10 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
}
} else {
currVersion = currSdkVersion
+ if isApex && (!ctx.Config().PlatformSdkFinal() ||
+ ctx.Config().PlatformSdkVersion().FinalInt() > 34) {
+ sourceDump = apexVariantDump
+ }
}
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
diff --git a/cc/sabi.go b/cc/sabi.go
index ef43c8daf..cd9bf6393 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -29,6 +29,7 @@ var (
type lsdumpTag string
const (
+ apexLsdumpTag lsdumpTag = "APEX"
llndkLsdumpTag lsdumpTag = "LLNDK"
ndkLsdumpTag lsdumpTag = "NDK"
platformLsdumpTag lsdumpTag = "PLATFORM"
@@ -39,6 +40,8 @@ const (
// Return the prebuilt ABI dump directory for a tag; an empty string for an opt-in dump.
func (tag *lsdumpTag) dirName() string {
switch *tag {
+ case apexLsdumpTag:
+ return "platform"
case ndkLsdumpTag:
return "ndk"
case llndkLsdumpTag:
@@ -134,11 +137,13 @@ func classifySourceAbiDump(ctx android.BaseModuleContext) []lsdumpTag {
if m.isImplementationForLLNDKPublic() {
result = append(result, llndkLsdumpTag)
}
- // Return NDK if the library is both NDK and APEX.
- // TODO(b/309880485): Split NDK and APEX ABI.
if m.IsNdk(ctx.Config()) {
result = append(result, ndkLsdumpTag)
- } else if m.library.hasStubsVariants() || headerAbiChecker.enabled() {
+ }
+ // APEX and opt-in platform dumps are placed in the same directory.
+ if m.library.hasStubsVariants() {
+ result = append(result, apexLsdumpTag)
+ } else if headerAbiChecker.enabled() {
result = append(result, platformLsdumpTag)
}
} else if headerAbiChecker.enabled() {