2020-07-22 02:47:15 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Check that all exported symbols are specified in the symbol version scripts.
|
|
|
|
|
|
|
|
If this fails, please update the appropriate .map file (adding new version
|
|
|
|
nodes as needed).
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import pathlib
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2023-09-28 01:50:43 -06:00
|
|
|
top_srcdir = pathlib.Path(os.environ["top_srcdir"])
|
2020-07-22 02:47:15 -06:00
|
|
|
|
|
|
|
|
|
|
|
def symbols_from_map(path):
|
2023-09-28 01:50:43 -06:00
|
|
|
return re.findall(r"^\s+(xkb_.*);", path.read_text("utf-8"), re.MULTILINE)
|
2020-07-22 02:47:15 -06:00
|
|
|
|
|
|
|
|
|
|
|
def symbols_from_src(path):
|
2023-09-28 01:50:43 -06:00
|
|
|
return re.findall(r"XKB_EXPORT.*\n(xkb_.*)\(", path.read_text("utf-8"))
|
2020-07-22 02:47:15 -06:00
|
|
|
|
|
|
|
|
|
|
|
def diff(map_path, src_paths):
|
|
|
|
map_symbols = set(symbols_from_map(map_path))
|
|
|
|
src_symbols = set.union(set(), *(symbols_from_src(path) for path in src_paths))
|
|
|
|
return sorted(map_symbols - src_symbols), sorted(src_symbols - map_symbols)
|
|
|
|
|
|
|
|
|
|
|
|
exit = 0
|
|
|
|
|
|
|
|
# xkbcommon symbols
|
|
|
|
left, right = diff(
|
2023-09-28 01:50:43 -06:00
|
|
|
top_srcdir / "xkbcommon.map",
|
2020-07-22 02:47:15 -06:00
|
|
|
[
|
2023-09-28 01:50:43 -06:00
|
|
|
*(top_srcdir / "src").glob("*.c"),
|
|
|
|
*(top_srcdir / "src" / "xkbcomp").glob("*.c"),
|
|
|
|
*(top_srcdir / "src" / "compose").glob("*.c"),
|
2020-07-22 02:47:15 -06:00
|
|
|
],
|
|
|
|
)
|
|
|
|
if left:
|
2023-09-28 01:50:43 -06:00
|
|
|
print("xkbcommon map has extra symbols:", " ".join(left))
|
2020-07-22 02:47:15 -06:00
|
|
|
exit = 1
|
|
|
|
if right:
|
2023-09-28 01:50:43 -06:00
|
|
|
print("xkbcommon src has extra symbols:", " ".join(right))
|
2020-07-22 02:47:15 -06:00
|
|
|
exit = 1
|
|
|
|
|
|
|
|
# xkbcommon-x11 symbols
|
|
|
|
left, right = diff(
|
2023-09-28 01:50:43 -06:00
|
|
|
top_srcdir / "xkbcommon-x11.map",
|
2020-07-22 02:47:15 -06:00
|
|
|
[
|
2023-09-28 01:50:43 -06:00
|
|
|
*(top_srcdir / "src" / "x11").glob("*.c"),
|
2020-07-22 02:47:15 -06:00
|
|
|
],
|
|
|
|
)
|
|
|
|
if left:
|
2023-09-28 01:50:43 -06:00
|
|
|
print("xkbcommon-x11 map has extra symbols:", " ".join(left))
|
2020-07-22 02:47:15 -06:00
|
|
|
exit = 1
|
|
|
|
if right:
|
2023-09-28 01:50:43 -06:00
|
|
|
print("xkbcommon-x11 src has extra symbols:", " ".join(right))
|
2020-07-22 02:47:15 -06:00
|
|
|
exit = 1
|
|
|
|
|
|
|
|
sys.exit(exit)
|