build versioning for pre-release builds

This commit is contained in:
Enno Rehling 2017-01-30 10:35:52 +01:00
commit 2b3617a998
5 changed files with 21 additions and 21 deletions

11
s/build
View File

@ -1,8 +1,5 @@
#!/bin/sh
ROOT=`pwd`
while [ ! -d $ROOT/.git ]; do
ROOT=`dirname $ROOT`
done
ROOT=$(git rev-parse --show-toplevel)
[ -z "$BUILD" ] && BUILD=Debug
if [ -z "$JOBS" ] ; then
@ -35,7 +32,13 @@ fi
echo "build eressea"
cd $ROOT/$BUILD
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
if [ "$BRANCH" == "master" ] ; then
VERSION=$(git describe --match 'v*.*.*' --tags | sed 's/^v//')
cmake -DERESSEA_VERSION="$VERSION" ..
else
REV=$(git rev-parse --short HEAD)
cmake -DERESSEA_BUILDNO="$REV" ..
fi
make $MAKEOPTS && make test
cd $OLDPWD

View File

@ -1,13 +1,6 @@
#!/bin/sh
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
if [ "$ROOT" == "/" ; then
echo "could not find root, are you in the git repository?"
exit
fi
done
ROOT=$(git rev-parse --show-toplevel)
[ -z $BUILD ] && BUILD=Debug
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"

View File

@ -1,11 +1,7 @@
#!/bin/bash
set -e
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
done
ROOT=$(git rev-parse --show-toplevel)
[ -z $BUILD ] && BUILD=Debug ; export BUILD
if [ ! -e $ROOT/$BUILD ]; then

View File

@ -15,6 +15,11 @@ set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}")
ENDIF()
IF(DEFINED ERESSEA_BUILDNO)
set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_BUILDNO="${ERESSEA_BUILDNO}")
ENDIF()
IF (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
ENDIF()

View File

@ -5,15 +5,18 @@
#ifndef ERESSEA_VERSION
// the version number, if it was not passed to make with -D
#define ERESSEA_VERSION "3.11.0-devel"
#define ERESSEA_VERSION "3.11.0"
#endif
const char *eressea_version(void) {
#ifdef ERESSEA_BUILDNO
return ERESSEA_VERSION "-" ERESSEA_BUILDNO;
#endif
return ERESSEA_VERSION;
}
int version_no(const char *str) {
int maj = 0, min = 0, bld = 0;
sscanf(str, "%d.%d.%d", &maj, &min, &bld);
return (maj << 16) | (min << 8) | bld;
int maj = 0, min = 0, pat = 0;
sscanf(str, "%d.%d.%d", &maj, &min, &pat);
return (maj << 16) | (min << 8) | pat;
}