Merge commit 'b5be6201e00421a59e574a07b3d28cde5defff84'
[foam-extend-4.0.git] / bin / foamVersion
blobf0f6109e73193f54d649184f8af2a90b4db8855c
1 #!/bin/bash
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 4.0
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamVersion
28 # Description
29 # Report on OpenFOAM version, and source code revision number.
30 # This implementation is using the Subversion revision control system
31 # for retrieving the revision number.
33 # Author:
34 # Martin Beaudoin, Hydro-Quebec, (2009)
36 #------------------------------------------------------------------------------
37 Script=${0##*/}
39 usage() {
40 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
41 cat<<USAGE
43 Usage: $Script [-revision] [-help]
45 Report on the version of OpenFOAM, and if available, the source code revision number.
47 If the source code revision number is not directly available, then the string
48 "exported" will be reported for the revision number.
50 Options:
51 -revision : Report only the revision number
52 -help : this help
54 USAGE
55 exit 1
59 # Initialize the SVN client command
60 SVN_CMD='svn'
62 # initialize the Revision number to "exported" by default.
63 # This is the expected information reported by svnversion when the source code is not from a
64 # svn working copy
65 FOAM_DEV_SVN_REVISION_NUMBER="exported"
67 if [ -e $WM_PROJECT_DIR/.svn ]
68 then
69 # Check if a svn client in available
70 status=`$SVN_CMD --version --quiet >& /dev/null`
72 if [ "$?" -eq 0 ]
73 then
74 # We are not using svnversion here because it is recursive, and this can take a while.
76 # We are forcing LC_ALL=C in order to get rid of any locale variations in the ouput of
77 # the command $SVN_CMD
79 # We are grabbing the revision number associated to "Last Changed Rev:" for the svn repository
80 # branch associated with $WM_PROJECT_DIR. That way, we will not pickup changes in revision number
81 # coming from other parts of the Subversion repository.
83 FOAM_DEV_SVN_REVISION_NUMBER=`LC_ALL=C $SVN_CMD info $WM_PROJECT_DIR | grep "Last Changed Rev:" | awk '{print $4}'`;
87 case "$1" in
88 -revision)
89 shift
90 # Only output the svn version number. Handy when called from Makefiles or scripts
91 echo $FOAM_DEV_SVN_REVISION_NUMBER
93 -help)
94 shift
95 usage
99 if [ $FOAM_DEV_SVN_REVISION_NUMBER ]
100 then
101 echo "OpenFOAM version $WM_PROJECT_VERSION, revision $FOAM_DEV_SVN_REVISION_NUMBER"
102 else
103 echo "OpenFOAM version $WM_PROJECT_VERSION"
106 esac
111 #------------------------------------------------------------------------------