waf: installation of dbus service file

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2474 0c269be4-1314-0410-8aa9-9f06e86f4224
This commit is contained in:
nedko 2008-06-07 10:36:31 +00:00
parent fab1fbf9d6
commit fdf5219ad4
2 changed files with 77 additions and 4 deletions

View File

@ -1,8 +1,22 @@
#! /usr/bin/env python
# encoding: utf-8
import Params
import os.path
import re # subst_func
def set_options(opt):
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')
def configure(conf):
conf.check_pkg('dbus-1')
conf.check_pkg('dbus-1', pkgvars=['session_bus_services_dir'])
if Params.g_options.enable_pkg_config_dbus_service_dir:
conf.env['DBUS_SERVICES_DIR'] = conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
else:
conf.env['DBUS_SERVICES_DIR'] = os.path.normpath(conf.env['PREFIX'] + '/share/dbus-1/services')
conf.check_tool('misc')
e = conf.create_header_configurator()
e.name = 'expat.h'
@ -14,6 +28,39 @@ def configure(conf):
conf.env['BUILD_JACKDBUS'] = conf.is_defined('HAVE_EXPAT') and conf.is_defined('HAVE_DBUS_1')
# by default waf subst tool uses @VAR@ while scons legacy is ${VAR}
# so we use same template as scons for now
def subst_func(tsk):
"Substitutes variables in a .in file"
print "subsituting!"
m4_re = re.compile('\$\{(\w+)\}', re.M)
env = tsk.env()
infile = tsk.m_inputs[0].abspath(env)
outfile = tsk.m_outputs[0].abspath(env)
file = open(infile, 'r')
code = file.read()
file.close()
s = m4_re.sub(r'%(\1)s', code)
dict = tsk.dict
if not dict:
names = m4_re.findall(code)
for i in names:
if env[i] and type(env[i]) is types.ListType :
dict[i] = " ".join(env[i])
else: dict[i] = env[i]
file = open(outfile, 'w')
file.write(s % dict)
file.close()
return 0
def build(bld):
if bld.env()["BUILD_JACKDBUS"] != True:
return
@ -38,3 +85,12 @@ def build(bld):
obj.uselib = 'PTHREAD DL RT DBUS-1 EXPAT'
obj.uselib_local = 'serverlib'
obj.target = 'jackdbus'
# process org.jackaudio.service.in -> org.jackaudio.service
obj = bld.create_obj('subst')
obj.source = 'org.jackaudio.service.in'
obj.target = 'org.jackaudio.service'
obj.dict = {'BINDIR': bld.env()['PREFIX'] + '/bin'}
obj.inst_var = bld.env()['DBUS_SERVICES_DIR']
obj.inst_dir = '/'
obj.fun = subst_func # @VAR@ -> ${VAR}

23
wscript
View File

@ -1,9 +1,9 @@
#! /usr/bin/env python
# encoding: utf-8
import os
import Params
import commands
import Params
from Configure import g_maxlen
#g_maxlen = 40
@ -43,6 +43,7 @@ def set_options(opt):
opt.tool_options('compiler_cc')
opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
opt.sub_options('linux/dbus')
def configure(conf):
conf.check_tool('compiler_cxx')
@ -58,8 +59,8 @@ def configure(conf):
conf.env['LIB_RT'] = ['rt']
conf.env['JACK_API_VERSION'] = JACK_API_VERSION
conf.define('ADDON_DIR', conf.env['PREFIX'] + '/lib/jack')
conf.define('JACK_LOCATION', conf.env['PREFIX'] + '/bin')
conf.define('ADDON_DIR', os.path.normpath(conf.env['PREFIX'] + '/lib/jack'))
conf.define('JACK_LOCATION', os.path.normpath(conf.env['PREFIX'] + '/bin'))
conf.define('SOCKET_RPC_FIFO_SEMA', 1)
conf.define('__SMP__', 1)
conf.define('USE_POSIX_SHM', 1)
@ -78,6 +79,22 @@ def configure(conf):
display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
if conf.env['BUILD_JACKDBUS'] == True:
display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
#display_msg('Settings persistence', xxx)
if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
print
print Params.g_colors['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
print Params.g_colors['RED'] + "WARNING:",
print Params.g_colors['CYAN'] + conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
print Params.g_colors['RED'] + 'WARNING: but service file will be installed in'
print Params.g_colors['RED'] + "WARNING:",
print Params.g_colors['CYAN'] + conf.env['DBUS_SERVICES_DIR']
print Params.g_colors['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
print 'WARNING: You can override dbus service install directory'
print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
print Params.g_colors['NORMAL'],
print
def build(bld):