-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwscript
More file actions
213 lines (193 loc) · 6.52 KB
/
Copy pathwscript
File metadata and controls
213 lines (193 loc) · 6.52 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from waflib.Build import BuildContext
from waflib import Utils, Options
import os.path
import subprocess
APPNAME='coyaml'
if os.path.exists('.git'):
VERSION=subprocess.getoutput('git describe').lstrip('v').replace('-', '_')
else:
VERSION='0.3.14'
top = '.'
out = 'build'
def options(opt):
import distutils.sysconfig
opt.load('compiler_c python')
opt.add_option('--build-shared', action="store_true", dest="build_shared",
help="Build shared library instead of static")
def configure(conf):
conf.load('compiler_c python')
conf.check_python_version((3,0,0))
conf.env.BUILD_SHARED = Options.options.build_shared
def build_only(bld):
bld(
features = ['c', ('cshlib'
if bld.env.BUILD_SHARED else 'cstlib')],
source = [
'src/parser.c',
'src/commandline.c',
'src/helpers.c',
'src/vars.c',
'src/types.c',
'src/emitter.c',
'src/copy.c',
'src/eval.c',
],
target = 'coyaml',
includes = ['include', 'src'],
defines = ['COYAML_VERSION="%s"' % VERSION],
cflags = ['-std=c99', '-Wall'],
lib = ['yaml'],
)
def build(bld):
build_only(bld)
if bld.env.BUILD_SHARED:
bld.install_files('${PREFIX}/lib', 'libcoyaml.so')
else:
bld.install_files('${PREFIX}/lib', 'libcoyaml.a')
bld.install_files('${PREFIX}/include', [
'include/coyaml_hdr.h',
'include/coyaml_src.h',
])
bld(features='py',
source=bld.path.ant_glob('coyaml/*.py'),
install_path='${PYTHONDIR}/coyaml')
bld.install_files('${PREFIX}/bin', 'scripts/coyaml', chmod=0o755)
def build_tests(bld):
import coyaml.waf
build(bld)
bld.add_group()
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'test/tinytest.c',
'test/tinyconfig.yaml',
],
target = 'tinytest',
includes = ['include', 'test'],
libpath = ['.'],
cflags = ['-std=c99', '-Wall'],
lib = ['coyaml', 'yaml'],
)
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'test/vartest.c',
'test/vars.yaml',
],
target = 'vartest',
includes = ['include', 'test'],
libpath = ['.'],
cflags = ['-std=c99', '-Wall'],
lib = ['coyaml', 'yaml'],
)
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'test/compr.c',
'test/comprehensive.yaml',
],
target = 'compr',
includes = ['include', 'test'],
libpath = ['.'],
cflags = ['-std=c99', '-Wall'],
lib = ['coyaml', 'yaml'],
config_name = 'cfg',
)
bld(
features = ['c', 'cprogram', 'coyaml'],
source = [
'test/recursive.c',
'test/recconfig.yaml',
],
target = 'recursive',
includes = ['include', 'test'],
libpath = ['.'],
cflags = ['-std=c99', '-Wall'],
lib = ['coyaml', 'yaml'],
config_name = 'cfg',
)
bld.add_group()
diff = 'diff -u ${SRC[0].abspath()} ${SRC[1]}'
bld(rule='./${SRC[0]} -c ${SRC[1].abspath()} -v -C -P > ${TGT[0]}',
source=['tinytest', 'examples/tinyexample.yaml'],
target='tinyexample.out',
always=True)
bld(rule=diff,
source=['examples/tinyexample.out', 'tinyexample.out'],
always=True)
bld(rule='./${SRC[0]} -c ${SRC[1].abspath()} -C -P > ${TGT[0]}',
source=['vartest', 'examples/varexample.yaml'],
target='varexample.out',
always=True)
bld(rule=diff,
source=['examples/varexample.out', 'varexample.out'],
always=True)
bld(rule='./${SRC[0]} -c ${SRC[1].abspath()} --config-var clivar=CLI -C -P > ${TGT[0]}',
source=['compr', 'examples/compexample.yaml'],
target='compexample.out.ws',
always=True)
bld(rule="sed -r 's/\s+$//g' ${SRC[0]} > ${TGT[0]}",
source='compexample.out.ws',
target='compexample.out',
always=True)
bld(rule=diff,
source=['examples/compexample.out', 'compexample.out'],
always=True)
bld(rule='COMPR_LOGLEVEL=7 ./${SRC[0]} -c ${SRC[1].abspath()} --config-var clivar=CLI -C -PP > ${TGT[0]}',
source=['compr', 'examples/compexample.yaml'],
target='compexample.out.ws1',
always=True)
bld(rule="sed -r 's/\s+$//g' ${SRC[0]} > ${TGT[0]}",
source='compexample.out.ws1',
target='compexample.out1',
always=True)
bld(rule=diff,
source=['examples/compexample_comments.out', 'compexample.out1'],
always=True)
bld(rule='./${SRC[0]} -c ${SRC[1].abspath()} -C -P > ${TGT[0]}',
source=['recursive', 'examples/recexample.yaml'],
target='recexample.out',
always=True)
bld(rule=diff,
source=['examples/recexample.out', 'recexample.out'],
always=True)
bld(rule='COMPR_CFG=${SRC[1].abspath()} ./${SRC[0]} -Dclivar=CLI > ${TGT[0]}',
source=['compr', 'examples/compexample.yaml'],
target='compr.out',
always=True)
bld(rule=diff,
source=['examples/compr.out', 'compr.out'],
always=True)
class test(BuildContext):
cmd = 'test'
fun = 'build_tests'
variant = 'test'
def dist(ctx):
ctx.excl = ['.waf*', '*.tar.bz2', '*.zip', 'build',
'.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(),
}))
class makepkg(BuildContext):
cmd = 'archpkg'
fun = 'archpkg'
variant = 'archpkg'
def archpkg(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)
def bumpver(ctx):
ctx.exec_command(r"sed -ri.bak 's/(X-Version[^0-9]*)[0-9.]+/\1"+VERSION+"/'"
" examples/compr.out examples/compexample.out")