forked from tomscii/zutty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wscript
101 lines (83 loc) · 3.25 KB
/
wscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! ./waf
# encoding: utf-8
import subprocess, sys
from waflib import Logs
top = '.'
out = 'build'
def options(opt):
opt.add_option('--debug', action='store_true', default=False,
dest='debug', help='Compile-in debug facilities')
opt.add_option('--no-werror', action='store_false', default=True,
dest='werror', help='Treat warnings as errors')
opt.load('compiler_cxx')
opt.recurse('src')
def configure(cfg):
vsn = cmd("(git checkout -- version.txt && " +
"git describe --tags --dirty) 2>/dev/null || cat version.txt")
with open("version.txt", 'w') as f: f.write(vsn + '\n')
cfg.msg('Zutty version', vsn)
if cfg.options.debug:
vsn = vsn + '-DEBUG'
cfg.msg('Debug build', "yes" if cfg.options.debug else "no")
cfg.load('compiler_cxx')
cfg.env.append_value('CXXFLAGS',
['-std=c++14',
'-fno-omit-frame-pointer',
'-fsigned-char',
'-Wall',
'-Wextra',
'-Wsign-compare',
'-Wno-unused-parameter',
'-DZUTTY_VERSION="{}"'.format (vsn)
])
platform = cmd("uname -s")
cfg.msg('Target platform', platform)
if platform == 'Linux':
cfg.env.append_value('CXXFLAGS', ['-DLINUX'])
elif platform == 'FreeBSD':
cfg.env.append_value('CXXFLAGS',
['-DBSD', '-DFREEBSD', '-I/usr/local/include'])
cfg.env.append_value('LINKFLAGS', ['-L/usr/local/lib'])
elif platform == 'OpenBSD':
cfg.env.append_value('CXXFLAGS',
['-DBSD', '-DOPENBSD', '-I/usr/X11R6/include'])
cfg.env.append_value('LINKFLAGS', ['-L/usr/X11R6/lib'])
elif platform == 'NetBSD':
cfg.env.append_value('CXXFLAGS', ['-DBSD'])
elif platform == 'Darwin':
cfg.env.append_value('CXXFLAGS', ['-DMACOS'])
elif platform == 'SunOS':
cfg.env.append_value('CXXFLAGS', ['-DSOLARIS'])
else:
Logs.error ('Unknown platform: {}'.format (platform))
sys.exit (1)
if cfg.options.debug:
cfg.env.target = 'zutty.dbg'
cfg.env.append_value('CXXFLAGS',
['-DDEBUG', '-Og', '-g', '-ggdb'])
else:
cfg.env.target = 'zutty'
cfg.env.append_value('CXXFLAGS',
['-Werror', '-O3', '-march=native', '-mtune=native', '-flto'])
cfg.env.append_value('LINKFLAGS',
['-flto'])
cfg.check_cfg(package='freetype2', args=['--cflags', '--libs'],
uselib_store='FT')
cfg.check_cfg(package='xmu', args=['--cflags', '--libs'],
uselib_store='XMU')
cfg.check_cxx(header_name='EGL/egl.h')
cfg.check_cxx(header_name='GLES3/gl31.h')
cfg.check_cxx(lib='EGL', uselib_store='EGL')
cfg.check_cxx(lib='GLESv2', uselib_store='GLES')
cfg.check_cxx(lib='pthread', uselib_store='THREAD')
cfg.recurse('src')
def build(bld):
bld.recurse('src')
def cmd(s):
# Try to cover all relevant Python versions (2.7 - 3.8+)
if (100 * sys.version_info.major + sys.version_info.minor >= 305):
proc = subprocess.run(s, shell=True, check=True,
stdout=subprocess.PIPE, universal_newlines=True)
return proc.stdout.strip('\r\n')
else:
return subprocess.check_output(s, shell=True).strip('\r\n')