summaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
Diffstat (limited to 'wscript')
-rw-r--r--wscript200
1 files changed, 200 insertions, 0 deletions
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..daa4de2
--- /dev/null
+++ b/wscript
@@ -0,0 +1,200 @@
+#!/usr/bin/env python
+import os
+import time
+import subprocess
+import waflib.Logs as Logs
+import waflib.Options as Options
+import waflib.extras.autowaf as autowaf
+
+# Mandatory waf variables
+APPNAME = 'drobillad' # Package name for waf dist
+VERSION = '0.0.0' # Package version for waf dist
+top = '.' # Source directory
+out = 'build' # Build directory
+
+projects = '''
+ serd
+ sord
+ sratom
+ suil
+ lilv
+ raul
+ ganv
+ patchage
+ ingen
+ jalv
+ machina
+ plugins/blop.lv2
+ plugins/fomp.lv2
+ plugins/mda.lv2
+ plugins/omins.lv2
+'''.split()
+
+def rebase(ctx):
+ 'rebase all git submodules'
+
+ def run(cmd):
+ 'run a command and return all output as a list of lines'
+ proc = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+ return proc.communicate()[0].splitlines()
+
+ for i in projects:
+ Logs.info('Updating %s' % i)
+ old_cwd = os.getcwd()
+ try:
+ os.chdir(i)
+ if os.system('git diff-files --quiet --'):
+ raise Exception
+ if os.system('git diff-index --cached --quiet HEAD --'):
+ raise Exception
+ output = run('git rev-parse --abbrev-ref HEAD')
+ branch = output[0].decode('utf-8')
+ if branch != "master":
+ os.system('git checkout master')
+ output = run('git log -n 1 --pretty="%H"')
+ curhead = output[0].decode('utf-8')
+ os.system('git pull --rebase')
+ newhead = output[0].decode('utf-8')
+ output = run('git log -n 1 --pretty="%H"')
+ if branch != "master":
+ os.system('git checkout ' + branch)
+ if curhead != newhead:
+ os.system('git branch bak-'+ str(time.time()))
+ os.system('git rebase master')
+ except Exception:
+ print("Repository is not clean, skipped")
+ finally:
+ os.chdir(old_cwd)
+
+def update(ctx):
+ 'updates all git submodules'
+ os.system('git submodule update')
+ for i in projects:
+ Logs.info('Updating %s' % i)
+ old_cwd = os.getcwd()
+ try:
+ os.chdir(i)
+ os.system('git checkout master')
+ os.system('git pull')
+ finally:
+ os.chdir(old_cwd)
+
+def options(opt):
+ opt.load('compiler_c')
+ opt.load('compiler_cxx')
+ opt.load('lv2')
+ autowaf.set_options(opt, test=True)
+ run_opts = opt.add_option_group('Run options')
+ run_opts.add_option('--cmd', type='string', dest='cmd',
+ help='command to run from build directory')
+ for i in projects:
+ opt.recurse(i)
+
+def sub_config_and_use(conf, name, has_objects = True, pkgname = ''):
+ conf.recurse(name)
+ if pkgname == '':
+ pkgname = name
+ autowaf.set_local_lib(conf, pkgname, has_objects)
+
+def configure(conf):
+ autowaf.display_header('Global Configuration')
+ autowaf.set_line_just(conf, 45)
+ conf.load('compiler_c', cache=True)
+ conf.load('compiler_cxx', cache=True)
+ conf.load('lv2', cache=True)
+ conf.load('autowaf', cache=True)
+ autowaf.set_recursive()
+
+ autowaf.check_pkg(conf, 'lv2', atleast_version='1.14.0', uselib_store='LV2')
+
+ # FIXME: I have no idea why this is necessary
+ conf.env.CXXFLAGS += ['-I%s/raul' % os.path.abspath(top)]
+
+ print('')
+ conf.env.DROBILLAD_BUILD = []
+ global to_build
+ for i in projects:
+ try:
+ sub_config_and_use(conf, i)
+ conf.env.DROBILLAD_BUILD += [i]
+ except Exception as e:
+ Logs.warn('Configuration failed, %s will not be built: %s\n' % (i, e))
+
+ Logs.info('Building:\n\t%s\n' % '\n\t'.join(conf.env.DROBILLAD_BUILD))
+
+ not_building = []
+ for i in projects:
+ if i not in conf.env.DROBILLAD_BUILD:
+ not_building += [i]
+
+ if not_building != []:
+ Logs.warn('Not building:\n\t%s\n' % '\n\t'.join(not_building))
+
+def source_tree_env():
+ "sets up the environment to run things from the source tree"
+ env = os.environ
+ library_path = []
+ if 'LD_LIBRARY_PATH' in env:
+ library_path = env['LD_LIBRARY_PATH'].split(os.pathsep)
+ for i in 'serd sord sratom lilv suil raul ganv'.split():
+ library_path += [ os.path.join(os.getcwd(), 'build', i) ]
+
+ ingen_module_path = []
+ for i in 'client server shared gui serialisation'.split():
+ path = os.path.join(os.getcwd(), 'build', 'ingen', 'src', i)
+ library_path += [ path ]
+ ingen_module_path += [ path ]
+
+ env.LD_LIBRARY_PATH = os.pathsep.join(library_path)
+ env.INGEN_MODULE_PATH = os.pathsep.join(ingen_module_path)
+ env.LV2_PATH = os.pathsep.join(['~/.lv2', os.path.join(os.getcwd(), 'lv2')])
+ return env
+
+def run(ctx):
+ if not Options.options.cmd:
+ Logs.error("missing --cmd option for run command")
+ return
+
+ cmd = Options.options.cmd
+ Logs.pprint('GREEN', 'Running %s' % cmd)
+
+ subprocess.call(cmd, shell=True, env=source_tree_env())
+
+def build(bld):
+ autowaf.set_recursive()
+ for i in bld.env.DROBILLAD_BUILD:
+ bld.recurse(i)
+
+def test(ctx):
+ autowaf.set_recursive();
+ os.environ = source_tree_env()
+ for i in ['raul', 'serd', 'sord', 'sratom', 'lilv', 'ingen']:
+ ctx.recurse(i)
+
+ if ctx.autowaf_tests_failed > 0:
+ Logs.pprint('RED', '\nSummary: %d / %d tests failed\n' % (
+ ctx.autowaf_tests_failed, ctx.autowaf_tests_total))
+ else:
+ Logs.pprint('GREEN', '\nSummary: All %d tests passed\n' % (
+ ctx.autowaf_tests_total))
+
+def posts(ctx):
+ autowaf.set_recursive()
+ try:
+ os.mkdir(os.path.join(out, 'posts'))
+ except:
+ pass
+
+ for i in ['serd',
+ 'sord',
+ 'sratom',
+ 'lilv',
+ 'ganv',
+ 'suil',
+ 'jalv',
+ 'raul',
+ 'patchage',
+ 'plugins/blop.lv2',
+ 'plugins/fomp.lv2',
+ 'plugins/mda.lv2']:
+ ctx.recurse(i)