11 import waflib.Logs
as msg
13 import waflib.Configure
16 import waflib.Tools.ccroot
17 from waflib.Configure
import conf
18 from waflib.TaskGen
import feature, before_method, after_method, extension, after
23 @after_method(
'apply_incpaths')
25 self.env.prepend_value(
'INCPATHS', self.env.BUILD_INSTALL_AREA_INCDIR)
26 self.env.prepend_value(
'INCPATHS',
'.')
28 self.env.prepend_value(
'LIBPATH', self.env.BUILD_INSTALL_AREA_LIBDIR)
32 @feature(
'hwaf_runtime_tsk',
'*')
33 @before_method(
'process_rule')
36 insert_project_level_pythonpath adds ${INSTALL_AREA}/python into the
37 ${PYTHONPATH} environment variable.
39 _get = getattr(self,
'hwaf_get_install_path',
None)
40 if not _get: _get = getattr(self.bld,
'hwaf_get_install_path')
41 pydir =
_get(
'${INSTALL_AREA}/python')
42 self.env.prepend_value(
'PYTHONPATH', pydir)
46 @feature(
'hwaf_runtime_tsk',
'*')
47 @before_method(
'process_rule')
50 insert_project_level_joboptpath adds ${INSTALL_AREA}/jobOptions into the
51 ${JOBOPTSEARCHPATH} environment variable.
53 _get = getattr(self,
'hwaf_get_install_path',
None)
54 if not _get: _get = getattr(self.bld,
'hwaf_get_install_path')
55 d =
_get(
'${INSTALL_AREA}/jobOptions')
56 self.env.prepend_value(
'JOBOPTSEARCHPATH', d)
60 @feature(
'hwaf_runtime_tsk',
'*')
61 @before_method(
'process_rule')
64 insert_project_level_datapath adds ${INSTALL_AREA}/share into the
65 ${DATAPATH} environment variable.
67 _get = getattr(self,
'hwaf_get_install_path',
None)
68 if not _get: _get = getattr(self.bld,
'hwaf_get_install_path')
69 d =
_get(
'${INSTALL_AREA}/share')
70 self.env.prepend_value(
'DATAPATH', d)
74 @feature(
'hwaf_runtime_tsk',
'*')
75 @before_method(
'process_rule')
78 insert_project_level_xmlpath adds ${INSTALL_AREA}/XML into the
79 ${XMLPATH} environment variable.
81 _get = getattr(self,
'hwaf_get_install_path',
None)
82 if not _get: _get = getattr(self.bld,
'hwaf_get_install_path')
83 d =
_get(
'${INSTALL_AREA}/XML')
84 self.env.prepend_value(
'XMLPATH', d)
91 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
95 pypath = waflib.Utils.subst_vars(
'${INSTALL_AREA}/python', ctx.env)
96 if not (pypath
in ctx.env.get_flat(
'PYTHONPATH')):
97 ctx.env.prepend_value(
'PYTHONPATH', pypath)
101 pydir = ctx.path.find_dir(
'python')
104 '[%s] no such directory: [%s]' % (
106 os.path.join(ctx.path.abspath(),
'python'),
109 msg.error(
'cannot execute [gaudi_install_python_modules]')
111 pyfiles = pydir.ant_glob(
118 name =
'py-%s' % PACKAGE_NAME,
120 install_path =
'${INSTALL_AREA}/python/%s' % PACKAGE_NAME,
128 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
130 source = kw.get(
'source',
'scripts/*')
132 source = waflib.Utils.to_list(source)
135 _srcs.extend(ctx.path.ant_glob(f, dir=
False))
140 '${INSTALL_AREA}/bin',
143 chmod=waflib.Utils.O755,
154 source = kw[
"source"]
155 selection_file = kw[
"selection_file"]
159 del kw[
"selection_file"]
161 o = ctx.build_reflex_dict(
164 selection_file = selection_file,
173 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
175 jobo_dir = ctx.path.find_dir(
'options')
176 jobos = jobo_dir.ant_glob(
'**/*', dir=
False)
179 '${INSTALL_AREA}/jobOptions/%s' % PACKAGE_NAME,
190 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
192 source = kw[
'source']
193 relative_trick = kw.get(
'relative_trick',
False)
194 cwd = kw.get(
'cwd',
None)
196 cwd = waflib.Utils.to_list(cwd)[0]
197 cwd = ctx.path.find_dir(cwd)
199 source = waflib.Utils.to_list(source)
202 _srcs.extend(ctx.path.ant_glob(f, dir=
False))
207 '${INSTALL_AREA}/share',
209 relative_trick=relative_trick,
220 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
223 inc_node = ctx.path.find_dir(PACKAGE_NAME)
227 if isinstance(incdir, str):
228 inc_node = ctx.path.find_dir(incdir)
234 if isinstance(cwd, str):
235 cwd = ctx.path.find_dir(cwd)
238 ctx.fatal(
'no such directory [%s] (pkg=%s)' % (incdir, ctx.hwaf_pkg_name()))
241 includes = inc_node.ant_glob(
'**/*', dir=
False)
243 '${INSTALL_AREA}/include', includes,
244 relative_trick=relative_trick,
249 incpath = waflib.Utils.subst_vars(
'${INSTALL_AREA}/include',ctx.env)
250 ctx.env.append_unique(
'INCLUDES_%s' % PACKAGE_NAME,
251 [incpath,inc_node.parent.abspath()])
265 PACKAGE_NAME = osp.basename(ctx.hwaf_pkg_name())
267 ctx.gaudi_gen_package_version_header()
271 source = kw[
"source"]
275 linkflags = kw.get(
'linkflags', [])
276 linkflags = ctx.env.SHLINKFLAGS + linkflags
277 kw[
'linkflags'] = linkflags
279 src_node = ctx.path.find_dir(
'src')
281 srcs = ctx._cmt_get_srcs_lst(source)
282 includes = waflib.Utils.to_list(kw.get(
'includes', []))
283 includes.insert(0, ctx.path.abspath())
284 kw[
'includes'] = includes + [src_node]
287 kw[
'export_includes'] = waflib.Utils.to_list(
288 kw.get(
'export_includes', [])
290 if not kw[
'export_includes']:
291 inc_node = ctx.path.find_dir(PACKAGE_NAME)
294 kw[
'export_includes'].append(export_incs)
296 export_incs = kw[
'export_includes']
300 kw[
'includes'].extend(kw[
'export_includes'])
302 kw[
'use'] = waflib.Utils.to_list(kw.get(
'use', [])) + [
'dl']
304 defines = waflib.Utils.to_list(kw.get(
'defines', []))
305 kw[
'defines'] = defines + ctx._get_pkg_version_defines()
307 kw[
'features'] = waflib.Utils.to_list(kw.get(
'features', [])) + [
308 'cxx',
'cxxshlib',
'symlink_tsk',
310 kw[
'target'] = kw.get(
'target', name)
316 install_path =
'${INSTALL_AREA}/lib',
317 libpath = ctx.env.LD_LIBRARY_PATH + [ctx.path.get_bld().abspath()],
322 ctx.env[
'LIB_%s' % name] = [name]
323 ctx.env.append_unique(
'LIBPATH_%s'%name, ctx.path.get_bld().abspath())
325 uses = waflib.Utils.to_list(kw.get(
'use', []))
326 ctx.hwaf_propagate_uselib(name, uses)
331 export_incs = waflib.Utils.to_list(export_incs)[0]
332 if export_incs ==
'.':
333 ctx.gaudi_install_headers()
343 do_genmap = kw.get(
'do_genmap',
True)
344 do_genconf= kw.get(
'do_genconf',
True)
347 source = kw[
"source"]
351 ctx.gaudi_gen_package_version_header()
355 src_node = ctx.path.find_dir(
'src')
356 bld_node = src_node.get_bld()
358 srcs = ctx._cmt_get_srcs_lst(source)
359 includes = waflib.Utils.to_list(kw.get(
'includes', []))
360 includes.insert(0, ctx.path.abspath())
361 includes.insert(1, ctx.path.get_bld().abspath())
363 kw[
'includes'] = includes + [src_node]
365 linkflags = waflib.Utils.to_list(kw.get(
'linkflags', []))
366 linkflags = ctx.env.SHLINKFLAGS + linkflags
367 kw[
'linkflags'] = linkflags
369 defines = waflib.Utils.to_list(kw.get(
'defines', []))
370 kw[
'defines'] = defines + ctx._get_pkg_version_defines()
372 kw[
'depends_on'] = waflib.Utils.to_list(kw.get(
'use', [])) + \
373 waflib.Utils.to_list(kw.get(
'depends_on', []))
377 PACKAGE_NAME = ctx._get_pkg_name()
380 features = [
'cxx',
'cxxshlib',]
381 features.append(
'symlink_tsk')
383 features.append(
'gen_map')
385 features.append(
'gen_conf')
388 kw[
'features'] = waflib.Utils.to_list(kw.get(
'features',[])) + features
389 kw[
'target'] = kw.get(
'target', name)
395 lib.name =
'complib-%s' % name
397 lib.install_path =
'${INSTALL_AREA}/lib'
398 lib.libpath = ctx.env.LD_LIBRARY_PATH + [ctx.path.get_bld().abspath()]
399 lib_name =
"lib%s.so" % (lib.target,)
400 lib.env[
'GENCONF_LIBNAME'] = lib.target
401 lib.env[
'PACKAGE_NAME'] = PACKAGE_NAME
416 source = kw[
"source"]
420 ctx.gaudi_gen_package_version_header()
423 do_test = kw.get(
'do_test',
False)
427 kw[
'features'] = waflib.Utils.to_list(
428 kw.get(
'features',
'')) + [
429 'cxx',
'cxxprogram',
'symlink_tsk',
432 kw[
'use'] = waflib.Utils.to_list(kw.get(
'use', []))
434 pkg_node = ctx.path.get_src()
435 src_node = ctx.path.find_dir(
'src')
437 srcs = ctx._cmt_get_srcs_lst(source)
438 linkflags = waflib.Utils.to_list(kw.get(
'linkflags', []))
439 linkflags = ctx.env.SHLINKFLAGS + linkflags
440 kw[
'linkflags'] = linkflags
442 defines = waflib.Utils.to_list(kw.get(
'defines', []))
443 kw[
'defines'] = defines + ctx._get_pkg_version_defines()
445 includes = waflib.Utils.to_list(kw.get(
'includes', []))
446 includes.insert(0, ctx.path.abspath())
448 kw[
'includes'] = includes + [src_node]
451 PACKAGE_NAME = ctx._get_pkg_name()
457 exe.install_path =
'${INSTALL_AREA}/bin'
458 exe.libpath = ctx.env.LD_LIBRARY_PATH + [ctx.path.get_bld().abspath()]
459 exe.target = name+
'.exe'
465 @after(
'symlink_tsk')
467 lnk_task = getattr(self,
'link_task',
None)
470 for n
in lnk_task.outputs:
474 @after(
'symlink_tsk')
476 "Bind the .dsomap file extension to the creation of a genconf task"
477 dso = self.env[
'GENCONF_LIBNAME']
478 bld_node = node.get_bld().parent
479 pkg_name = bld_node.name
480 genconf_dir_node = bld_node.make_node(
'genConf').make_node(pkg_name)
481 self.env[
'GENCONF_OUTPUTDIR'] = genconf_dir_node.abspath()
482 genconf_node = genconf_dir_node.make_node(
'%sConf.py' % dso)
483 initpy_node = genconf_dir_node.make_node(
'__init__.py')
484 confdb_node = genconf_dir_node.make_node(
'%s_confDb.py' % dso)
485 tsk = self.create_task(
'gen_conf',
487 [genconf_node,genconf_dir_node,initpy_node,confdb_node])
492 src_node = self.path.get_src()
493 py_dir = src_node.find_dir(
'python')
494 py_files = [genconf_node, confdb_node]
496 py_files.append(initpy_node)
497 PACKAGE_NAME = self.env[
'PACKAGE_NAME']
500 name =
'py-genconf-%s' % PACKAGE_NAME,
502 install_path =
'${INSTALL_AREA}/python/%s' % PACKAGE_NAME,
506 pypath = waflib.Utils.subst_vars(
'${INSTALL_AREA}/python', self.env)
507 if not pypath
in self.env.get_flat(
'PYTHONPATH'):
508 self.env.prepend_value(
'PYTHONPATH', pypath)
514 vars = [
'GENCONF',
'DEFINES',
'INCLUDES',
'GENCONF_CONFIGURABLE_MODULE']
516 ext_in = [
'.bin',
'.so']
520 after = [
'cxxshlib',
'cxxprogram',
'symlink_tsk',
'gen_map']
521 depends_on = [
'genconf',
'complib-GaudiCoreSvc']
525 cmd =
'${GENCONF} -p ${PACKAGE_NAME} -i %s -o ${GENCONF_OUTPUTDIR} --configurable-module ${GENCONF_CONFIGURABLE_MODULE}' % (
528 cmd = waflib.Utils.subst_vars(cmd, self.env)
530 bld_node = self.inputs[0].parent.get_bld()
532 o = self.outputs[0].change_ext(
'.genconf.log')
533 fout_node = bld_node.find_or_declare(o.name)
534 fout = open(fout_node.abspath(),
'w')
535 env = self.generator.bld._get_env_for_subproc()
536 rc = self.generator.bld.exec_command(
543 msg.error(
"** error running [%s]" % cmd)
544 msg.error(fout_node.read())
548 g_confdb_merger =
None
549 @feature(
'merge_confdb')
553 @extension(
'_confDb.py')
555 global g_confdb_merger
556 if g_confdb_merger
is None:
558 bld_area = os.path.basename(self.env[
'BUILD_INSTALL_AREA'])
559 bld_node = self.bld.bldnode.find_dir(bld_area)
560 py_node = bld_node.make_node(
'python')
562 out_node = py_node.make_node(
563 'project_%s_merged_confDb.py' %
564 self.bld.hwaf_project_name().replace(
'-',
'_')
566 g_confdb_merger = self.create_task(
'merge_confdb', node, out_node)
567 self.bld.install_files(
568 '${INSTALL_AREA}/python',
573 g_confdb_merger.inputs.append(node)
574 return g_confdb_merger
578 ext_in = [
'_confDb.py']
580 after = [
'merge_dsomap',]
581 run_str =
'cat ${SRC} > ${TGT}'
585 status = waflib.Task.Task.runnable_status(self)
586 if status == waflib.Task.ASK_LATER:
590 for in_node
in self.inputs:
592 os.stat(in_node.abspath())
594 msg.debug(
"::missing input [%s]" % in_node.abspath())
595 return waflib.Task.ASK_LATER
596 return waflib.Task.RUN_ME
604 pkgname = osp.basename(ctx.hwaf_pkg_name())
605 hdr = ctx.path.get_bld().make_node(
'%sVersion.h' % pkgname)
607 tgt = task.outputs[0]
609 #ifndef %(proj)s_VERSION
610 /* Automatically generated file: do not modify! */
611 #ifndef CALC_GAUDI_VERSION
612 #define CALC_GAUDI_VERSION(maj,min) (((maj) << 16) + (min))
614 #define %(proj)s_MAJOR_VERSION %(maj)d
615 #define %(proj)s_MINOR_VERSION %(min)d
616 #define %(proj)s_PATCH_VERSION %(pat)d
617 #define %(proj)s_VERSION CALC_GAUDI_VERSION(%(proj)s_MAJOR_VERSION,%(proj)s_MINOR_VERSION)
619 ''' % getattr(task.generator,
'pkg_version_data')
623 pkg_infos = ctx.hwaf_pkg_infos()
624 version = pkg_infos.get(
'version',
None)
626 version_hwaf = ctx.path.get_src().find_resource(
'version.hwaf')
627 if version_hwaf: version = version_hwaf.read().strip()
628 else: version =
'HEAD'
632 majver, minver, patver = 999, 999, 0
634 if version.startswith(
'HEAD'):
635 majver, minver, patver = 999, 999, 0
637 m = re.match(
"(v|([A-Za-z]+\-))(?P<maj_ver>[0-9]+)(r|\-)(?P<min_ver>[0-9]+)(?:(p|\-)(?P<pat_ver>[0-9]+))?", version)
639 majver = int(m.groupdict()[
'maj_ver'])
640 minver = int(m.groupdict()[
'min_ver'])
641 patver = int(m.groupdict()[
'pat_ver']
or 0)
642 pkg_version = (majver,minver,patver)
644 if not ctx.env[
'GEN_PKG_VERSION_HDR_%s' % pkgname]:
646 name =
'gen-pkg-version-hdr-'+pkgname,
651 'proj':pkgname.upper(),
658 ctx.env[
'GEN_PKG_VERSION_HDR_%s' % pkgname] =
'1'
663 waflib.Build.BuildContext.gaudi_module = gaudi_module
664 waflib.Build.BuildContext.gaudi_library = gaudi_library
665 waflib.Build.BuildContext.gaudi_application = gaudi_application
667 waflib.Build.BuildContext.gaudi_install_headers = gaudi_install_headers
668 waflib.Build.BuildContext.gaudi_gen_package_version_header = gaudi_gen_package_version_header