-
Notifications
You must be signed in to change notification settings - Fork 27
/
wscript
167 lines (142 loc) · 4.32 KB
/
wscript
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from waflib import Utils, Options
from waflib.Build import BuildContext
from waflib.Scripting import Dist
import subprocess
import os.path
APPNAME='zerogw'
if os.path.exists('.git'):
VERSION=subprocess.getoutput('git describe').lstrip('v').replace('-', '_')
else:
VERSION='0.6.2'
top = '.'
out = 'build'
def options(opt):
opt.recurse('coyaml')
opt.recurse('libwebsite')
opt.load('compiler_c')
def configure(conf):
conf.recurse('coyaml')
conf.recurse('libwebsite')
conf.load('compiler_c')
def build(bld):
bld.recurse('coyaml', name='build_only')
bld.recurse('libwebsite', name='build_only')
bld.add_group()
import sys
sys.path.append("coyaml")
import coyaml.waf
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'src/config.yaml',
'src/main.c',
'src/log.c',
'src/websocket.c',
'src/sieve.c',
'src/zutils.c',
'src/http.c',
'src/resolve.c',
'src/uidgen.c',
'src/request.c',
'src/polling.c',
'src/disk.c',
'src/commands.c',
'src/pool.c',
'src/msgqueue.c',
],
target = 'zerogw',
includes = ['src', 'coyaml/include', 'libwebsite/include'],
libpath = [
bld.bldnode.abspath() + '/coyaml',
bld.bldnode.abspath() + '/libwebsite',
],
defines = [
'LOG_STRIP_PATH="../src/"',
],
cflags = ['-std=gnu99'],
lib = [
'coyaml',
'yaml',
'zmq',
'ev',
'website',
'crypto',
'pthread',
'm',
],
)
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'src/config.yaml',
'src/zerogwctl.c',
],
target = 'zerogwctl',
includes = ['src', 'coyaml/include', 'libwebsite/include'],
libpath = [
bld.bldnode.abspath() + '/coyaml',
bld.bldnode.abspath() + '/libwebsite',
],
cflags = ['-std=gnu99'],
lib = ['coyaml', 'yaml', 'zmq'],
)
bld(
features = ['c', 'cprogram'],
source = 'src/openport.c',
target = 'openport',
)
if bld.env['PREFIX'] == '/usr':
bld.install_files('/etc', ['examples/zerogw.yaml'])
bld.install_as('/etc/bash_completion.d/zerogwctl',
'completion/bash')
else:
bld.install_files('${PREFIX}/etc', ['examples/zerogw.yaml'])
bld.install_as('${PREFIX}/etc/bash_completion.d/zerogwctl',
'completion/bash')
bld.install_as('${PREFIX}/share/zsh/site-functions/_zerogwctl',
'completion/zsh')
def dist(ctx):
ctx.excl = [
'doc/_build/**',
'.waf*', '*.tar.bz2', '*.zip', 'build',
'.git*', '.lock*', '**/*.pyc', '**/*.swp', '**/*~',
'tmp/**',
'examples/tabbedchat/run',
]
ctx.algo = 'tar.bz2'
def make_pkgbuild(task):
import hashlib
task.outputs[0].write(Utils.subst_vars(task.inputs[0].read(), {
'VERSION': VERSION,
'DIST_MD5': hashlib.md5(task.inputs[1].read('rb')).hexdigest(),
}))
def archpkg(ctx):
from waflib import Options
Options.commands = ['dist', 'makepkg'] + Options.commands
def build_package(bld):
distfile = APPNAME + '-' + VERSION + '.tar.bz2'
bld(rule=make_pkgbuild,
source=['PKGBUILD.tpl', distfile, 'wscript'],
target='PKGBUILD')
bld(rule='cp ${SRC} ${TGT}', source=distfile, target='.')
bld.add_group()
bld(rule='makepkg -f', source=distfile)
bld.add_group()
bld(rule='makepkg -f --source', source=distfile)
class makepkg(BuildContext):
cmd = 'makepkg'
fun = 'build_package'
variant = 'archpkg'
def build_tests(bld):
build(bld)
bld.add_group()
bld(rule='cd ${SRC[0].parent.parent.abspath()};'
'export BUILDDIR=${SRC[1].parent.abspath()};'
'python -m unittest discover -s test -p "*.py" -t . -v',
source=['test/simple.py', 'zerogw'],
always=True)
class test(BuildContext):
cmd = 'test'
fun = 'build_tests'