Repository navigation
Expand file tree
/
Copy pathAMBuildScript
More file actions
230 lines (215 loc) · 6.48 KB
/
Copy pathAMBuildScript
File metadata and controls
230 lines (215 loc) · 6.48 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# AMBuildScript for EvoBot, written by Anonymous Player
# vim: set sts=4 ts=8 sw=4 tw=99 et ft=python:
import os, sys
builder.cxx = builder.DetectCxx(target_arch = 'x86')
# Include search paths
include_paths = [
os.path.join(builder.currentSourcePath, 'common'),
os.path.join(builder.currentSourcePath, 'engine'),
os.path.join(builder.currentSourcePath, 'dlls'),
os.path.join(builder.currentSourcePath, 'pm_shared'),
]
# Compiler setup
builder.cxx.defines += [
'HAVE_STDINT_H',
'RCBOT_META_BUILD'
]
if builder.cxx.like('gcc'):
builder.cxx.defines += [
'stricmp=strcasecmp',
'strcmpi=strcasecmp'
]
builder.cxx.c_only_flags += ['-std=gnu99']
if builder.cxx.target.platform == 'linux':
# Linux defines
builder.cxx.defines += ['_LINUX', 'POSIX', 'LINUX', 'linux']
# Linux compiler C flags
builder.cxx.cflags += [
'-mtune=generic',
'-pipe',
'-fPIC',
'-msse',
'-msse2',
'-mfpmath=sse',
'-fno-strict-aliasing',
'-fstack-protector-strong',
'-fstack-clash-protection',
'-fcf-protection',
'-Wall',
#'-Werror',
'-Wextra',
'-Wshadow',
'-Wnon-virtual-dtor',
#'-Wold-style-cast',
'-Wcast-align',
'-Woverloaded-virtual',
'-Wpedantic',
'-Wconversion',
'-Wno-sign-conversion',
'-Wnull-dereference',
#'-Wdouble-promotion',
'-Wformat-security',
'-Wno-uninitialized',
'-Wno-unused',
'-Wno-switch',
'-m32',
]
# Compiler-specific warning suppressions. These three names only exist in
# Clang; GCC prints "unrecognized command-line option" notes for them
# whenever another warning fires, so each compiler gets its own spelling.
if builder.cxx.family == 'clang':
builder.cxx.cflags += [
'-Wno-unknown-attributes',
'-Wno-logical-op-parentheses',
'-Wno-return-stack-address',
]
elif builder.cxx.family == 'gcc':
builder.cxx.cflags += [
'-Wno-attributes',
'-Wno-parentheses',
'-Wno-return-local-addr',
]
# Linux compiler C++ flags
builder.cxx.cxxflags += [
'-Wno-invalid-offsetof',
'-Wno-write-strings',
'-std=c++17',
]
# Linux linker flags
builder.cxx.linkflags += [
'-m32',
'-ldl',
'-lm',
'-Wl,--gc-sections',
'-Wl,--as-needed',
'-Wl,--no-undefined',
]
elif builder.cxx.target.platform == 'windows':
# Windows defines
builder.cxx.defines += [
'_CRT_SECURE_NO_DEPRECATE',
'_CRT_SECURE_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE',
'NOMINMAX',
'WIN32',
'_WINDOWS'
]
# Windows compiler C flags
builder.cxx.cflags += [
'/W4',
]
# Windows compiler C++ flags
builder.cxx.cxxflags += [
'/std:c++17',
'/arch:SSE2',
'/fp:precise',
'/Qspectre',
'/EHsc',
'/GS'
]
# Windows linker flags
builder.cxx.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'kernel32.lib',
'user32.lib',
'gdi32.lib',
'winspool.lib',
'comdlg32.lib',
'advapi32.lib',
'shell32.lib',
'ole32.lib',
'oleaut32.lib',
'uuid.lib',
'/SECTION:.data,RW',
'/MACHINE:X86',
]
# Compiler options for optimization ( --enable-optimize )
if builder.options.optimize:
# Shared optimization definitions
builder.cxx.defines += ['NDEBUG']
if builder.cxx.target.platform == 'linux':
# Linux optimization flags
builder.cxx.cflags += ['-O2', '-flto=auto', '-ffunction-sections', '-fdata-sections']
# Linux optimization link flags - LTO must be in link flags too - [APG]RoboCop[CL]
builder.cxx.linkflags += ['-flto=auto', '-Wl,-z,relro,-z,now', '-Wl,-z,noexecstack',]
# Clang LTO through GNU ld needs the LLVMgold plugin; lld handles it natively.
if builder.cxx.family == 'clang':
builder.cxx.linkflags += ['-fuse-ld=lld']
elif builder.cxx.target.platform == 'windows':
# Windows optimization flags - /Ob3 needs to be after /Ox, enables aggressive function inling -caxanga334
builder.cxx.cflags += ['/Ox', '/Zo', '/Ob3', '/GL', '/MD']
# Windows optimization link flags
builder.cxx.linkflags += ['/OPT:ICF', '/OPT:REF', '/LTCG']
# This needs to be after our optimization flags which could otherwise disable it.
builder.cxx.cflags += ['/Oy-']
# Compiler options for debugging ( --enable-debug )
if builder.options.debug:
# Shared debug definitions
builder.cxx.defines += ['DEBUG', '_DEBUG']
if builder.cxx.target.platform == 'linux':
# Linux debug flags. LeakSanitizer is 64-bit only, so it is not used for
# this 32-bit build. The sanitizers must be passed at link time as well or
# the __asan_*/__ubsan_* references stay unresolved (and --no-undefined
# then fails the link). Clang links the runtime statically by default,
# which is not allowed into a shared object, hence -shared-libsan. At run
# time hlds itself is not instrumented, so start it with the matching
# libasan/libclang_rt.asan in LD_PRELOAD. [APG]RoboCop[CL]
builder.cxx.cflags += ['-g3', '-Og', '-ggdb3', '-fsanitize=address,undefined', '-fno-omit-frame-pointer']
builder.cxx.linkflags += ['-fsanitize=address,undefined']
if builder.cxx.family == 'clang':
builder.cxx.cflags += ['-shared-libsan']
builder.cxx.linkflags += ['-shared-libsan']
elif builder.cxx.target.platform == 'windows':
# Windows debug flags
builder.cxx.cflags += ['/Od', '/RTC1', '/MTd']
# Windows debug link flags
builder.cxx.linkflags += ['/NODEFAULTLIB:libcmt']
# Handle --enable-static-lib and --enable-shared-lib
if builder.cxx.target.platform == 'linux':
if builder.options.staticlib == '1':
builder.cxx.linkflags += [
'-static-libgcc',
'-static-libstdc++'
]
elif builder.options.sharedlib == '1':
builder.cxx.linkflags += [
'-shared-libgcc',
]
library = builder.cxx.Library('rcbot_mm')
library.compiler.includes += include_paths
library.sources += [
'dlls/bits.cpp',
'dlls/bot.cpp',
'dlls/bot_client.cpp',
'dlls/bot_commands.cpp',
'dlls/bot_ga.cpp',
'dlls/bot_menu.cpp',
'dlls/bot_navigate.cpp',
'dlls/bot_nn.cpp',
'dlls/bot_rep.cpp',
'dlls/bot_visibles.cpp',
'dlls/bot_weapons.cpp',
'dlls/client.cpp',
'dlls/dir.cpp',
'dlls/dll.cpp',
'dlls/engine.cpp',
'dlls/ga.cpp',
'dlls/globals.cpp',
'dlls/h_export.cpp',
'dlls/linkfunc.cpp',
'dlls/megahal.cpp',
'dlls/netmessages.cpp',
'dlls/perceptron.cpp',
'dlls/rcbot_meta_api.cpp',
'dlls/util.cpp',
'dlls/rc_compress.cpp',
'dlls/miniz.c',
'dlls/miniz_tdef.c',
'dlls/miniz_tinfl.c',
'dlls/miniz_zip.c',
'dlls/waypoint.cpp',
]
#
# Run scripts, add binaries
#
builder.Add(library)