mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-29 05:08:00 +03:00

Rebuilding the exe was not updating the git version shown inside the game, which caused me some issues when I was working on the project across two machines. This new approach forces meson to always reconsider the current version, and rebuild relevant autogenerated files: version.rc and init.c prior to linking the .exe. Furthermore, the versioned init.c was removed. The existing users who choose to build without Docker will continue to see fallback information, but the mechanism was changed from a versioned file to a special environment variable that's set by the Docker builds. This change should require no action other than a clean project rebuild on the part of the users.
26 lines
595 B
Python
26 lines
595 B
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
from pathlib import Path
|
|
from subprocess import run
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-o", "--output", type=Path)
|
|
return parser.parse_args()
|
|
|
|
|
|
def generate_version() -> str:
|
|
cmd = ["git", "describe", "--abbrev=7", "--tags"]
|
|
version = run(cmd, capture_output=True, text=True).stdout
|
|
return f'T1M {version or "?"}'
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
version = generate_version()
|
|
args.output.write_text(version)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|