2 '''This tool implements a source package following a few contentions. 4 Your source package may build any combination of the following: 7 - headers exposing an API to libraries 8 - a ROOT dictionary for this API 12 This tool will produce various methods on the build context. You can 13 avoid passing <name> to them if you set APPNAME in your wscript file. 18 from waflib.Utils
import to_list
19 from waflib.Configure
import conf
21 from waflib.Logs
import debug, info, error, warn
23 _tooldir = osp.dirname(osp.abspath(__file__))
26 opt.load(
'compiler_cxx')
27 opt.load(
'waf_unit_test')
31 cfg.load(
'compiler_cxx')
32 cfg.load(
'waf_unit_test')
34 cfg.env.append_unique(
'CXXFLAGS',[
'-std=c++17'])
36 cfg.find_program(
'python', var=
'PYTHON', mandatory=
True)
37 cfg.find_program(
'bash', var=
'BASH', mandatory=
True)
42 from waflib.Tools
import waf_unit_test
43 bld.add_post_fun(waf_unit_test.summary)
47 def smplpkg(bld, name, use='', app_use='', test_use=''):
48 use = list(set(to_list(use)))
49 app_use = list(set(use + to_list(app_use)))
50 test_use = list(set(use + to_list(test_use)))
56 incdir = bld.path.find_dir(
'inc')
57 srcdir = bld.path.find_dir(
'src')
58 dictdir = bld.path.find_dir(
'dict')
60 testsrc = bld.path.ant_glob(
'test/test_*.cxx')
61 test_scripts = bld.path.ant_glob(
'test/test_*.sh') + bld.path.ant_glob(
'test/test_*.py')
62 appsdir = bld.path.find_dir(
'apps')
65 headers += incdir.ant_glob(name +
'/*.h')
67 bld.env[
'INCLUDES_'+name] = [incdir.abspath()]
70 bld.install_files(
'${PREFIX}/include/%s' % name, headers)
73 source += srcdir.ant_glob(
'*.cxx')
74 source += srcdir.ant_glob(
'*.cu')
80 error(
'No header files for ROOT dictionary "%s"' % name)
83 linkdef = dictdir.find_resource(
'LinkDef.h')
84 bld.gen_rootcling_dict(name, linkdef,
88 source.append(bld.path.find_or_declare(name+
'Dict.cxx'))
90 warn(
'No ROOT dictionary will be generated for "%s" unless "ROOTSYS" added to "use"' % name)
92 def get_rpath(uselst, local=True):
93 ret = set([bld.env[
"PREFIX"]+
"/lib"])
95 libpath = bld.env[
"LIBPATH_"+one]
99 if one.startswith(
"WireCell"):
101 blddir = bld.path.find_or_declare(bld.out_dir)
102 pkgdir = blddir.find_or_declare(sd).abspath()
109 if incdir
and srcdir:
111 bld(features =
'cxx cxxshlib',
117 export_includes =
'inc',
120 if (testsrc
or test_scripts)
and not bld.options.no_tests:
121 for test_main
in testsrc:
123 rpath = get_rpath(test_use + [name])
125 bld.program(features =
'test',
126 source = [test_main],
128 target = test_main.name.replace(
'.cxx',
''),
131 includes = [
'inc',
'test',
'tests'],
132 use = test_use + [name])
133 for test_script
in test_scripts:
135 if test_script.abspath().endswith(
".py"):
138 bld(features=
"test_scripts",
140 test_scripts_source = test_script,
141 test_scripts_template =
"pwd && " + interp +
" ${SCRIPT}")
144 for app
in appsdir.ant_glob(
'*.cxx'):
146 bld.program(source = [app],
147 target = app.name.replace(
'.cxx',
''),
149 rpath = get_rpath(app_use + [name], local=
False),
150 use = app_use + [name])
def smplpkg(bld, name, use='', app_use='', test_use='')