root/wscript @ 1b1d5bbfa9cc007b5d629a8e200165e9649adbdd

Revision 1b1d5bbfa9cc007b5d629a8e200165e9649adbdd, 13.3 KB (checked in by Nedko Arnaudov <nedko@…>, 4 years ago)

command queue; not really used yet

  • Property mode set to 100644
Line 
1#! /usr/bin/env python
2# encoding: utf-8
3
4import os
5import Options
6import Utils
7import shutil
8import re
9
10APPNAME='ladish'
11VERSION='0.2'
12DBUS_NAME_BASE = 'org.ladish'
13
14# these variables are mandatory ('/' are converted automatically)
15srcdir = '.'
16blddir = 'build'
17
18def display_msg(conf, msg="", status = None, color = None):
19    if status:
20        conf.check_message_1(msg)
21        conf.check_message_2(status, color)
22    else:
23        Utils.pprint('NORMAL', msg)
24
25def display_raw_text(conf, text, color = 'NORMAL'):
26    Utils.pprint(color, text, sep = '')
27
28def display_line(conf, text, color = 'NORMAL'):
29    Utils.pprint(color, text, sep = os.linesep)
30
31def yesno(bool):
32    if bool:
33        return "yes"
34    else:
35        return "no"
36
37def set_options(opt):
38    opt.tool_options('compiler_cc')
39    opt.tool_options('compiler_cxx')
40    opt.tool_options('boost')
41    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')
42    opt.add_option('--enable-liblash', action='store_true', default=False, help='Build LASH compatibility library')
43
44def add_cflag(conf, flag):
45    conf.env.append_unique('CXXFLAGS', flag)
46    conf.env.append_unique('CCFLAGS', flag)
47
48def configure(conf):
49    conf.check_tool('compiler_cc')
50    conf.check_tool('compiler_cxx')
51    conf.check_tool('boost')
52
53    conf.check_cfg(
54        package = 'dbus-1',
55        atleast_version = '1.0.0',
56        mandatory = True,
57        errmsg = "not installed, see http://dbus.freedesktop.org/",
58        args = '--cflags --libs')
59
60    dbus_dir = conf.check_cfg(package='dbus-1', args='--variable=session_bus_services_dir', msg="Retrieving D-Bus services dir")
61    if not dbus_dir:
62        return
63
64    dbus_dir = dbus_dir.strip()
65    conf.env['DBUS_SERVICES_DIR_REAL'] = dbus_dir
66
67    if Options.options.enable_pkg_config_dbus_service_dir:
68        conf.env['DBUS_SERVICES_DIR'] = dbus_dir
69    else:
70        conf.env['DBUS_SERVICES_DIR'] = os.path.join(os.path.normpath(conf.env['PREFIX']), 'share', 'dbus-1', 'services')
71
72    conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
73
74    conf.check_cfg(
75        package = 'uuid',
76        mandatory = True,
77        errmsg = "not installed, see http://e2fsprogs.sourceforge.net/",
78        args = '--cflags --libs')
79
80    conf.check(header_name='expat.h', define_name="HAVE_EXPAT")
81
82    if conf.is_defined('HAVE_EXPAT'):
83        conf.env['LIB_EXPAT'] = ['expat']
84
85    build_gui = True
86
87    if build_gui and not conf.check_cfg(
88        package = 'glib-2.0',
89        mandatory = False,
90        errmsg = "not installed, see http://www.gtk.org/",
91        args = '--cflags --libs'):
92        build_gui = False
93
94    if build_gui and not conf.check_cfg(
95        package = 'dbus-glib-1',
96        mandatory = False,
97        errmsg = "not installed, see http://dbus.freedesktop.org/",
98        args = '--cflags --libs'):
99        build_gui = False
100
101    if build_gui and not conf.check_cfg(
102        package = 'gtk+-2.0',
103        mandatory = False,
104        errmsg = "not installed, see http://www.gtk.org/",
105        args = '--cflags --libs'):
106        build_gui = False
107
108    if build_gui and not conf.check_cfg(
109        package = 'libglade-2.0',
110        mandatory = False,
111        errmsg = "not installed, see http://ftp.gnome.org/pub/GNOME/sources/libglade/",
112        args = '--cflags --libs'):
113        build_gui = False
114
115    if build_gui and not conf.check_cfg(
116        package = 'flowcanvas',
117        mandatory = False,
118        atleast_version = '0.5.3',
119        errmsg = "not installed, see http://drobilla.net/software/flowcanvas/",
120        args = '--cflags --libs'):
121        build_gui = False
122
123    if build_gui:
124        # We need the boost headers package (e.g. libboost-dev)
125        # shared_ptr.hpp and weak_ptr.hpp
126        build_gui = conf.check_boost(errmsg="not found, see http://boost.org/")
127
128    conf.env['BUILD_GLADISH'] = build_gui
129
130    add_cflag(conf, '-g')
131    add_cflag(conf, '-Wall')
132    add_cflag(conf, '-Werror')
133
134    conf.define('DATA_DIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'share', APPNAME)))
135    conf.define('PACKAGE_VERSION', VERSION)
136    conf.define('DBUS_NAME_BASE', DBUS_NAME_BASE)
137    conf.define('DBUS_BASE_PATH', '/' + DBUS_NAME_BASE.replace('.', '/'))
138    conf.define('BASE_NAME', APPNAME)
139    conf.define('_GNU_SOURCE', 1)
140    conf.write_config_header('config.h')
141
142    display_msg(conf)
143
144    display_msg(conf, "==================")
145    version_msg = APPNAME + "-" + VERSION
146
147    if os.access('version.h', os.R_OK):
148        data = file('version.h').read()
149        m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
150        if m != None:
151            version_msg += " exported from " + m.group(1)
152    elif os.access('.git', os.R_OK):
153        version_msg += " git revision will checked and eventually updated during build"
154
155    display_msg(conf, version_msg)
156
157    display_msg(conf)
158    display_msg(conf, "Install prefix", conf.env['PREFIX'], 'CYAN')
159
160    display_msg(conf, 'Build gladish', yesno(conf.env['BUILD_GLADISH']))
161    display_msg(conf, 'Build liblash', yesno(Options.options.enable_liblash))
162
163    if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
164        display_msg(conf)
165        display_line(conf,     "WARNING: D-Bus session services directory as reported by pkg-config is", 'RED')
166        display_raw_text(conf, "WARNING:", 'RED')
167        display_line(conf,      conf.env['DBUS_SERVICES_DIR_REAL'], 'CYAN')
168        display_line(conf,     'WARNING: but service file will be installed in', 'RED')
169        display_raw_text(conf, "WARNING:", 'RED')
170        display_line(conf,      conf.env['DBUS_SERVICES_DIR'], 'CYAN')
171        display_line(conf,     'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus', 'RED')
172        display_line(conf,     'WARNING: You can override dbus service install directory', 'RED')
173        display_line(conf,     'WARNING: with --enable-pkg-config-dbus-service-dir option to this script', 'RED')
174
175    display_msg(conf)
176
177def build(bld):
178    daemon = bld.new_task_gen('cc', 'program')
179    daemon.target = 'ladishd'
180    daemon.includes = "build/default" # XXX config.h version.h and other generated files
181    daemon.uselib = 'DBUS-1 UUID EXPAT'
182    daemon.ver_header = 'version.h'
183    daemon.env.append_value("LINKFLAGS", ["-lutil", "-ldl", "-Wl,-E"])
184
185    daemon.source = [
186        'jack_proxy.c',
187        'graph_proxy.c',
188        'catdup.c',
189        ]
190
191    for source in [
192        'main.c',
193        'loader.c',
194        'log.c',
195        'dirhelpers.c',
196        'sigsegv.c',
197        'proctitle.c',
198        'appdb.c',
199        'procfs.c',
200        'control.c',
201        'studio.c',
202        'graph.c',
203        'client.c',
204        'port.c',
205        'jack_dispatch.c',
206        'dict.c',
207        'graph_dict.c',
208        'escape.c',
209        'studio_jack_conf.c',
210        'studio_load.c',
211        'studio_save.c',
212        'cmd_load_studio.c',
213        'cmd_new_studio.c',
214        'cmd_rename_studio.c',
215        'cmd_save_studio.c',
216        'cmd_start_studio.c',
217        'cmd_stop_studio.c',
218        'cmd_unload_studio.c',
219        'cqueue.c',
220        ]:
221        daemon.source.append(os.path.join("daemon", source))
222
223    for source in [
224        'signal.c',
225        'method.c',
226        'error.c',
227        'object_path.c',
228        'interface.c',
229        'helpers.c',
230        ]:
231        daemon.source.append(os.path.join("dbus", source))
232
233    daemon.source.append(os.path.join("common", "safety.c"))
234
235    # process name.arnaudov.nedko.ladish.service.in -> name.arnaudov.nedko.ladish.service
236    import misc
237    obj = bld.new_task_gen('subst')
238    obj.source = os.path.join('daemon', 'dbus.service.in')
239    obj.target = DBUS_NAME_BASE + '.service'
240    obj.dict = {'dbus_object_path': DBUS_NAME_BASE,
241                'daemon_bin_path': os.path.join(bld.env['PREFIX'], 'bin', daemon.target)}
242    obj.install_path = bld.env['DBUS_SERVICES_DIR'] + os.path.sep
243    obj.fun = misc.subst_func
244
245    if bld.env['BUILD_LIBLASH']:
246        liblash = bld.new_task_gen('cc', 'shlib')
247        liblash.includes = "build/default" # XXX config.h version.h and other generated files
248        liblash.uselib = 'DBUS-1'
249        liblash.target = 'lash'
250        liblash.vnum = "1.1.1"
251        liblash.defines = ['LOG_OUTPUT_STDOUT']
252        liblash.source = [os.path.join("lash_compat", "liblash", 'lash.c')]
253
254    # pkgpyexec_LTLIBRARIES = _lash.la
255    # INCLUDES = $(PYTHON_INCLUDES)
256    # _lash_la_LDFLAGS = -module -avoid-version ../liblash/liblash.la
257    # _lash_la_SOURCES = lash.c lash.h lash_wrap.c
258    # pkgpyexec_SCRIPTS = lash.py
259    # CLEANFILES = lash_wrap.c lash.py lash.pyc zynjacku.defs
260    # EXTRA_DIST = test.py lash.i lash.py
261    # lash_wrap.c lash.py: lash.i lash.h
262    #   swig -o lash_wrap.c -I$(top_srcdir) -python $(top_srcdir)/$(subdir)/lash.i
263
264    #####################################################
265    # gladish
266    if bld.env['BUILD_GLADISH']:
267        gladish = bld.new_task_gen('cxx', 'program')
268        gladish.features.append('cc')
269        gladish.target = 'gladish'
270        gladish.defines = ['LOG_OUTPUT_STDOUT']
271        gladish.includes = "build/default" # XXX config.h version.h and other generated files
272        gladish.uselib = 'DBUS-1 DBUS-GLIB-1 LIBGLADE-2.0 FLOWCANVAS'
273
274        gladish.source = [
275            'jack_proxy.c',
276            'graph_proxy.c',
277            'studio_proxy.c',
278            'catdup.c',
279            ]
280
281        for source in [
282            'main.c',
283            #'lash_client.cpp',
284            #'lash_proxy.cpp',
285            #'load_projects_dialog.cpp',
286            #'project.cpp',
287            'world_tree.c',
288            'graph_view.c',
289            #'project_properties.cpp',
290            #'session.cpp',
291            #'a2j_proxy.cpp',
292            'dbus_helpers.c',
293            'canvas.cpp',
294            'graph_canvas.c',
295            'glade.c',
296            'control_proxy.c',
297            'ask_dialog.c',
298            ]:
299            gladish.source.append(os.path.join("gui", source))
300
301        for source in [
302            'method.c',
303            'helpers.c',
304            ]:
305            gladish.source.append(os.path.join("dbus", source))
306
307        # Glade UI definitions (XML)
308        bld.install_files(bld.env['DATA_DIR'], 'gui/gui.glade')
309   
310    bld.install_files('${PREFIX}/bin', 'ladish_control', chmod=0755)
311
312    # 'Desktop' file (menu entry, icon, etc)
313    #obj = bld.create_obj('subst')
314    #obj.source = 'patchage.desktop.in'
315    #obj.target = 'patchage.desktop'
316    #obj.dict = {
317    #    'BINDIR'           : bld.env()['BINDIR'],
318    #    'APP_INSTALL_NAME' : bld.env()['APP_INSTALL_NAME'],
319    #    'APP_HUMAN_NAME'   : bld.env()['APP_HUMAN_NAME'],
320    #}
321    #install_as(os.path.normpath(bld.env()['DATADIR'] + 'applications/'), bld.env()['APP_INSTALL_NAME'] + '.desktop', 'build/default/patchage.desktop')
322
323    # Icons
324    #
325    # Installation layout (with /usr prefix)
326    # /usr/bin/patchage
327    # /usr/share/applications/patchage.desktop
328    # /usr/share/icons/hicolor/16x16/apps/patchage.png
329    # /usr/share/icons/hicolor/22x22/apps/patchage.png
330    # /usr/share/icons/hicolor/24x24/apps/patchage.png
331    # /usr/share/icons/hicolor/32x32/apps/patchage.png
332    # /usr/share/icons/hicolor/48x48/apps/patchage.png
333    # /usr/share/icons/hicolor/scalable/apps/patchage.svg
334    # /usr/share/patchage/patchage.glade
335    #
336    # icon cache is updated using:
337    # gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
338
339    # Dave disabled this, ask why before removing this
340    #install_as(os.path.normpath(bld.env()['PREFIX'] + '/share/icons/hicolor/scalable/apps/'), bld.env()['APP_INSTALL_NAME'] + '.svg', 'icons/scalable/patchage.svg')
341
342    #icon_sizes = ['16x16', '22x22', '24x24', '32x32', '48x48']
343    #for icon_size in icon_sizes:
344    #    install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png')
345
346def dist_hook():
347    shutil.copy('../build/default/version.h', "./")
348
349import commands
350from Constants import RUN_ME
351from TaskGen import feature, after
352import Task, Utils
353
354@feature('cc')
355@after('apply_core')
356def process_git(self):
357    if getattr(self, 'ver_header', None):
358        tsk = self.create_task('git_ver')
359        tsk.set_outputs(self.path.find_or_declare(self.ver_header))
360
361def git_ver(self):
362    header = self.outputs[0].abspath(self.env)
363    if os.access('../version.h', os.R_OK):
364        shutil.copy('../version.h', header)
365        data = file(header).read()
366        m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
367        if m != None:
368            self.ver = m.group(1)
369            Utils.pprint('BLUE', "tarball from git revision " + self.ver)
370        else:
371            self.ver = "tarball"
372        return
373
374    if os.access('../.git', os.R_OK):
375        self.ver = commands.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
376        if commands.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
377            self.ver += "-dirty"
378
379        Utils.pprint('BLUE', "git revision " + self.ver)
380    else:
381        self.ver = "unknown"
382
383    fi = open(header, 'w')
384    fi.write('#define GIT_VERSION "%s"\n' % self.ver)
385    fi.close()
386
387cls = Task.task_type_from_func('git_ver', vars=[], func=git_ver, color='BLUE', before='cc')
388
389def always(self):
390    return RUN_ME
391cls.runnable_status = always
392
393def post_run(self):
394    sg = Utils.h_list(self.ver)
395    node = self.outputs[0]
396    variant = node.variant(self.env)
397    self.generator.bld.node_sigs[variant][node.id] = sg
398cls.post_run = post_run
Note: See TracBrowser for help on using the browser.