()
| 18 | |
| 19 | |
| 20 | def main() -> int: |
| 21 | root = Path(__file__).resolve().parent.parent |
| 22 | version_txt = root / "version.txt" |
| 23 | out_header = root / "VersionGenerated.h" |
| 24 | |
| 25 | version_str = version_txt.read_text(encoding="ascii").strip() |
| 26 | |
| 27 | if not re.fullmatch(r"\d+\.\d+\.\d+\.\d+", version_str): |
| 28 | print(f"Invalid version format in {version_txt}: {version_str}", file=sys.stderr) |
| 29 | return 1 |
| 30 | |
| 31 | comma_version = version_str.replace(".", ",") |
| 32 | git_hash = get_git_short_hash() |
| 33 | |
| 34 | content = f"""#pragma once |
| 35 | |
| 36 | #define VER_FILEVERSION {comma_version} |
| 37 | #define VER_PRODUCTVERSION {comma_version} |
| 38 | |
| 39 | #define VER_FILEVERSION_STR "{version_str}" |
| 40 | #define VER_PRODUCTVERSION_STR "{version_str} ({git_hash})" |
| 41 | """ |
| 42 | |
| 43 | old_content = None |
| 44 | if out_header.exists(): |
| 45 | old_content = out_header.read_text(encoding="utf-8") |
| 46 | |
| 47 | if content != old_content: |
| 48 | out_header.write_text(content, encoding="utf-8") |
| 49 | |
| 50 | return 0 |
| 51 | |
| 52 | |
| 53 | if __name__ == "__main__": |
no test coverage detected