diff options
-rw-r--r-- | ext.pc.template | 2 | ||||
-rwxr-xr-x | genreleases.py | 21 | ||||
-rw-r--r-- | genwscript.py | 77 | ||||
-rw-r--r-- | wscript | 182 | ||||
-rw-r--r-- | wscript.template | 1 |
5 files changed, 120 insertions, 163 deletions
diff --git a/ext.pc.template b/ext.pc.template index 93dad69..88ea421 100644 --- a/ext.pc.template +++ b/ext.pc.template @@ -1,6 +1,6 @@ includedir=@INCLUDEDIR@ -Name: @NAME@ +Name: LV2 @NAME@ Version: @VERSION@ Description: @DESCRIPTION@ Cflags: -I${includedir}/@INCLUDE_PATH@ diff --git a/genreleases.py b/genreleases.py deleted file mode 100755 index e69aaa9..0000000 --- a/genreleases.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import glob -import os - -import genwscript - -manifests = glob.glob('ext/*.lv2/manifest.ttl') -manifests += ['extensions/ui.lv2/manifest.ttl'] -manifests += ['extensions/units.lv2/manifest.ttl'] - -try: os.mkdir('build') -except: pass - -try: os.mkdir('build/spec') -except: pass - -for i in manifests: - genwscript.genwscript(i) - diff --git a/genwscript.py b/genwscript.py deleted file mode 100644 index 91ac980..0000000 --- a/genwscript.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import rdflib -import glob -import os -import shutil - -lv2 = rdflib.Namespace('http://lv2plug.in/ns/lv2core#') -rdf = rdflib.Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#') - -# 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('Bad LV2 extension data') - -def genwscript(manifest): - dir = os.path.dirname(manifest) - name = os.path.basename(dir).replace('.lv2', '') - - m = rdflib.ConjunctiveGraph() - m.parse(manifest, format='n3') - - try: - uri = query(m, None, rdf.type, lv2.Specification)[0] - minor = query(m, uri, lv2.minorVersion, None)[2] - micro = query(m, uri, lv2.microVersion, None)[2] - except: - return False - - if int(minor) != 0 and int(micro) % 2 == 0: - print('Packaging %s extension version %s.%s' % (name, minor, micro)) - - # Make directory and copy all files to it - distdir = 'build/spec/lv2-%s-%s.%s' % (name, minor, micro) - os.mkdir(distdir) - for f in glob.glob('%s/*.*' % dir): - shutil.copy(f, '%s/%s' % (distdir, os.path.basename(f))) - - 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' % distdir) - - # Generate pkgconfig file - subst_file('ext.pc.template', '%s/%s.pc.in' % (distdir, pkgconfig_name)) - - try: - os.remove('%s/waf' % distdir) - except: - pass - os.symlink('../../../waf', '%s/waf' % distdir) - - olddir = os.getcwd() - os.chdir(distdir + '/..') - os.system('tar --exclude=".*" -cjhf %s.tar.bz2 %s' % ( - os.path.basename(distdir), os.path.basename(distdir))) - os.chdir(olddir) - - return True @@ -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') diff --git a/wscript.template b/wscript.template index 725d0b5..7205abd 100644 --- a/wscript.template +++ b/wscript.template @@ -20,6 +20,7 @@ def options(opt): def configure(conf): autowaf.configure(conf) + autowaf.display_header('LV2 @NAME@ Configuration') conf.env['COPY_HEADERS'] = Options.options.copy_headers autowaf.display_msg(conf, "LV2 bundle directory", conf.env['LV2DIR']) |