1
|
from SCons.Script.SConscript import SConsEnvironment # pylint: disable-msg=F0401
|
2
|
import glob
|
3
|
import os
|
4
|
|
5
|
def my_exit(code = 1):
|
6
|
"""Internal routine to exit
|
7
|
|
8
|
Currently this is its own function to allow easy disabling or a pylint
|
9
|
warning.
|
10
|
"""
|
11
|
Exit(code) # pylint: disable-msg=E0602
|
12
|
|
13
|
maus_root_dir = os.environ.get('MAUS_ROOT_DIR')
|
14
|
if not maus_root_dir:
|
15
|
print('!! Could not find the $MAUS_ROOT_DIR environmental variable')
|
16
|
print('!! Did you try running: "source env.sh"?')
|
17
|
my_exit(1)
|
18
|
|
19
|
#this is our catch-all Dev class
|
20
|
class Dev:
|
21
|
cflags = ''
|
22
|
ecflags = ''
|
23
|
|
24
|
# sets up the sconscript file for a given sub-project
|
25
|
def Subproject(self, project):
|
26
|
SConscript(env.jDev.SPath(project), exports=['project']) # pylint: disable-msg=E0602
|
27
|
|
28
|
#sets up the build for a given project
|
29
|
def Buildit(self, localenv, project, \
|
30
|
use_root, use_g4, use_unpacker = False):
|
31
|
if use_root and not env['USE_ROOT']:
|
32
|
if not env.GetOption('clean'):
|
33
|
print "The worker", project, \
|
34
|
"requires ROOT which is disabled. Skipping..."
|
35
|
return False
|
36
|
|
37
|
if use_g4 and not env['USE_G4']:
|
38
|
if not env.GetOption('clean'):
|
39
|
print "The worker", project, \
|
40
|
"requires Geant4 which is disabled. Skipping..."
|
41
|
return False
|
42
|
|
43
|
if use_unpacker and not env['USE_UNPACKER']:
|
44
|
if not env.GetOption('clean'):
|
45
|
print "The worker", project, \
|
46
|
"requires Unpacker which is disabled. Skipping..."
|
47
|
return False
|
48
|
|
49
|
name = project.split('/')[-1]
|
50
|
builddir = 'build'
|
51
|
targetpath = os.path.join('build', '_%s' % name)
|
52
|
|
53
|
#append the user's additional compile flags
|
54
|
#assume debugcflags and releasecflags are defined
|
55
|
localenv.Append(CCFLAGS=self.cflags)
|
56
|
if use_root and use_g4:
|
57
|
localenv.Append(LIBS=['MausCpp'])
|
58
|
|
59
|
#specify the build directory
|
60
|
localenv.VariantDir(variant_dir=builddir, src_dir='.', duplicate=0)
|
61
|
localenv.Append(CPPPATH='.')
|
62
|
|
63
|
srclst = map(lambda x: builddir + '/' + x, glob.glob('*.cc'))
|
64
|
srclst += map(lambda x: builddir + '/' + x, glob.glob('*.i'))
|
65
|
pgm = localenv.LoadableModule(targetpath, source=srclst)
|
66
|
|
67
|
tests = glob.glob('test_*.py')
|
68
|
|
69
|
full_build_dir = os.path.join(maus_root_dir, builddir)
|
70
|
|
71
|
env.Install(full_build_dir, "build/%s.py" % name)
|
72
|
env.Install(full_build_dir, pgm)
|
73
|
env.Install(full_build_dir, tests)
|
74
|
env.Alias('all', pgm) #note: not localenv
|
75
|
|
76
|
return True
|
77
|
|
78
|
#---- PRIVATE ----
|
79
|
|
80
|
#---
|
81
|
# return the sconscript path to use
|
82
|
def SPath(self, project):
|
83
|
return project + '/sconscript'
|
84
|
|
85
|
def CheckCommand(context, cmd):
|
86
|
context.Message('Checking for %s command... ' % cmd)
|
87
|
result = WhereIs(cmd) # pylint: disable-msg=E0602
|
88
|
context.Result(result is not None)
|
89
|
return result
|
90
|
|
91
|
## autoconf-like stuff
|
92
|
def set_cpp(conf, env):
|
93
|
"""
|
94
|
Sanity checks that the compiler is installed correctly
|
95
|
"""
|
96
|
|
97
|
if not conf.CheckCXX():
|
98
|
print('!! Your compiler or environment is not correctly configured.')
|
99
|
my_exit(1)
|
100
|
|
101
|
if not conf.CheckLib( "json" , language='C++') or\
|
102
|
not conf.CheckCXXHeader('json/json.h'):
|
103
|
|
104
|
print( "!! Can't find jsoncpp which is needed." )
|
105
|
print ( "You may install it by running:")
|
106
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/52jsoncpp.bash"\
|
107
|
% maus_root_dir)
|
108
|
my_exit(1)
|
109
|
|
110
|
if not conf.CheckLib( "stdc++" , language='C++'):
|
111
|
my_exit(1)
|
112
|
|
113
|
if not conf.CheckFunc('printf'):
|
114
|
print('!! Your compiler or environment is not correctly configured.')
|
115
|
my_exit(1)
|
116
|
|
117
|
if not conf.CheckHeader('math.h'):
|
118
|
my_exit(1)
|
119
|
|
120
|
if not conf.CheckCHeader('stdlib.h'):
|
121
|
my_exit(1)
|
122
|
|
123
|
if not conf.CheckCXXHeader('iostream', '<>'):
|
124
|
my_exit(1)
|
125
|
|
126
|
def set_python(conf, env):
|
127
|
EnsurePythonVersion(2, 7) # pylint: disable-msg=E0602
|
128
|
|
129
|
if not conf.CheckCommand('python'):
|
130
|
my_exit(1)
|
131
|
|
132
|
if not conf.CheckCXXHeader('Python.h'):
|
133
|
print "You need 'Python.h' to compile this program"
|
134
|
print "If you want to install python locally, run:"
|
135
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/01python.bash" \
|
136
|
% maus_root_dir)
|
137
|
my_exit(1)
|
138
|
|
139
|
if not conf.CheckCommand('swig'):
|
140
|
print "Cound't find swig. If you want it, then run:"
|
141
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/02swig.bash" \
|
142
|
% maus_root_dir)
|
143
|
my_exit(1)
|
144
|
|
145
|
conf.env.Append(LIBS = ['python2.7'])
|
146
|
|
147
|
def set_gsl(conf, env):
|
148
|
if not conf.CheckLib('gslcblas'):
|
149
|
print "Cound't find GSL (required for ROOT). If you want it, then run:"
|
150
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/20gsl.bash" \
|
151
|
% maus_root_dir)
|
152
|
my_exit(1)
|
153
|
else:
|
154
|
conf.env.Append(LIBS = ['gslcblas'])
|
155
|
|
156
|
if not conf.CheckLib('gsl'):
|
157
|
print "Cound't find GSL (required for ROOT). If you want it, then run:"
|
158
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/20gsl.bash" \
|
159
|
% maus_root_dir)
|
160
|
my_exit(1)
|
161
|
|
162
|
def get_root_libs():
|
163
|
"""ROOT libs
|
164
|
|
165
|
Important libraries for ROOT to run. Worth checking for. The list is not
|
166
|
exhaustive but just for sanity checks.
|
167
|
"""
|
168
|
return ['Cint', \
|
169
|
'Core', \
|
170
|
'Gpad', \
|
171
|
'Graf', \
|
172
|
'Graf3d', \
|
173
|
'Hist', \
|
174
|
'MathCore', \
|
175
|
'Matrix', \
|
176
|
'Minuit', \
|
177
|
'Net', \
|
178
|
'Physics', \
|
179
|
'Postscript', \
|
180
|
'RIO', \
|
181
|
'Rint', \
|
182
|
'Thread', \
|
183
|
'Tree', \
|
184
|
'dl', \
|
185
|
'm', \
|
186
|
'pthread']
|
187
|
|
188
|
def set_root(conf, env):
|
189
|
if not conf.CheckCommand('root'):
|
190
|
print "Cound't find root. If you want it, after installing GSL, run:"
|
191
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/21root.bash" \
|
192
|
% maus_root_dir)
|
193
|
print ("where you can install GSL by running:")
|
194
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/20gsl.bash" \
|
195
|
% maus_root_dir)
|
196
|
my_exit(1)
|
197
|
|
198
|
else:
|
199
|
print
|
200
|
print "!! Found the program 'root', so MAUS will use it."
|
201
|
print
|
202
|
env['USE_ROOT'] = True
|
203
|
|
204
|
if not conf.CheckCommand('root-config'):
|
205
|
my_exit(1)
|
206
|
|
207
|
conf.env.ParseConfig("root-config --cflags --ldflags --libs")
|
208
|
|
209
|
root_libs = get_root_libs()
|
210
|
|
211
|
for lib in root_libs:
|
212
|
if not conf.CheckLib(lib, language='c++'):
|
213
|
my_exit(1)
|
214
|
|
215
|
if not conf.CheckCXXHeader('TH1F.h'):
|
216
|
my_exit(1)
|
217
|
|
218
|
if not conf.CheckCXXHeader('TMinuit.h'):
|
219
|
my_exit(1)
|
220
|
|
221
|
def set_clhep(conf, env):
|
222
|
if not conf.CheckLib('CLHEP', language='c++'):
|
223
|
print "Cound't find CLHEP (required for geant4). If you want it, then run:"
|
224
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/30clhep.bash" % maus_root_dir)
|
225
|
my_exit(1)
|
226
|
|
227
|
conf.env.Append(LIBS = ['CLHEP'])
|
228
|
|
229
|
def get_g4_libs():
|
230
|
return [ 'G4FR', \
|
231
|
'G4RayTracer', \
|
232
|
'G4Tree', \
|
233
|
'G4UIGAG', \
|
234
|
'G4UIbasic', \
|
235
|
'G4UIcommon', \
|
236
|
'G4VRML', \
|
237
|
'G4baryons', \
|
238
|
'G4biasing', \
|
239
|
'G4bosons', \
|
240
|
'G4brep', \
|
241
|
'G4csg', \
|
242
|
'G4cuts', \
|
243
|
'G4decay', \
|
244
|
'G4detector', \
|
245
|
'G4detscorer', \
|
246
|
'G4detutils', \
|
247
|
'G4digits', \
|
248
|
'G4emhighenergy', \
|
249
|
'G4emlowenergy', \
|
250
|
'G4empolar', \
|
251
|
'G4emstandard', \
|
252
|
'G4emutils', \
|
253
|
'G4error_propagation', \
|
254
|
'G4event', \
|
255
|
'G4geomBoolean', \
|
256
|
'G4geombias', \
|
257
|
'G4geomdivision', \
|
258
|
'G4geometrymng', \
|
259
|
'G4geomtext', \
|
260
|
'G4gflash', \
|
261
|
'G4globman', \
|
262
|
'G4graphics_reps', \
|
263
|
'G4had_im_r_matrix', \
|
264
|
'G4had_lll_fis', \
|
265
|
'G4had_mod_man', \
|
266
|
'G4had_mod_util', \
|
267
|
'G4had_muon_nuclear', \
|
268
|
'G4had_neu_hp', \
|
269
|
'G4had_preequ_exciton', \
|
270
|
'G4had_string_diff', \
|
271
|
'G4had_string_frag', \
|
272
|
'G4had_string_man', \
|
273
|
'G4had_theo_max', \
|
274
|
'G4hadronic_HE', \
|
275
|
'G4hadronic_LE', \
|
276
|
'G4hadronic_RPG', \
|
277
|
'G4hadronic_ablation', \
|
278
|
'G4hadronic_abrasion', \
|
279
|
'G4hadronic_bert_cascade', \
|
280
|
'G4hadronic_binary', \
|
281
|
'G4hadronic_body_ci', \
|
282
|
'G4hadronic_coherent_elastic', \
|
283
|
'G4hadronic_deex_evaporation', \
|
284
|
'G4hadronic_deex_fermi_breakup', \
|
285
|
'G4hadronic_deex_fission', \
|
286
|
'G4hadronic_deex_gem_evaporation', \
|
287
|
'G4hadronic_deex_handler', \
|
288
|
'G4hadronic_deex_management', \
|
289
|
'G4hadronic_deex_multifragmentation', \
|
290
|
'G4hadronic_deex_photon_evaporation', \
|
291
|
'G4hadronic_deex_util', \
|
292
|
'G4hadronic_em_dissociation', \
|
293
|
'G4hadronic_hetcpp_evaporation', \
|
294
|
'G4hadronic_hetcpp_utils', \
|
295
|
'G4hadronic_incl_cascade', \
|
296
|
'G4hadronic_interface_ci', \
|
297
|
'G4hadronic_iso', \
|
298
|
'G4hadronic_leading_particle', \
|
299
|
'G4hadronic_mgt', \
|
300
|
'G4hadronic_proc', \
|
301
|
'G4hadronic_qgstring', \
|
302
|
'G4hadronic_qmd', \
|
303
|
'G4hadronic_radioactivedecay', \
|
304
|
'G4hadronic_stop', \
|
305
|
'G4hadronic_util', \
|
306
|
'G4hadronic_xsect', \
|
307
|
'G4hepnumerics', \
|
308
|
'G4hits', \
|
309
|
'G4intercoms', \
|
310
|
'G4ions', \
|
311
|
'G4leptons', \
|
312
|
'G4magneticfield', \
|
313
|
'G4materials', \
|
314
|
'G4mctruth', \
|
315
|
'G4mesons', \
|
316
|
'G4modeling', \
|
317
|
'G4muons', \
|
318
|
'G4navigation', \
|
319
|
'G4optical', \
|
320
|
'G4parameterisation', \
|
321
|
'G4partadj', \
|
322
|
'G4partman', \
|
323
|
'G4partutils', \
|
324
|
'G4phys_builders', \
|
325
|
'G4phys_lists', \
|
326
|
'G4procman', \
|
327
|
'G4readout', \
|
328
|
'G4run', \
|
329
|
'G4scoring', \
|
330
|
'G4shortlived', \
|
331
|
'G4specsolids', \
|
332
|
'G4track', \
|
333
|
'G4tracking', \
|
334
|
'G4transportation', \
|
335
|
'G4visHepRep', \
|
336
|
'G4visXXX', \
|
337
|
'G4vis_management', \
|
338
|
'G4volumes', \
|
339
|
'G4xrays']
|
340
|
|
341
|
|
342
|
def set_geant4(conf, env):
|
343
|
if 'G4INSTALL' not in os.environ or (not os.path.exists(os.environ.get('G4INSTALL'))):
|
344
|
print "Cound't find geant4. If you want it, after installing CLHEP, then run:"
|
345
|
print (" MAUS_ROOT_DIR=%s ./third_party/bash/31geant4.bash" % maus_root_dir)
|
346
|
my_exit(1)
|
347
|
else:
|
348
|
print
|
349
|
print "!! Found the package 'geant4', so assume you want to use it with MAUS."
|
350
|
print
|
351
|
env['USE_G4'] = True
|
352
|
|
353
|
env.Append(LIBPATH = ["%s/%s" % (os.environ.get('G4LIB'), os.environ.get('G4SYSTEM'))])
|
354
|
env.Append(CPPPATH=[os.environ.get("G4INCLUDE")])
|
355
|
|
356
|
if not conf.CheckCXXHeader('G4EventManager.hh'):
|
357
|
my_exit(1)
|
358
|
|
359
|
# removing this line (and using the append(libs) one below, because this is messy and breaks/seg-faults.
|
360
|
# conf.env.ParseConfig('%s/liblist -m %s < %s/libname.map'.replace('%s', os.path.join(os.environ.get('G4LIB'), os.environ.get('G4SYSTEM'))))
|
361
|
|
362
|
|
363
|
env.Append(LIBS=get_g4_libs())
|
364
|
|
365
|
for lib in get_g4_libs():
|
366
|
if not conf.CheckLib(lib, language='c++'):
|
367
|
my_exit(1)
|
368
|
|
369
|
def set_recpack(conf, env):
|
370
|
if not conf.CheckLib('recpack', language='c++') or\
|
371
|
not conf.CheckCXXHeader('recpack/RecpackManager.h'):
|
372
|
my_exit(1)
|
373
|
|
374
|
def set_gtest(conf, env):
|
375
|
if not conf.CheckLib('gtest', language='c++'):
|
376
|
my_exit(1)
|
377
|
if not conf.CheckCXXHeader('gtest/gtest.h'):
|
378
|
my_exit(1)
|
379
|
|
380
|
def set_unpacker(conf, env):
|
381
|
if (not conf.CheckLib('MDunpack', language='c++') or \
|
382
|
not conf.CheckCXXHeader('MDevent.h')):
|
383
|
print
|
384
|
print "!! Unpacker module not found, you will not be able to use the RealData module."
|
385
|
print
|
386
|
else:
|
387
|
env["USE_UNPACKER"] = True
|
388
|
|
389
|
def cpp_extras(env):
|
390
|
"""
|
391
|
Sets compilation to include coverage, debugger, profiler depending on
|
392
|
environment variable flags. Following controls are enabled:
|
393
|
if maus_lcov is set, sets gcov flags (for subsequent use in lcov); also
|
394
|
disables inlining
|
395
|
if maus_debug is set, sets debug flag -g
|
396
|
if maus_gprof is set, sets profiling flag -pg
|
397
|
if maus_no_optimize is not set and none of the others are set, sets
|
398
|
optimise flag -O3
|
399
|
"""
|
400
|
lcov = 'maus_lcov' in os.environ and os.environ['maus_lcov'] != '0'
|
401
|
debug = 'maus_debug' in os.environ and os.environ['maus_debug'] != '0'
|
402
|
gprof = 'maus_gprof' in os.environ and os.environ['maus_gprof'] != '0'
|
403
|
optimise = not ('maus_no_optimize' in os.environ
|
404
|
and os.environ['maus_no_optimize'] != '0') # optimise by default
|
405
|
|
406
|
if lcov:
|
407
|
env.Append(LIBS=['gcov'])
|
408
|
env.Append(CCFLAGS=["""-fprofile-arcs""", """-ftest-coverage""",
|
409
|
"""-fno-inline""", """-fno-default-inline"""])
|
410
|
|
411
|
if debug:
|
412
|
env.Append(CCFLAGS=["""-g"""])
|
413
|
|
414
|
if gprof: # only works on pure c code (i.e. unit tests)
|
415
|
env.Append(CCFLAGS=["""-pg"""])
|
416
|
env.Append(LINKFLAGS=["""-pg"""])
|
417
|
|
418
|
if not (lcov or debug or gprof) and optimise:
|
419
|
env.Append(CCFLAGS=["""-O3"""])
|
420
|
|
421
|
# Setup the environment. NOTE: SHLIBPREFIX means that shared libraries don't
|
422
|
# have a 'lib' prefix, which is needed for python to find SWIG generated libraries
|
423
|
env = Environment(SHLIBPREFIX="") # pylint: disable-msg=E0602
|
424
|
|
425
|
(sysname, nodename, release, version, machine) = os.uname()
|
426
|
|
427
|
# Darwin defaults to no prefix or suffix. All others default to "lib" prefix
|
428
|
# and .so suffix. We want no suffix and .so prefix for all systems by default.
|
429
|
if (sysname == 'Darwin'):
|
430
|
env.Append(LDMODULESUFFIX=".so")
|
431
|
else:
|
432
|
env.Append(LDMODULEPREFIX="")
|
433
|
|
434
|
|
435
|
if env.GetOption('clean'):
|
436
|
print("In cleaning mode!")
|
437
|
|
438
|
for root, dirs, files in os.walk('%s/build' % maus_root_dir):
|
439
|
for basename in files:
|
440
|
filename = os.path.join(root, basename)
|
441
|
if os.path.isfile(filename):
|
442
|
print 'Removing:', filename
|
443
|
os.remove(filename)
|
444
|
|
445
|
|
446
|
|
447
|
|
448
|
if os.path.isfile('.use_llvm_with_maus'):
|
449
|
env['CC'] = "llvm-gcc"
|
450
|
env['CXX'] = "llvm-g++"
|
451
|
|
452
|
env.Tool('swig', '%s/third_party/swig-2.0.1' % maus_root_dir)
|
453
|
env.Append(SWIGFLAGS=['-python', '-c++']) # tell SWIG to make python bindings for C++
|
454
|
|
455
|
#env.Append(PATH="%s/third_party/install/bin" % maus_root_dir)
|
456
|
env['ENV']['PATH'] = os.environ.get('PATH') # useful to set for root-config
|
457
|
env['ENV']['LD_LIBRARY_PATH'] = os.environ.get('LD_LIBRARY_PATH')
|
458
|
env['ENV']['DYLD_LIBRARY_PATH'] = os.environ.get('DYLD_LIBRARY_PATH')
|
459
|
|
460
|
libs = str(os.environ.get('LD_LIBRARY_PATH'))+':'+str(os.environ.get('DYLD_LIBRARY_PATH'))
|
461
|
|
462
|
# to find third party libs, includes
|
463
|
env.Append(LIBPATH = libs.split(':') + ["%s/build" % maus_root_dir])
|
464
|
|
465
|
env.Append(CPPPATH=["%s/third_party/install/include" % maus_root_dir, \
|
466
|
"%s/third_party/install/include/python2.7" % maus_root_dir, \
|
467
|
"%s/third_party/install/include/root" % maus_root_dir, \
|
468
|
"%s/src/legacy" % maus_root_dir, \
|
469
|
"%s/src/common_cpp" % maus_root_dir, \
|
470
|
""])
|
471
|
|
472
|
env['USE_G4'] = False
|
473
|
env['USE_ROOT'] = False
|
474
|
env['USE_UNPACKER'] = False
|
475
|
|
476
|
#put all .sconsign files in one place
|
477
|
env.SConsignFile()
|
478
|
|
479
|
#we can put variables right into the environment, however
|
480
|
#we must watch out for name clashes.
|
481
|
SConsEnvironment.jDev = Dev()
|
482
|
|
483
|
#make sure the sconscripts can get to the variables
|
484
|
#don't need to export anything but 'env'
|
485
|
Export('env') # pylint: disable-msg=E0602
|
486
|
|
487
|
#### Target: Documentation
|
488
|
#dox = env.Command('does_not_exist3', 'doc/Doxyfile',
|
489
|
# 'doxygen doc/Doxyfile && cd doc/html')
|
490
|
#env.Alias('doc', [dox])
|
491
|
|
492
|
#python_executable = '%s/third_party/install/bin/python' % maus_root_dir
|
493
|
#if os.path.isfile(python_executable):
|
494
|
# unit = env.Command('does_not_exist2', 'build', '%s -m unittest discover -b -v build' % python_executable)
|
495
|
# env.Alias('unittest', [unit])
|
496
|
|
497
|
print "Configuring..."
|
498
|
# Must have long32 & long64 for the unpacking library
|
499
|
env.Append(CCFLAGS=["""-Wall""", """-Dlong32='int'""", """-Dlong64='long long'"""])
|
500
|
cpp_extras(env)
|
501
|
|
502
|
conf = Configure(env, custom_tests = {'CheckCommand' : CheckCommand}) # pylint: disable-msg=E0602
|
503
|
set_cpp(conf, env)
|
504
|
set_python(conf, env)
|
505
|
set_gsl(conf, env)
|
506
|
set_root(conf, env)
|
507
|
set_clhep(conf, env)
|
508
|
set_geant4(conf, env)
|
509
|
set_recpack(conf, env)
|
510
|
set_gtest(conf, env)
|
511
|
set_unpacker(conf, env)
|
512
|
|
513
|
# check types size!!!
|
514
|
env = conf.Finish()
|
515
|
if 'configure' in COMMAND_LINE_TARGETS: # pylint: disable-msg=E0602
|
516
|
my_exit(0)
|
517
|
|
518
|
|
519
|
# NOTE: do this after configure! So we know if we have ROOT/geant4
|
520
|
#specify all of the sub-projects in the section
|
521
|
if env['USE_G4'] and env['USE_ROOT']:
|
522
|
#env.Append(CCFLAGS=['-g','-pg'])
|
523
|
#env.Append(LINKFLAGS='-pg')
|
524
|
|
525
|
common_cpp_files = glob.glob("src/legacy/*/*cc") + \
|
526
|
glob.glob("src/legacy/*/*/*cc") + \
|
527
|
glob.glob("src/common_cpp/*/*cc") + \
|
528
|
glob.glob("src/common_cpp/*/*/*cc")
|
529
|
|
530
|
#SharedLibrary is identical to LoadableModule on non-Darwin systems, so
|
531
|
#only do SharedLibrary if we have to to get a dylib in addition to a bundle
|
532
|
if (sysname == 'Darwin'):
|
533
|
maus_cpp = env.SharedLibrary(target = 'src/common_cpp/libMausCpp',
|
534
|
source = common_cpp_files,
|
535
|
LIBS=env['LIBS'] + ['recpack'])
|
536
|
env.Install("build", maus_cpp)
|
537
|
|
538
|
|
539
|
maus_cpp_so = env.LoadableModule(target = 'src/common_cpp/libMausCpp',
|
540
|
source = common_cpp_files,
|
541
|
LIBS=env['LIBS'] + ['recpack'])
|
542
|
env.Install("build", maus_cpp_so)
|
543
|
|
544
|
env.Append(LIBPATH = 'src/common_cpp')
|
545
|
env.Append(CPPPATH = maus_root_dir)
|
546
|
|
547
|
if 'Darwin' in os.environ.get('G4SYSTEM'):
|
548
|
env.Append(LINKFLAGS=['-undefined','suppress','-flat_namespace'])
|
549
|
|
550
|
test_cpp_files = glob.glob("tests/cpp_unit/*/*cc")+\
|
551
|
glob.glob("tests/cpp_unit/*cc")
|
552
|
|
553
|
testmain = env.Program(target = 'tests/cpp_unit/test_cpp_unit', \
|
554
|
source = test_cpp_files, \
|
555
|
LIBS= env['LIBS'] + ['recpack'] + ['MausCpp'])
|
556
|
env.Install('build', ['tests/cpp_unit/test_cpp_unit'])
|
557
|
|
558
|
test_optics_files = glob.glob("tests/integration/optics/src/*cc")
|
559
|
test_optics = env.Program(target = 'tests/integration/optics/optics', \
|
560
|
source = test_optics_files, \
|
561
|
LIBS= env['LIBS'] + ['MausCpp'])
|
562
|
|
563
|
|
564
|
directories = []
|
565
|
types = ["input", "map", "reduce", "output"]
|
566
|
for my_type in types:
|
567
|
directories += glob.glob("src/%s/*" % my_type)
|
568
|
|
569
|
stuff_to_import = []
|
570
|
|
571
|
for directory in directories:
|
572
|
parts = directory.split("/")
|
573
|
assert len(parts) == 3
|
574
|
assert parts[0] == 'src'
|
575
|
assert parts[1] in types
|
576
|
|
577
|
if 'Py' in parts[2] and 'Cpp' not in parts[2]:
|
578
|
print 'Found Python module: %s' % parts[2]
|
579
|
files = glob.glob('%s/*.py' % directory)
|
580
|
env.Install("build", files)
|
581
|
|
582
|
stuff_to_import.append(parts[2])
|
583
|
|
584
|
if (parts[2][0:6] == 'MapCpp') or (parts[2][0:8] == 'InputCpp'):
|
585
|
print 'Found C++ module: %s' % parts[2]
|
586
|
env.jDev.Subproject(directory)
|
587
|
stuff_to_import.append(parts[2])
|
588
|
|
589
|
file_to_import = open('%s/build/MAUS.py' % maus_root_dir, 'w')
|
590
|
|
591
|
file_to_import.write("try:\n")
|
592
|
file_to_import.write(" from Go import Go\n")
|
593
|
file_to_import.write("except ImportError:\n")
|
594
|
file_to_import.write(" print 'failed to import Go'\n")
|
595
|
file_to_import.write("\n")
|
596
|
|
597
|
for single_stuff in stuff_to_import:
|
598
|
file_to_import.write("try:\n")
|
599
|
file_to_import.write(" from %s import %s\n" % (single_stuff, single_stuff))
|
600
|
file_to_import.write("except ImportError:\n")
|
601
|
file_to_import.write(" print 'failed to import %s'\n" % single_stuff)
|
602
|
file_to_import.write("\n")
|
603
|
|
604
|
file_to_import.close()
|
605
|
|
606
|
files = glob.glob('tests/py_unit/test_*.py')+glob.glob('tests/style/*.py')
|
607
|
env.Install("build", files)
|
608
|
|
609
|
env.Install("build", "tests/py_unit/test_cdb")
|
610
|
env.Install("build", "tests/py_unit/suds")
|
611
|
|
612
|
env.Alias('install', ['%s/build' % maus_root_dir])
|