/[escript]/trunk/SConstruct
ViewVC logotype

Contents of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6241 - (show annotations)
Wed Jun 1 06:00:06 2016 UTC (2 years, 8 months ago) by caltinay
File size: 30434 byte(s)
**Warning, this may break your build**
- Bumped required options version to 203 - new options for trilinos, paso, weipa
- scons/templates/README_FIRST is now the file that explains all the options,
  added comment to README but need to change install guide still.
- removed some obsolete options files
- removed most comments from template files, they now refer to README_FIRST
- removed usepython3 option as we now determine this based on python version
  string.
- enabled use of numpy.h with python 3 (last commit should have fixed the
  issues)

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

  ViewVC Help
Powered by ViewVC 1.1.26