mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00

Fix linux build issue : https://github.com/LostArtefacts/TR1X/issues/1296 'init.c' file is generated into meson build directory. > [3/201] /usr/bin/python3 /var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init -o init.c > FAILED: init.c > /usr/bin/python3 /var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init -o init.c > fatal: not a git repository (or any parent up to mount point /var/tmp) > Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). > Traceback (most recent call last): > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init", line 37, in <module> > main() > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init", line 31, in main > update_init_c(output_path=args.output) > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init", line 23, in update_init_c > new_text = get_init_c() > ^^^^^^^^^^^^ > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/generate_init", line 19, in get_init_c > return TEMPLATE.format(version=generate_version()) > ^^^^^^^^^^^^^^^^^^ > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/shared/versioning.py", line 21, in generate_version > version = get_branch_version(None) > ^^^^^^^^^^^^^^^^^^^^^^^^ > File "/var/tmp/portage/games-engines/TR1X-9999/work/TR1X-9999/tools/shared/versioning.py", line 5, in get_branch_version > return check_output( > ^^^^^^^^^^^^^ > File "/usr/lib/python3.11/subprocess.py", line 466, in check_output > return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/lib/python3.11/subprocess.py", line 571, in run > raise CalledProcessError(retcode, process.args, > subprocess.CalledProcessError: Command '['git', 'describe', '--dirty', '--always', '--abbrev=7', '--tags', '--exclude', 'latest']' returned non-zero exit status 128. Signed-off-by: Fabrice Delliaux <netbox253@gmail.com>
25 lines
546 B
Python
25 lines
546 B
Python
from subprocess import check_output
|
|
|
|
from shared.common import SRC_DIR
|
|
|
|
|
|
def get_branch_version(branch: str | None) -> str:
|
|
return check_output(
|
|
[
|
|
"git",
|
|
"describe",
|
|
*([branch] if branch else ["--dirty"]),
|
|
"--always",
|
|
"--abbrev=7",
|
|
"--tags",
|
|
"--exclude",
|
|
"latest",
|
|
],
|
|
cwd=SRC_DIR,
|
|
text=True,
|
|
).strip()
|
|
|
|
|
|
def generate_version() -> str:
|
|
version = get_branch_version(None)
|
|
return f'TR1X {version or "?"}'
|