aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ext.pc.template6
-rw-r--r--genwscript.py64
-rw-r--r--wscript.template9
3 files changed, 56 insertions, 23 deletions
diff --git a/ext.pc.template b/ext.pc.template
new file mode 100644
index 0000000..93dad69
--- /dev/null
+++ b/ext.pc.template
@@ -0,0 +1,6 @@
+includedir=@INCLUDEDIR@
+
+Name: @NAME@
+Version: @VERSION@
+Description: @DESCRIPTION@
+Cflags: -I${includedir}/@INCLUDE_PATH@
diff --git a/genwscript.py b/genwscript.py
index 6d3c42c..e4e020e 100644
--- a/genwscript.py
+++ b/genwscript.py
@@ -1,14 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import RDF
+import rdflib
import glob
import os
import re
import shutil
-rdf = RDF.NS('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
-lv2 = RDF.NS('http://lv2plug.in/ns/lv2core#')
+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):
+ triples = model.triples([s, p, o])
+ for i in triples:
+ return i
+ raise Exception('Bad LV2 extension data')
def genwscript(manifest):
match = re.search('.*/([^/]*).lv2/.*', manifest)
@@ -17,44 +24,57 @@ def genwscript(manifest):
match = re.search('(.*)/.*', manifest)
dir = match.group(1)
- m = RDF.Model()
- p = RDF.Parser(name="turtle")
- p.parse_into_model(m, 'file:' + manifest)
+ m = rdflib.ConjunctiveGraph()
+ m.parse('file:' + manifest, format='n3')
- s = m.find_statements(RDF.Statement(None, rdf.type, lv2.Specification))
- if not s.current():
+ try:
+ # ?uri a lv2:Specification
+ uri = query(m, None, rdf.type, lv2.Specification)[0]
+
+ # uri lv2:minorVersion ?minor
+ minor = query(m, uri, lv2.minorVersion, None)[2]
+
+ # uri lv2:microVersion ?
+ micro = query(m, uri, lv2.microVersion, None)[2]
+ except:
return False
- uri = str(s.current().subject.uri)
-
- s = m.find_statements(RDF.Statement(None, lv2.minorVersion, None))
- if not s.current():
- return False
- minor = s.current().object.literal_value['string']
-
- s = m.find_statements(RDF.Statement(None, lv2.microVersion, None))
- if not s.current():
- return False
- micro = s.current().object.literal_value['string']
-
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('/', '-')
+
+ # Generate wscript
wscript_template = open('wscript.template')
wscript = open('%s/wscript' % distdir, 'w')
for l in wscript_template:
wscript.write(l.replace(
'@NAME@', name).replace(
- '@URI@', uri).replace(
+ '@URI@', str(uri)).replace(
'@MINOR@', minor).replace(
- '@MICRO@', micro))
+ '@MICRO@', micro).replace(
+ '@PKGCONFIG_NAME@', pkgconfig_name))
wscript_template.close()
wscript.close()
+
+ # Generate pkgconfig file
+ pkgconfig_template = open('ext.pc.template', 'r')
+ pkgconfig = open('%s/%s.pc.in' % (distdir, pkgconfig_name), 'w')
+ for l in pkgconfig_template:
+ pkgconfig.write(l.replace(
+ '@NAME@', 'LV2 ' + name.title()).replace(
+ '@DESCRIPTION@', 'The LV2 "' + name + '" extension').replace(
+ '@VERSION@', '%s.%s' % (minor, micro)).replace(
+ '@INCLUDE_PATH@', str(uri).replace('http://', 'lv2/')))
+ pkgconfig_template.close()
+ pkgconfig.close()
+
try:
os.remove('%s/waf' % distdir)
except:
diff --git a/wscript.template b/wscript.template
index eba53b0..725d0b5 100644
--- a/wscript.template
+++ b/wscript.template
@@ -6,7 +6,7 @@ import waflib.Options as Options
# Variables for 'waf dist'
APPNAME = 'lv2-@NAME@'
-VERSION = '1.2'
+VERSION = '@VERSION@'
# Mandatory variables
top = '.'
@@ -31,6 +31,13 @@ def build(bld):
bundle_dir = os.path.join(bld.env['LV2DIR'], '@NAME@.lv2')
include_dir = os.path.join(bld.env['INCLUDEDIR'], 'lv2', include_base)
+ # Pkgconfig file
+ obj = bld(features = 'subst',
+ source = '@PKGCONFIG_NAME@.pc.in',
+ target = '@PKGCONFIG_NAME@.pc',
+ install_path = '${LIBDIR}/pkgconfig',
+ INCLUDEDIR = bld.env['INCLUDEDIR'])
+
# Install bundle
bld.install_files(bundle_dir,
bld.path.ant_glob('?*.*'))