public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pankaj Bansal" <pankaj.bansal@nxp.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Pankaj Bansal <pankaj.bansal@nxp.com>,
	Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH] BaseTools: Retrieve git version info
Date: Sun, 5 Jan 2020 12:41:29 +0000	[thread overview]
Message-ID: <20200105180132.23306-1-pankaj.bansal@nxp.com> (raw)

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.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Pankaj Bansal <pankaj.bansal@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


             reply	other threads:[~2020-01-05 12:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-05 12:41 Pankaj Bansal [this message]
2020-01-09  6:13 ` [PATCH] BaseTools: Retrieve git version info Bob Feng
2020-01-09  7:09   ` Pankaj Bansal
2020-01-09 10:01     ` Bob Feng
2020-01-09 10:10       ` Pankaj Bansal
2020-01-10  6:27         ` Bob Feng
2020-01-10  8:40           ` Pankaj Bansal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200105180132.23306-1-pankaj.bansal@nxp.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox