-
Notifications
You must be signed in to change notification settings - Fork 2
/
find_root.py
116 lines (94 loc) · 4.04 KB
/
find_root.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
import os.path as osp
import waflib
import waflib.Utils
from waflib.Configure import conf
_tooldir = osp.dirname(osp.abspath(__file__))
def options(opt):
opt.add_option('--with-root', default=None,
help="Look for CERN ROOT System at the given path")
return
def configure(cfg):
cfg.env.CXXFLAGS += ['-fPIC']
path_list = list()
for topdir in [getattr(cfg.options, 'with_root', None), os.getenv('ROOTSYS', None)]:
if topdir:
path_list.append(osp.join(topdir, "bin"))
kwargs = dict(path_list=path_list)
cfg.find_program('root-config', var='ROOT-CONFIG', **kwargs)
cfg.check_cfg(path=cfg.env['ROOT-CONFIG'], uselib_store='ROOTSYS',
args = '--cflags --libs --ldflags', package='')
cfg.find_program('rootcling', var='ROOTCLING', path_list=path_list)
cfg.find_program('rootcint', var='ROOTCINT', path_list=path_list)
cfg.find_program('rlibmap', var='RLIBMAP', path_list=path_list, mandatory=False)
#cfg.env.LIB_ROOTSYS += ['Minuit2','TreePlayer','Spectrum']
cfg.env.LIB_ROOTSYS += ['Minuit2','TreePlayer','Spectrum','TMVA', 'TMVAGui']
return
@conf
def gen_rootcling_dict(bld, name, linkdef, headers = '', includes = '', use=''):
'''
rootcling -f NAMEDict.cxx -rml libNAME.so -rmf libNAME.rootmap myHeader1.h myHeader2.h ... LinkDef.h
'''
use = waflib.Utils.to_list(use) + ['ROOTSYS']
#print 'USE',use
includes = waflib.Utils.to_list(includes)
for u in use:
more = bld.env['INCLUDES_'+u]
if not isinstance(more,list):
more = [more]
#print 'USE(%s)=%s: %s' % (name, u, more)
includes += more
# make into -I...
incs = list()
for inc in includes:
if inc.startswith('/'):
newinc = '-I%s' % inc
else:
newinc = '-I%s' % bld.path.find_dir(inc).abspath()
if not newinc in incs:
incs.append(newinc)
incs = ' '.join(incs)
#print 'INCS(%s): %s' % (name, str(incs))
dict_src = name + 'Dict.cxx'
# dict_lib = 'lib' + name + 'Dict.so' # what for Mac OS X?
# dict_map = 'lib' + name + 'Dict.rootmap'
# dict_pcm = name + 'Dict_rdict.pcm'
dict_lib = 'lib' + name + '.so' # what for Mac OS X?
dict_map = 'lib' + name + '.rootmap'
dict_pcm = name + 'Dict_rdict.pcm'
if type(linkdef) == type(""):
linkdef = bld.path.find_resource(linkdef)
source_nodes = headers + [linkdef]
sources = ' '.join([x.abspath() for x in source_nodes])
#rule = '${ROOTCLING} -f ${TGT[0].abspath()} -rml %s -rmf ${TGT[1].abspath()} %s %s' % (dict_lib, incs, sources)
rule = '${ROOTCLING} -f ${TGT[0].abspath()} -noIncludePaths -inlineInputHeader -rml %s -rmf ${TGT[1].abspath()} %s %s' % (dict_lib, incs, sources)
#print 'RULE:',rule
bld(source = source_nodes,
target = [dict_src, dict_map, dict_pcm],
rule=rule, use = use)
# bld.shlib(source = dict_src,
# target = name+'Dict',
# includes = includes,
# use = use + [name])
bld.install_files('${PREFIX}/lib64/', dict_map)
bld.install_files('${PREFIX}/lib64/', dict_pcm)
@conf
def gen_rootcint_dict(bld, name, linkdef, headers = '', includes=''):
'''Generate a rootcint dictionary, compile it to a shared lib,
produce its rootmap file and install it all.
'''
headers = waflib.Utils.to_list(headers)
incs = ['-I%s' % bld.path.find_dir(x).abspath() for x in waflib.Utils.to_list(includes)]
incs = ' '.join(incs)
dict_src = name + 'Dict.cxx'
bld(source = headers + [linkdef],
target = dict_src,
rule='${ROOTCINT} -f ${TGT} -c %s ${SRC}' % incs)
bld.shlib(source = dict_src,
target = name+'Dict',
includes = includes,
use = 'ROOTSYS')
rootmap = 'lib%sDict.rootmap'%name
bld(source = [linkdef], target=rootmap,
rule='${RLIBMAP} -o ${TGT} -l lib%sDict.so -d lib%s.so -c ${SRC}' % (name, name))
bld.install_files('${PREFIX}/lib64/', rootmap)