From e6240f18c41da32ebdc71a7223b862ad3f875e21 Mon Sep 17 00:00:00 2001 From: evbse <133204505+evbse@users.noreply.github.com> Date: Wed, 23 Jul 2025 10:20:06 +0300 Subject: [PATCH] Add version to amalgamated files (#2400) --- singleheader/amalgamate.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/singleheader/amalgamate.py b/singleheader/amalgamate.py index d6590f28a..6b556a783 100755 --- a/singleheader/amalgamate.py +++ b/singleheader/amalgamate.py @@ -296,10 +296,10 @@ class SimdjsonRepository: class Amalgamator: @classmethod - def amalgamate(cls, output_path: str, filename: str, roots: List[RelativeRoot], timestamp: str): + def amalgamate(cls, output_path: str, filename: str, roots: List[RelativeRoot], timestamp: str, version: str): print(f"Creating {output_path}") fid = open(output_path, 'w') - print(f"/* auto-generated on {timestamp}. Do not edit! */", file=fid) + print(f"/* auto-generated on {timestamp}. version {version} Do not edit! */", file=fid) amalgamator = cls(fid, SimdjsonRepository(PROJECTPATH, roots)) file = amalgamator.repository[filename] assert file, f"{filename} not found in {[os.path.join(PROJECTPATH, root) for root in roots]}!" @@ -480,8 +480,13 @@ AMAL_C = os.path.join(AMALGAMATE_OUTPUT_PATH, "simdjson.cpp") DEMOCPP = os.path.join(AMALGAMATE_OUTPUT_PATH, "amalgamate_demo.cpp") README = os.path.join(AMALGAMATE_OUTPUT_PATH, "README.md") -Amalgamator.amalgamate(AMAL_H, "simdjson.h", ['include'], timestamp).validate_all_files_used('include') -Amalgamator.amalgamate(AMAL_C, "simdjson.cpp", ['src', 'include'], timestamp).validate_all_files_used('src') +def read_version(): + with open(os.path.join(PROJECTPATH, 'include/simdjson/simdjson_version.h')) as f: + return re.search(r'\d+\.\d+\.\d+', f.read()).group(0) + +version = read_version() +Amalgamator.amalgamate(AMAL_H, "simdjson.h", ['include'], timestamp, version).validate_all_files_used('include') +Amalgamator.amalgamate(AMAL_C, "simdjson.cpp", ['src', 'include'], timestamp, version).validate_all_files_used('src') # copy the README and DEMOCPP if SCRIPTPATH != AMALGAMATE_OUTPUT_PATH: