2 #-------------------------------------------------------------------------------
4 # | ____| _| |_ / __ \ /\ | \/ |
5 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
6 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
7 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
8 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
10 # FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
13 # Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
16 # This file is part of FreeFOAM.
18 # FreeFOAM is free software: you can redistribute it and/or modify it
19 # under the terms of the GNU General Public License as published by the
20 # Free Software Foundation, either version 3 of the License, or (at your
21 # option) any later version.
23 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 # You should have received a copy of the GNU General Public License
29 # along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
32 # checkVersionInfo [--warn]
35 # Verifies the version information contained in various files.
37 # Requires the source directory to be a git checkout
39 #------------------------------------------------------------------------------
41 """Usage: checkVersionInfo.py
43 Verifies the version information contained in various files.
47 --warn Only warn about version information issues, don't treat them as errors.
52 sys
.path
.insert(0, '@FOAM_PYTHON_DIR@')
53 from FreeFOAM
.compat
import *
59 # parse --warn argument if present
62 if len(sys
.argv
) == 2:
63 if sys
.argv
[1] == '--warn':
67 echo('ERROR: unknown option "%s"'%sys
.argv
[1], file=sys
.stderr
)
69 elif len(sys
.argv
) > 2:
70 echo('ERROR: too many arguments', file=sys
.stderr
)
74 SOURCE_DIR
= '@CMAKE_SOURCE_DIR@'
75 GIT_EXECUTABLE
= '@GIT_EXECUTABLE@'
76 UPSTREAM_VERSION
= '1.7.x'
80 # get version info, output is of the form vX.Y.Z
81 v
= subprocess
.check_output(
82 [GIT_EXECUTABLE
, 'describe', '--abbrev=0'])[1:].decode().strip()
83 major
, minor
, patch
= v
.split('.')
85 idx
= patch
.find('rc', 1)
91 h
= subprocess
.check_output(
92 [GIT_EXECUTABLE
, 'merge-base', 'HEAD',
93 'origin/upstream/OpenFOAM-'+UPSTREAM_VERSION
]).decode().strip()
94 u
= UPSTREAM_VERSION
+'-'+subprocess
.check_output(
95 [GIT_EXECUTABLE
, 'log', '-1', '--pretty=format:%h', h
]).decode().strip()
100 op
.join(SOURCE_DIR
, 'CMakeLists.txt'): {
101 'FOAM_VERSION_MAJOR': {
102 'regex': re
.compile(r
'set\(FOAM_VERSION_MAJOR\s+"?(\d+)'),
106 'FOAM_VERSION_MINOR': {
107 'regex': re
.compile(r
'set\(FOAM_VERSION_MINOR\s+"?(\d+)'),
111 'FOAM_VERSION_PATCH': {
112 'regex': re
.compile(r
'set\(FOAM_VERSION_PATCH\s+"?(\d+)'),
116 'FOAM_VERSION_SUFFIX': {
117 'regex': re
.compile(r
'set\(FOAM_VERSION_SUFFIX\s*"?([^\")]*)'),
122 op
.join(SOURCE_DIR
, 'data', 'asciidoc', 'common.conf'): {
124 'regex': re
.compile(r
'^shortver=(\d+\.\d+)$'),
125 'value': '%s.%s'%(major
, minor
),
129 'regex': re
.compile(r
'^ver=(\d+\.\d+\.\d+)$'),
130 'value': '%s.%s.%s'%(major
, minor
, patch
),
134 'regex': re
.compile(r
'^fullver=(\d+\.\d+\.\d+\S*)$'),
135 'value': '%s.%s.%s%s'%(major
, minor
, patch
, rc
),
142 for fname
, items
in checks
.items():
143 for l
in open(fname
, 'rt'):
144 for var
, ctrl
in items
.items():
145 m
= ctrl
['regex'].search(l
)
148 if m
.group(1) != ctrl
['value']:
150 echo('%s: %s in file %s is out of date. Should be "%s".'%(
151 errText
, var
, fname
, ctrl
['value']), file=sys
.stderr
)
153 # verify that we found all version info
154 for fname
, items
in checks
.items():
155 for var
, ctrl
in items
.items():
156 if not ctrl
['found']:
158 echo('%s: Failed to parse %s in file %s.'%(errText
, var
, fname
))
163 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file