ladishd: remove unneeded asignment
[ladish.git] / wscript
blob680dec2b1fc6ebad194097256a5fba2445115553
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
5 import Options
6 import Utils
7 import shutil
8 import re
9 import misc
11 APPNAME='ladish'
12 VERSION='0.3-rc'
13 DBUS_NAME_BASE = 'org.ladish'
14 RELEASE = False
16 # these variables are mandatory ('/' are converted automatically)
17 srcdir = '.'
18 blddir = 'build'
20 def display_msg(conf, msg="", status = None, color = None):
21 if status:
22 conf.check_message_1(msg)
23 conf.check_message_2(status, color)
24 else:
25 Utils.pprint('NORMAL', msg)
27 def display_raw_text(conf, text, color = 'NORMAL'):
28 Utils.pprint(color, text, sep = '')
30 def display_line(conf, text, color = 'NORMAL'):
31 Utils.pprint(color, text, sep = os.linesep)
33 def yesno(bool):
34 if bool:
35 return "yes"
36 else:
37 return "no"
39 def set_options(opt):
40 opt.tool_options('compiler_cc')
41 opt.tool_options('compiler_cxx')
42 opt.tool_options('boost')
43 opt.tool_options('python')
44 opt.add_option('--enable-pkg-config-dbus-service-dir', action='store_true', default=False, help='force D-Bus service install dir to be one returned by pkg-config')
45 opt.add_option('--enable-liblash', action='store_true', default=False, help='Build LASH compatibility library')
46 opt.add_option('--enable-pylash', action='store_true', default=False, help='Build python bindings for LASH compatibility library')
47 opt.add_option('--debug', action='store_true', default=False, dest='debug', help="Build debuggable binaries")
48 opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
49 opt.add_option('--distnodeps', action='store_true', default=False, help="When creating distribution tarball, don't package git submodules")
51 def add_cflag(conf, flag):
52 conf.env.append_unique('CXXFLAGS', flag)
53 conf.env.append_unique('CCFLAGS', flag)
55 def add_linkflag(conf, flag):
56 conf.env.append_unique('LINKFLAGS', flag)
58 def check_gcc_optimizations_enabled(flags):
59 gcc_optimizations_enabled = False
60 for flag in flags:
61 if len(flag) < 2 or flag[0] != '-' or flag[1] != 'O':
62 continue
63 if len(flag) == 2:
64 gcc_optimizations_enabled = True;
65 else:
66 gcc_optimizations_enabled = flag[2] != '0';
67 return gcc_optimizations_enabled
69 def create_service_taskgen(bld, target, opath, binary):
70 obj = bld.new_task_gen('subst')
71 obj.source = os.path.join('daemon', 'dbus.service.in')
72 obj.target = target
73 obj.dict = {'dbus_object_path': opath,
74 'daemon_bin_path': os.path.join(bld.env['PREFIX'], 'bin', binary)}
75 obj.install_path = bld.env['DBUS_SERVICES_DIR'] + os.path.sep
76 obj.fun = misc.subst_func
78 def _get_python_variables(python_exe,variables,imports=['import sys']):
79 program=list(imports)
80 program.append('')
81 for v in variables:
82 program.append("print(repr(%s))"%v)
83 os_env=dict(os.environ)
84 try:
85 del os_env['MACOSX_DEPLOYMENT_TARGET']
86 except KeyError:
87 pass
88 proc=Utils.pproc.Popen([python_exe,"-c",'\n'.join(program)],stdout=Utils.pproc.PIPE,env=os_env)
89 output=proc.communicate()[0].split("\n")
90 if proc.returncode:
91 if Options.options.verbose:
92 warn("Python program to extract python configuration variables failed:\n%s"%'\n'.join(["line %03i: %s"%(lineno+1,line)for lineno,line in enumerate(program)]))
93 raise RuntimeError
94 return_values=[]
95 for s in output:
96 s=s.strip()
97 if not s:
98 continue
99 if s=='None':
100 return_values.append(None)
101 elif s[0]=="'"and s[-1]=="'":
102 return_values.append(s[1:-1])
103 elif s[0].isdigit():
104 return_values.append(int(s))
105 else:break
106 return return_values
108 def configure(conf):
109 conf.check_tool('compiler_cc')
110 conf.check_tool('compiler_cxx')
111 conf.check_tool('boost')
112 conf.check_tool('python')
113 #conf.check_tool('ParallelDebug')
115 conf.env['LIB_DL'] = ['dl']
117 conf.check_cfg(
118 package = 'jack',
119 mandatory = True,
120 errmsg = "not installed, see http://jackaudio.org/",
121 args = '--cflags --libs')
123 conf.check_cfg(
124 package = 'dbus-1',
125 atleast_version = '1.0.0',
126 mandatory = True,
127 errmsg = "not installed, see http://dbus.freedesktop.org/",
128 args = '--cflags --libs')
130 dbus_dir = conf.check_cfg(package='dbus-1', args='--variable=session_bus_services_dir', msg="Retrieving D-Bus services dir")
131 if not dbus_dir:
132 return
134 dbus_dir = dbus_dir.strip()
135 conf.env['DBUS_SERVICES_DIR_REAL'] = dbus_dir
137 if Options.options.enable_pkg_config_dbus_service_dir:
138 conf.env['DBUS_SERVICES_DIR'] = dbus_dir
139 else:
140 conf.env['DBUS_SERVICES_DIR'] = os.path.join(os.path.normpath(conf.env['PREFIX']), 'share', 'dbus-1', 'services')
142 conf.env['LIBDIR'] = os.path.join(os.path.normpath(conf.env['PREFIX']), 'lib')
144 conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
146 conf.check_cfg(
147 package = 'uuid',
148 mandatory = True,
149 errmsg = "not installed, see http://e2fsprogs.sourceforge.net/",
150 args = '--cflags --libs')
152 conf.check(
153 header_name='expat.h',
154 mandatory = True,
155 errmsg = "not installed, see http://expat.sourceforge.net/")
157 conf.env['LIB_EXPAT'] = ['expat']
159 build_gui = True
161 if build_gui and not conf.check_cfg(
162 package = 'glib-2.0',
163 mandatory = False,
164 errmsg = "not installed, see http://www.gtk.org/",
165 args = '--cflags --libs'):
166 build_gui = False
168 if build_gui and not conf.check_cfg(
169 package = 'dbus-glib-1',
170 mandatory = False,
171 errmsg = "not installed, see http://dbus.freedesktop.org/",
172 args = '--cflags --libs'):
173 build_gui = False
175 if build_gui and not conf.check_cfg(
176 package = 'gtk+-2.0',
177 mandatory = False,
178 atleast_version = '2.20.0',
179 errmsg = "not installed, see http://www.gtk.org/",
180 args = '--cflags --libs'):
181 build_gui = False
183 if build_gui and not conf.check_cfg(
184 package = 'flowcanvas',
185 mandatory = False,
186 atleast_version = '0.6.4',
187 errmsg = "not installed, see http://drobilla.net/software/flowcanvas/",
188 args = '--cflags --libs'):
189 build_gui = False
191 if build_gui:
192 # We need the boost headers package (e.g. libboost-dev)
193 # shared_ptr.hpp and weak_ptr.hpp
194 build_gui = conf.check_boost(errmsg="not found, see http://boost.org/")
196 conf.env['BUILD_GLADISH'] = build_gui
198 conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
199 conf.env['BUILD_PYLASH'] = Options.options.enable_pylash
200 if conf.env['BUILD_PYLASH'] and not conf.env['BUILD_LIBLASH']:
201 conf.fatal("pylash build was requested but liblash was not")
202 conf.env['BUILD_PYLASH'] = False
203 if conf.env['BUILD_PYLASH']:
204 conf.check_python_version()
205 #print conf.env['PYTHONDIR']
206 python = conf.env['PYTHON']
207 #print python
208 pymajmin = '.'.join(conf.env['PYTHON_VERSION'].split('.')[:2])
209 try:
210 v='prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split()
211 (python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET)=_get_python_variables(python,["get_config_var('%s')"%x for x in v],['from distutils.sysconfig import get_config_var'])
212 except RuntimeError:
213 conf.fatal("Python development headers not found (-v for details).")
214 conf.log.write("""Configuration returned from %r:
215 python_prefix = %r
216 python_SO = %r
217 python_SYSLIBS = %r
218 python_LDFLAGS = %r
219 python_SHLIBS = %r
220 python_LIBDIR = %r
221 python_LIBPL = %r
222 INCLUDEPY = %r
223 Py_ENABLE_SHARED = %r
224 MACOSX_DEPLOYMENT_TARGET = %r
225 """%(python,python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET))
227 conf.env['pyext_PATTERN'] = '%s' + python_SO
229 for pattern in 'python%s-config', 'python-config-%s':
230 python_config = conf.find_program(pattern % pymajmin, var = 'PYTHON_CONFIG')
231 if python_config:
232 includes=[]
233 #print conf.env['PYTHON_CONFIG']
234 for incstr in Utils.cmd_output("%s --includes" % (conf.env['PYTHON_CONFIG'])).strip().split():
235 if (incstr.startswith('-I') or incstr.startswith('/I')):
236 incstr = incstr[2:]
237 if incstr not in includes:
238 includes.append(incstr)
239 conf.log.write("Include path for Python extensions ""(found via python-config --includes): %r\n"%(includes,))
240 conf.env['CPPPATH_PYEXT'] = includes
241 conf.env['CPPPATH_PYEMBED'] = includes
242 break
244 if not python_config:
245 conf.log.write("Include path for Python extensions ""(found via distutils module): %r\n"%(INCLUDEPY,))
246 conf.env['CPPPATH_PYEXT'] = [INCLUDEPY]
247 conf.env['CPPPATH_PYEMBED'] = [INCLUDEPY]
249 conf.env['BUILD_WERROR'] = not RELEASE
250 if conf.env['BUILD_WERROR']:
251 add_cflag(conf, '-Wall')
252 add_cflag(conf, '-Werror')
253 # for pre gcc-4.4, enable optimizations so use of uninitialized variables gets detected
254 try:
255 is_gcc = conf.env['CC_NAME'] == 'gcc'
256 if is_gcc:
257 gcc_ver = []
258 for n in conf.env['CC_VERSION']:
259 gcc_ver.append(int(n))
260 if gcc_ver[0] < 4 or gcc_ver[1] < 4:
261 #print "optimize force enable is required"
262 if not check_gcc_optimizations_enabled(conf.env['CCFLAGS']):
263 if Options.options.debug:
264 print "C optimization must be forced in order to enable -Wuninitialized"
265 print "However this will not be made because debug compilation is enabled"
266 else:
267 print "C optimization forced in order to enable -Wuninitialized"
268 conf.env.append_unique('CCFLAGS', "-O")
269 except:
270 pass
272 conf.env['BUILD_DEBUG'] = Options.options.debug
273 if conf.env['BUILD_DEBUG']:
274 add_cflag(conf, '-g')
275 add_cflag(conf, '-O0')
276 add_linkflag(conf, '-g')
278 conf.define('DATA_DIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'share', APPNAME)))
279 conf.define('PACKAGE_VERSION', VERSION)
280 conf.define('DBUS_NAME_BASE', DBUS_NAME_BASE)
281 conf.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE.replace('.', '/'))
282 conf.define('BASE_NAME', APPNAME)
283 conf.define('_GNU_SOURCE', 1)
284 conf.write_config_header('config.h')
286 display_msg(conf)
288 display_msg(conf, "==================")
289 version_msg = APPNAME + "-" + VERSION
291 if os.access('version.h', os.R_OK):
292 data = file('version.h').read()
293 m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
294 if m != None:
295 version_msg += " exported from " + m.group(1)
296 elif os.access('.git', os.R_OK):
297 version_msg += " git revision will checked and eventually updated during build"
299 display_msg(conf, version_msg)
301 display_msg(conf)
302 display_msg(conf, "Install prefix", conf.env['PREFIX'], 'CYAN')
304 display_msg(conf, 'Build gladish', yesno(conf.env['BUILD_GLADISH']))
305 display_msg(conf, 'Build liblash', yesno(Options.options.enable_liblash))
306 display_msg(conf, 'Build pylash', yesno(conf.env['BUILD_PYLASH']))
307 display_msg(conf, 'Treat warnings as errors', yesno(conf.env['BUILD_WERROR']))
308 display_msg(conf, 'Debuggable binaries', yesno(conf.env['BUILD_DEBUG']))
309 display_msg(conf, 'Build doxygen documentation', yesno(conf.env['BUILD_DOXYGEN_DOCS']))
311 if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
312 display_msg(conf)
313 display_line(conf, "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
314 display_raw_text(conf, "WARNING:", 'RED')
315 display_line(conf, conf.env['DBUS_SERVICES_DIR_REAL'], 'CYAN')
316 display_line(conf, 'WARNING: but service file will be installed in', 'RED')
317 display_raw_text(conf, "WARNING:", 'RED')
318 display_line(conf, conf.env['DBUS_SERVICES_DIR'], 'CYAN')
319 display_line(conf, 'WARNING: You may need to adjust your D-Bus configuration after installing ladish', 'RED')
320 display_line(conf, 'WARNING: You can override dbus service install directory', 'RED')
321 display_line(conf, 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
323 display_msg(conf, 'C compiler flags', repr(conf.env['CCFLAGS']))
324 display_msg(conf, 'C++ compiler flags', repr(conf.env['CXXFLAGS']))
326 if not conf.env['BUILD_GLADISH']:
327 display_msg(conf)
328 display_line(conf, "WARNING: The GUI frontend will not built", 'RED')
330 display_msg(conf)
332 def build(bld):
333 daemon = bld.new_task_gen('cc', 'program')
334 daemon.target = 'ladishd'
335 daemon.includes = "build/default" # XXX config.h version.h and other generated files
336 daemon.uselib = 'DBUS-1 UUID EXPAT'
337 daemon.ver_header = 'version.h'
338 daemon.env.append_value("LINKFLAGS", ["-lutil", "-ldl", "-Wl,-E"])
340 daemon.source = []
342 for source in [
343 'main.c',
344 'loader.c',
345 'log.c',
346 'sigsegv.c',
347 'proctitle.c',
348 'appdb.c',
349 'procfs.c',
350 'control.c',
351 'studio.c',
352 'graph.c',
353 'client.c',
354 'port.c',
355 'virtualizer.c',
356 'dict.c',
357 'graph_dict.c',
358 'escape.c',
359 'studio_jack_conf.c',
360 'save.c',
361 'load.c',
362 'cmd_load_studio.c',
363 'cmd_new_studio.c',
364 'cmd_rename_studio.c',
365 'cmd_save_studio.c',
366 'cmd_start_studio.c',
367 'cmd_stop_studio.c',
368 'cmd_unload_studio.c',
369 'cmd_new_app.c',
370 'cmd_change_app_state.c',
371 'cmd_remove_app.c',
372 'cmd_create_room.c',
373 'cmd_delete_room.c',
374 'cmd_save_project.c',
375 'cmd_unload_project.c',
376 'cmd_load_project.c',
377 'cmd_exit.c',
378 'cqueue.c',
379 'app_supervisor.c',
380 'room.c',
381 'room_save.c',
382 'room_load.c',
383 'recent_store.c',
384 'recent_projects.c',
386 daemon.source.append(os.path.join("daemon", source))
388 for source in [
389 'jack_proxy.c',
390 'graph_proxy.c',
391 'a2j_proxy.c',
392 "jmcore_proxy.c",
393 "notify_proxy.c",
394 "conf_proxy.c",
396 daemon.source.append(os.path.join("proxies", source))
398 for source in [
399 'signal.c',
400 'method.c',
401 'error.c',
402 'object_path.c',
403 'interface.c',
404 'helpers.c',
406 daemon.source.append(os.path.join("dbus", source))
408 for source in [
409 'time.c',
410 'dirhelpers.c',
411 'catdup.c',
413 daemon.source.append(os.path.join("common", source))
415 daemon.source.append(os.path.join("alsapid", "helper.c"))
417 # process dbus.service.in -> ladish.service
418 create_service_taskgen(bld, DBUS_NAME_BASE + '.service', DBUS_NAME_BASE, daemon.target)
420 #####################################################
421 # jmcore
422 jmcore = bld.new_task_gen('cc', 'program')
423 jmcore.target = 'jmcore'
424 jmcore.includes = "build/default" # XXX config.h version.h and other generated files
425 jmcore.uselib = 'DBUS-1 JACK'
426 jmcore.defines = ['LOG_OUTPUT_STDOUT']
427 jmcore.source = ['jmcore.c']
429 for source in [
430 #'signal.c',
431 'method.c',
432 'error.c',
433 'object_path.c',
434 'interface.c',
435 'helpers.c',
437 jmcore.source.append(os.path.join("dbus", source))
439 create_service_taskgen(bld, DBUS_NAME_BASE + '.jmcore.service', DBUS_NAME_BASE + ".jmcore", jmcore.target)
441 #####################################################
442 # conf
443 ladiconfd = bld.new_task_gen('cc', 'program')
444 ladiconfd.target = 'ladiconfd'
445 ladiconfd.includes = "build/default" # XXX config.h version.h and other generated files
446 ladiconfd.uselib = 'DBUS-1'
447 ladiconfd.defines = ['LOG_OUTPUT_STDOUT']
448 ladiconfd.source = ['conf.c']
450 for source in [
451 'dirhelpers.c',
452 'catdup.c',
454 ladiconfd.source.append(os.path.join("common", source))
456 for source in [
457 'signal.c',
458 'method.c',
459 'error.c',
460 'object_path.c',
461 'interface.c',
462 'helpers.c',
464 ladiconfd.source.append(os.path.join("dbus", source))
466 create_service_taskgen(bld, DBUS_NAME_BASE + '.conf.service', DBUS_NAME_BASE + ".conf", ladiconfd.target)
468 #####################################################
469 # alsapid
470 alsapid = bld.new_task_gen('cc', 'shlib')
471 alsapid.target = 'alsapid'
472 alsapid.uselib = 'DL'
473 alsapid.source = [os.path.join("alsapid", 'lib.c'), os.path.join("alsapid", "helper.c")]
475 #####################################################
476 # liblash
477 if bld.env['BUILD_LIBLASH']:
478 liblash = bld.new_task_gen('cc', 'shlib')
479 liblash.includes = "build/default" # XXX config.h version.h and other generated files
480 liblash.uselib = 'DBUS-1'
481 liblash.target = 'lash'
482 liblash.vnum = "1.1.1"
483 liblash.defines = ['LOG_OUTPUT_STDOUT']
484 liblash.source = [os.path.join("lash_compat", "liblash", 'lash.c'), os.path.join("common", "catdup.c")]
486 bld.install_files('${PREFIX}/include/lash', 'lash_compat/liblash/lash/*.h')
488 # process lash-1.0.pc.in -> lash-1.0.pc
489 obj = bld.new_task_gen('subst')
490 obj.source = [os.path.join("lash_compat", 'lash-1.0.pc.in')]
491 obj.target = 'lash-1.0.pc'
492 obj.dict = {'prefix': bld.env['PREFIX'],
493 'exec_prefix': bld.env['PREFIX'],
494 'libdir': bld.env['LIBDIR'],
495 'includedir': os.path.normpath(bld.env['PREFIX'] + '/include'),
497 obj.install_path = '${LIBDIR}/pkgconfig/'
498 obj.fun = misc.subst_func
500 #####################################################
501 # pylash
502 if bld.env['BUILD_PYLASH']:
503 pylash = bld.new_task_gen('cc', 'shlib', 'pyext')
504 pylash.target = '_lash'
505 pylash.uselib_local = 'lash'
506 pylash.source = []
507 pylash.install_path = bld.env['PYTHONDIR']
509 for source in [
510 'lash.c',
511 'lash_wrap.c',
513 pylash.source.append(os.path.join("lash_compat", "pylash", source))
515 bld.install_files(bld.env['PYTHONDIR'], os.path.join("lash_compat", "pylash", "lash.py"))
517 # pkgpyexec_LTLIBRARIES = _lash.la
518 # INCLUDES = $(PYTHON_INCLUDES)
519 # _lash_la_LDFLAGS = -module -avoid-version ../liblash/liblash.la
520 # _lash_la_SOURCES = lash.c lash.h lash_wrap.c
521 # pkgpyexec_SCRIPTS = lash.py
522 # CLEANFILES = lash_wrap.c lash.py lash.pyc zynjacku.defs
523 # EXTRA_DIST = test.py lash.i lash.py
524 # lash_wrap.c lash.py: lash.i lash.h
525 # swig -o lash_wrap.c -I$(top_srcdir) -python $(top_srcdir)/$(subdir)/lash.i
527 #####################################################
528 # gladish
529 if bld.env['BUILD_GLADISH']:
530 gladish = bld.new_task_gen('cxx', 'program')
531 gladish.features.append('cc')
532 gladish.target = 'gladish'
533 gladish.defines = ['LOG_OUTPUT_STDOUT']
534 gladish.includes = "build/default" # XXX config.h version.h and other generated files
535 gladish.uselib = 'DBUS-1 DBUS-GLIB-1 FLOWCANVAS'
537 gladish.source = []
539 for source in [
540 'main.c',
541 'load_project_dialog.c',
542 'save_project_dialog.c',
543 'world_tree.c',
544 'graph_view.c',
545 'canvas.cpp',
546 'graph_canvas.c',
547 'gtk_builder.c',
548 'ask_dialog.c',
549 'create_room_dialog.c',
550 'menu.c',
551 'dynmenu.c',
552 'toolbar.c',
553 'about.c',
554 'dbus.c',
555 'studio.c',
556 'studio_list.c',
557 'dialogs.c',
558 'jack.c',
559 'control.c',
560 'pixbuf.c',
561 'room.c',
562 'statusbar.c',
563 'action.c',
564 'settings.c',
565 'zoom.c',
567 gladish.source.append(os.path.join("gui", source))
569 for source in [
570 'jack_proxy.c',
571 'graph_proxy.c',
572 'studio_proxy.c',
573 'control_proxy.c',
574 'app_supervisor_proxy.c',
575 "room_proxy.c",
576 "conf_proxy.c",
578 gladish.source.append(os.path.join("proxies", source))
580 for source in [
581 'method.c',
582 'helpers.c',
584 gladish.source.append(os.path.join("dbus", source))
586 for source in [
587 'catdup.c',
589 gladish.source.append(os.path.join("common", source))
591 # GtkBuilder UI definitions (XML)
592 bld.install_files(bld.env['DATA_DIR'], 'gui/gladish.ui')
594 bld.install_files('${PREFIX}/bin', 'ladish_control', chmod=0755)
596 # 'Desktop' file (menu entry, icon, etc)
597 bld.install_files('${PREFIX}/share/applications/', 'gui/gladish.desktop', chmod=0644)
599 # Icons
600 icon_sizes = ['16x16', '22x22', '24x24', '32x32', '48x48', '256x256']
601 for icon_size in icon_sizes:
602 bld.path.ant_glob('art/' + icon_size + '/apps/*.png')
603 bld.install_files('${PREFIX}/share/icons/hicolor/' + icon_size + '/apps/', 'art/' + icon_size + '/apps/gladish.png')
605 status_images = []
606 for status in ["down", "unloaded", "started", "stopped", "warning", "error"]:
607 status_images.append("art/status_" + status + ".png")
609 bld.install_files(bld.env['DATA_DIR'], status_images)
610 bld.install_files(bld.env['DATA_DIR'], "art/ladish-logo-128x128.png")
611 bld.install_files(bld.env['DATA_DIR'], ["COPYING", "AUTHORS", "README", "NEWS"])
613 if bld.env['BUILD_DOXYGEN_DOCS'] == True:
614 html_docs_source_dir = "build/default/html"
615 if Options.commands['clean']:
616 if os.access(html_docs_source_dir, os.R_OK):
617 Utils.pprint('CYAN', "Removing doxygen generated documentation...")
618 shutil.rmtree(html_docs_source_dir)
619 Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
620 elif Options.commands['build']:
621 if not os.access(html_docs_source_dir, os.R_OK):
622 os.popen("doxygen").read()
623 else:
624 Utils.pprint('CYAN', "doxygen documentation already built.")
626 def get_tags_dirs():
627 source_root = os.path.dirname(Utils.g_module.root_path)
628 if 'relpath' in os.path.__all__:
629 source_root = os.path.relpath(source_root)
630 paths = source_root
631 paths += " " + os.path.join(source_root, "common")
632 paths += " " + os.path.join(source_root, "dbus")
633 paths += " " + os.path.join(source_root, "proxies")
634 paths += " " + os.path.join(source_root, "daemon")
635 paths += " " + os.path.join(source_root, "gui")
636 paths += " " + os.path.join(source_root, "example-apps")
637 paths += " " + os.path.join(source_root, "lib")
638 paths += " " + os.path.join(source_root, "lash_compat", "liblash")
639 paths += " " + os.path.join(source_root, "lash_compat", "liblash", "lash")
640 return paths
642 def gtags(ctx):
643 '''build tag files for GNU global'''
644 cmd = "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | gtags --statistics -f -" % get_tags_dirs()
645 #print("Running: %s" % cmd)
646 os.system(cmd)
648 def etags(ctx):
649 '''build TAGS file using etags'''
650 cmd = "find %s -mindepth 1 -maxdepth 1 -name '*.[ch]' -print | etags -" % get_tags_dirs()
651 #print("Running: %s" % cmd)
652 os.system(cmd)
653 os.system("stat -c '%y' TAGS")
655 def dist_hook():
656 #print repr(Options.options)
657 if Options.options.distnodeps:
658 shutil.rmtree('laditools')
659 shutil.rmtree('flowcanvas')
660 shutil.rmtree('jack2')
661 shutil.rmtree('a2jmidid')
662 nodist_files = ['.gitmodules', 'GTAGS', 'GRTAGS', 'GPATH', 'GSYMS'] # waf does not ignore these file
663 for nodist_file in nodist_files:
664 if os.access(nodist_file, os.F_OK):
665 os.remove(nodist_file)
666 shutil.copy('../build/default/version.h', "./")
668 import commands
669 from Constants import RUN_ME
670 from TaskGen import feature, after
671 import Task, Utils
673 @feature('cc')
674 @after('apply_core')
675 def process_git(self):
676 if getattr(self, 'ver_header', None):
677 tsk = self.create_task('git_ver')
678 tsk.set_outputs(self.path.find_or_declare(self.ver_header))
680 # needs some help with implicit dependencies
681 # http://code.google.com/p/waf/issues/detail?id=732
682 tg = self.bld.name_to_obj('ladishd', self.env)
683 if id(tg) != id(self):
684 tg.post()
685 for x in tg.tasks:
686 if x.inputs and x.inputs[0].name == 'main.c' and x.inputs[0].parent.name == 'daemon':
687 x.set_run_after(tsk)
689 def git_ver(self):
690 header = self.outputs[0].abspath(self.env)
691 if os.access('../version.h', os.R_OK):
692 shutil.copy('../version.h', header)
693 data = file(header).read()
694 m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
695 if m != None:
696 self.ver = m.group(1)
697 Utils.pprint('BLUE', "tarball from git revision " + self.ver)
698 else:
699 self.ver = "tarball"
700 return
702 if os.access('../.git', os.R_OK):
703 self.ver = commands.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
704 if commands.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
705 self.ver += "-dirty"
707 Utils.pprint('BLUE', "git revision " + self.ver)
708 else:
709 self.ver = "unknown"
711 fi = open(header, 'w')
712 fi.write('#define GIT_VERSION "%s"\n' % self.ver)
713 fi.close()
715 cls = Task.task_type_from_func('git_ver', vars=[], func=git_ver, color='BLUE')
717 def always(self):
718 return RUN_ME
719 cls.runnable_status = always
721 def post_run(self):
722 sg = Utils.h_list(self.ver)
723 node = self.outputs[0]
724 variant = node.variant(self.env)
725 self.generator.bld.node_sigs[variant][node.id] = sg
726 cls.post_run = post_run
728 import Runner
730 old_refill = Runner.Parallel.refill_task_list
731 def refill_task_list(self):
732 old_refill(self)
733 self.outstanding.sort(cmp=lambda a, b: cmp(b.__class__.__name__, a.__class__.__name__))
734 Runner.Parallel.refill_task_list = refill_task_list