forked from Lokaltog/candybar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
94 lines (72 loc) · 4.42 KB
/
Copy pathwscript
File metadata and controls
94 lines (72 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
import subprocess
import os
import time
from waflib import Utils
PACKAGE = 'wkline'
LIBDIR = '${PREFIX}/lib/wkline'
def get_version():
'''Attempt to fetch the current version number from git.'''
version = 'beta'
if not os.path.exists('.git'):
return version + '-unknown'
version += '-git-' + subprocess.Popen('git rev-list --count HEAD', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8').strip()
version += '.' + subprocess.Popen('git rev-parse --short HEAD', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8').strip()
return version
def options(opt):
opt.load('compiler_c')
opt.add_option('--confdir', dest='confdir', default='/etc/xdg/wkline', help='directory to store wkline global configuration files [default: %default]')
opt.add_option('--libdir', dest='libdir', default=LIBDIR, help='shared library search path override (useful for development) [default: %default]')
opt.add_option('--debug', dest='debug', default=False, action='store_true', help='build debug version')
def configure(ctx):
ctx.load('compiler_c')
ctx.check_cfg(atleast_pkgconfig_version='0.0.0')
# compiler options
if ctx.options.debug:
ctx.env.append_unique('CFLAGS', ['-g3', '-O0', '-Wall', '-Werror'])
ctx.define('DEBUG', 1)
else:
ctx.env.append_unique('CFLAGS', ['-O3', '-Wall', '-Werror'])
ctx.env.append_value('INCLUDES', ['./src'])
# defines
ctx.define('PACKAGE', PACKAGE)
ctx.define('CONFDIR', ctx.options.confdir)
ctx.define('LIBDIR', Utils.subst_vars(ctx.options.libdir, ctx.env))
# deps
ctx.check_cfg(package='gtk+-3.0', uselib_store='GTK', args=['--cflags', '--libs'])
ctx.check_cfg(package='glib-2.0 gmodule-2.0', uselib_store='GLIB', args=['--cflags', '--libs'])
ctx.check_cfg(package='webkitgtk-3.0', uselib_store='WEBKITGTK', args=['--cflags', '--libs'])
ctx.check_cfg(package='jansson', uselib_store='JANSSON', args=['--cflags', '--libs'])
# optdeps
ctx.check_cfg(package='alsa', uselib_store='ALSA', args=['--cflags', '--libs'], mandatory=False)
ctx.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'], mandatory=False)
ctx.check_cfg(package='dbus-1 dbus-glib-1', uselib_store='DBUS', args=['--cflags', '--libs'], mandatory=False)
ctx.check_cfg(package='libmpdclient', uselib_store='LIBMPDCLIENT', args=['--cflags', '--libs'], mandatory=False)
ctx.check_cfg(package='xcb-util xcb-ewmh xcb-icccm', uselib_store='XCB', args=['--cflags', '--libs'], mandatory=False)
def build(bld):
basedeps = ['GTK', 'GLIB', 'WEBKITGTK', 'JANSSON']
# add build version/time defines
wkline_defines = [
'VERSION="{0}"'.format(get_version()),
'BUILD_TIME="{0}"'.format(time.strftime('%c')),
]
bld.objects(source=bld.path.ant_glob('src/util/(log|config|copy_prop).c'), target='baseutils', use=basedeps)
bld.objects(source='src/widgets.c', target='widgets', use=basedeps)
# widgets
if bld.is_defined('HAVE_ALSA'):
bld.shlib(source='src/widgets/volume.c', target='widget_volume', use=basedeps + ['ALSA'], install_path=LIBDIR)
if bld.is_defined('HAVE_CURL'):
bld.objects(source='src/util/curl.c', target='util_curl', use=basedeps + ['CURL'], cflags=['-fPIC'])
bld.shlib(source='src/widgets/external_ip.c', target='widget_external_ip', use=basedeps + ['CURL', 'util_curl'], install_path=LIBDIR)
bld.shlib(source='src/widgets/weather.c', target='widget_weather', use=basedeps + ['CURL', 'util_curl'], install_path=LIBDIR)
if bld.is_defined('HAVE_DBUS'):
bld.objects(source='src/util/dbus_helpers.c', target='util_dbus_helpers', use=basedeps + ['DBUS'], cflags=['-fPIC'])
bld.shlib(source='src/widgets/battery.c', target='widget_battery', use=basedeps + ['DBUS', 'util_dbus_helpers'], install_path=LIBDIR)
bld.shlib(source='src/widgets/notifications.c', target='widget_notifications', use=basedeps + ['DBUS', 'util_dbus_helpers'], install_path=LIBDIR)
if bld.is_defined('HAVE_LIBMPDCLIENT'):
bld.shlib(source='src/widgets/now_playing_mpd.c', target='widget_now_playing_mpd', use=basedeps + ['LIBMPDCLIENT'], install_path=LIBDIR)
if bld.is_defined('HAVE_XCB'):
bld.shlib(source='src/widgets/desktops.c', target='widget_desktops', use=basedeps + ['XCB'], install_path=LIBDIR)
bld.shlib(source='src/widgets/window_title.c', target='widget_window_title', use=basedeps + ['util_copy_prop', 'XCB'], install_path=LIBDIR)
bld.program(source='src/wkline.c', target=PACKAGE, use=['baseutils', 'widgets'] + basedeps, defines=wkline_defines)
bld.install_files(bld.options.confdir, ['config.json'])