-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAMBuildScript
171 lines (156 loc) · 4.24 KB
/
AMBuildScript
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
# 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, 'hlsdk', 'common'),
os.path.join(builder.currentSourcePath, 'hlsdk', 'dlls'),
os.path.join(builder.currentSourcePath, 'hlsdk', 'engine'),
os.path.join(builder.currentSourcePath, 'hlsdk', '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',
'-Wall',
'-Werror',
'-Wno-uninitialized',
'-Wno-unused',
'-Wno-switch',
'-Wno-format',
'-Wno-format-security',
'-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']
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'
]
# 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 == '1':
# Shared optimization definitions
builder.cxx.defines += ['NDEBUG']
if builder.cxx.target.platform == 'linux':
# Linux optimization flags
builder.cxx.cflags += ['-O3']
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', '/GF']
# Windows optimization link flags
builder.cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
# 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 == '1':
# Shared debug definitions
builder.cxx.defines += ['DEBUG', '_DEBUG']
if builder.cxx.target.platform == 'linux':
# Linux debug flags
builder.cxx.cflags += ['-g3', '-O0']
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)