diff options
| author | David Robillard <d@drobilla.net> | 2011-11-07 03:32:56 +0000 | 
|---|---|---|
| committer | David Robillard <d@drobilla.net> | 2011-11-07 03:32:56 +0000 | 
| commit | 2e4db9e54a5b14c387767d9d552976497d0fb550 (patch) | |
| tree | 6b2d35d9c5c228735fea3db5d325c16f7aba24d7 /wscript | |
| parent | 46842827988ae464c4940cd938ebe258bc0446be (diff) | |
| download | lv2-2e4db9e54a5b14c387767d9d552976497d0fb550.tar.xz | |
Remove generated junk from source directory in favour of a smarter extension wscript that figures out the necessary data from RDF (so the wscript itself can be identical for every extension).
Diffstat (limited to 'wscript')
| -rw-r--r-- | wscript | 134 | 
1 files changed, 35 insertions, 99 deletions
| @@ -5,6 +5,7 @@ import os  import rdflib  import shutil  import subprocess +import sys  from waflib.extras import autowaf as autowaf  import waflib.Logs as Logs @@ -31,99 +32,17 @@ def options(opt):      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.configure(conf) +      conf.env.append_unique('CFLAGS', '-std=c99') +    subdirs = ['core.lv2'] +    subdirs += glob.glob('ext/*.lv2/') +    subdirs += glob.glob('extensions/*.lv2/') +      for i in subdirs:          conf.recurse(i) @@ -134,20 +53,37 @@ def build(bld):          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']: +    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#') + +    manifests = glob.glob('ext/*.lv2/manifest.ttl') +    manifests += glob.glob('extensions/*.lv2/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: -            subprocess.call( -                ['./waf', 'distclean', 'configure', 'build', 'distcheck'], -                cwd=i) +            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: -            print('Error building %s release' % i) +            e = sys.exc_info()[1] +            Logs.error('error: %s: %s' % (manifest, str(e))) +            continue + +        if minor != 0 and micro % 2 == 0: +            try: +                subprocess.call( +                    ['./waf', 'distclean', 'configure', 'build', 'distcheck', 'distclean'], +                    cwd=dir) +            except: +                Logs.error('Error building %s release' % name)  def lint(ctx):      for i in (['core.lv2/lv2.h'] |