Skip to content

Commit 82a2b07

Browse files
committed
scripts/kabi: tui: add interactive interface.
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@vates.tech>
1 parent 5d564ed commit 82a2b07

6 files changed

Lines changed: 941 additions & 3 deletions

File tree

‎scripts/kabi/src/kabi/cli.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,52 @@ def main() -> None:
173173
help="kabi_lockedlist file",
174174
)
175175

176+
tui_p = subp.add_parser(
177+
"tui",
178+
help="Opens an interactive user interface to help fixing kABI changes",
179+
)
180+
tui_p.set_defaults(func=commands.tui)
181+
tui_p.add_argument(
182+
"--locked-file",
183+
"-l",
184+
required=True,
185+
metavar="KABI.LOCKED_FILE",
186+
help="Path to the kabi.locked_file (e.g. xcpng-8.3-kabi.locked_list)",
187+
)
188+
tui_p.add_argument(
189+
"--repository",
190+
"-r",
191+
default="./",
192+
help="Path to the git repository hosting the source code",
193+
)
194+
tui_p.add_argument(
195+
"--rev-list",
196+
required=True,
197+
help="Options passed to git rev-list to get the list of commits to audit (e.g. v4.19.19..v4.19.325)",
198+
)
199+
tui_p.add_argument(
200+
"--old-vmlinux",
201+
metavar="VMLINUX.O",
202+
required=False,
203+
help="Unstripped vmlinux.o file before changes",
204+
)
205+
tui_p.add_argument(
206+
"--new-vmlinux",
207+
metavar="VMLINUX.O",
208+
required=False,
209+
help="Unstripped vmlinux.o file after changes",
210+
)
211+
tui_p.add_argument(
212+
"symtypes_lhs",
213+
metavar="Modules.kabi|Symtypes.build",
214+
help="Symtypes file for baseline (e.g. kABI Modules.kabi-v4.19.19)",
215+
)
216+
tui_p.add_argument(
217+
"symtypes_rhs",
218+
metavar="Modules.kabi|Symtypes.build",
219+
help=("Symtypes file for comparison (e.g. Symtypes.build-v4.19.325)"),
220+
)
221+
176222
args = p.parse_args()
177223
if not getattr(args, "func", None):
178224
p.print_help()

‎scripts/kabi/src/kabi/commands.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .fileio import read_lockedlist, read_symbols, read_symvers
1010
from .symtypes import SymTypes
1111
from .utils import collect_helper, compare_helper, print_diffs
12+
from .ui.app import KabiTuiApp
1213

1314

1415
def check(args: argparse.Namespace) -> NoReturn:
@@ -182,3 +183,7 @@ def smoke(args: argparse.Namespace) -> NoReturn:
182183
print("Unless you've modified Module.kabi or Symtypes.kabi, you should")
183184
print("report these to the UEK maintainers.")
184185
sys.exit(ret)
186+
187+
188+
def tui(args: argparse.Namespace):
189+
KabiTuiApp(args).run()

‎scripts/kabi/src/kabi/fileio.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections import defaultdict
2+
13
def read_symvers(filename: str) -> dict[str, tuple[str, str, str]]:
24
vers: dict[str, tuple[str, str, str]] = {}
35
with open(filename) as f:
@@ -15,6 +17,19 @@ def read_lockedlist(filename: str) -> set[str]:
1517
return {line.strip() for line in f if not line.startswith("[")}
1618

1719

20+
def read_lockedlist_grouped(filename: str) -> dict[str, str]:
21+
module_symbols: defaultdict[str, list] = defaultdict(list)
22+
with open(filename) as f:
23+
cur_module = "unknown"
24+
for line in f:
25+
line = line.strip()
26+
if line.startswith("["):
27+
cur_module = line[1:-1]
28+
else:
29+
module_symbols[line].append(cur_module)
30+
return module_symbols
31+
32+
1833
def read_symbols(filename: str) -> set[str]:
1934
with open(filename) as f:
2035
first_line = f.readline()

‎scripts/kabi/src/kabi/symtypes.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class SymTypes:
1010
PREFIXES: dict[str, str] = {
11-
"t": "",
11+
"t": "typedef ",
1212
"E": "",
1313
"e": "enum ",
1414
"s": "struct ",
@@ -65,7 +65,7 @@ def gen_short_decl(self, token: str) -> str:
6565
result: list[str] = []
6666
for tok in self.symtok[token]:
6767
result.append(self.name(tok))
68-
return pretty(" ".join(result))
68+
return pretty(" ".join(result), enum_mode=token.startswith("e#"))
6969

7070
def crc(self, token: str, fn: str | None = None) -> int:
7171
if not fn:

0 commit comments

Comments
 (0)