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

Annotation of /branches/ROBW_XPLATFORM/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log


Revision 678 - (hide annotations)
Sun Mar 26 12:20:00 2006 UTC (16 years, 4 months ago) by robwdcock
File size: 11660 byte(s)
+Allow for environment variable PATH, LD_LIBRARY_PATH, and PYTHONPATH to 
not exist in the users environment.

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

  ViewVC Help
Powered by ViewVC 1.1.26