output: add _get_plugin()
[libmpdclient.git] / build / configure.py
blob5fb2e1d783bfc04d36cccfc7ed67c935cbc6c5bc
1 #!/usr/bin/env python3
3 import os, sys, shutil, subprocess
5 global_options = ['--werror']
7 flavors = {
8 'debug': {
9 'options': [
10 '-Ddocumentation=true',
11 '-Dtest=true',
15 'asan': {
16 'options': [
17 '-Db_sanitize=address',
18 '-Dtest=true',
22 'release': {
23 'options': [
24 '--buildtype', 'release',
25 '--unity',
26 '-Db_ndebug=true',
27 '-Dtest=true',
31 'musl': {
32 'options': [
33 '--buildtype', 'minsize',
34 '--default-library', 'static',
35 '-Db_ndebug=true',
37 'env': {
38 'CC': 'musl-gcc',
42 'win32': {
43 'arch': 'i686-w64-mingw32',
46 'win64': {
47 'arch': 'x86_64-w64-mingw32',
51 source_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
52 output_path = os.path.join(source_root, 'output')
53 cross_path = os.path.join(source_root, 'build', 'cross')
54 prefix_root = '/usr/local/stow'
56 for name, data in flavors.items():
57 print(name)
58 build_root = os.path.join(output_path, name)
60 env = os.environ.copy()
61 if 'env' in data:
62 env.update(data['env'])
64 cmdline = [
65 'meson', source_root, build_root,
66 ] + global_options
68 if 'options' in data:
69 cmdline.extend(data['options'])
71 prefix = os.path.join(prefix_root, 'libmpdclient-' + name)
73 if 'arch' in data:
74 prefix = os.path.join(prefix, data['arch'])
75 cmdline += ('--cross-file', os.path.join(cross_path, name + '.txt'))
77 # this is necessary because Meson uses Debian's build machine
78 # MultiArch path (e.g. "lib/x86_64-linux-gnu") for cross
79 # builds, which is obviously wrong
80 cmdline += ('--libdir', 'lib')
82 cmdline += ('--prefix', prefix)
84 try:
85 shutil.rmtree(build_root)
86 except:
87 pass
89 subprocess.check_call(cmdline, env=env)