examples/buildall.py: Add meson build system
With `--build-system` option, we can select either the waf build
system or the meson build system.  The default build system is still
waf because of how our CI is set up.
import subprocess
import sys
+import argparse
-def build_with_waf():
+DEFAULT_BUILD_SYSTEM = 'waf'
+
+
+def build_with_meson():
+ extra_target = ['csp_server_client',
+ 'csp_arch',
+ 'zmqproxy']
+ builddir = 'build'
+
+ meson_setup = ['meson', 'setup', builddir]
+ meson_compile = ['meson', 'compile', '-C', builddir]
+ subprocess.check_call(meson_setup)
+ subprocess.check_call(meson_compile + extra_target)
+
+
+def build_with_waf(options):
target_os = 'posix' # default OS
- options = sys.argv[1:]
if (len(options) > 0) and not options[0].startswith('--'):
target_os = options[0]
options = options[1:]
@@ -53,9 +68,18 @@ def build_with_waf():
subprocess.check_call(waf + options + ['--enable-examples'])
-def main():
- build_with_waf()
+def main(with_waf, options):
+ if (with_waf):
+ build_with_waf(options)
+ else:
+ build_with_meson()
if __name__ == '__main__':
- main()
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--build-system',
+ default=DEFAULT_BUILD_SYSTEM,
+ choices=['meson', 'waf'])
+ args, rest = parser.parse_known_args()
+
+ main(args.build_system == DEFAULT_BUILD_SYSTEM, rest)
