mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow -pkg|-package option for wmakePrintBuild
- improves the chances of tracking who built OpenFOAM, where, etc
ENH: make it easier to parse version/build from OpenFOAM -help output
- For example,
foamListTimes -help | awk '{ if (/^Using:/) print $2}'
foamListTimes -help | awk '{ if (/^Build:/) print $2}'
This commit is contained in:
@ -507,13 +507,23 @@ Foam::argList::argList
|
||||
jobInfo.add("startTime", timeString);
|
||||
jobInfo.add("userName", userName());
|
||||
jobInfo.add("foamVersion", word(FOAMversion));
|
||||
jobInfo.add("foamBuild", Foam::FOAMbuild);
|
||||
jobInfo.add("code", executable_);
|
||||
jobInfo.add("argList", argListString);
|
||||
jobInfo.add("currentDir", cwd());
|
||||
jobInfo.add("PPID", ppid());
|
||||
jobInfo.add("PGID", pgid());
|
||||
|
||||
// add build information - only use the first word
|
||||
{
|
||||
std::string build(Foam::FOAMbuild);
|
||||
std::string::size_type found = build.find(' ');
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
build.resize(found);
|
||||
}
|
||||
jobInfo.add("foamBuild", build);
|
||||
}
|
||||
|
||||
|
||||
// Case is a single processor run unless it is running parallel
|
||||
int nProcs = 1;
|
||||
@ -883,9 +893,10 @@ void Foam::argList::printUsage() const
|
||||
printNotes();
|
||||
|
||||
Info<< nl
|
||||
<<"Using OpenFOAM-" << Foam::FOAMversion
|
||||
<<" (build: " << Foam::FOAMbuild << ") - see www.OpenFOAM.com"
|
||||
<< nl << endl;
|
||||
<<"Using: OpenFOAM-" << Foam::FOAMversion
|
||||
<< " (see www.OpenFOAM.com)" << nl
|
||||
<<"Build: " << Foam::FOAMbuild << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
# update version strings in C++ file and in $WM_PROJECT_DIR/.build file
|
||||
#
|
||||
Cvertoo = \
|
||||
sed -e 's/VERSION_STRING/$(shell wmakePrintBuild -major)/' \
|
||||
-e 's/BUILD_STRING/$(shell wmakePrintBuild -update)/' \
|
||||
sed -e 's!VERSION_STRING!$(shell wmakePrintBuild -major)!' \
|
||||
-e 's!BUILD_STRING!$(shell wmakePrintBuild -update)!' \
|
||||
$$SOURCE > $*.C; \
|
||||
$(CC) $(c++FLAGS) -c $*.C -o $@
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
# \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -30,6 +30,8 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
usage: ${0##*/} [OPTION]
|
||||
@ -38,6 +40,7 @@ options:
|
||||
(exit code 0 for no changes)
|
||||
-major report \$WM_PROJECT_VERSION only and exit
|
||||
-update update \$WM_PROJECT_DIR/.build from the git information
|
||||
-pkg TAG specify packager/release tag ('none' marks an empty packager)
|
||||
-version VER specify an alternative version
|
||||
|
||||
Print the version used when building the project, in this order of precedence:
|
||||
@ -50,7 +53,7 @@ USAGE
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset checkOnly update version
|
||||
unset checkOnly update package version oldPackage oldVersion
|
||||
|
||||
# parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
@ -71,6 +74,12 @@ do
|
||||
update=true
|
||||
shift
|
||||
;;
|
||||
-pkg | -package)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
# mark empty as 'none', disallow '!' and spaces in string
|
||||
package=$(echo "${2:-none}" | sed -e 's/!//g' -e 's/ //g')
|
||||
shift 2
|
||||
;;
|
||||
-v | -version)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
version="$2"
|
||||
@ -88,7 +97,31 @@ done
|
||||
# persistent build tag
|
||||
#
|
||||
build="$WM_PROJECT_DIR/.build"
|
||||
previous=$(tail -1 $build 2>/dev/null)
|
||||
|
||||
# retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as
|
||||
# version [packager]
|
||||
set -- $(tail -1 $build 2>/dev/null)
|
||||
|
||||
oldVersion="$1"; shift
|
||||
oldPackage="$@"
|
||||
[ "${oldPackage:-none}" = none ] && unset oldPackage
|
||||
|
||||
|
||||
#
|
||||
# printTag - output the build tag
|
||||
# reuses the old -package tag if needed
|
||||
#
|
||||
printTag()
|
||||
{
|
||||
if [ "${package:-${oldPackage:-none}}" = none ]
|
||||
then
|
||||
echo "$version"
|
||||
else
|
||||
echo "$version ${package:-$oldPackage}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [ -n "$version" ]
|
||||
then
|
||||
@ -115,12 +148,17 @@ else
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# update persistent build tag if possible
|
||||
if [ $rc -eq 0 -a -n "$update" -a "$version" != "$previous" ]
|
||||
#
|
||||
if [ $rc -eq 0 -a -n "$update" ]
|
||||
then
|
||||
if [ "$version:$package" != "$oldVersion:$oldPackage" ]
|
||||
then
|
||||
if [ -w "$build" -o \( -w "$WM_PROJECT_DIR" -a ! -e "$build" \) ]
|
||||
then
|
||||
echo $version >| "$build" 2>/dev/null
|
||||
printTag >| "$build" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -130,32 +168,38 @@ if [ -n "$checkOnly" ]
|
||||
then
|
||||
if [ $rc -eq 0 ]
|
||||
then
|
||||
test "$version" = "$previous"
|
||||
test "$version:${package:-$oldPackage}" = "$oldVersion:$oldPackage"
|
||||
rc=$?
|
||||
if [ $rc -eq 0 ]
|
||||
then
|
||||
echo "same version as previous build"
|
||||
echo "same version as previous build" 1>&2
|
||||
else
|
||||
echo "version changed from previous build"
|
||||
echo "version changed from previous build" 1>&2
|
||||
fi
|
||||
else
|
||||
echo "no git description found"
|
||||
echo "no git description found" 1>&2
|
||||
fi
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
|
||||
if [ $rc -eq 0 ]
|
||||
#
|
||||
# cannot get git information or -version version
|
||||
#
|
||||
if [ $rc -ne 0 ]
|
||||
then
|
||||
# output the git information or the -version version
|
||||
echo $version
|
||||
elif [ -n "$previous" ]
|
||||
if [ -n "$oldVersion" ]
|
||||
then
|
||||
# use previous build tag
|
||||
echo $previous
|
||||
# use previous version info
|
||||
version="$oldVersion"
|
||||
else
|
||||
# fallback to WM_PROJECT_VERSION alone
|
||||
echo ${WM_PROJECT_VERSION:-unknown}
|
||||
version="${WM_PROJECT_VERSION:-unknown}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# output the tag
|
||||
printTag
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user