--
From af952a40005536215cedbbeea9102915e461486f Mon Sep 17 00:00:00 2001
From: Ryan Harkin <
ryan.harkin@linaro.org>
Date: Tue, 30 Jun 2015 15:10:56 +0100
Subject: [PATCH] Use commit id as default FIRMWARE_VER
If a FIRMWARE_VER setting is not provided and we are building from a GIT
repo, provide a default value based on the SHA ID of the commit where we
built from.
If the repo has local uncommited changes, then we mark the version
string with "-dirty".
This is based loosely on the same idea from the linux kernel in:
scripts/setlocalversion
Signed-off-by: Ryan Harkin <
ryan.harkin@linaro.org>
---
uefi-build.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/uefi-build.sh b/uefi-build.sh
index 486cf86..60ea872 100755
--- a/uefi-build.sh
+++ b/uefi-build.sh
@@ -27,6 +27,16 @@ function build_platform
PLATFORM_DSC="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $board get -o dsc`"
PLATFORM_ARCH="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $board get -o arch`"
+ if [[ $PLATFORM_BUILDFLAGS != *"FIRMWARE_VER"* ]]; then
+ if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
+ FIRMWARE_VER=`git rev-parse --short HEAD`
+ if ! git diff-index --quiet HEAD --; then
+ FIRMWARE_VER="${FIRMWARE_VER}-dirty"
+ fi
+ PLATFORM_BUILDFLAGS="$PLATFORM_BUILDFLAGS -D FIRMWARE_VER=$FIRMWARE_VER"
+ fi
+ fi
+
set_cross_compile
CROSS_COMPILE="$TEMP_CROSS_COMPILE"
--
2.1.0