aboutsummaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-19 00:43:20 +0000
committerDavid Robillard <d@drobilla.net>2011-10-19 00:43:20 +0000
commit018877914225343b10edfa1f80628cc54242cb82 (patch)
tree474452f34115c4b3fd8fc23bb8b76edd8268a6e1 /wscript
parent8acafed02d7f2645aacc5a6947c2caaed6a45977 (diff)
downloadlv2-018877914225343b10edfa1f80628cc54242cb82.tar.xz
Move extension build script generation stuff into wscript configure phase
Diffstat (limited to 'wscript')
-rw-r--r--wscript182
1 files changed, 118 insertions, 64 deletions
diff --git a/wscript b/wscript
index cdb613f..f927da9 100644
--- a/wscript
+++ b/wscript
@@ -1,11 +1,14 @@
#!/usr/bin/env python
import datetime
+import glob
import os
+import rdflib
+import shutil
import subprocess
-import glob
from waflib.extras import autowaf as autowaf
import waflib.Logs as Logs
+import waflib.Options as Options
# Version of this package (even if built as a child)
LV2EXT_VERSION = datetime.date.isoformat(datetime.datetime.now()).replace('-', '.')
@@ -22,79 +25,130 @@ def options(opt):
opt.load('compiler_cc')
opt.load('compiler_cxx')
autowaf.set_options(opt)
- for i in ['core.lv2']: #, 'plugins/eg-amp.lv2', 'plugins/eg-sampler.lv2']:
+ opt.add_option('--experimental', action='store_true', default=False,
+ dest='experimental',
+ help='Install unreleased experimental extensions')
+ for i in ['core.lv2']:
opt.recurse(i)
+lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#')
+rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
+
+def genwscript(manifest, experimental):
+ dir = os.path.dirname(manifest)
+ name = os.path.basename(dir).replace('.lv2', '')
+
+ m = rdflib.ConjunctiveGraph()
+ m.parse(manifest, format='n3')
+
+ # Get the first match for a triple pattern, or throw if no matches
+ def query(model, s, p, o):
+ for i in model.triples([s, p, o]):
+ return i
+ raise Exception('Insufficient data for %s' % manifest)
+
+ try:
+ uri = query(m, None, rdf.type, lv2.Specification)[0]
+ except:
+ print('Skipping: %s' % name)
+ return False
+
+ minor = micro = '0'
+ try:
+ minor = query(m, uri, lv2.minorVersion, None)[2]
+ micro = query(m, uri, lv2.microVersion, None)[2]
+ except:
+ if not experimental:
+ print('Skipping: %s' % name)
+ return False
+
+ if experimental or (int(minor) != 0 and int(micro) % 2 == 0):
+ print('Generating: %s %s.%s' % (name, minor, micro))
+
+ pkgconfig_name = str(uri).replace('http://', 'lv2-').replace('/', '-')
+
+ def subst_file(source_path, target_path):
+ source = open(source_path, 'r')
+ target = open(target_path, 'w')
+ for l in source:
+ target.write(l.replace(
+ '@DESCRIPTION@', 'LV2 "' + name + '" extension').replace(
+ '@INCLUDE_PATH@', str(uri).replace('http://', 'lv2/')).replace(
+ '@MICRO@', micro).replace(
+ '@MINOR@', minor).replace(
+ '@NAME@', name).replace(
+ '@PKGCONFIG_NAME@', pkgconfig_name).replace(
+ '@URI@', str(uri)).replace(
+ '@VERSION@', '%s.%s' % (minor, micro)))
+ source.close()
+ target.close()
+
+ # Generate wscript
+ subst_file('wscript.template', '%s/wscript' % dir)
+
+ # Generate pkgconfig file
+ subst_file('ext.pc.template', '%s/%s.pc.in' % (dir, pkgconfig_name))
+
+ try:
+ os.remove('%s/waf' % dir)
+ except:
+ pass
+
+ #os.symlink('../../waf', '%s/waf' % dir)
+ shutil.copy('waf', '%s/waf' % dir)
+
+ return True
+ else:
+ return False
+
def configure(conf):
+ subdirs = ['core.lv2']
+
+ manifests = glob.glob('ext/*.lv2/manifest.ttl') + [
+ 'extensions/ui.lv2/manifest.ttl',
+ 'extensions/units.lv2/manifest.ttl'
+ ]
+
+ manifests.sort()
+
+ print('')
+ autowaf.display_header("Generating build files")
+ for manifest in manifests:
+ if genwscript(manifest, Options.options.experimental):
+ subdirs += [ os.path.dirname(manifest) ]
+ print('')
+
conf.load('compiler_cc')
conf.load('compiler_cxx')
- autowaf.set_recursive()
+
autowaf.configure(conf)
- for i in ['core.lv2']: #, 'plugins/eg-amp.lv2', 'plugins/eg-sampler.lv2']:
+ conf.env.append_unique('CFLAGS', '-std=c99')
+
+ for i in subdirs:
conf.recurse(i)
- conf.env.append_value('CFLAGS', '-std=c99')
- pat = conf.env['cshlib_PATTERN']
- ext = pat[pat.rfind('.'):]
- conf.env.append_value('cshlib_EXTENSION', ext)
- conf.write_config_header('lv2-config.h', remove=False)
-
-def build_extension(bld, name, dir):
- # Bundle
- data_file = '%s/%s.lv2/%s.ttl' % (dir, name, name)
- manifest_file = '%s/%s.lv2/manifest.ttl' % (dir, name)
- header_files = '%s/%s.lv2/*.h' % (dir, name)
- bld.install_files('${LV2DIR}/' + name + '.lv2', bld.path.ant_glob(data_file))
- bld.install_files('${LV2DIR}/' + name + '.lv2', bld.path.ant_glob(manifest_file))
- bld.install_files('${LV2DIR}/' + name + '.lv2', bld.path.ant_glob(header_files))
-
- # URI-style include
- include_dir = bld.env['INCLUDEDIR'] + '/lv2/lv2plug.in/ns/%s' % dir
- bundle_dir = os.path.join(bld.env['LV2DIR'], name + '.lv2')
- bld.symlink_as(os.path.join(include_dir, name),
- os.path.relpath(bundle_dir, include_dir))
+
+ conf.env['LV2_SUBDIRS'] = subdirs
def build(bld):
- autowaf.set_recursive()
- bld.recurse('core.lv2')
- ext = '''
- atom
- contexts
- cv-port
- data-access
- dyn-manifest
- event
- files
- host-info
- instance-access
- midi
- osc
- parameter
- persist
- port-groups
- presets
- pui
- pui-event
- pui-gtk
- reference
- resize-port
- string-port
- uri-map
- uri-unmap
- urid
- '''
- for e in ext.split():
- build_extension(bld, e, 'ext')
-
- extensions = '''
- ui
- units
- '''
- for e in extensions.split():
- build_extension(bld, e, 'extensions')
-
- #for i in ['plugins/eg-amp.lv2', 'plugins/eg-sampler.lv2']:
- # bld.recurse(i)
+ for i in bld.env['LV2_SUBDIRS']:
+ bld.recurse(i)
+def release(ctx):
+ for i in ['ext/data-access.lv2',
+ 'ext/midi.lv2',
+ 'ext/event.lv2',
+ 'ext/uri-map.lv2',
+ 'ext/instance-access.lv2',
+ 'extensions/ui.lv2',
+ 'extensions/units.lv2',
+ 'core.lv2']:
+ try:
+ subprocess.call(
+ ['./waf', 'distclean', 'configure', 'build', 'distcheck'],
+ cwd=i)
+ except:
+ print('Error building %s release' % i)
+
def lint(ctx):
for i in (['core.lv2/lv2.h']
+ glob.glob('ext/*/*.h')