From 85941f0fd77d61b200aa6bf36498832436fe7a16 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Wed, 16 Jan 2008 01:04:07 +0100 Subject: Added version suffix detection based on CVS log and status and on git show. Still not perfect because it does not trigger a recompile if no changes in the sources are present. --- buildutil/version-util | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 buildutil/version-util (limited to 'buildutil/version-util') diff --git a/buildutil/version-util b/buildutil/version-util new file mode 100755 index 0000000..7e377ab --- /dev/null +++ b/buildutil/version-util @@ -0,0 +1,43 @@ +#!/bin/sh +# ----------------------------------------------------------------------------- +# Small shell script to determine the last commit version of the project +# It checks for CVS and .git repositories. +# The output is a string that can be used in a define at compile time to +# automatically mark repository versions. +# For CVS repositories the string contains the date and time of the commit +# that lead to the current version of files. +# For git repositories the output contains the git-id of the current tree. +# An indication if localy modified files exist is added. +# ----------------------------------------------------------------------------- + +function cvsVers () +{ + d=`cvs log -r -N 2> /dev/null \ + | grep '^date:' \ + | cut -d ' ' -f 2-4 \ + | sort -u \ + | tail -1 \ + | tr -d ' \-:'` + m=`cvs status 2> /dev/null \ + | grep 'Status: Locally Modified' > /dev/null && echo "_MOD"` + echo "_cvs_${d}${m}" +} + +function gitVers () +{ + b=`git branch \ + | grep '^*' \ + | sed -e's/^* //'` + h=`git show --pretty=format:"%h_%ci" HEAD \ + | head -1 \ + | tr -d ' \-:'` + echo "_git_${b}_${h}" +} + +if [ -d CVS ]; then + cvsVers +fi + +if [ -d .git ]; then + gitVers +fi -- cgit v1.2.3 From e565e758763f32f49350b78b63308539cc0d90ab Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Wed, 16 Jan 2008 23:57:00 +0100 Subject: Some cleanup in the Makefile dependencies for subdirs Added target to create a generated version suffix file. --- buildutil/version-util | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'buildutil/version-util') diff --git a/buildutil/version-util b/buildutil/version-util index 7e377ab..cf2aa31 100755 --- a/buildutil/version-util +++ b/buildutil/version-util @@ -10,6 +10,23 @@ # An indication if localy modified files exist is added. # ----------------------------------------------------------------------------- +[ $# -lt 1 ] && echo "USAGE: version-util " && exit 1 + +VERS_FILE=$1 + +function createVers () +{ +cat < /dev/null \ @@ -34,10 +51,26 @@ function gitVers () echo "_git_${b}_${h}" } +function checkVers () +{ + s=`$1` + if [ ! -e ${VERS_FILE} ]; then + echo "$VERS_FILE does not exist! creating a new one." + createVers $s > ${VERS_FILE} + else + v=`grep '^#define VERSION_SUFFIX' ${VERS_FILE} \ + | awk '{print $3}'` + if [ "$v" != "$s" ]; then + echo "$VERS_FILE is being recreated!" + createVers $s > ${VERS_FILE} + fi + fi +} + if [ -d CVS ]; then - cvsVers + checkVers cvsVers fi if [ -d .git ]; then - gitVers + checkVers gitVers fi -- cgit v1.2.3 From 880ee6e7feb33daeb94c6a1195c8eb4202a570b0 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Thu, 17 Jan 2008 00:22:07 +0100 Subject: Fixed some compile time problems with the version generation. --- buildutil/version-util | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'buildutil/version-util') diff --git a/buildutil/version-util b/buildutil/version-util index cf2aa31..f35d7f7 100755 --- a/buildutil/version-util +++ b/buildutil/version-util @@ -22,7 +22,7 @@ cat < ${VERS_FILE} fi -- cgit v1.2.3 From fe2a596b9b968b7df225d1c47246b25434c8d469 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Fri, 18 Jan 2008 00:07:45 +0100 Subject: Based CVS version calculation on checked out version of the single files. Some script enhancements. Works now even when no version detection is possible. --- buildutil/version-util | 75 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'buildutil/version-util') diff --git a/buildutil/version-util b/buildutil/version-util index f35d7f7..fa4b127 100755 --- a/buildutil/version-util +++ b/buildutil/version-util @@ -1,18 +1,32 @@ #!/bin/sh # ----------------------------------------------------------------------------- -# Small shell script to determine the last commit version of the project -# It checks for CVS and .git repositories. -# The output is a string that can be used in a define at compile time to -# automatically mark repository versions. -# For CVS repositories the string contains the date and time of the commit -# that lead to the current version of files. -# For git repositories the output contains the git-id of the current tree. -# An indication if localy modified files exist is added. +# Shell script to determine the last commit version of the project It +# checks for CVS and .git repositories. The output is a string that +# can be used in a define at compile time to automatically mark +# repository versions. For CVS repositories the string contains the +# date and time of the commit that lead to the current version of +# files. For git repositories the output contains the git-id of the +# current tree. An indication if localy modified files exist is +# added currently only for CVS. # ----------------------------------------------------------------------------- -[ $# -lt 1 ] && echo "USAGE: version-util " && exit 1 +[ $# -lt 1 ] && echo "USAGE: version-util [-F] " && exit 1 VERS_FILE=$1 +FORCE_EMPTY=0 + +[ "$VERS_FILE" == "-F" -a $# -lt 2 ] && echo "USAGE: version-util [-F] " && exit 1 + +if [ $# -gt 1 ]; then + VERS_FILE=$2 + FORCE_EMPTY=1 +fi + + +SCRIPT_PATH=`dirname $0` + +# echo "file: ${VERS_FILE}, force = $FORCE_EMPTY" +# exit 0 function createVers () { @@ -27,11 +41,32 @@ cat < /dev/null +} + +function cvsData() +{ + fileVersions + cvsLog +} + function cvsVers () { - d=`cvs log -r -N 2> /dev/null \ - | grep '^date:' \ - | cut -d ' ' -f 2-4 \ + d=`cvsData \ + | awk -f ${SCRIPT_PATH}/version-util.awk \ | sort -u \ | tail -1 \ | tr -d ' \-:'` @@ -51,6 +86,11 @@ function gitVers () echo "_git_${b}_${h}" } +function emptyVers () +{ + echo "" +} + function checkVers () { s=`$1` @@ -60,8 +100,6 @@ function checkVers () else v=`grep '^#define VERSION_SUFFIX' ${VERS_FILE} \ | awk '{print $3}'` - echo "s: $s" - echo "v: $v" if [ "$v" != "\"$s\"" ]; then echo "$VERS_FILE is being recreated!" createVers $s > ${VERS_FILE} @@ -69,10 +107,19 @@ function checkVers () fi } +if [ $FORCE_EMPTY -eq 1 ]; then + checkVers emptyVers + exit 0 +fi + if [ -d CVS ]; then checkVers cvsVers + exit 0 fi if [ -d .git ]; then checkVers gitVers + exit 0 fi + +checkVers emptyVers -- cgit v1.2.3