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/>.
35 # Compares the dependency files generated by generateOpenFOAMDeps.py and
38 #------------------------------------------------------------------------------
40 """Usage: generateOpenFOAMDeps <WM_PROJECT_DIR>
42 Compares the dependency files generated by generateOpenFOAMDeps.py and
47 <WM_PROJECT_DIR> Top-level OpenFOAM source directory
52 sys
.path
.insert(0, '@FOAM_PYTHON_DIR@')
53 from FreeFOAM
.compat
import *
61 echo('Error: the path to the OpenFOAM installation is required',
65 WM_PROJECT_DIR
=op
.abspath(args
[0])
68 re
.compile(r
'ImplI?\.C\.ffd$'),
69 re
.compile(r
'[pP]rintStack\.C\.ffd$'),
70 re
.compile(r
'PDRFoamAutoRefine\.C\.ffd$'),
71 re
.compile(r
'src/OpenFOAM/db/dlLibraryTable/dlLibraryTable'),
74 def checkBlacklistPatterns(f
):
75 for p
in blacklistPatterns
:
76 if p
.search(f
) is not None:
80 blacklistDepsPatterns
= (
81 re
.compile(r
'src/OpenFOAM/db/dlLibraryTable'),
82 re
.compile(r
'src/OpenFOAM/primitives/Lists/fileNameList.H'),
83 re
.compile(r
'src/OpenFOAM/primitives/ints/long/long.H'),
84 re
.compile(r
'src/OpenFOAM/include/OSspecific.H'),
87 def removeBlacklistDeps(l
):
89 for p
in blacklistDepsPatterns
:
90 result
= list(filter(lambda f
: p
.search(f
) is None, result
))
94 (re
.compile(r
'_(\.C\.ffd)$'), r
'\1'),
95 (re
.compile(r
'_subst(\.C\.ffd)$'), r
'\1'),
96 (re
.compile(r
'mpi(PstreamGlobals\.C\.ffd)$'), r
'\1'),
97 (re
.compile(r
'\.C.ffd$'), r
'.ofd'),
100 def applySubstPatterns(f
):
102 for p
, r
in substPatterns
:
103 result
= p
.sub(r
, result
)
107 re
.compile(r
'parMetisDecomp\.C\.ffd$'),
108 re
.compile(r
'decompositionMethod\.C\.ffd$'),
109 re
.compile(r
'hierarchGeomDecomp\.C\.ffd$'),
110 re
.compile(r
'geomDecomp\.C\.ffd$'),
111 re
.compile(r
'manualDecomp\.C\.ffd$'),
112 re
.compile(r
'simpleGeomDecomp\.C\.ffd$'),
113 re
.compile(r
'mpiPstreamGlobals\.C\.ffd$'),
116 def checkMpiPatterns(f
):
117 for p
in mpiPatterns
:
118 if p
.search(f
) is not None:
122 SOURCE_DIR
= "@PROJECT_SOURCE_DIR@"
123 BINARY_DIR
= "@PROJECT_BINARY_DIR@"
125 for parent
, dirs
, files
in os
.walk(BINARY_DIR
):
126 for f
in filter(lambda f
: op
.splitext(f
)[1]=='.ffd', files
):
127 f
= op
.join(parent
, f
)
128 # skip blacklisted items
129 if checkBlacklistPatterns(f
):
131 # construct name in OpenFOAM
132 i
= f
.rfind('/', 0, f
.find('@CMAKE_FILES_DIRECTORY@')+1)
133 d
= op
.join(WM_PROJECT_DIR
, op
.relpath(f
[:i
], BINARY_DIR
), 'Make',
134 'linux64FreeFOAMDPDep')
135 if checkMpiPatterns(f
):
138 of
= applySubstPatterns(of
)
140 if not op
.isfile(of
):
141 echo('ERROR: failed to find', of
, file=sys
.stderr
)
144 ffdeps
= removeBlacklistDeps(map(str.strip
, open(f
, 'rt').readlines()))
147 ofdeps
= set(removeBlacklistDeps(map(
148 str.strip
, open(of
, 'rt').readlines())))
149 ffadd
= ffdeps
- ofdeps
150 ffrem
= ofdeps
- ffdeps
151 if len(ffadd
) or len(ffrem
):
154 echo(' +', '\n + '.join(ffadd
))
156 echo(' -', '\n - '.join(ffrem
))
158 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file