From b26482feca11378119149bebe3cdfc2f3d33f6be Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Wed, 2 May 2012 17:15:50 +0200 Subject: [PATCH] Started script to describe version. --- src/build-brutus.sh | 3 +++ src/build-debug.sh | 3 +++ src/build.sh | 5 ++++ src/describe-version.py | 52 +++++++++++++++++++++++++++++++++++++++++ src/version.h | 20 ---------------- 5 files changed, 63 insertions(+), 20 deletions(-) create mode 100755 src/describe-version.py delete mode 100644 src/version.h diff --git a/src/build-brutus.sh b/src/build-brutus.sh index 34fce5b..bd26490 100755 --- a/src/build-brutus.sh +++ b/src/build-brutus.sh @@ -7,6 +7,9 @@ echo " module load cmake" echo " module load gcc" echo +# Store version number in version.h +./describe-version.py + # Default flags CMFLAGS="-D CMAKE_BUILD_TYPE:STRING=Release" diff --git a/src/build-debug.sh b/src/build-debug.sh index 69ede6f..11632ff 100755 --- a/src/build-debug.sh +++ b/src/build-debug.sh @@ -1,5 +1,8 @@ #!/bin/sh +# Store version number in version.h +./describe-version.py + # Default flags CMFLAGS="-D CMAKE_BUILD_TYPE:STRING=Debug" diff --git a/src/build.sh b/src/build.sh index c68c94e..77d6981 100755 --- a/src/build.sh +++ b/src/build.sh @@ -1,5 +1,9 @@ #!/bin/sh +# Store version number in version.h +./describe-version.py + +# Different choice if on Darwin PLATFORM=`uname` echo $PLATFORM if [ "$PLATFORM" = "Darwin" ] @@ -8,6 +12,7 @@ then else if [ "$PLATFORM" = "Linux" ] then + # Build both versions ./subbuild-unix-both.sh else echo "I don't know platform $PLATFORM, so I won't do anything" diff --git a/src/describe-version.py b/src/describe-version.py new file mode 100755 index 0000000..cb68042 --- /dev/null +++ b/src/describe-version.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +""" + Scyther : An automatic verifier for security protocols. + Copyright (C) 2007-2012 Cas Cremers + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" + +def writeTag(tag=None): + """ + Write tag file + """ + if tag == None: + tag = "unknown" + fp = open('version.h','w') + s = "#define TAGVERSION \"%s\"\n" % tag + fp.write(s) + fp.close() + +def getDescription(): + """ + If possible, use Git to extract a description of the current commit + """ + + try: + import sys + import subprocess + res = subprocess.check_output(["git","describe","--tags","--dirty"]+sys.argv[1:]) + except: + res = None + + return res.strip() + + +if __name__ == '__main__': + tag = getDescription() + writeTag(tag) + print tag + + diff --git a/src/version.h b/src/version.h deleted file mode 100644 index a62166f..0000000 --- a/src/version.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Scyther : An automatic verifier for security protocols. - * Copyright (C) 2007-2012 Cas Cremers - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#define TAGVERSION "unknown"