Code

build with Meson instead of autotools
[ncmpc.git] / build / configure.py
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             '-Dcurses=ncursesw',
12             '-Dmouse=true',
13             '-Dlirc=true',
14             '-Dlyrics_screen=true',
15             '-Dchat_screen=true',
16         ],
17     },
19     'release': {
20         'options': [
21             '--buildtype', 'release',
22             '-Db_ndebug=true',
23             '-Db_lto=true',
24             '-Dcurses=ncursesw',
25             '-Dmouse=true',
26         ],
27     },
29     'mini': {
30         'options': [
31             '--buildtype', 'minsize',
32             '-Db_ndebug=true',
33             '-Db_lto=true',
34             '-Dlirc=false',
35             '-Dcurses=ncurses',
36             '-Dcolor=false',
37             '-Dmouse=false',
38             '-Dmultibyte=false',
39             '-Dlocale=false',
40             '-Dnls=false',
41             '-Dtcp=false',
42             '-Dasync_connect=false',
43             '-Dmini=true',
44         ],
45     },
46 }
48 project_name = 'ncmpc'
49 source_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
50 output_path = os.path.join(source_root, 'output')
51 prefix_root = '/usr/local/stow'
53 for name, data in flavors.items():
54     print(name)
55     build_root = os.path.join(output_path, name)
57     env = os.environ.copy()
58     if 'env' in data:
59         env.update(data['env'])
61     cmdline = [
62         'meson', source_root, build_root,
63     ] + global_options
65     if 'options' in data:
66         cmdline.extend(data['options'])
68     prefix = os.path.join(prefix_root, project_name + '-' + name)
70     if 'arch' in data:
71         prefix = os.path.join(prefix, data['arch'])
72         cmdline += ('--cross-file', os.path.join(source_root, 'build', name, 'cross-file.txt'))
74     cmdline += ('--prefix', prefix)
76     try:
77         shutil.rmtree(build_root)
78     except:
79         pass
81     subprocess.check_call(cmdline, env=env)