diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
| commit | bdaedce69b17b654bd0060579dd9b9ff120009b5 (patch) | |
| tree | 0e9cd8597652263a96c48ba678fb0b66e1fc131b /tools | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/amalgamate.py | 33 | ||||
| -rw-r--r-- | tools/generate_unicode.py | 16 |
2 files changed, 25 insertions, 24 deletions
diff --git a/tools/amalgamate.py b/tools/amalgamate.py index 09c6c91..79f011a 100644 --- a/tools/amalgamate.py +++ b/tools/amalgamate.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 -"""Write the term core as one term.c and one term.h. +"""Write the wsap_vtcore core as one wsap_vtcore.c and one wsap_vtcore.h. -term.h joins the public headers. term.c joins every source file and puts -each private header in at its first include. A host compiles term.c once, -with any C11 compiler, and links libm and the thread library. +wsap_vtcore.h joins the public headers. wsap_vtcore.c joins every source +file and puts each private header in at its first include. A host compiles +wsap_vtcore.c once, with any C11 compiler, and links libm and the thread +library. - amalgamate.py TERM_DIR OUT_DIR [DEPFILE] + amalgamate.py WSAP_VTCORE_DIR OUT_DIR [DEPFILE] -TERM_DIR is the directory with src/ and include/. DEPFILE lists every file +WSAP_VTCORE_DIR is the directory with src/ and include/. DEPFILE lists every file read, for the build system. """ @@ -16,14 +17,14 @@ import sys from pathlib import Path INCLUDE = re.compile(r'^\s*#\s*include\s+"([^"]+)"') -PUBLIC = ("term_types.h", "term_input.h", "term.h") +PUBLIC = ("wsap_vtcore_types.h", "wsap_vtcore_input.h", "wsap_vtcore.h") class Joiner: def __init__(self, root: Path): self.root = root - # The sources find the public headers without the term/ prefix. - self.search = (root / "src", root / "include" / "term") + # The sources find the public headers without the wsap_vtcore/ prefix. + self.search = (root / "src", root / "include" / "wsap_vtcore") self.seen: set[Path] = set() def resolve(self, name: str, base: Path) -> Path: @@ -60,15 +61,15 @@ def main() -> int: print(__doc__, file=sys.stderr) return 2 root = Path(sys.argv[1]).resolve() - public = root / "include" / "term" + public = root / "include" / "wsap_vtcore" out_dir = Path(sys.argv[2]) out_dir.mkdir(parents=True, exist_ok=True) banner = "/* Generated by tools/amalgamate.py. Do not edit. */\n" header = Joiner(root) text = [banner] - header.emit(public / "term.h", text) - (out_dir / "term.h").write_text("".join(text)) + header.emit(public / "wsap_vtcore.h", text) + (out_dir / "wsap_vtcore.h").write_text("".join(text)) body = Joiner(root) text = [banner, @@ -77,16 +78,16 @@ def main() -> int: "#if defined(__clang__)\n" '#pragma clang diagnostic ignored "-Wunused-function"\n' "#endif\n", - '#include "term.h"\n'] - # The public headers are in term.h, so the sources skip them. + '#include "wsap_vtcore.h"\n'] + # The public headers are in wsap_vtcore.h, so the sources skip them. body.seen.update((public / name).resolve() for name in PUBLIC) for src in sources(root / "src"): body.emit(src, text) - (out_dir / "term.c").write_text("".join(text)) + (out_dir / "wsap_vtcore.c").write_text("".join(text)) if len(sys.argv) == 4: read = sorted(header.seen | body.seen) deps = " ".join(str(p).replace(" ", "\\ ") for p in read) - Path(sys.argv[3]).write_text(f"{out_dir / 'term.c'}: {deps}\n") + Path(sys.argv[3]).write_text(f"{out_dir / 'wsap_vtcore.c'}: {deps}\n") return 0 diff --git a/tools/generate_unicode.py b/tools/generate_unicode.py index 22f12a6..340509a 100644 --- a/tools/generate_unicode.py +++ b/tools/generate_unicode.py @@ -71,7 +71,7 @@ def unicode_categories(path): return by_category def emit_table(out, name, ranges): - out.append(f"static const struct term_unicode_range {name}[] = {{") + out.append(f"static const struct wsap_vtcore_unicode_range {name}[] = {{") for i in range(0, len(ranges), 4): chunk = ranges[i:i + 4] out.append("\t" + ",".join(f"{{0x{lo:X},0x{hi:X}}}" for lo, hi in chunk) + ",") @@ -104,13 +104,13 @@ def main(): emoji_presentation = field_ranges(args.emoji_data, {"Emoji_Presentation"}) out = [f"/* Generated from Unicode {version} data by tools/generate_unicode.py. */", "", - f'#define TERM_UNICODE_DATA_VERSION "{version}"', ""] - emit_table(out, "term_zero_width", zero) - emit_table(out, "term_nonprintable", nonprint) - emit_table(out, "term_unicode_wide", wide) - emit_table(out, "term_spacing_mark", spacing) - emit_table(out, "term_extended_pictographic", pictographic) - emit_table(out, "term_emoji_presentation", emoji_presentation) + f'#define WSAP_VTCORE_UNICODE_DATA_VERSION "{version}"', ""] + emit_table(out, "wsap_vtcore_zero_width", zero) + emit_table(out, "wsap_vtcore_nonprintable", nonprint) + emit_table(out, "wsap_vtcore_unicode_wide", wide) + emit_table(out, "wsap_vtcore_spacing_mark", spacing) + emit_table(out, "wsap_vtcore_extended_pictographic", pictographic) + emit_table(out, "wsap_vtcore_emoji_presentation", emoji_presentation) args.output.write_text("\n".join(out)) if __name__ == "__main__": |
