/[escript]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6184 - (hide annotations)
Wed Apr 27 01:30:57 2016 UTC (2 years, 6 months ago) by caltinay
File size: 31010 byte(s)
more fixes to weipa readerlib build

1 jfenwick 3982 ##############################################################################
2 jgs 214 #
3 jfenwick 5863 # Copyright (c) 2003-2016 by The University of Queensland
4 jfenwick 3982 # http://www.uq.edu.au
5 ksteube 1811 #
6     # Primary Business: Queensland, Australia
7 jfenwick 6112 # Licensed under the Apache License, version 2.0
8     # http://www.apache.org/licenses/LICENSE-2.0
9 ksteube 1811 #
10 jfenwick 3982 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
12     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 jfenwick 3982 #
14     ##############################################################################
15 jgs 455
16 jfenwick 3259 EnsureSConsVersion(0,98,1)
17     EnsurePythonVersion(2,5)
18 ksteube 1811
19 caltinay 4295 import atexit, sys, os, platform, re
20 jfenwick 3259 from distutils import sysconfig
21 caltinay 4295 from dependencies import *
22 jfenwick 3259 from site_init import *
23 jgs 214
24 jfenwick 3259 # Version number to check for in options file. Increment when new features are
25     # added or existing options changed.
26 caltinay 5148 REQUIRED_OPTS_VERSION=202
27 ksteube 1705
28     # MS Windows support, many thanks to PH
29 jfenwick 3259 IS_WINDOWS = (os.name == 'nt')
30 gross 806
31 jfenwick 4640 IS_OSX = (os.uname()[0] == 'Darwin')
32    
33 jfenwick 3259 ########################## Determine options file ############################
34     # 1. command line
35     # 2. scons/<hostname>_options.py
36     # 3. name as part of a cluster
37 jfenwick 2391 options_file=ARGUMENTS.get('options_file', None)
38     if not options_file:
39 jfenwick 3259 ext_dir = os.path.join(os.getcwd(), 'scons')
40     hostname = platform.node().split('.')[0]
41     for name in hostname, effectiveName(hostname):
42     mangledhostname = re.sub('[^0-9a-zA-Z]', '_', hostname)
43     options_file = os.path.join(ext_dir, mangledhostname+'_options.py')
44     if os.path.isfile(options_file): break
45 jfenwick 2391
46 ksteube 1866 if not os.path.isfile(options_file):
47 jfenwick 3259 print("\nWARNING:\nOptions file %s" % options_file)
48     print("not found! Default options will be used which is most likely suboptimal.")
49 jfenwick 5601 print("We recommend that you copy the most relavent options file in the scons/template/")
50 jfenwick 3259 print("subdirectory and customize it to your needs.\n")
51     options_file = None
52 ksteube 1217
53 jfenwick 3259 ############################### Build options ################################
54 gross 1149
55 jfenwick 3259 default_prefix='/usr'
56 jfenwick 3618 mpi_flavours=('no', 'none', 'MPT', 'MPICH', 'MPICH2', 'OPENMPI', 'INTELMPI')
57 jfenwick 3259 lapack_flavours=('none', 'clapack', 'mkl')
58 caltinay 6119 all_domains = ['dudley','finley','ripley','speckley']
59 jfenwick 2430
60 jfenwick 5589 #Note that scons construction vars the the following purposes:
61     # CPPFLAGS -> to the preprocessor
62     # CCFLAGS -> flags for _both_ C and C++
63     # CXXFLAGS -> flags for c++ _only_
64     # CFLAGS -> flags for c only
65    
66 jfenwick 3259 vars = Variables(options_file, ARGUMENTS)
67     vars.AddVariables(
68     PathVariable('options_file', 'Path to options file', options_file, PathVariable.PathIsFile),
69     PathVariable('prefix', 'Installation prefix', Dir('#.').abspath, PathVariable.PathIsDirCreate),
70 caltinay 3349 PathVariable('build_dir', 'Top-level build directory', Dir('#/build').abspath, PathVariable.PathIsDirCreate),
71 jfenwick 3259 BoolVariable('verbose', 'Output full compile/link lines', False),
72     # Compiler/Linker options
73     ('cxx', 'Path to C++ compiler', 'default'),
74 jfenwick 5589 ('cc_flags', 'Base (C and C++) compiler flags', 'default'),
75     ('cc_optim', 'Additional (C and C++) flags for a non-debug build', 'default'),
76     ('cc_debug', 'Additional (C and C++) flags for a debug build', 'default'),
77 caltinay 2967 ('cxx_extra', 'Extra C++ compiler flags', ''),
78 jfenwick 5589 ('cpp_flags', 'C Pre-processor flags', ''),
79 jfenwick 5601 ('cpp_extra', 'Extra C Pre-processor flags', ''),
80 ksteube 1771 ('ld_extra', 'Extra linker flags', ''),
81 caltinay 5148 ('nvcc', 'Path to CUDA compiler', 'default'),
82     ('nvccflags', 'Base CUDA compiler flags', 'default'),
83 jfenwick 3259 BoolVariable('werror','Treat compiler warnings as errors', True),
84     BoolVariable('debug', 'Compile with debug flags', False),
85     BoolVariable('openmp', 'Compile parallel version using OpenMP', False),
86     ('omp_flags', 'OpenMP compiler flags', 'default'),
87     ('omp_ldflags', 'OpenMP linker flags', 'default'),
88     # Mandatory libraries
89     ('boost_prefix', 'Prefix/Paths of boost installation', default_prefix),
90 jfenwick 3338 ('boost_libs', 'Boost libraries to link with', ['boost_python-mt']),
91 caltinay 3597 # Mandatory for tests
92     ('cppunit_prefix', 'Prefix/Paths of CppUnit installation', default_prefix),
93     ('cppunit_libs', 'CppUnit libraries to link with', ['cppunit']),
94 jfenwick 3259 # Optional libraries and options
95     EnumVariable('mpi', 'Compile parallel version using MPI flavour', 'none', allowed_values=mpi_flavours),
96     ('mpi_prefix', 'Prefix/Paths of MPI installation', default_prefix),
97     ('mpi_libs', 'MPI shared libraries to link with', ['mpi']),
98 caltinay 5250 BoolVariable('cuda', 'Enable GPU code with CUDA (requires thrust)', False),
99 caltinay 5435 ('cuda_prefix', 'Prefix/Paths to NVidia CUDA installation', default_prefix),
100 jfenwick 3259 BoolVariable('netcdf', 'Enable netCDF file support', False),
101     ('netcdf_prefix', 'Prefix/Paths of netCDF installation', default_prefix),
102     ('netcdf_libs', 'netCDF libraries to link with', ['netcdf_c++', 'netcdf']),
103     BoolVariable('parmetis', 'Enable ParMETIS (requires MPI)', False),
104     ('parmetis_prefix', 'Prefix/Paths of ParMETIS installation', default_prefix),
105     ('parmetis_libs', 'ParMETIS libraries to link with', ['parmetis', 'metis']),
106     BoolVariable('mkl', 'Enable the Math Kernel Library', False),
107     ('mkl_prefix', 'Prefix/Paths to MKL installation', default_prefix),
108     ('mkl_libs', 'MKL libraries to link with', ['mkl_solver','mkl_em64t','guide','pthread']),
109     BoolVariable('umfpack', 'Enable UMFPACK', False),
110     ('umfpack_prefix', 'Prefix/Paths to UMFPACK installation', default_prefix),
111     ('umfpack_libs', 'UMFPACK libraries to link with', ['umfpack']),
112 lgao 3508 BoolVariable('boomeramg', 'Enable BoomerAMG', False),
113     ('boomeramg_prefix', 'Prefix/Paths to BoomerAMG installation', default_prefix),
114     ('boomeramg_libs', 'BoomerAMG libraries to link with', ['boomeramg']),
115 jfenwick 3259 EnumVariable('lapack', 'Set LAPACK flavour', 'none', allowed_values=lapack_flavours),
116     ('lapack_prefix', 'Prefix/Paths to LAPACK installation', default_prefix),
117     ('lapack_libs', 'LAPACK libraries to link with', []),
118     BoolVariable('silo', 'Enable the Silo file format in weipa', False),
119     ('silo_prefix', 'Prefix/Paths to Silo installation', default_prefix),
120 caltinay 2184 ('silo_libs', 'Silo libraries to link with', ['siloh5', 'hdf5']),
121 caltinay 6119 BoolVariable('trilinos', 'Enable the Trilinos solvers', False),
122     ('trilinos_prefix', 'Prefix/Paths to Trilinos installation', default_prefix),
123     ('trilinos_libs', 'Trilinos libraries to link with', []),
124 jfenwick 3259 BoolVariable('visit', 'Enable the VisIt simulation interface', False),
125     ('visit_prefix', 'Prefix/Paths to VisIt installation', default_prefix),
126     ('visit_libs', 'VisIt libraries to link with', ['simV2']),
127 caltinay 6119 ListVariable('domains', 'Which domains to build', 'all', all_domains),
128     BoolVariable('paso', 'Build Paso solver library', True),
129     BoolVariable('weipa', 'Build Weipa data export library', True),
130 jfenwick 3259 # Advanced settings
131 caltinay 5266 ('launcher', 'Launcher command (e.g. mpirun)', 'default'),
132     ('prelaunch', 'Command to execute before launcher (e.g. mpdboot)', 'default'),
133     ('postlaunch', 'Command to execute after launcher (e.g. mpdexit)', 'default'),
134 jfenwick 3259 #dudley_assemble_flags = -funroll-loops to actually do something
135     ('dudley_assemble_flags', 'compiler flags for some dudley optimisations', ''),
136     # To enable passing function pointers through python
137     BoolVariable('iknowwhatimdoing', 'Allow non-standard C', False),
138 caltinay 5266 # An option for specifying the compiler tools
139 jfenwick 3259 ('tools_names', 'Compiler tools to use', ['default']),
140     ('env_export', 'Environment variables to be passed to tools',[]),
141     EnumVariable('forcelazy', 'For testing use only - set the default value for autolazy', 'leave_alone', allowed_values=('leave_alone', 'on', 'off')),
142     EnumVariable('forcecollres', 'For testing use only - set the default value for force resolving collective ops', 'leave_alone', allowed_values=('leave_alone', 'on', 'off')),
143 caltinay 6119 BoolVariable('build_shared', 'Build dynamic libraries only (ignored)', True),
144 jfenwick 3259 ('sys_libs', 'Extra libraries to link with', []),
145     ('escript_opts_version', 'Version of options file (do not specify on command line)'),
146 jfenwick 3618 ('SVN_VERSION', 'Do not use from options file', -2),
147 jfenwick 3851 ('pythoncmd', 'which python to compile with','python'),
148 caltinay 6119 BoolVariable('usepython3', 'Is this a python3 build?', False),
149 jfenwick 3892 ('pythonlibname', 'Name of the python library to link. (This is found automatically for python2.X.)', ''),
150 jfenwick 3942 ('pythonlibpath', 'Path to the python library. (You should not need to set this unless your python has moved)',''),
151     ('pythonincpath','Path to python include files. (You should not need to set this unless your python has moved',''),
152 caltinay 5250 BoolVariable('longindices', 'use long indices (for very large matrices)', False),
153 sshaw 4738 BoolVariable('compressed_files','Enables reading from compressed binary files', True),
154 caltinay 5250 ('compression_libs', 'Compression libraries to link with', ['boost_iostreams']),
155     BoolVariable('papi', 'Enable PAPI', False),
156     ('papi_prefix', 'Prefix/Paths to PAPI installation', default_prefix),
157     ('papi_libs', 'PAPI libraries to link with', ['papi']),
158 jfenwick 5851 BoolVariable('papi_instrument_solver', 'Use PAPI to instrument each iteration of the solver', False),
159 caltinay 6137 BoolVariable('osx_dependency_fix', 'Fix dependencies for libraries to have absolute paths (OSX)', False)
160 robwdcock 682 )
161 phornby 1232
162 jfenwick 3259 ##################### Create environment and help text #######################
163 jfenwick 3078
164 jfenwick 3259 # Intel's compiler uses regular expressions improperly and emits a warning
165     # about failing to find the compilers. This warning can be safely ignored.
166 jfenwick 3078
167 caltinay 3319 # PATH is needed so the compiler, linker and tools are found if they are not
168     # in default locations.
169     env = Environment(tools = ['default'], options = vars,
170     ENV = {'PATH': os.environ['PATH']})
171 jfenwick 3967
172 caltinay 4295 # set the vars for clang
173 jfenwick 3967 def mkclang(env):
174 caltinay 4295 env['CXX']='clang++'
175    
176 caltinay 5045 if env['tools_names'] != ['default']:
177 jfenwick 3967 zz=env['tools_names']
178     if 'clang' in zz:
179     zz.remove('clang')
180     zz.insert(0, mkclang)
181 caltinay 3319 env = Environment(tools = ['default'] + env['tools_names'], options = vars,
182     ENV = {'PATH' : os.environ['PATH']})
183 jfenwick 3078
184 jfenwick 3259 if options_file:
185     opts_valid=False
186     if 'escript_opts_version' in env.Dictionary() and \
187     int(env['escript_opts_version']) >= REQUIRED_OPTS_VERSION:
188     opts_valid=True
189     if opts_valid:
190     print("Using options in %s." % options_file)
191     else:
192     print("\nOptions file %s" % options_file)
193     print("is outdated! Please update the file by examining one of the TEMPLATE")
194     print("files in the scons/ subdirectory and setting escript_opts_version to %d.\n"%REQUIRED_OPTS_VERSION)
195     Exit(1)
196 jfenwick 3078
197 jfenwick 3259 # Generate help text (scons -h)
198     Help(vars.GenerateHelpText(env))
199 jfenwick 3078
200 jfenwick 3259 # Check for superfluous options
201 caltinay 3268 if len(vars.UnknownVariables())>0:
202     for k in vars.UnknownVariables():
203     print("Unknown option '%s'" % k)
204     Exit(1)
205 jfenwick 3078
206 caltinay 5148 if env['cuda']:
207     if env['nvcc'] != 'default':
208     env['NVCC'] = env['nvcc']
209     env.Tool('nvcc')
210    
211 sshaw 5381 if 'dudley' in env['domains']:
212     env['domains'].append('finley')
213    
214 caltinay 6119 env['domains'] = sorted(set(env['domains']))
215    
216 caltinay 4295 # create dictionary which will be populated with info for buildvars file
217 caltinay 6119 env['buildvars'] = {}
218 caltinay 4295 # create list which will be populated with warnings if there are any
219 caltinay 6119 env['warnings'] = []
220 caltinay 4295
221 jfenwick 3259 #################### Make sure install directories exist #####################
222 ksteube 1705
223 caltinay 6119 env['BUILD_DIR'] = Dir(env['build_dir']).abspath
224     prefix = Dir(env['prefix']).abspath
225     env['buildvars']['prefix'] = prefix
226 jfenwick 3259 env['incinstall'] = os.path.join(prefix, 'include')
227     env['bininstall'] = os.path.join(prefix, 'bin')
228     env['libinstall'] = os.path.join(prefix, 'lib')
229     env['pyinstall'] = os.path.join(prefix, 'esys')
230 jfenwick 2604 if not os.path.isdir(env['bininstall']):
231     os.makedirs(env['bininstall'])
232     if not os.path.isdir(env['libinstall']):
233     os.makedirs(env['libinstall'])
234     if not os.path.isdir(env['pyinstall']):
235     os.makedirs(env['pyinstall'])
236    
237 jfenwick 3259 env.Append(CPPPATH = [env['incinstall']])
238     env.Append(LIBPATH = [env['libinstall']])
239 jfenwick 2603
240 jfenwick 3259 ################# Fill in compiler options if not set above ##################
241 ksteube 1312
242 caltinay 6119 if env['cxx'] != 'default':
243     env['CXX'] = env['cxx']
244 gross 1024
245 jfenwick 3259 # default compiler/linker options
246     cc_flags = ''
247     cc_optim = ''
248     cc_debug = ''
249     omp_flags = ''
250     omp_ldflags = ''
251     fatalwarning = '' # switch to turn warnings into errors
252     sysheaderopt = '' # how to indicate that a header is a system header
253 jfenwick 2130
254 jfenwick 3259 # env['CC'] might be a full path
255 caltinay 4520 cc_name=os.path.basename(env['CXX'])
256 caltinay 2882
257 caltinay 4520 if cc_name == 'icpc':
258 jfenwick 3259 # Intel compiler
259 caltinay 6010 # #1478: class "std::auto_ptr<...>" was declared deprecated
260 caltinay 4090 # #1875: offsetof applied to non-POD types is nonstandard (in boost)
261 jfenwick 4542 # removed -std=c99 because icpc doesn't like it and we aren't using c anymore
262 caltinay 6010 cc_flags = "-std=c++11 -fPIC -w2 -wd1875 -wd1478 -Wno-unknown-pragmas"
263 caltinay 4877 cc_optim = "-O3 -ftz -fno-alias -inline-level=2 -ipo -xHost"
264 jfenwick 6098 cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK -DSLOWSHARECHECK"
265 caltinay 4090 omp_flags = "-openmp"
266     omp_ldflags = "-openmp -openmp_report=1"
267 jfenwick 3259 fatalwarning = "-Werror"
268 caltinay 4520 elif cc_name[:3] == 'g++':
269 caltinay 5250 # GNU C++ on any system
270 caltinay 4173 # note that -ffast-math is not used because it breaks isnan(),
271     # see mantis #691
272 caltinay 5939 cc_flags = "-std=c++11 -pedantic -Wall -fPIC -Wno-unknown-pragmas -Wno-sign-compare -Wno-system-headers -Wno-long-long -Wno-strict-aliasing -finline-functions"
273 jfenwick 3259 cc_optim = "-O3"
274 caltinay 5250 #max-vartrack-size: avoid vartrack limit being exceeded with escriptcpp.cpp
275 jfenwick 6098 cc_debug = "-g3 -O0 -D_GLIBCXX_DEBUG -DDOASSERT -DDOPROF -DBOUNDS_CHECK -DSLOWSHARECHECK --param=max-vartrack-size=100000000"
276 jfenwick 3259 omp_flags = "-fopenmp"
277     omp_ldflags = "-fopenmp"
278     fatalwarning = "-Werror"
279     sysheaderopt = "-isystem"
280     elif cc_name == 'cl':
281     # Microsoft Visual C on Windows
282     cc_flags = "/EHsc /MD /GR /wd4068 /D_USE_MATH_DEFINES /DDLL_NETCDF"
283     cc_optim = "/O2 /Op /W3"
284     cc_debug = "/Od /RTCcsu /ZI /DBOUNDS_CHECK"
285     fatalwarning = "/WX"
286     elif cc_name == 'icl':
287     # Intel C on Windows
288     cc_flags = '/EHsc /GR /MD'
289     cc_optim = '/fast /Oi /W3 /Qssp /Qinline-factor- /Qinline-min-size=0 /Qunroll'
290     cc_debug = '/Od /RTCcsu /Zi /Y- /debug:all /Qtrapuv'
291     omp_flags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
292     omp_ldflags = '/Qvec-report0 /Qopenmp /Qopenmp-report0 /Qparallel'
293 phornby 1243
294 caltinay 4295 env['sysheaderopt']=sysheaderopt
295    
296 jfenwick 3259 # set defaults if not otherwise specified
297     if env['cc_flags'] == 'default': env['cc_flags'] = cc_flags
298     if env['cc_optim'] == 'default': env['cc_optim'] = cc_optim
299     if env['cc_debug'] == 'default': env['cc_debug'] = cc_debug
300     if env['omp_flags'] == 'default': env['omp_flags'] = omp_flags
301     if env['omp_ldflags'] == 'default': env['omp_ldflags'] = omp_ldflags
302     if env['cxx_extra'] != '': env.Append(CXXFLAGS = env['cxx_extra'])
303     if env['ld_extra'] != '': env.Append(LINKFLAGS = env['ld_extra'])
304 jfenwick 5589 if env['cpp_flags'] != '': env.Append(CPPFLAGS = env['cpp_flags'])
305 jfenwick 5601 if env['cpp_extra'] != '': env.Append(CPPFLAGS = " "+env['cpp_extra'])
306 jfenwick 2130
307 caltinay 5148 if env['nvccflags'] != 'default':
308     env['NVCCFLAGS'] = env['nvccflags']
309     env['SHNVCCFLAGS'] = env['nvccflags'] + ' -shared'
310    
311 caltinay 5183 if env['longindices']:
312     env.Append(CPPDEFINES = ['ESYS_INDEXTYPE_LONG'])
313    
314 jfenwick 3892 if env['usepython3']:
315     env.Append(CPPDEFINES=['ESPYTHON3'])
316    
317 jfenwick 3259 # set up the autolazy values
318     if env['forcelazy'] == 'on':
319     env.Append(CPPDEFINES=['FAUTOLAZYON'])
320     elif env['forcelazy'] == 'off':
321     env.Append(CPPDEFINES=['FAUTOLAZYOFF'])
322 ksteube 1312
323 jfenwick 3259 # set up the collective resolve values
324     if env['forcecollres'] == 'on':
325     env.Append(CPPDEFINES=['FRESCOLLECTON'])
326     elif env['forcecollres'] == 'off':
327     env.Append(CPPDEFINES=['FRESCOLLECTOFF'])
328 jfenwick 2273
329 jfenwick 3259 # allow non-standard C if requested
330 jfenwick 2827 if env['iknowwhatimdoing']:
331 jfenwick 3259 env.Append(CPPDEFINES=['IKNOWWHATIMDOING'])
332 jfenwick 2827
333 jfenwick 3259 # Disable OpenMP if no flags provided
334     if env['openmp'] and env['omp_flags'] == '':
335 caltinay 4295 env['warnings'].append("OpenMP requested but no flags provided - disabling OpenMP!")
336 jfenwick 3259 env['openmp'] = False
337 gross 1160
338 jfenwick 3259 if env['openmp']:
339     env.Append(CCFLAGS = env['omp_flags'])
340     if env['omp_ldflags'] != '': env.Append(LINKFLAGS = env['omp_ldflags'])
341     else:
342     env['omp_flags']=''
343     env['omp_ldflags']=''
344 ksteube 1312
345 caltinay 4295 env['buildvars']['openmp']=int(env['openmp'])
346    
347 jfenwick 3259 # add debug/non-debug compiler flags
348 caltinay 4295 env['buildvars']['debug']=int(env['debug'])
349 jfenwick 3259 if env['debug']:
350     env.Append(CCFLAGS = env['cc_debug'])
351 gross 2423 else:
352 jfenwick 3259 env.Append(CCFLAGS = env['cc_optim'])
353 gross 1163
354 jfenwick 3259 # always add cc_flags
355     env.Append(CCFLAGS = env['cc_flags'])
356 phornby 1243
357 jfenwick 3259 # add system libraries
358     env.AppendUnique(LIBS = env['sys_libs'])
359 gross 2363
360 caltinay 5266 # set defaults for launchers if not otherwise specified
361     if env['prelaunch'] == 'default':
362     if env['mpi'] == 'INTELMPI' and env['openmp']:
363     env['prelaunch'] = "export I_MPI_PIN_DOMAIN=omp"
364     elif env['mpi'] == 'OPENMPI':
365     # transform comma-separated list to '-x a -x b -x c ...'
366 jfenwick 5408 env['prelaunch'] = "EE=$(echo -x %e|sed -e 's/,/ -x /g')"
367 caltinay 5266 elif env['mpi'] == 'MPT':
368     env['prelaunch'] = "export MPI_NUM_MEMORY_REGIONS=0"
369     elif env['mpi'] == 'MPICH2':
370     env['prelaunch'] = "mpdboot -n %n -r ssh -f %f"
371     else:
372     env['prelaunch'] = ""
373    
374     if env['launcher'] == 'default':
375     if env['mpi'] == 'INTELMPI':
376     env['launcher'] = "mpirun -hostfile %f -n %N -ppn %p %b"
377     elif env['mpi'] == 'OPENMPI':
378 caltinay 6119 env['launcher'] = "mpirun ${AGENTOVERRIDE} --gmca mpi_warn_on_fork 0 ${EE} --host %h --cpus-per-rank %t -np %N %b"
379     #newer OpenMPI version:
380     #env['launcher'] = "mpirun ${AGENTOVERRIDE} --gmca mpi_warn_on_fork 0 ${EE} --host %h --map-by node:pe=%t -bind-to core -np %N %b"
381 caltinay 5266 elif env['mpi'] == 'MPT':
382     env['launcher'] = "mpirun %h -np %p %b"
383     elif env['mpi'] == 'MPICH':
384     env['launcher'] = "mpirun -machinefile %f -np %N %b"
385     elif env['mpi'] == 'MPICH2':
386     env['launcher'] = "mpiexec -genvlist %e -np %N %b"
387     else:
388     env['launcher'] = "%b"
389    
390     if env['postlaunch'] == 'default':
391     if env['mpi'] == 'MPICH2':
392     env['postlaunch'] = "mpdallexit"
393     else:
394     env['postlaunch'] = ""
395    
396 caltinay 4295 # determine svn revision
397 jfenwick 3618 global_revision=ARGUMENTS.get('SVN_VERSION', None)
398     if global_revision:
399     global_revision = re.sub(':.*', '', global_revision)
400     global_revision = re.sub('[^0-9]', '', global_revision)
401     if global_revision == '': global_revision='-2'
402     else:
403     # Get the global Subversion revision number for the getVersion() method
404     try:
405 jfenwick 3259 global_revision = os.popen('svnversion -n .').read()
406     global_revision = re.sub(':.*', '', global_revision)
407     global_revision = re.sub('[^0-9]', '', global_revision)
408     if global_revision == '': global_revision='-2'
409 jfenwick 3618 except:
410 jfenwick 3259 global_revision = '-1'
411 caltinay 3271 env['svn_revision']=global_revision
412 caltinay 4295 env['buildvars']['svn_revision']=global_revision
413 jfenwick 3259 env.Append(CPPDEFINES=['SVN_VERSION='+global_revision])
414 gross 2363
415 caltinay 4295 env['IS_WINDOWS']=IS_WINDOWS
416 jfenwick 5407 env['IS_OSX']=IS_OSX
417 caltinay 4295
418 jfenwick 3259 ###################### Copy required environment vars ########################
419 gross 2363
420 jfenwick 3259 # Windows doesn't use LD_LIBRARY_PATH but PATH instead
421     if IS_WINDOWS:
422     LD_LIBRARY_PATH_KEY='PATH'
423     env['ENV']['LD_LIBRARY_PATH']=''
424     else:
425     LD_LIBRARY_PATH_KEY='LD_LIBRARY_PATH'
426 robwdcock 682
427 caltinay 4295 env['LD_LIBRARY_PATH_KEY']=LD_LIBRARY_PATH_KEY
428    
429 caltinay 3319 # the following env variables are exported for the unit tests
430 phornby 1244
431 jfenwick 3259 for key in 'OMP_NUM_THREADS', 'ESCRIPT_NUM_PROCS', 'ESCRIPT_NUM_NODES':
432     try:
433     env['ENV'][key] = os.environ[key]
434     except KeyError:
435 caltinay 5045 env['ENV'][key] = '1'
436 robwdcock 682
437 jfenwick 3259 env_export=env['env_export']
438 caltinay 4917 env_export.extend(['ESCRIPT_NUM_THREADS','ESCRIPT_HOSTFILE','DISPLAY','XAUTHORITY','PATH','HOME','KMP_MONITOR_STACKSIZE','TMPDIR','TEMP','TMP','LD_PRELOAD'])
439 robwdcock 682
440 jfenwick 3259 for key in set(env_export):
441     try:
442     env['ENV'][key] = os.environ[key]
443     except KeyError:
444     pass
445 ksteube 1312
446 caltinay 5436 for key in os.environ.keys():
447     if key.startswith("SLURM_"):
448     env['ENV'][key] = os.environ[key]
449    
450 jfenwick 3259 try:
451     env.PrependENVPath(LD_LIBRARY_PATH_KEY, os.environ[LD_LIBRARY_PATH_KEY])
452     except KeyError:
453     pass
454 ksteube 1312
455 jfenwick 4640 if IS_OSX:
456     try:
457     env.PrependENVPath('DYLD_LIBRARY_PATH', os.environ['DYLD_LIBRARY_PATH'])
458     except KeyError:
459     pass
460    
461    
462 jfenwick 3259 # these shouldn't be needed
463     #for key in 'C_INCLUDE_PATH','CPLUS_INCLUDE_PATH','LIBRARY_PATH':
464     # try:
465     # env['ENV'][key] = os.environ[key]
466     # except KeyError:
467     # pass
468 ksteube 1312
469 jfenwick 3259 try:
470     env['ENV']['PYTHONPATH'] = os.environ['PYTHONPATH']
471     except KeyError:
472     pass
473 ksteube 1312
474 jfenwick 3259 ######################## Add some custom builders ############################
475 ksteube 1312
476 caltinay 6124 # Takes care of prefix and suffix for Python modules:
477     def build_python_module(env, target, source):
478     return env.SharedLibrary(target, source, SHLIBPREFIX='', SHLIBSUFFIX='.so')
479     env.AddMethod(build_python_module, "PythonModule")
480    
481 jfenwick 3851 if env['pythoncmd']=='python':
482     py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
483     else:
484 jfenwick 3892 py_builder = Builder(action = env['pythoncmd']+" scripts/py_comp.py $SOURCE $TARGET", suffix = '.pyc', src_suffix = '.py', single_source=True)
485 jfenwick 3259 env.Append(BUILDERS = {'PyCompile' : py_builder});
486 gross 2423
487 jfenwick 3259 runUnitTest_builder = Builder(action = runUnitTest, suffix = '.passed', src_suffix=env['PROGSUFFIX'], single_source=True)
488     env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
489 gross 2423
490 jfenwick 3259 runPyUnitTest_builder = Builder(action = runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
491     env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
492 ksteube 1756
493 sshaw 5017 runPyExample_builder = Builder(action = runPyExample, suffix = '.passed', src_suffic='.py', single_source=True)
494     env.Append(BUILDERS = {'RunPyExample' : runPyExample_builder});
495    
496 jfenwick 3259 epstopdfbuilder = Builder(action = eps2pdf, suffix='.pdf', src_suffix='.eps', single_source=True)
497     env.Append(BUILDERS = {'EpsToPDF' : epstopdfbuilder});
498 ksteube 817
499 jfenwick 3259 ############################ Dependency checks ###############################
500 phornby 1246
501 caltinay 4295 ######## Compiler
502     env=checkCompiler(env)
503 phornby 1634
504 jfenwick 3259 ######## Python headers & library (required)
505 caltinay 4295 env=checkPython(env)
506 gross 806
507 caltinay 4295 ######## boost & boost-python (required)
508     env=checkBoost(env)
509 jfenwick 3892
510 caltinay 4295 ######## numpy (required) and numpy headers (optional)
511     env=checkNumpy(env)
512 jfenwick 3892
513 caltinay 3597 ######## CppUnit (required for tests)
514 caltinay 4295 env=checkCppUnit(env)
515 caltinay 3597
516 caltinay 6119 ######## NVCC version (optional)
517     if env['cuda'] and 'ripley' in env['domains']:
518     env=checkCudaVersion(env)
519     env=checkCUDA(env)
520    
521 caltinay 4295 ######## optional python modules (sympy, pyproj)
522     env=checkOptionalModules(env)
523 caltinay 3597
524 caltinay 4295 ######## optional dependencies (netCDF, PAPI, MKL, UMFPACK, Lapack, Silo, ...)
525     env=checkOptionalLibraries(env)
526 caltinay 3975
527 caltinay 3604 ######## PDFLaTeX (for documentation)
528 caltinay 4295 env=checkPDFLatex(env)
529 caltinay 3604
530 caltinay 6119 # dependency sanity checks
531    
532     if len(env['domains']) == 0:
533     env['warnings'].append("No domains have been built, escript will not be very useful!")
534    
535 jfenwick 3259 # keep some of our install paths first in the list for the unit tests
536     env.PrependENVPath(LD_LIBRARY_PATH_KEY, env['libinstall'])
537     env.PrependENVPath('PYTHONPATH', prefix)
538     env['ENV']['ESCRIPT_ROOT'] = prefix
539 ksteube 1705
540 jfenwick 3259 if not env['verbose']:
541     env['CXXCOMSTR'] = "Compiling $TARGET"
542     env['SHCXXCOMSTR'] = "Compiling $TARGET"
543     env['ARCOMSTR'] = "Linking $TARGET"
544     env['LINKCOMSTR'] = "Linking $TARGET"
545     env['SHLINKCOMSTR'] = "Linking $TARGET"
546 caltinay 3271 env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
547     env['BIBTEXCOMSTR'] = "Generating bibliography $TARGET"
548     env['MAKEINDEXCOMSTR'] = "Generating index $TARGET"
549     env['PDFLATEXCOMSTR'] = "Building $TARGET from LaTeX input $SOURCES"
550 jfenwick 3259 #Progress(['Checking -\r', 'Checking \\\r', 'Checking |\r', 'Checking /\r'], interval=17)
551 ksteube 1705
552 caltinay 6119 ########################### Configure the targets ############################
553 ksteube 1247
554 caltinay 6119 from grouptest import GroupTest
555 jfenwick 2235 TestGroups=[]
556    
557 jfenwick 3259 # keep an environment without warnings-as-errors
558     dodgy_env=env.Clone()
559 jfenwick 2827
560 jfenwick 3259 # now add warnings-as-errors flags. This needs to be done after configuration
561     # because the scons test files have warnings in them
562     if ((fatalwarning != '') and (env['werror'])):
563     env.Append(CCFLAGS = fatalwarning)
564 jfenwick 2827
565 phornby 2027 Export(
566 jfenwick 3259 ['env',
567     'dodgy_env',
568     'IS_WINDOWS',
569     'TestGroups'
570     ]
571     )
572 ksteube 1705
573 caltinay 3604 target_init = env.Command(os.path.join(env['pyinstall'],'__init__.py'), None, Touch('$TARGET'))
574 ksteube 1705 env.Alias('target_init', [target_init])
575    
576 caltinay 6119 # escript can't be turned off
577 caltinay 6174 build_all_list = ['build_escript']
578     install_all_list = ['target_init', 'install_escript']
579 caltinay 2810
580 caltinay 6119 if env['usempi']:
581     build_all_list += ['build_pythonMPI', 'build_overlord']
582     install_all_list += ['install_pythonMPI', 'install_overlord']
583 caltinay 3096
584 caltinay 6119 if env['paso']:
585 caltinay 6167 env.Append(CPPDEFINES = ['ESYS_HAVE_PASO'])
586 caltinay 6119 build_all_list += ['build_paso']
587     install_all_list += ['install_paso']
588 caltinay 2910
589 caltinay 6119 if env['trilinos']:
590     build_all_list += ['build_trilinoswrap']
591     install_all_list += ['install_trilinoswrap']
592 caltinay 3792
593 caltinay 6119 for domain in env['domains']:
594 caltinay 6174 env.Append(CPPDEFINES = ['ESYS_HAVE_'+domain.upper()])
595 caltinay 6119 build_all_list += ['build_%s'%domain]
596     install_all_list += ['install_%s'%domain]
597 ksteube 1705
598 caltinay 6119 if env['weipa']:
599 caltinay 6174 env.Append(CPPDEFINES = ['ESYS_HAVE_WEIPA'])
600 caltinay 6119 build_all_list += ['build_weipa']
601     install_all_list += ['install_weipa']
602 caltinay 6184 if 'finley' in env['domains'] or 'dudley' in env['domains']:
603 caltinay 6119 build_all_list += ['build_escriptreader']
604     install_all_list += ['install_escriptreader']
605 ksteube 1705
606 caltinay 6174 variant='$BUILD_DIR/$PLATFORM/'
607     env.SConscript('escriptcore/SConscript', variant_dir=variant+'escriptcore', duplicate=0)
608     env.SConscript('escript/py_src/SConscript', variant_dir=variant+'escript', duplicate=0)
609     env.SConscript('pythonMPI/src/SConscript', variant_dir=variant+'pythonMPI', duplicate=0)
610     env.SConscript('tools/overlord/SConscript', variant_dir=variant+'tools/overlord', duplicate=0)
611     env.SConscript('paso/SConscript', variant_dir=variant+'paso', duplicate=0)
612     env.SConscript('trilinoswrap/SConscript', variant_dir=variant+'trilinoswrap', duplicate=0)
613     env.SConscript('cusplibrary/SConscript')
614     env.SConscript('dudley/SConscript', variant_dir=variant+'dudley', duplicate=0)
615     env.SConscript('finley/SConscript', variant_dir=variant+'finley', duplicate=0)
616     env.SConscript('ripley/SConscript', variant_dir=variant+'ripley', duplicate=0)
617     env.SConscript('speckley/SConscript', variant_dir=variant+'speckley', duplicate=0)
618     env.SConscript('weipa/SConscript', variant_dir=variant+'weipa', duplicate=0)
619     env.SConscript(dirs = ['downunder/py_src'], variant_dir=variant+'downunder', duplicate=0)
620     env.SConscript(dirs = ['modellib/py_src'], variant_dir=variant+'modellib', duplicate=0)
621     env.SConscript(dirs = ['pycad/py_src'], variant_dir=variant+'pycad', duplicate=0)
622     env.SConscript('tools/escriptconvert/SConscript', variant_dir=variant+'tools/escriptconvert', duplicate=0)
623     env.SConscript('doc/SConscript', variant_dir=variant+'doc', duplicate=0)
624 ksteube 1705
625 caltinay 6119 env.Alias('build', build_all_list)
626    
627 caltinay 3947 install_all_list += ['install_downunder_py']
628 jfenwick 3259 install_all_list += ['install_modellib_py']
629     install_all_list += ['install_pycad_py']
630 caltinay 6119 install_all_list += [env.Install(Dir('scripts',env['build_dir']), os.path.join('scripts', 'release_sanity.py'))]
631 ksteube 1705
632 jfenwick 5851 if env['osx_dependency_fix']:
633     print("Require dependency fix")
634 caltinay 6119 install_all=env.Command('install', install_all_list, 'scripts/moveall.sh')
635 jfenwick 5851 else:
636 caltinay 6119 install_all=env.Alias('install', install_all_list)
637 jfenwick 5851
638 jfenwick 5811 sanity=env.Alias('sanity', env.Command('dummy','',os.path.join(env['prefix'], 'bin', 'run-escript')+' '+os.path.join(env['build_dir'],'scripts', 'release_sanity.py')))
639 jfenwick 5802 env.Depends('dummy', install_all)
640 jfenwick 5801 if env['usempi']:
641 caltinay 6119 env.Depends('dummy', ['install_pythonMPI'])
642 jfenwick 5801
643 caltinay 6119 # if all domains are built:
644     if env['domains'] == all_domains:
645 jfenwick 5802 env.AlwaysBuild('sanity')
646     env.Default('sanity')
647     else:
648 caltinay 6119 env.Default('install')
649 jfenwick 5800
650 jfenwick 3259 ################## Targets to build and run the test suite ###################
651 ksteube 1705
652 caltinay 3597 if not env['cppunit']:
653 caltinay 4520 test_msg = env.Command('.dummy.', None, '@echo "Cannot run C++ unit tests, CppUnit not found!";exit 1')
654 caltinay 3597 env.Alias('run_tests', test_msg)
655 caltinay 4249 env.Alias('build_tests', '')
656 caltinay 6119 env.Alias('run_tests', ['install'])
657     env.Alias('all_tests', ['install', 'run_tests', 'py_tests'])
658     env.Alias('build_full',['install','build_tests','build_py_tests'])
659     Requires('py_tests', 'install')
660 ksteube 1705
661 jfenwick 3259 ##################### Targets to build the documentation #####################
662 artak 2820
663 jfenwick 4244 env.Alias('pdfdocs',['user_pdf', 'install_pdf', 'cookbook_pdf', 'inversion_pdf'])
664     env.Alias('basedocs', ['pdfdocs','examples_tarfile', 'examples_zipfile', 'api_doxygen'])
665 jfenwick 4167 env.Alias('docs', ['basedocs', 'sphinxdoc'])
666 caltinay 6119 env.Alias('release_prep', ['docs', 'install'])
667     env.Alias('release_prep_old', ['basedocs', 'api_epydoc', 'install'])
668 ksteube 1705
669 jfenwick 4078 # The test scripts are always generated, this target allows us to
670     # generate the testscripts without doing a full build
671     env.Alias('testscripts',[])
672    
673 jfenwick 3259 if not IS_WINDOWS:
674 caltinay 4295 generateTestScripts(env, TestGroups)
675 jfenwick 2879
676 caltinay 6119 ######################## Populate the buildvars file #########################
677 caltinay 3604
678 caltinay 6119 write_buildvars(env)
679     # delete buildvars upon cleanup - target_init is default so use it
680     env.Clean('target_init', File('buildvars', env['libinstall']))
681    
682     write_launcher(env)
683    
684     # remove obsolete files
685     if not env['usempi']:
686     Execute(Delete(File(['pythonMPI','pythonMPIredirect'], env['libinstall'])))
687     Execute(Delete(File('escript-overlord', env['bininstall'])))
688    
689 caltinay 4295 ######################## Summarize our environment ###########################
690     def print_summary():
691     print("")
692 caltinay 4299 print("*** Config Summary (see config.log and <prefix>/lib/buildvars for details) ***")
693 caltinay 6119 print("Escript revision %s"%global_revision)
694 caltinay 4295 print(" Install prefix: %s"%env['prefix'])
695     print(" Python: %s"%sysconfig.PREFIX)
696 caltinay 5696 print(" boost: %s (Version %s)"%(env['boost_prefix'],env['boost_version']))
697 caltinay 4299 if env['numpy_h']:
698     print(" numpy: YES (with headers)")
699     else:
700     print(" numpy: YES (without headers)")
701 caltinay 4295 if env['usempi']:
702     print(" MPI: YES (flavour: %s)"%env['mpi'])
703     else:
704 caltinay 5250 print(" MPI: NO")
705 caltinay 5696 if env['parmetis']:
706     print(" ParMETIS: %s (Version %s)"%(env['parmetis_prefix'],env['parmetis_version']))
707     else:
708     print(" ParMETIS: NO")
709 caltinay 4295 if env['uselapack']:
710     print(" LAPACK: YES (flavour: %s)"%env['lapack'])
711     else:
712 caltinay 5250 print(" LAPACK: NO")
713 caltinay 5148 if env['cuda']:
714     print(" CUDA: YES (nvcc: %s)"%env['nvcc_version'])
715     else:
716 caltinay 5250 print(" CUDA: NO")
717 caltinay 4295 d_list=[]
718     e_list=[]
719 caltinay 6119 for i in 'debug','openmp','boomeramg','cppunit','gdal','mkl','netcdf','papi','pyproj','scipy','silo','sympy','trilinos','umfpack','visit':
720 caltinay 4295 if env[i]: e_list.append(i)
721     else: d_list.append(i)
722     for i in e_list:
723     print("%16s: YES"%i)
724     for i in d_list:
725 caltinay 5250 print("%16s: NO"%i)
726 caltinay 5391 if env['gmshpy']:
727     gmshpy=" + python module"
728     else:
729     gmshpy=""
730 caltinay 4295 if env['gmsh']=='m':
731 caltinay 5391 print(" gmsh: YES, MPI-ENABLED"+gmshpy)
732 caltinay 4295 elif env['gmsh']=='s':
733 caltinay 5391 print(" gmsh: YES"+gmshpy)
734 caltinay 4295 else:
735 caltinay 5391 if env['gmshpy']:
736     print(" gmsh: python module only")
737     else:
738     print(" gmsh: NO")
739 sshaw 4738 print( " gzip: " + ("YES" if env['compressed_files'] else "NO"))
740 caltinay 4299
741 caltinay 4295 if ((fatalwarning != '') and (env['werror'])):
742     print(" Treating warnings as errors")
743     else:
744     print(" NOT treating warnings as errors")
745     print("")
746     for w in env['warnings']:
747     print("WARNING: %s"%w)
748 sshaw 4726 if len(GetBuildFailures()):
749     print("\nERROR: build stopped due to errors\n")
750     else:
751     print("\nSUCCESS: build complete\n")
752 caltinay 4295
753     atexit.register(print_summary)
754    

  ViewVC Help
Powered by ViewVC 1.1.26