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 2 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, write to the Free Software Foundation,
30 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 # Compares the dependency files generated by generateOpenFOAMDeps.py and
39 #------------------------------------------------------------------------------
41 """Usage: generateOpenFOAMDeps <WM_PROJECT_DIR>
43 Compares the dependency files generated by generateOpenFOAMDeps.py and
48 <WM_PROJECT_DIR> Top-level OpenFOAM source directory
53 sys
.path
.insert(0, '@FOAM_PYTHON_DIR@')
54 from FreeFOAM
.compat
import *
62 echo('Error: the path to the OpenFOAM installation is required',
66 WM_PROJECT_DIR
=op
.abspath(args
[0])
69 re
.compile(r
'ImplI?\.C\.ffd$'),
70 re
.compile(r
'[pP]rintStack\.C\.ffd$'),
71 re
.compile(r
'PDRFoamAutoRefine\.C\.ffd$'),
72 re
.compile(r
'src/OpenFOAM/db/dlLibraryTable/dlLibraryTable'),
75 def checkBlacklistPatterns(f
):
76 for p
in blacklistPatterns
:
77 if p
.search(f
) is not None:
81 blacklistDepsPatterns
= (
82 re
.compile(r
'src/OpenFOAM/db/dlLibraryTable'),
83 re
.compile(r
'src/OpenFOAM/primitives/Lists/fileNameList.H'),
84 re
.compile(r
'src/OpenFOAM/primitives/ints/long/long.H'),
85 re
.compile(r
'src/OpenFOAM/include/OSspecific.H'),
88 def removeBlacklistDeps(l
):
90 for p
in blacklistDepsPatterns
:
91 result
= list(filter(lambda f
: p
.search(f
) is None, result
))
95 (re
.compile(r
'_(\.C\.ffd)$'), r
'\1'),
96 (re
.compile(r
'_subst(\.C\.ffd)$'), r
'\1'),
97 (re
.compile(r
'mpi(PstreamGlobals\.C\.ffd)$'), r
'\1'),
98 (re
.compile(r
'\.C.ffd$'), r
'.ofd'),
101 def applySubstPatterns(f
):
103 for p
, r
in substPatterns
:
104 result
= p
.sub(r
, result
)
108 re
.compile(r
'parMetisDecomp\.C\.ffd$'),
109 re
.compile(r
'decompositionMethod\.C\.ffd$'),
110 re
.compile(r
'hierarchGeomDecomp\.C\.ffd$'),
111 re
.compile(r
'geomDecomp\.C\.ffd$'),
112 re
.compile(r
'manualDecomp\.C\.ffd$'),
113 re
.compile(r
'simpleGeomDecomp\.C\.ffd$'),
114 re
.compile(r
'mpiPstreamGlobals\.C\.ffd$'),
117 def checkMpiPatterns(f
):
118 for p
in mpiPatterns
:
119 if p
.search(f
) is not None:
123 SOURCE_DIR
= "@PROJECT_SOURCE_DIR@"
124 BINARY_DIR
= "@PROJECT_BINARY_DIR@"
126 for parent
, dirs
, files
in os
.walk(BINARY_DIR
):
127 for f
in filter(lambda f
: op
.splitext(f
)[1]=='.ffd', files
):
128 f
= op
.join(parent
, f
)
129 # skip blacklisted items
130 if checkBlacklistPatterns(f
):
132 # construct name in OpenFOAM
133 i
= f
.rfind('/', 0, f
.find('@CMAKE_FILES_DIRECTORY@')+1)
134 d
= op
.join(WM_PROJECT_DIR
, op
.relpath(f
[:i
], BINARY_DIR
), 'Make',
135 'linux64FreeFOAMDPDep')
136 if checkMpiPatterns(f
):
139 of
= applySubstPatterns(of
)
141 if not op
.isfile(of
):
142 echo('ERROR: failed to find', of
, file=sys
.stderr
)
145 ffdeps
= removeBlacklistDeps(map(str.strip
, open(f
, 'rt').readlines()))
148 ofdeps
= set(removeBlacklistDeps(map(
149 str.strip
, open(of
, 'rt').readlines())))
150 ffadd
= ffdeps
- ofdeps
151 ffrem
= ofdeps
- ffdeps
152 if len(ffadd
) or len(ffrem
):
155 echo(' +', '\n + '.join(ffadd
))
157 echo(' -', '\n - '.join(ffrem
))
159 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file