[libc-commits] [libc] [libc][wctype][codegen] Add generation script for conversion data (PR #170868)
Marcell Leleszi via libc-commits
libc-commits at lists.llvm.org
Fri Dec 5 11:21:20 PST 2025
================
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+#
+# ===- Run wctype generator ----------------------------------*- python -*--==#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ==------------------------------------------------------------------------==#
+
+from conversion.gen_conversion_data import extract_maps_from_unicode_file
+from conversion.hex_writer import write_hex_conversions
+from data.fetch import fetch_unicode_data_files
+from sys import argv
+from sys import exit
+
+
+def write_wctype_conversion_data(llvm_project_root_path: str) -> None:
+ """Generates and writes wctype conversion data files"""
+ lower_to_upper, upper_to_lower = extract_maps_from_unicode_file(
+ f"{llvm_project_root_path}/libc/utils/wctype_utils/data/UnicodeData.txt"
+ )
+ write_hex_conversions(
+ file_path=f"{llvm_project_root_path}/libc/src/__support/wctype/lower_to_upper.inc",
+ mappings=lower_to_upper,
+ )
+ write_hex_conversions(
+ file_path=f"{llvm_project_root_path}/libc/src/__support/wctype/upper_to_lower.inc",
+ mappings=upper_to_lower,
+ )
+
+
+def main() -> None:
+ if len(argv) < 2:
----------------
mleleszi wrote:
You could use the built in argparse lib
https://github.com/llvm/llvm-project/pull/170868
More information about the libc-commits
mailing list