mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-29 13:17:58 +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.
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
REPO_DIR = Path(__file__).parent.parent
|
|
RESOURCES_DIR = REPO_DIR / "tools" / "resources"
|
|
SRC_DIR = REPO_DIR / "src"
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--version-file", type=Path)
|
|
parser.add_argument('-o', "--output", type=Path, nargs="+")
|
|
return parser.parse_args()
|
|
|
|
|
|
def write_rc_template(input_path: Path, output_path: Path, version: str) -> None:
|
|
template = input_path.read_text()
|
|
template = template.replace("{version}", version)
|
|
template = template.replace("{icon_path}", str(RESOURCES_DIR / "icon.ico"))
|
|
output_path.write_text(template)
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
if args.version_file and args.version_file.exists():
|
|
version = args.version_file.read_text().strip()
|
|
else:
|
|
version = ""
|
|
|
|
for output_path in args.output:
|
|
write_rc_template(
|
|
input_path=RESOURCES_DIR / output_path.name,
|
|
output_path=output_path,
|
|
version=version,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|