-
Notifications
You must be signed in to change notification settings - Fork 1
/
wscript
139 lines (111 loc) · 4.73 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
APPNAME = 'gravity'
VERSION = '1.0'
from waflib.Task import Task
def options(opt):
opt.load('compiler_cxx')
opt.add_option(
'--release', action='store_true', default=False, dest='release_build',
help='Build a release build.')
opt.add_option(
'--enable-profiling', action='store_true', default=False, dest='profiling_enabled',
help='Enable collecting profiling information.'
)
opt.add_option(
'--windows', action='store_true', default=False, dest='windows_build',
help='Configure the build for Windows.'
)
opt.add_option(
'--installer', action='store_true', default=False, dest='create_installer',
help='Create a Windows installer using NSIS.'
)
opt.add_option(
'--static', action='store_true', default=False, dest='static_build',
help='Use static linking (for some of the SDL2 libraries and Box2D).'
)
opt.add_option(
'--emscripten', action='store_true', default=False, dest='emscripten',
help='Build the emscripten version of the game.'
)
def configure(cfg):
cfg.load('compiler_cxx')
pkgconfig_static = ' --static' if cfg.options.static_build else ''
cfg.check_cfg(package='sdl2', args='--cflags --libs' + pkgconfig_static, uselib_store='SDL2')
cfg.check_cxx(lib='box2d', uselib_store='BOX2D')
cfg.check_cfg(package='SDL2_ttf', args='--cflags --libs' + pkgconfig_static, uselib_store='SDL2_TTF')
cfg.check_cxx(lib='SDL2_mixer', uselib_store='SDL2_MIXER')
if cfg.options.windows_build:
cfg.env['windows_build'] = True
cfg.check_cxx(lib='opengl32', uselib_store='GL')
cfg.check_cxx(lib='glu32', uselib_store='GLU')
cfg.env.append_value('CXXFLAGS', '-DGLEW_STATIC')
cfg.load('winres')
if cfg.options.create_installer:
cfg.env['create_installer'] = True
cfg.find_program('makensis', var='MAKENSIS')
cfg.env.append_value('LINKFLAGS', '-Wl,-subsystem,windows')
else:
if cfg.options.create_installer:
raise cfg.errors.ConfigurationError('--installer options only available when --windows is used.')
cfg.check_cxx(lib='GL', uselib_store='GL')
cfg.env.append_value('CXXFLAGS', ['-std=c++11', '-DGLEW_NO_GLU'])
if cfg.options.static_build:
cfg.env.append_value('LINKFLAGS', ['-static'])
if cfg.options.release_build:
cfg.env.append_value('CXXFLAGS', ['-O3'])
cfg.env.append_value('LINKFLAGS', '-Wl,-s')
cfg.env.append_value('DEFINES', 'RELEASE_BUILD')
else:
cfg.env.append_value('CXXFLAGS', ['-g'])
if cfg.options.profiling_enabled:
cfg.env.append_value('CXXFLAGS', ['-pg'])
cfg.env.append_value('LINKFLAGS', ['-pg'])
def build(bld):
source = [
'main.cc',
'camera.cc',
'timer.cc',
'credits-screen.cc',
'splash-screen.cc',
'game-screen.cc',
'main-menu-screen.cc',
'high-scores-screen.cc',
'entity.cc',
'resource-cache.cc',
'helpers.cc',
'config.cc',
'number-widget.cc',
'image-widget.cc',
'image-button-widget.cc',
'label-widget.cc',
'button-widget.cc',
'mesh.cc',
'renderer.cc',
'glew.c'
]
if bld.env.windows_build:
source.append('windows/windows.cc')
source.append('windows/resources.rc')
else:
source.append('posix/posix.cc')
bld.program(
source=source,
target='gravity-bin',
use='SDL2 SDL2_TTF SDL2_MIXER GL BOX2D'
)
if bld.env.create_installer:
bld(rule='${MAKENSIS} -NOCD ${SRC}', source='windows/installer.nsis', target='gravity-installer.exe')
if not bld.env.windows_build:
bld(
rule='echo "#!/bin/sh\\n{0}/bin/gravity-bin {0}/share/gravity"'.format(bld.env.PREFIX) + ' > ${TGT}',
target='launcher.sh'
)
bld.install_as('${PREFIX}/bin/gravity', 'launcher.sh', chmod=0755)
bld.install_as('${PREFIX}/share/doc/gravity/copyright', 'debian/copyright')
images_dir = bld.path.find_dir('resources/images')
bld.install_files('${PREFIX}/share/gravity/images', images_dir.ant_glob('*.png'), cwd=images_dir, relative_trick=True)
fonts_dir = bld.path.find_dir('resources/fonts')
bld.install_files('${PREFIX}/share/gravity/fonts', fonts_dir.ant_glob('*.ttf'), cwd=fonts_dir, relative_trick=True)
sounds_dir = bld.path.find_dir('resources/sound')
bld.install_files('${PREFIX}/share/gravity/sound', sounds_dir.ant_glob('*.wav'), cwd=sounds_dir, relative_trick=True)
shaders_dir = bld.path.find_dir('resources/shaders')
bld.install_files('${PREFIX}/share/gravity/shaders', shaders_dir.ant_glob('*.glsl'), cwd=shaders_dir, relative_trick=True)