Retrieve git version info and save as environment variable These variables can be used in modules to print the vesrion info when uefi boots. This helps in identifying the codebase from logs.
Cc: Bob Feng <bob.c.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Signed-off-by: Pankaj Bansal <pankaj.ban...@nxp.com> --- Notes: When i ran PatchCheck.py script on this patch i received two errors: 1. Line ending ('\n') is not CRLF 2. The commit message format is not valid: * Contributed-under! (Note: this must be removed by the code contributor!) I have fixed the [2] but i have not fixed [1], as this file's line endings are already unix like. Please suggest if i need to change these to windows like? BaseTools/BinWrappers/PosixLike/build | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build index f3770eed42..f32796db5d 100755 --- a/BaseTools/BinWrappers/PosixLike/build +++ b/BaseTools/BinWrappers/PosixLike/build @@ -10,5 +10,23 @@ full_cmd=${BASH_SOURCE:-$0} # see http://mywiki.wooledge.org/BashFAQ/028 for a d dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} +git_version() +{ + command -v git>/dev/null 2>&1 + if [ $? -eq 0 ] && [ -n "$1" ] + then + head_or_tag=`git -C $1 describe --always 2>/dev/null` + printf $head_or_tag + git -C $1 diff-index --ignore-submodules --exit-code HEAD>/dev/null + if [ $? -eq 1 ]; then + printf '%s' -dirty + fi + else + printf "unknown" + fi +} + +export WORKSPACE_GIT_VERSION=$(git_version $WORKSPACE) +export PACKAGES_PATH_GIT_VERSION=$(git_version $PACKAGES_PATH) export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" exec "${python_exe:-python}" "$dir/../../Source/Python/$cmd/$cmd.py" "$@" -- 2.17.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52851): https://edk2.groups.io/g/devel/message/52851 Mute This Topic: https://groups.io/mt/69437290/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-