/[escript]/trunk/SConstruct
ViewVC logotype

Annotation of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6255 - (hide annotations)
Thu Jun 2 06:52:06 2016 UTC (2 years, 10 months ago) by caltinay
File size: 31439 byte(s)
modified build summary so we save some space and make clear what solvers
are available.

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

  ViewVC Help
Powered by ViewVC 1.1.26