-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwscript
163 lines (148 loc) · 4.39 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from waflib.Build import BuildContext
from waflib import Utils, Options
import os.path
import subprocess
APPNAME='libwebsite'
if os.path.exists('.git'):
VERSION = subprocess.Popen(['git', 'describe'], stdout=subprocess.PIPE)\
.communicate()[0].decode('ascii').strip().lstrip('v').replace('-', '_')
else:
VERSION='0.2.23'
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_c')
opt.add_option('--build-shared', action="store_true", dest="build_shared",
help="Build shared library instead of static", default=False)
def configure(ctx):
ctx.check_tool('compiler_c')
ctx.env.BUILD_SHARED = Options.options.build_shared
def build_only(bld):
bld(
features = ['c', ('cshlib'
if bld.env.BUILD_SHARED else 'cstlib')],
source = [
'src/core.c',
'src/search.c',
],
target = 'website',
includes = ['src', 'include'],
cflags = ['-std=c99'],
)
def build(bld):
build_only(bld)
if Options.options.build_shared:
bld.install_files('${PREFIX}/lib', 'libwebsite.so')
else:
bld.install_files('${PREFIX}/lib', 'libwebsite.a')
bld.install_files('${PREFIX}/include', 'include/website.h')
def build_tests(bld):
build(bld)
bld.add_group()
lib = [
'website',
'ev',
'crypto',
'm',
'cunit',
]
bld(
features = ['c', 'cprogram'],
source = [
'test/simple.c',
],
target = 'simple',
includes = ['src', 'include'],
cflags = ['-std=gnu99'],
libpath = ['.'],
lib = lib,
)
bld(
features = ['c', 'cprogram'],
source = [
'test/detailed.c',
],
target = 'detailed',
includes = ['src', 'include'],
defines = [],
cflags = ['-std=c99'],
libpath = ['.'],
lib = lib,
)
bld(
features = ['c', 'cprogram'],
source = [
'test/routing.c',
],
target = 'routing',
includes = ['src', 'include'],
cflags = ['-std=c99'],
libpath = ['.'],
lib = lib,
)
bld(
features = ['c', 'cprogram'],
source = [
'test/websocket.c',
],
target = 'websocket',
includes = ['src', 'include'],
cflags = ['-std=c99'],
libpath = ['.'],
lib = lib,
)
bld(
features = ['c', 'cprogram'],
source = [
'test/runtests.c',
],
target = 'runtests',
includes = ['src', 'include'],
cflags = ['-std=c99'],
libpath = ['.'],
lib = lib,
)
bld.add_group()
bld(rule='./runtests', always=True)
bld.add_group()
bld(rule='cd ${SRC[0].parent.abspath()};'
' SIMPLE_BIN=${SRC[1].abspath()}'
' WEBSOCK_BIN=${SRC[2].abspath()}'
' DETAILED_BIN=${SRC[3].abspath()}'
' python ${SRC[0].abspath()} -v',
source=['test/httptest.py', 'simple', 'websocket', 'detailed'],
always=True)
class test(BuildContext):
cmd = 'test'
fun = 'build_tests'
variant = 'test'
def dist(ctx):
ctx.excl = ['.waf*', '*.tar.bz2', '*.zip', 'build',
'tmp', '*~',
'.git*', '.lock*', '**/*.pyc']
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'