Add EGS name and branch to app name

This commit is contained in:
Ashcon Mohseninia 2022-09-27 19:55:27 +01:00
parent e51ebc9a2b
commit 3756baba9d
3 changed files with 14 additions and 8 deletions

View File

@ -141,9 +141,18 @@ def get_project_name(env) -> Tuple[str, str]:
Note, didn't reuse :func:`get_program_name()` bc app-infos can accomodate
relative git-path of project-root as `appname`.
"""
branch = ""
try:
branch = subprocess.check_output(
"git branch --show-current".split(), universal_newlines=True
).strip()
except Exception as ex:
branch = "UNKNOWN"
return progname.fallback_get(
(
lambda: env.GetProjectOption(progname.PROG_NAME_OPTION, None),
lambda: "{}_{}".format(env.GetProjectOption("egs_ver"), branch), #env.GetProjectOption(progname.PROG_NAME_OPTION, None),
"custom_option",
),
(lambda: git_relative_dir(), "git_relative_dir"),
@ -164,13 +173,6 @@ def _collect_app_infos(env) -> Tuple[AppInfos, AppInfos]:
if bool_option("custom_appinfos_patch_appname", True):
appname, appname_src = get_project_name(env)
if bool_option("custom_appinfos_patch_builder", True):
import getpass
import socket
user = getpass.getuser()
host = socket.gethostname()
appname = f"{appname}({user}@{host})"
## TODO: parse var-value as False if off/false/no/0.
if bool_option("custom_appinfos_patch_appver", True):

View File

@ -26,12 +26,15 @@ extra_scripts = post:patchappinfo.py
[env:egs51]
build_flags = -Wall -DEGS51_MODE
egs_ver = egs51
[env:egs52]
build_flags = -Wall -DEGS52_MODE
egs_ver = egs52
[env:egs53]
build_flags = -Wall -DEGS53_MODE
egs_ver = egs53
[env:latest_stable]
platform = linux_x86_64

View File

@ -26,6 +26,7 @@ PROG_VERSION_OPTION = "custom_prog_version"
PROG_VERSION_FPATH = "${PROJECT_PATH}/version.txt"
#: The shell-command to collect the output of `git describe`.
GIT_DESCRIBE_CMD = "git describe --always --long --dirty".split()
# Shell command to get current branch
def fallback_get(*getters: Tuple[callable, str]):