summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2022-08-10 18:58:43 +0100
committerGiuliano Procida <gprocida@google.com>2022-08-11 15:35:04 +0000
commit2ae37a98ebb77a48a899c8c0d3a77894213a3676 (patch)
treee4437a44c7b417db085bad861b8ebc04d471c384
parent3d45fa2a5ba577089e2ce03ac0bc648875464add (diff)
downloadbuild-2ae37a98ebb77a48a899c8c0d3a77894213a3676.tar.gz
abitool.py: replace stgdiff post-processing with own functionality
This impacts `diff_abi --abi-tool delegated` which is what is used by AOSP kernel build tools. With this commit: * `stgdiff` is invoked with `--compare-options all` which causes * symbol type presence changes to be ignored * type definedness changes to be ignored * (these options are needed to deal with varying `abidw` output and replace specially coded post-processing) * `stgdiff` additionally produces a `short` format report * this includes all the existing report compression: * runs of CRC-only changes * runs of offset changes * and adds: * grouping together of symbol removals and additions * the `.stg.small.short` report has been removed * it was a post-processed version of `.stg.small` * but has been obsoleted by `.stg.short` * if STG finds a diff (but libabigail does not) then * the printed report is now the `.stg.short` one Bug: 231304878 Change-Id: Iffe29ea030558bbe422118cf082f24c3b14f0f72 Signed-off-by: Giuliano Procida <gprocida@google.com>
-rw-r--r--abi/abitool.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/abi/abitool.py b/abi/abitool.py
index dce38ca..6803681 100644
--- a/abi/abitool.py
+++ b/abi/abitool.py
@@ -369,7 +369,7 @@ def _shorten_abidiff(diff_report, short_report):
STGDIFF_ERROR = (1<<0)
STGDIFF_ABI_CHANGE = (1<<1)
-STGDIFF_FORMATS = ["plain", "flat", "small", "viz"]
+STGDIFF_FORMATS = ["plain", "flat", "small", "short", "viz"]
def _run_stgdiff(old_dump, new_dump, basename, symbol_list=None):
@@ -391,7 +391,11 @@ def _run_stgdiff(old_dump, new_dump, basename, symbol_list=None):
["abitidy", "-S", symbol_list, "-i", raw, "-o", cooked])
dumps[ix] = cooked
- command = ["stgdiff", "--abi", dumps[0], dumps[1]]
+ command = [
+ "stgdiff",
+ "--compare-options", "all",
+ "--abi", dumps[0], dumps[1]
+ ]
for f in STGDIFF_FORMATS:
command.extend(["--format", f, "--output", f"{basename}.{f}"])
@@ -458,7 +462,7 @@ class Delegated(AbiTool):
abg_leaf = basename + ".leaf"
abg_full = basename + ".full"
stg_basename = basename + ".stg"
- stg_small = stg_basename + ".small"
+ stg_short = stg_basename + ".short"
links = {
basename: abg_leaf,
basename + ".short": abg_leaf + ".short",
@@ -483,13 +487,11 @@ class Delegated(AbiTool):
# post-process
for report in [abg_leaf, abg_full]:
_shorten_abidiff(report, report + ".short")
- stgdiff_changed = _shorten_stgdiff(stgdiff_changed, stg_small,
- stg_small + ".short")
print("ABI diff reports have been created")
paths = [abg_leaf, abg_full,
*(f"{stg_basename}.{format}" for format in STGDIFF_FORMATS),
- *(f"{path}.short" for path in [abg_leaf, abg_full, stg_small])]
+ *(f"{path}.short" for path in [abg_leaf, abg_full])]
for path in paths:
count = _line_count(path)
print(f" {path} [{count} lines]")
@@ -498,16 +500,16 @@ class Delegated(AbiTool):
changed = []
if abidiff_leaf_changed:
- changed.append(("abidiff (leaf changes)", abg_leaf))
+ changed.append(("abidiff (leaf changes)", abg_leaf + ".short"))
if stgdiff_changed:
- changed.append(("stgdiff", stg_small))
+ changed.append(("stgdiff", stg_short))
if changed:
print()
print("ABI DIFFERENCES HAVE BEEN DETECTED!")
for which, _ in changed:
print(f" by {which}")
print()
- with open(changed[0][1] + ".short") as input:
+ with open(changed[0][1]) as input:
print(input.read(), end="")
return True
return False