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("startTime", timeString);
|
||||||
jobInfo.add("userName", userName());
|
jobInfo.add("userName", userName());
|
||||||
jobInfo.add("foamVersion", word(FOAMversion));
|
jobInfo.add("foamVersion", word(FOAMversion));
|
||||||
jobInfo.add("foamBuild", Foam::FOAMbuild);
|
|
||||||
jobInfo.add("code", executable_);
|
jobInfo.add("code", executable_);
|
||||||
jobInfo.add("argList", argListString);
|
jobInfo.add("argList", argListString);
|
||||||
jobInfo.add("currentDir", cwd());
|
jobInfo.add("currentDir", cwd());
|
||||||
jobInfo.add("PPID", ppid());
|
jobInfo.add("PPID", ppid());
|
||||||
jobInfo.add("PGID", pgid());
|
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
|
// Case is a single processor run unless it is running parallel
|
||||||
int nProcs = 1;
|
int nProcs = 1;
|
||||||
@ -883,9 +893,10 @@ void Foam::argList::printUsage() const
|
|||||||
printNotes();
|
printNotes();
|
||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<<"Using OpenFOAM-" << Foam::FOAMversion
|
<<"Using: OpenFOAM-" << Foam::FOAMversion
|
||||||
<<" (build: " << Foam::FOAMbuild << ") - see www.OpenFOAM.com"
|
<< " (see www.OpenFOAM.com)" << nl
|
||||||
<< nl << endl;
|
<<"Build: " << Foam::FOAMbuild << nl
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
# update version strings in C++ file and in $WM_PROJECT_DIR/.build file
|
# update version strings in C++ file and in $WM_PROJECT_DIR/.build file
|
||||||
#
|
#
|
||||||
Cvertoo = \
|
Cvertoo = \
|
||||||
sed -e 's/VERSION_STRING/$(shell wmakePrintBuild -major)/' \
|
sed -e 's!VERSION_STRING!$(shell wmakePrintBuild -major)!' \
|
||||||
-e 's/BUILD_STRING/$(shell wmakePrintBuild -update)/' \
|
-e 's!BUILD_STRING!$(shell wmakePrintBuild -update)!' \
|
||||||
$$SOURCE > $*.C; \
|
$$SOURCE > $*.C; \
|
||||||
$(CC) $(c++FLAGS) -c $*.C -o $@
|
$(CC) $(c++FLAGS) -c $*.C -o $@
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
# \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -30,6 +30,8 @@
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
|
exec 1>&2
|
||||||
|
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
cat<<USAGE
|
cat<<USAGE
|
||||||
usage: ${0##*/} [OPTION]
|
usage: ${0##*/} [OPTION]
|
||||||
@ -38,6 +40,7 @@ options:
|
|||||||
(exit code 0 for no changes)
|
(exit code 0 for no changes)
|
||||||
-major report \$WM_PROJECT_VERSION only and exit
|
-major report \$WM_PROJECT_VERSION only and exit
|
||||||
-update update \$WM_PROJECT_DIR/.build from the git information
|
-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
|
-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:
|
||||||
@ -50,7 +53,7 @@ USAGE
|
|||||||
}
|
}
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
unset checkOnly update version
|
unset checkOnly update package version oldPackage oldVersion
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
@ -71,6 +74,12 @@ do
|
|||||||
update=true
|
update=true
|
||||||
shift
|
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)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
version="$2"
|
version="$2"
|
||||||
@ -88,7 +97,31 @@ done
|
|||||||
# persistent build tag
|
# persistent build tag
|
||||||
#
|
#
|
||||||
build="$WM_PROJECT_DIR/.build"
|
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" ]
|
if [ -n "$version" ]
|
||||||
then
|
then
|
||||||
@ -115,12 +148,17 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
# update persistent build tag if possible
|
# update persistent build tag if possible
|
||||||
if [ $rc -eq 0 -a -n "$update" -a "$version" != "$previous" ]
|
#
|
||||||
|
if [ $rc -eq 0 -a -n "$update" ]
|
||||||
then
|
then
|
||||||
|
if [ "$version:$package" != "$oldVersion:$oldPackage" ]
|
||||||
|
then
|
||||||
if [ -w "$build" -o \( -w "$WM_PROJECT_DIR" -a ! -e "$build" \) ]
|
if [ -w "$build" -o \( -w "$WM_PROJECT_DIR" -a ! -e "$build" \) ]
|
||||||
then
|
then
|
||||||
echo $version >| "$build" 2>/dev/null
|
printTag >| "$build" 2>/dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -130,32 +168,38 @@ if [ -n "$checkOnly" ]
|
|||||||
then
|
then
|
||||||
if [ $rc -eq 0 ]
|
if [ $rc -eq 0 ]
|
||||||
then
|
then
|
||||||
test "$version" = "$previous"
|
test "$version:${package:-$oldPackage}" = "$oldVersion:$oldPackage"
|
||||||
rc=$?
|
rc=$?
|
||||||
if [ $rc -eq 0 ]
|
if [ $rc -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "same version as previous build"
|
echo "same version as previous build" 1>&2
|
||||||
else
|
else
|
||||||
echo "version changed from previous build"
|
echo "version changed from previous build" 1>&2
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "no git description found"
|
echo "no git description found" 1>&2
|
||||||
fi
|
fi
|
||||||
exit $rc
|
exit $rc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ $rc -eq 0 ]
|
#
|
||||||
|
# cannot get git information or -version version
|
||||||
|
#
|
||||||
|
if [ $rc -ne 0 ]
|
||||||
then
|
then
|
||||||
# output the git information or the -version version
|
if [ -n "$oldVersion" ]
|
||||||
echo $version
|
then
|
||||||
elif [ -n "$previous" ]
|
# use previous version info
|
||||||
then
|
version="$oldVersion"
|
||||||
# use previous build tag
|
else
|
||||||
echo $previous
|
|
||||||
else
|
|
||||||
# fallback to WM_PROJECT_VERSION alone
|
# fallback to WM_PROJECT_VERSION alone
|
||||||
echo ${WM_PROJECT_VERSION:-unknown}
|
version="${WM_PROJECT_VERSION:-unknown}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# output the tag
|
||||||
|
printTag
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user