/[escript]/branches/refine/SConstruct
ViewVC logotype

Annotation of /branches/refine/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 682 - (hide annotations)
Mon Mar 27 02:43:09 2006 UTC (13 years, 3 months ago) by robwdcock
Original Path: trunk/SConstruct
File size: 12085 byte(s)
+ NEW BUILD SYSTEM

This commit contains the new build system with cross-platform support.
Most things work are before though you can have more control.

ENVIRONMENT settings have changed:
+ You no longer require LD_LIBRARY_PATH or PYTHONPATH to point to the
esysroot for building and testing performed via scons
+ ACcESS altix users: It is recommended you change your modules to load
the latest intel compiler and other libraries required by boost to match
the setup in svn (you can override). The correct modules are as follows

module load intel_cc.9.0.026
export
MODULEPATH=${MODULEPATH}:/data/raid2/toolspp4/modulefiles/gcc-3.3.6
module load boost/1.33.0/python-2.4.1
module load python/2.4.1
module load numarray/1.3.3


1 elspeth 643 # Copyright 2006 by ACcESS MNRF
2     #
3     # http://www.access.edu.au
4     # Primary Business: Queensland, Australia
5     # Licensed under the Open Software License version 3.0
6     # http://www.opensource.org/licenses/osl-3.0.php
7     #
8 jgs 214 #
9 elspeth 643 #
10 jgs 455
11 robwdcock 682 # top-level Scons configuration file for all esys13 modules
12     # Begin initialisation Section
13     # all of this section just intialises default environments and helper
14     # scripts. You shouldn't need to modify this section.
15     EnsureSConsVersion(0,96,91)
16     EnsurePythonVersion(2,3)
17 jgs 214
18 robwdcock 682 import sys, os
19     # Add our extensions
20     if sys.path.count('scons')==0: sys.path.append('scons')
21     import scons_extensions
22 jgs 192
23 robwdcock 682 # Default options and options help text
24     # These are defaults and can be overridden using command line arguments or an options file.
25     # if the options_file or ARGUMENTS do not exist then the ones listed as default here are used
26     # DO NOT CHANGE THEM HERE
27     if ARGUMENTS.get('options_file',0):
28     options_file = ARGUMENTS.get('options_file',0)
29     else:
30     import socket
31     from string import ascii_letters,digits
32     hostname=""
33     for s in socket.gethostname().split('.')[0]:
34     if s in ascii_letters+digits:
35     hostname+=s
36     else:
37     hostname+="_"
38     options_file = "scons/"+hostname+"_options.py"
39 jgs 214
40 robwdcock 682 opts = Options(options_file, ARGUMENTS)
41     opts.AddOptions(
42     # Where to install esys stuff
43     ('incinstall', 'where the esys headers will be installed', Dir('#.').abspath+'/include'),
44     ('libinstall', 'where the esys libraries will be installed', Dir('#.').abspath+'/lib'),
45     ('pyinstall', 'where the esys python modules will be installed', Dir('#.').abspath),
46     # Compilation options
47     BoolOption('dodebug', 'Do you want a debug build?', 'yes'),
48     ('options_file', "Optional file containing preferred options. Ignored if it doesn't exist (default: scons/hostname_options.py)", options_file),
49     ('cc_defines','C/C++ defines to use', None),
50     ('cc_flags','C compiler flags to use (Release build)', None),
51     ('cc_flags_debug', 'C compiler flags to use (Debug build)', None),
52     ('cxx_flags', 'C++ compiler flags to use (Release build)', None),
53     ('cxx_flags_debug', 'C++ compiler flags to use (Debug build)', None),
54     ('ar_flags', 'Static library archiver flags to use', None),
55     ('sys_libs', 'System libraries to link with', None),
56     # MKL
57     PathOption('mkl_path', 'Path to MKL includes', None),
58     PathOption('mkl_lib_path', 'Path to MKL libs', None),
59     ('mkl_libs', 'MKL libraries to link with', None),
60     # SCSL
61     PathOption('scsl_path', 'Path to SCSL includes', None),
62     PathOption('scsl_lib_path', 'Path to SCSL libs', None),
63     ('scsl_libs', 'SCSL libraries to link with', None),
64     # UMFPACK
65     PathOption('umf_path', 'Path to UMF includes', None),
66     PathOption('umf_lib_path', 'Path to UMF libs', None),
67     ('umf_libs', 'UMF libraries to link with', None),
68     # Python
69     PathOption('python_path', 'Path to Python includes', '/usr/include'),
70     PathOption('python_lib_path', 'Path to Python libs', '/usr/lib'),
71     ('python_lib', 'Python libraries to link with', ['python2.3',]),
72     # Boost
73     PathOption('boost_path', 'Path to Boost includes', '/usr/include'),
74     PathOption('boost_lib_path', 'Path to Boost libs', '/usr/lib'),
75     ('boost_lib', 'Boost libraries to link with', ['boost_python',]),
76     # CppUnit
77     PathOption('cppunit_path', 'Path to CppUnit includes', Dir('#.').abspath+'/tools/CppUnitTest/inc'),
78     PathOption('cppunit_lib_path', 'Path to CppUnit libs', Dir('#.').abspath+'/lib'),
79     ('cppunit_lib', 'CppUnit libraries to link with', ['CppUnitTest',]),
80     # Doc building
81     PathOption('doxygen_path', 'Path to Doxygen executable', None),
82     PathOption('epydoc_path', 'Path to Epydoc executable', None),
83     PathOption('epydoc_pythonpath', 'Path to Epydoc python files', None),
84     # PAPI
85     PathOption('papi_path', 'Path to PAPI includes', None),
86     PathOption('papi_lib_path', 'Path to PAPI libs', None),
87     ('papi_libs', 'PAPI libraries to link with', None),
88     )
89    
90     # Initialise Scons Build Environment
91     # check for user environment variables we are interested in
92     try:
93     python_path = os.environ['PYTHONPATH']
94     except KeyError:
95     python_path = ''
96     try:
97     path = os.environ['PATH']
98     except KeyError:
99     path = ''
100     try:
101     ld_library_path = os.environ['LD_LIBRARY_PATH']
102     except KeyError:
103     ld_library_path = ''
104    
105     # Note: On the Altix the intel compilers are not automatically
106     # detected by scons intelc.py script. The Altix has a different directory
107     # path and in some locations the "modules" facility is used to support
108     # multiple compiler versions. This forces the need to import the users PATH
109     # environment which isn't the "scons way"
110     # This doesn't impact linux and windows which will use the default compiler (g++ or msvc, or the intel compiler if it is installed on both platforms)
111     # FIXME: Perhaps a modification to intelc.py will allow better support for ia64 on altix
112    
113     if os.name != "nt" and os.uname()[4]=='ia64':
114     env = Environment(ENV = {'PATH':path, 'LD_LIBRARY_PATH':ld_library_path, 'PYTHONPATH':python_path}, tools = ['default', 'intelc'], options = opts)
115     if env['CXX'] == 'icpc':
116     env['LINK'] = env['CXX'] # version >=9 of intel c++ compiler requires use of icpc to link in C++ runtimes (icc does not). FIXME: this behaviour could be directly incorporated into scons intelc.py
117     elif os.name == "nt":
118     # FIXME: Need to implement equivalent of ld library path for windoze
119     env = Environment(ENV = {'PYTHONPATH':python_path}, tools = ['default', 'intelc'], options = opts)
120     else:
121     env = Environment(ENV = {'PATH':path, 'LD_LIBRARY_PATH':ld_library_path, 'PYTHONPATH':python_path}, tools = ['default'], options = opts)
122    
123     # Setup help for options
124     Help(opts.GenerateHelpText(env))
125    
126     # Add some customer builders
127     py_builder = Builder(action = scons_extensions.build_py, suffix = '.pyc', src_suffix = '.py', single_source=True)
128     env.Append(BUILDERS = {'PyCompile' : py_builder});
129    
130     if env['PLATFORM'] == "win32":
131     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', src_suffix='.exe', single_source=True)
132     else:
133     runUnitTest_builder = Builder(action = scons_extensions.runUnitTest, suffix = '.passed', single_source=True)
134     env.Append(BUILDERS = {'RunUnitTest' : runUnitTest_builder});
135    
136     runPyUnitTest_builder = Builder(action = scons_extensions.runPyUnitTest, suffix = '.passed', src_suffic='.py', single_source=True)
137     env.Append(BUILDERS = {'RunPyUnitTest' : runPyUnitTest_builder});
138    
139     # Convert the options which are held in environment variable into python variables for ease of handling and configure compilation options
140     try:
141     incinstall = env['incinstall']
142     env.Append(CPPPATH = [incinstall,])
143     except KeyError:
144     incinstall = None
145     try:
146     libinstall = env['libinstall']
147     env.Append(LIBPATH = [libinstall,])
148     env.PrependENVPath('LD_LIBRARY_PATH', libinstall)
149     except KeyError:
150     libinstall = None
151     try:
152     pyinstall = env['pyinstall']+'/esys' # all targets will install into pyinstall/esys but PYTHONPATH points at straight pyinstall so you go import esys.escript etc
153     env.PrependENVPath('PYTHONPATH', env['pyinstall'])
154     except KeyError:
155     pyinstall = None
156     try:
157     dodebug = env['dodebug']
158     except KeyError:
159     dodebug = None
160     try:
161     cc_defines = env['cc_defines']
162     env.Append(CPPDEFINES = [cc_defines,])
163     except KeyError:
164     pass
165     if dodebug:
166     try:
167     flags = env['cc_flags_debug']
168     env.Append(CCFLAGS = flags)
169     except KeyError:
170     pass
171     else:
172     try:
173     flags = env['cc_flags']
174     env.Append(CCFLAGS = flags)
175     except KeyError:
176     pass
177    
178     if dodebug:
179     try:
180     flags = env['cxx_flags_debug']
181     env.Append(CXXFLAGS = flags)
182     except KeyError:
183     pass
184     else:
185     try:
186     flags = env['cxx_flags']
187     env.Append(CXXFLAGS = flags)
188     except KeyError:
189     pass
190    
191     try:
192     flags = env['ar_flags']
193     env.Append(ARFLAGS = flags)
194     except KeyError:
195     ar_flags = None
196     try:
197     sys_libs = env['sys_libs']
198     except KeyError:
199     sys_libs = ''
200    
201     try:
202     includes = env['mkl_path']
203     env.Append(CPPPATH = [includes,])
204     except KeyError:
205     pass
206     try:
207     lib_path = env['mkl_lib_path']
208     env.Append(LIBPATH = [lib_path,])
209     except KeyError:
210     pass
211     try:
212     mkl_libs = env['mkl_libs']
213     except KeyError:
214     mkl_libs = ''
215     try:
216     includes = env['scsl_path']
217     env.Append(CPPPATH = [includes,])
218     except KeyError:
219     pass
220     try:
221     lib_path = env['scsl_lib_path']
222     env.Append(LIBPATH = [lib_path,])
223     except KeyError:
224     pass
225     try:
226     scsl_libs = env['scsl_libs']
227     except KeyError:
228     scsl_libs = ''
229     try:
230     includes = env['umf_path']
231     env.Append(CPPPATH = [includes,])
232     except KeyError:
233     pass
234     try:
235     lib_path = env['umf_lib_path']
236     env.Append(LIBPATH = [lib_path,])
237     except KeyError:
238     pass
239     try:
240     umf_libs = env['umf_libs']
241     except KeyError:
242     umf_libs = ''
243     try:
244     includes = env['boost_path']
245     env.Append(CPPPATH = [includes,])
246     except KeyError:
247     pass
248     try:
249     lib_path = env['boost_lib_path']
250     env.Append(LIBPATH = [lib_path,])
251     except KeyError:
252     pass
253     try:
254     boost_lib = env['boost_lib']
255     except KeyError:
256     boost_lib = None
257     try:
258     includes = env['cppunit_path']
259     env.Append(CPPPATH = [includes,])
260     except KeyError:
261     pass
262     try:
263     lib_path = env['cppunit_lib_path']
264     env.Append(LIBPATH = [lib_path,])
265     except KeyError:
266     pass
267     try:
268     cppunit_lib = env['cppunit_lib']
269     except KeyError:
270     boost_lib = None
271     try:
272     includes = env['python_path']
273     env.Append(CPPPATH = [includes,])
274     except KeyError:
275     pass
276     try:
277     lib_path = env['python_lib_path']
278     env.Append(LIBPATH = [lib_path,])
279     except KeyError:
280     pass
281     try:
282     python_lib = env['python_lib']
283     except KeyError:
284     python_lib = None
285     try:
286     doxygen_path = env['doxygen_path']
287     except KeyError:
288     doxygen_path = None
289     try:
290     epydoc_path = env['epydoc_path']
291     except KeyError:
292     epydoc_path = None
293     try:
294     epydoc_pythonpath = env['epydoc_pythonpath']
295     except KeyError:
296     epydoc_pythonpath = None
297     try:
298     includes = env['papi_path']
299     env.Append(CPPPATH = [includes,])
300     except KeyError:
301     pass
302     try:
303     lib_path = env['papi_lib_path']
304     env.Append(LIBPATH = [lib_path,])
305     except KeyError:
306     pass
307     try:
308     papi_libs = env['papi_libs']
309     except KeyError:
310     papi_libs = None
311    
312     # Targets
313     env.Default(libinstall)
314     env.Default(incinstall)
315     env.Default(pyinstall)
316     env.Alias('build_tests')
317     env.Alias('run_tests')
318     env.Alias('py_tests')
319     env.Alias('all_tests', ['run_tests', 'py_tests'])
320    
321     # Python install - esys __init__.py
322     # This is just an empty file but stills need to be touched so add a special target and Command. Note you can't use the scons Touch() function as it will not
323     # create the file if it doesn't exist
324     env.Command('esys/__init__.py', None, 'touch $TARGET')
325    
326     # Allow sconscripts to see the env
327     Export(["env", "incinstall", "libinstall", "pyinstall", "dodebug", "mkl_libs", "scsl_libs", "umf_libs",
328     "boost_lib", "python_lib", "doxygen_path", "epydoc_path", "epydoc_pythonpath", "papi_libs", "cppunit_lib", "sys_libs" ])
329    
330     # End initialisation section
331     # Begin configuration section
332     # Insert new components to be build here
333     # FIXME: might be nice to replace this verbosity with a list of targets and some
334     # FIXME: nifty python to create the lengthy but very similar env.Sconscript lines
335     # Third Party libraries
336     env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0)
337     # C/C++ Libraries
338     env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0)
339     env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0)
340     env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0)
341     env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0)
342     env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0)
343     env.SConscript(dirs = ['modellib/py_src'], build_dir='build/$PLATFORM/modellib', duplicate=0)
344    
345     # FIXME:need to be incorporated into build system
346     # FIXME: 'pyvisi/SConstruct']
347     # FIXME: 'doc/SConstruct']
348     # FIXME: 'doc/SConstruct']

  ViewVC Help
Powered by ViewVC 1.1.26