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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
#!/usr/bin/env python
import datetime
import glob
import os
import rdflib
import shutil
import subprocess
import sys
from waflib.extras import autowaf as autowaf
import waflib.Logs as Logs
import waflib.Options as Options
import waflib.Scripting as Scripting
# Version of this package (even if built as a child)
LV2EXT_VERSION = datetime.date.isoformat(datetime.datetime.now()).replace('-', '.')
# Variables for 'waf dist'
APPNAME = 'lv2world'
VERSION = LV2EXT_VERSION
# Mandatory variables
top = '.'
out = 'build'
def options(opt):
opt.load('compiler_cc')
opt.load('compiler_cxx')
autowaf.set_options(opt)
opt.add_option('--test', action='store_true', default=False, dest='build_tests',
help="Build unit tests")
opt.add_option('--experimental', action='store_true', default=False,
dest='experimental',
help='Install unreleased experimental extensions')
for i in ['lv2/lv2plug.in/ns/lv2core']:
opt.recurse(i)
def get_subdirs(with_plugins=True):
subdirs = ['lv2/lv2plug.in/ns/lv2core/']
subdirs += glob.glob('lv2/lv2plug.in/ns/ext/*/')
subdirs += glob.glob('lv2/lv2plug.in/ns/extensions/*/')
if with_plugins:
subdirs += glob.glob('plugins/*/')
return subdirs
def configure(conf):
conf.load('compiler_cc')
conf.load('compiler_cxx')
autowaf.configure(conf)
autowaf.set_recursive()
conf.env.append_unique('CFLAGS', '-std=c99')
subdirs = get_subdirs()
for i in subdirs:
conf.recurse(i)
conf.env['LV2_SUBDIRS'] = subdirs
# Rule for copying a file to the build directory
def copy(task):
shutil.copy(task.inputs[0].abspath(), task.outputs[0].abspath())
def chop_lv2_prefix(s):
if s.startswith('lv2/lv2plug.in/'):
return s[len('lv2/lv2plug.in/'):]
return s
# Rule for calling lv2specgen on a spec bundle
def specgen(task):
import rdflib
doap = rdflib.Namespace('http://usefulinc.com/ns/doap#')
lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#')
owl = rdflib.Namespace('http://www.w3.org/2002/07/owl#')
rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
sys.path.append("./lv2specgen")
import lv2specgen
spec = task.inputs[0]
path = os.path.dirname(spec.srcpath())
indir = os.path.dirname(spec.abspath())
outdir = os.path.abspath(os.path.join(out, chop_lv2_prefix(path)))
bundle = str(outdir)
b = os.path.basename(outdir)
if not os.access(spec.abspath(), os.R_OK):
print('warning: extension %s has no %s.ttl file' % (root, root))
return
try:
model = rdflib.ConjunctiveGraph()
for i in glob.glob('%s/*.ttl' % bundle):
model.parse(i, format='n3')
except:
e = sys.exc_info()[1]
print('error parsing %s: %s' % (bundle, str(e)))
return
# Get extension URI
ext_node = model.value(None, rdf.type, lv2.Specification)
if not ext_node:
print('no extension found in %s' % bundle)
return
ext = str(ext_node)
# Get version
minor = 0
micro = 0
try:
minor = int(model.value(ext_node, lv2.minorVersion, None))
micro = int(model.value(ext_node, lv2.microVersion, None))
except Exception as e:
print("warning: %s: failed to find version for %s" % (bundle, ext))
# Get date
date = None
for r in model.triples([ext_node, doap.release, None]):
revision = model.value(r[2], doap.revision, None)
if revision == ("%d.%d" % (minor, micro)):
date = model.value(r[2], doap.created, None)
break
# Verify that this date is the latest
for r in model.triples([ext_node, doap.release, None]):
revision = model.value(r[2], doap.revision, None)
this_date = model.value(r[2], doap.created, None)
if this_date > date:
print("warning: revision %d.%d (%s) is not the latest release" % (
minor, micro, date))
break
# Get short description
shortdesc = model.value(ext_node, doap.shortdesc, None)
SPECGENDIR = 'lv2specgen'
STYLEPATH = 'build/aux/style.css'
TAGFILE = 'build/tags'
specdoc = lv2specgen.specgen(
spec.abspath(),
SPECGENDIR,
os.path.relpath('build/doc', bundle),
os.path.relpath(STYLEPATH, bundle),
os.path.abspath('build'),
'doc/html/',
TAGFILE,
instances=True)
lv2specgen.save(task.outputs[0].abspath(), specdoc)
# Name (comment is to act as a sort key)
row = '<tr><!-- %s --><td><a rel="rdfs:seeAlso" href="%s">%s</a></td>' % (
b, path[len('lv2/lv2plug.in/ns/'):], b)
# Description
if shortdesc:
row += '<td>' + str(shortdesc) + '</td>'
else:
row += '<td></td>'
# Version
version_str = '%s.%s' % (minor, micro)
if minor == 0 or (micro % 2 != 0):
row += '<td><span style="color: red">' + version_str + '</span></td>'
else:
row += '<td>' + version_str + '</td>'
# Date
row += '<td>%s</td>' % (str(date) if date else '')
# Status
deprecated = model.value(ext_node, owl.deprecated, None)
if minor == 0:
row += '<td><span class="error">Experimental</span></td>'
elif deprecated and str(deprecated[2]) != "false":
row += '<td><span class="warning">Deprecated</span></td>'
elif micro % 2 == 0:
row += '<td><span class="success">Stable</span></td>'
row += '</tr>'
index = open(os.path.join('build', 'index_rows', b), 'w')
index.write(row)
index.close()
def subst_file(template, output, dict):
i = open(template, 'r')
o = open(output, 'w')
for line in i:
for key in dict:
line = line.replace(key, dict[key])
o.write(line)
i.close()
o.close()
# Task to build extension index
def build_index(task):
global index_lines
rows = []
for f in task.inputs:
if not f.abspath().endswith('index.html.in'):
rowfile = open(f.abspath(), 'r')
rows += rowfile.readlines()
rowfile.close()
subst_file(task.inputs[0].abspath(), task.outputs[0].abspath(),
{ '@ROWS@': ''.join(rows),
'@TIME@': datetime.datetime.utcnow().strftime('%F %H:%M UTC') })
def build(bld):
for i in bld.env['LV2_SUBDIRS']:
bld.recurse(i)
if bld.env['DOCS']:
# Build Doxygen documentation (and tags file)
autowaf.build_dox(bld, 'LV2', VERSION, top, out)
# Copy stylesheet to build directory
obj = bld(rule = copy,
name = 'copy',
source = 'doc/style.css',
target = 'aux/style.css')
index_files = []
# Generate .htaccess files (and directory skeleton)
for i in bld.env['LV2_SUBDIRS']:
if i.startswith('lv2/lv2plug.in'):
# Copy spec files to build dir
for f in bld.path.ant_glob(i + '*.*'):
obj = bld(rule = copy,
name = 'copy',
source = f,
target = chop_lv2_prefix(f.srcpath()))
base = i[len('lv2/lv2plug.in'):]
name = os.path.basename(i[:len(i)-1])
index_file = os.path.join('index_rows', name)
index_files += [index_file]
# Generate .htaccess file
obj = bld(features = 'subst',
source = 'doc/htaccess.in',
target = os.path.join(base, '.htaccess'),
install_path = None,
NAME = name,
BASE = base)
bld.add_group()
# Call lv2specgen to generate spec docs
obj = bld(rule = specgen,
name = 'specgen',
source = os.path.join(i, name + '.ttl'),
target = ['%s%s.html' % (chop_lv2_prefix(i), name),
index_file])
# Build extension index
obj = bld(rule = build_index,
name = 'index',
source = ['lv2/lv2plug.in/ns/index.html.in'] + index_files,
target = 'ns/index.html')
def release(ctx):
lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#')
rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
doap = rdflib.Namespace('http://usefulinc.com/ns/doap#')
try:
shutil.rmtree('build/spec')
except:
pass
os.makedirs('build/spec')
manifests = glob.glob('lv2/lv2plug.in/ns/lv2core/manifest.ttl')
manifests += glob.glob('lv2/lv2plug.in/ns/*/*/manifest.ttl')
for manifest in manifests:
dir = os.path.dirname(manifest)
name = os.path.basename(dir).replace('.lv2', '')
m = rdflib.ConjunctiveGraph()
m.parse(manifest, format='n3')
uri = minor = micro = None
try:
spec = m.value(None, rdf.type, lv2.Specification)
uri = str(spec)
minor = int(m.value(spec, lv2.minorVersion, None))
micro = int(m.value(spec, lv2.microVersion, None))
except:
e = sys.exc_info()[1]
Logs.error('error: %s: %s' % (manifest, str(e)))
continue
if minor != 0 and micro % 2 == 0:
autowaf.display_header('\nBuilding %s Release\n' % dir)
try:
subprocess.call(
['./waf', 'distclean', 'configure', 'build', 'distcheck'],
cwd=dir)
for i in glob.glob(dir + '/*.tar.bz2'):
shutil.move(i, 'build/spec')
except:
Logs.error('Error building %s release' % (name, e))
subprocess.call(['./waf', 'distclean'], cwd=dir)
def news(ctx):
ctx.recurse(get_subdirs(False))
def dist(ctx):
ctx.recurse(get_subdirs(False), name='pre_dist')
ctx.archive()
ctx.recurse(get_subdirs(False), name='post_dist')
def lint(ctx):
for i in (['lv2/lv2plug.in/ns/lv2core/lv2.h']
+ glob.glob('lv2/lv2plug.in/ns/ext/*/*.h')
+ glob.glob('lv2/lv2plug.in/ns/extensions/*/*.h')):
subprocess.call('cpplint.py --filter=+whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-whitespace/blank_line,-build/header_guard,-readability/casting,-readability/todo,-build/include ' + i, shell=True)
|