1#!/usr/bin/env python3 2 3import os, sys, shutil, subprocess 4 5global_options = ['--werror'] 6 7flavors = { 8 'debug': { 9 'options': [ 10 '-Ddocumentation=enabled', 11 '-Dcurses=ncursesw', 12 '-Dmouse=enabled', 13 '-Dlirc=enabled', 14 '-Dlyrics_screen=true', 15 '-Dchat_screen=true', 16 ], 17 }, 18 19 'clang': { 20 'options': [ 21 '-Dcurses=ncursesw', 22 '-Dmouse=enabled', 23 '-Dlirc=enabled', 24 '-Dlyrics_screen=true', 25 '-Dchat_screen=true', 26 '-Ddocumentation=disabled', 27 ], 28 'env': { 29 'CC': 'clang', 30 'CXX': 'clang++', 31 'LDFLAGS': '-fuse-ld=lld', 32 }, 33 }, 34 35 'release': { 36 'options': [ 37 '--buildtype', 'debugoptimized', 38 '-Db_ndebug=true', 39 '-Db_lto=true', 40 '-Dcurses=ncursesw', 41 '-Dmouse=enabled', 42 '-Ddocumentation=disabled', 43 ], 44 'env': { 45 'LDFLAGS': '-fuse-ld=gold -Wl,--gc-sections,--icf=all', 46 }, 47 }, 48 49 'llvm': { 50 'options': [ 51 '--buildtype', 'debugoptimized', 52 '-Db_ndebug=true', 53 '-Db_lto=true', 54 '-Dcurses=ncursesw', 55 '-Dmouse=enabled', 56 '-Ddocumentation=disabled', 57 ], 58 'env': { 59 'CC': 'clang', 60 'CXX': 'clang++', 61 'LDFLAGS': '-fuse-ld=lld', 62 }, 63 }, 64 65 'mini': { 66 'options': [ 67 '--buildtype', 'minsize', 68 '-Db_ndebug=true', 69 '-Db_lto=true', 70 '-Dlirc=disabled', 71 '-Dcurses=ncurses', 72 '-Dcolors=false', 73 '-Dmouse=disabled', 74 '-Dmultibyte=false', 75 '-Dlocale=disabled', 76 '-Dnls=disabled', 77 '-Dtcp=false', 78 '-Dasync_connect=false', 79 '-Dmini=true', 80 '-Ddocumentation=disabled', 81 ], 82 'env': { 83 'LDFLAGS': '-fuse-ld=gold -Wl,--gc-sections,--icf=all', 84 }, 85 }, 86} 87 88project_name = 'ncmpc' 89source_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..')) 90output_path = os.path.join(source_root, 'output') 91prefix_root = '/usr/local/stow' 92 93for name, data in flavors.items(): 94 print(name) 95 build_root = os.path.join(output_path, name) 96 97 env = os.environ.copy() 98 if 'env' in data: 99 env.update(data['env']) 100 101 cmdline = [ 102 'meson', source_root, build_root, 103 ] + global_options 104 105 if 'options' in data: 106 cmdline.extend(data['options']) 107 108 prefix = os.path.join(prefix_root, project_name + '-' + name) 109 110 if 'arch' in data: 111 prefix = os.path.join(prefix, data['arch']) 112 cmdline += ('--cross-file', os.path.join(source_root, 'build', name, 'cross-file.txt')) 113 114 cmdline += ('--prefix', prefix) 115 116 try: 117 shutil.rmtree(build_root) 118 except: 119 pass 120 121 subprocess.check_call(cmdline, env=env) 122