-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAMBuildScript
More file actions
197 lines (182 loc) · 4.92 KB
/
AMBuildScript
File metadata and controls
197 lines (182 loc) · 4.92 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
# 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
hlsdk_path = os.path.join(builder.currentSourcePath, 'hlsdk')
include_paths = [
os.path.join(hlsdk_path, 'common'),
os.path.join(hlsdk_path, 'dlls'),
os.path.join(hlsdk_path, 'engine'),
os.path.join(hlsdk_path, 'pm_shared'),
os.path.join(builder.currentSourcePath, 'metamod-p'),
]
# Compiler setup
builder.cxx.defines += [
'HAVE_STDINT_H'
]
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',
'-msse4.2',
'-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',
'-Wunused',
'-Woverloaded-virtual',
'-Wpedantic',
'-Wconversion',
'-Wsign-conversion',
'-Wnull-dereference',
'-Wdouble-promotion',
'-Wformat=2',
'-Wformat-security',
'-Wno-uninitialized',
'-Wno-unused',
'-Wno-switch',
'-Wno-unknown-attributes',
'-Wno-logical-op-parentheses',
'-Wno-return-stack-address',
'-m32',
]
# 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',
'odbc32.lib',
'odbccp32.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 += ['-O3', '-flto=auto']
# Linux optimization link flags - LTO must be in link flags too - [APG]RoboCop[CL]
builder.cxx.linkflags += ['-flto=auto', '-s', '-Wl,-z,relro,-z,now', '-Wl,-z,noexecstack',]
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', '/MT']
# 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
builder.cxx.cflags += ['-g3', '-Og', '-ggdb3', '-fsanitize=address', '-fsanitize=undefined', '-fsanitize=leak']
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('foxbot')
library.compiler.includes += include_paths
library.sources += [
'bot.cpp',
'bot_client.cpp',
'bot_combat.cpp',
'bot_job_assessors.cpp',
'bot_job_functions.cpp',
'bot_job_think.cpp',
'bot_navigate.cpp',
'bot_start.cpp',
'botcam.cpp',
'dll.cpp',
'engine.cpp',
'h_export.cpp',
'linkfunc.cpp',
'meta_api.cpp',
'sdk_util.cpp',
'util.cpp',
'version.cpp',
'waypoint.cpp',
]
#
# Run scripts, add binaries
#
builder.Add(library)