Merge branch 'olesenm'

This commit is contained in:
andy
2008-12-19 13:05:19 +00:00
4 changed files with 92 additions and 37 deletions

View File

@ -2,8 +2,8 @@
cd ${0%/*} || exit 1 # run from this directory cd ${0%/*} || exit 1 # run from this directory
set -x set -x
# force update of Foam::FOAMversion string (git tag or $WM_PROJECT_VERSION) # update Foam::FOAMversion string if required
/bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
wmakeLnInclude -f OpenFOAM wmakeLnInclude -f OpenFOAM
wmakeLnInclude -f OSspecific/$WM_OS wmakeLnInclude -f OSspecific/$WM_OS

View File

@ -23,20 +23,19 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description Description
Define the globals used in the FOAM library. It is important that these Define the globals used in the OpenFOAM library.
are constructed in the appropriate order to avoid the use of unconstructed It is important that these are constructed in the appropriate order to
data in the global namespace. avoid the use of unconstructed data in the global namespace.
This file has the extension .ver to force it to be parsed by the script This file has the extension .Cver to trigger a Makefile rule that converts
which converts WM_PROJECT_VERSION into the appropriate version number WM_PROJECT_VERSION into the appropriate version string.
string.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "foamVersion.H" #include "foamVersion.H"
const char* const Foam::FOAMversion = WM_PROJECT_VERSION; const char* const Foam::FOAMversion = "WM_PROJECT_VERSION";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Setup an error handler for the global new operator // Setup an error handler for the global new operator
@ -51,7 +50,7 @@ const char* const Foam::FOAMversion = WM_PROJECT_VERSION;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "JobInfo.H" #include "JobInfo.H"
bool Foam::JobInfo::constructed = false; bool Foam::JobInfo::constructed(false);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global error definitions (initialised by construction) // Global error definitions (initialised by construction)

View File

@ -1,10 +1,10 @@
.SUFFIXES: .Cver .SUFFIXES: .Cver
# #
# update version string # update version string in C++ file and in $WM_PROJECT_DIR/.build file
# #
Cvertoo = \ Cvertoo = \
sed s/WM_PROJECT_VERSION/\"$(shell wmakePrintBuild)\"/ $$SOURCE > $*.C; \ sed 's/WM_PROJECT_VERSION/$(shell wmakePrintBuild -update)/' $$SOURCE > $*.C; \
$(CC) $(c++FLAGS) -c $*.C -o $@ $(CC) $(c++FLAGS) -c $*.C -o $@
.Cver.dep: .Cver.dep:

View File

@ -35,10 +35,15 @@ Script=${0##*/}
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: $Script usage: $Script [OPTION]
options:
-check check the git head commit vs. \$WM_PROJECT_DIR/.build
(exit code 0 for no changes)
-update update the \$WM_PROJECT_DIR/.build from the git information
-version VER specify an alternative version
Print the version used when building the project, in this order of precedence: Print the version used when building the project, in this order of precedence:
* git description * the git head commit (prefixed with \$WM_PROJECT_VERSION)
* \$WM_PROJECT_DIR/.build * \$WM_PROJECT_DIR/.build
* \$WM_PROJECT_VERSION * \$WM_PROJECT_VERSION
@ -47,11 +52,33 @@ USAGE
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# provide immediate help unset checkOnly update version
if [ "$1" = "-h" -o "$1" = "-help" ]
then # parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage usage
fi ;;
-check)
checkOnly=true
shift
;;
-update)
update=true
shift
;;
-version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version=$2
shift 2
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -61,15 +88,25 @@ fi
build="$WM_PROJECT_DIR/.build" build="$WM_PROJECT_DIR/.build"
previous=$(tail -1 $build 2>/dev/null) previous=$(tail -1 $build 2>/dev/null)
# if [ -n "$version" ]
# building under git
# note: could also use --abbrev=32 for maximum resolution
#
version=$(git describe --always --tags 2>/dev/null)
if [ $? -eq 0 ]
then then
# update persistent build tag (this could be made optional or removed) # specified a version - no error possible
if [ "$version" != "$previous" ] rc=0
else
# building under git (get the head SHA1)
version=$(git show-ref --hash=12 --head HEAD 2>/dev/null)
rc=$?
# prefix with WM_PROJECT_VERSION
if [ $rc -eq 0 ]
then
version="${WM_PROJECT_VERSION}-$version"
fi
fi
# update persistent build tag if possible
if [ $rc -eq 0 -a -n "$update" -a "$version" != "$previous" ]
then then
if [ -w "$build" -a \( -w "$WM_PROJECT_DIR" -o ! -e "$build" \) ] if [ -w "$build" -a \( -w "$WM_PROJECT_DIR" -o ! -e "$build" \) ]
then then
@ -77,19 +114,38 @@ then
fi fi
fi fi
echo $version
# check git vs. persistent build tag - no output
if [ -n "$checkOnly" ]
then
if [ $rc -eq 0 ]
then
test "$version" = "$previous"
rc=$?
if [ $rc -eq 0 ]
then
echo "same version as previous build"
else
echo "version changed from previous build"
fi
else
echo "no git description found"
fi
exit $rc
fi
if [ $rc -eq 0 ]
then
# output the git information or the -version version
echo $version
elif [ -n "$previous" ] elif [ -n "$previous" ]
then then
# use previous build tag # use previous build tag
echo $previous echo $previous
else else
# fallback to WM_PROJECT_VERSION alone
# fallback to WM_PROJECT_VERSION
echo ${WM_PROJECT_VERSION:-unknown} echo ${WM_PROJECT_VERSION:-unknown}
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------