build: fix version embedding

This commit is contained in:
Marcin Kurczewski 2024-04-26 19:39:43 +02:00
parent 439e615ba4
commit 8447c0f67b
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
11 changed files with 11 additions and 15 deletions

View File

@ -1,6 +1,6 @@
<p align="center">
<img alt="TR2X logo" src="tools/resources/logo-light-theme.png#gh-light-mode-only" width="400"/>
<img alt="TR2X logo" src="tools/resources/logo-dark-theme.png#gh-dark-mode-only" width="400"/>
<img alt="TR2X logo" src="data/logo-light-theme.png#gh-light-mode-only" width="400"/>
<img alt="TR2X logo" src="data/logo-dark-theme.png#gh-dark-mode-only" width="400"/>
</p>
TR2X is an open-source decompilation project for Tomb Raider 2, created as a

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

0
tools/generate_init Normal file → Executable file
View File

22
tools/generate_rcfile Normal file → Executable file
View File

@ -2,35 +2,32 @@
import argparse
from pathlib import Path
REPO_DIR = Path(__file__).parent.parent
RESOURCES_DIR = REPO_DIR / "tools" / "resources"
SRC_DIR = REPO_DIR / "src"
from shared.common import DATA_DIR
from shared.versioning import generate_version
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("--version-file", type=Path)
parser.add_argument('-o', "--output", type=Path, nargs="+")
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:
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"))
template = template.replace("{icon_path}", str(DATA_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 = ""
version = generate_version()
for output_path in args.output:
write_rc_template(
input_path=RESOURCES_DIR / output_path.name,
input_path=DATA_DIR / output_path.name,
output_path=output_path,
version=version,
)
@ -38,4 +35,3 @@ def main() -> None:
if __name__ == "__main__":
main()