forked from KZGlobalTeam/cs2kz-metamod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMBuilder
334 lines (274 loc) · 15.6 KB
/
AMBuilder
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
import os
# Here only one sdk should be available to generate only one executable in the end,
# as multi-sdk loading isn't supported out of the box by metamod, and would require specifying the full path in the vdf
# which in the end would ruin the multi-platform (unix, win etc) loading by metamod as it won't be able to append platform specific extension
# so just fall back to the single binary.
# Multi-sdk solutions should be manually loaded with a custom plugin loader (examples being sourcemod, stripper:source)
for sdk_target in MMSPlugin.sdk_targets:
sdk = sdk_target.sdk
cxx = sdk_target.cxx
CXXINCLUDES = [
os.path.join(builder.sourcePath, 'src'),
os.path.join(builder.sourcePath, 'hl2sdk-cs2'),
os.path.join(builder.sourcePath, 'hl2sdk-cs2', 'public', 'entity2'),
os.path.join(builder.sourcePath, 'hl2sdk-cs2', 'game', 'server'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'include'),
]
PROTOS = [
os.path.join(sdk['path'], 'common', 'netmessages.proto'),
os.path.join(sdk['path'], 'game', 'shared', 'usermessages.proto'),
os.path.join(sdk['path'], 'common', 'network_connection.proto'),
os.path.join(sdk['path'], 'common', 'networkbasetypes.proto'),
os.path.join(sdk['path'], 'common', 'engine_gcmessages.proto'),
os.path.join(sdk['path'], 'gcsdk', 'steammessages.proto'),
os.path.join(sdk['path'], 'gcsdk', 'gcsdk_gcmessages.proto'),
os.path.join(builder.sourcePath, 'protobuf', 'cstrike15_gcmessages.proto'),
os.path.join(builder.sourcePath, 'protobuf', 'cstrike15_usermessages.proto'),
os.path.join(sdk['path'], 'game', 'shared', 'usercmd.proto'),
os.path.join(sdk['path'], 'game', 'shared', 'gameevents.proto'),
os.path.join(builder.sourcePath, 'protobuf', 'cs_gameevents.proto'),
os.path.join(builder.sourcePath, 'protobuf', 'cs_usercmd.proto'),
]
# Main binary
binary = MMSPlugin.HL2Library(builder, cxx, MMSPlugin.plugin_name, sdk)
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
if binary.compiler.family == 'clang':
binary.compiler.cxxflags += ['-Wno-register', '-frtti', '-Wno-invalid-offsetof', '-Wno-parentheses']
binary.compiler.cxxincludes += CXXINCLUDES
if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += [
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libfunchook.a'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libdistorm.a'),
os.path.join(sdk['path'], 'lib', 'linux64', 'mathlib.a'),
]
binary.sources += [
'src/utils/plat_linux.cpp'
]
elif binary.compiler.target.platform == 'windows':
binary.compiler.postlink += [
os.path.join('psapi.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'funchook.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'distorm.lib'),
os.path.join(sdk['path'], 'lib', 'public', 'win64', 'mathlib.lib'),
os.path.join(builder.sourcePath, 'vendor', 'steam_api64.lib')
]
binary.sources += [
'src/utils/plat_win.cpp'
]
binary.sources += [
os.path.join(sdk['path'], 'entity2', 'entityidentity.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitysystem.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitykeyvalues.cpp'),
os.path.join(sdk['path'], 'tier1', 'generichash.cpp'),
os.path.join(sdk['path'], 'tier1', 'keyvalues3.cpp'),
os.path.join(builder.sourcePath, 'src', 'cs2kz.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'utils.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'utils_interface.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'utils_print.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'gameconfig.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'hooks.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'detours.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'schema.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'simplecmds.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'ctimer.cpp'),
os.path.join(builder.sourcePath, 'src', 'player', 'player_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'player', 'player.cpp'),
os.path.join(builder.sourcePath, 'src', 'movement', 'mv_hooks.cpp'),
os.path.join(builder.sourcePath, 'src', 'movement', 'mv_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'movement', 'mv_player.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'misc', 'kz_misc.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'misc', 'block_radio.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'misc', 'time_limit.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'kz_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'kz_player.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'kz_player_print.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'anticheat', 'kz_anticheat.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'checkpoint', 'kz_checkpoint.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'checkpoint', 'commands.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'course', 'kz_course.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'kz_db.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'find_courses.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'find_pb.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'find_player.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'find_records.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'migrations.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'save_prefs.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'save_time.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_client.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_database.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_map_courses.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_map.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_modes.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'db', 'setup_styles.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'global', 'kz_global.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'hud', 'kz_hud.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mappingapi', 'kz_mappingapi.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'jumpstats', 'kz_jumpstats.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'jumpstats', 'jump_reporting.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'jumpstats', 'recorder.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'language', 'kz_language.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'measure', 'kz_measure.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mode', 'kz_mode_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mode', 'kz_mode_vnl.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'noclip', 'kz_noclip.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'option', 'kz_option.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'quiet', 'kz_quiet.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'racing', 'kz_racing.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'replays', 'kz_replays.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'saveloc', 'kz_saveloc.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'spec', 'kz_spec.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'goto', 'kz_goto.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'style', 'kz_style_manager.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'telemetry', 'kz_telemetry.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'kz_timer.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'announce_queue.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'course_top.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'get_records.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'timer', 'personal_best.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'tip', 'kz_tip.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'trigger', 'callbacks.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'trigger', 'kz_trigger.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'trigger', 'mapping_api.cpp'),
]
binary.custom = [builder.tools.Protoc(protoc = sdk_target.protoc, sources = PROTOS)]
# CKZ_Mode binaries
ckz_mode_binary = MMSPlugin.HL2Library(builder, cxx, f"{MMSPlugin.plugin_name}-mode-ckz", sdk)
if ckz_mode_binary.compiler.family == 'gcc' or ckz_mode_binary.compiler.family == 'clang':
ckz_mode_binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
if ckz_mode_binary.compiler.family == 'clang':
ckz_mode_binary.compiler.cxxflags += ['-Wno-register', '-frtti', '-Wno-invalid-offsetof', '-Wno-parentheses']
ckz_mode_binary.compiler.cxxincludes += CXXINCLUDES
if ckz_mode_binary.compiler.target.platform == 'linux':
ckz_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'linux64', 'mathlib.a'),
]
ckz_mode_binary.sources += [
'src/utils/plat_linux.cpp'
]
elif ckz_mode_binary.compiler.target.platform == 'windows':
ckz_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'public', 'win64', 'mathlib.lib'),
]
ckz_mode_binary.sources += [
'src/utils/plat_win.cpp'
]
ckz_mode_binary.sources += [
os.path.join(sdk['path'], 'entity2', 'entityidentity.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitysystem.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'schema.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'gameconfig.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mode', 'kz_mode_ckz.cpp'),
]
# CKZ_Bind_Mode binaries
ckz_bind_mode_binary = MMSPlugin.HL2Library(builder, cxx, f"{MMSPlugin.plugin_name}-mode-ckz-bind", sdk)
if ckz_bind_mode_binary.compiler.family == 'gcc' or ckz_bind_mode_binary.compiler.family == 'clang':
ckz_bind_mode_binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
if ckz_bind_mode_binary.compiler.family == 'clang':
ckz_bind_mode_binary.compiler.cxxflags += ['-Wno-register', '-frtti', '-Wno-invalid-offsetof', '-Wno-parentheses']
ckz_bind_mode_binary.compiler.cxxincludes += CXXINCLUDES
if ckz_bind_mode_binary.compiler.target.platform == 'linux':
ckz_bind_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'linux64', 'mathlib.a'),
]
ckz_bind_mode_binary.sources += [
'src/utils/plat_linux.cpp'
]
elif ckz_bind_mode_binary.compiler.target.platform == 'windows':
ckz_bind_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'public', 'win64', 'mathlib.lib'),
]
ckz_bind_mode_binary.sources += [
'src/utils/plat_win.cpp'
]
ckz_bind_mode_binary.sources += [
os.path.join(sdk['path'], 'entity2', 'entityidentity.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitysystem.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'schema.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'gameconfig.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mode', 'kz_mode_ckz-bind.cpp'),
]
# VNL_128_Mode binaries
vnl_128_mode_binary = MMSPlugin.HL2Library(builder, cxx, f"{MMSPlugin.plugin_name}-mode-vnl-128", sdk)
if vnl_128_mode_binary.compiler.family == 'gcc' or vnl_128_mode_binary.compiler.family == 'clang':
vnl_128_mode_binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
if vnl_128_mode_binary.compiler.family == 'clang':
vnl_128_mode_binary.compiler.cxxflags += ['-Wno-register', '-frtti', '-Wno-invalid-offsetof', '-Wno-parentheses']
vnl_128_mode_binary.compiler.cxxincludes += CXXINCLUDES
if vnl_128_mode_binary.compiler.target.platform == 'linux':
vnl_128_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'linux64', 'mathlib.a'),
]
vnl_128_mode_binary.sources += [
'src/utils/plat_linux.cpp'
]
elif vnl_128_mode_binary.compiler.target.platform == 'windows':
vnl_128_mode_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'public', 'win64', 'mathlib.lib'),
]
vnl_128_mode_binary.sources += [
'src/utils/plat_win.cpp'
]
vnl_128_mode_binary.sources += [
os.path.join(sdk['path'], 'entity2', 'entityidentity.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitysystem.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'schema.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'gameconfig.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'mode', 'kz_mode_vnl-128.cpp'),
]
# Style binaries
style_binary = MMSPlugin.HL2Library(builder, cxx, f"{MMSPlugin.plugin_name}-style-autobhop", sdk)
if style_binary.compiler.family == 'gcc' or style_binary.compiler.family == 'clang':
style_binary.compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
if style_binary.compiler.family == 'clang':
style_binary.compiler.cxxflags += ['-Wno-register', '-frtti', '-Wno-invalid-offsetof', '-Wno-parentheses']
style_binary.compiler.cxxincludes += CXXINCLUDES
if style_binary.compiler.target.platform == 'linux':
style_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'linux64', 'mathlib.a'),
]
style_binary.sources += [
'src/utils/plat_linux.cpp'
]
elif style_binary.compiler.target.platform == 'windows':
style_binary.compiler.postlink += [
os.path.join(sdk['path'], 'lib', 'public', 'win64', 'mathlib.lib'),
]
style_binary.sources += [
'src/utils/plat_win.cpp'
]
style_binary.sources += [
os.path.join(sdk['path'], 'entity2', 'entityidentity.cpp'),
os.path.join(sdk['path'], 'entity2', 'entitysystem.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'schema.cpp'),
os.path.join(builder.sourcePath, 'src', 'utils', 'gameconfig.cpp'),
os.path.join(builder.sourcePath, 'src', 'kz', 'style', 'kz_style_autobhop.cpp'),
]
protoc_builder = builder.tools.Protoc(protoc = sdk_target.protoc, sources = PROTOS)
protoc_builder.protoc.includes += [
os.path.join(sdk['path'], 'gcsdk'),
os.path.join(builder.sourcePath, 'protobuf')
]
binary.custom = [protoc_builder]
ckz_mode_binary.custom = [protoc_builder]
ckz_bind_mode_binary.custom = [protoc_builder]
vnl_128_mode_binary.custom = [protoc_builder]
style_binary.custom = [protoc_builder]
nodes = builder.Add(binary)
ckz_mode_nodes = builder.Add(ckz_mode_binary)
ckz_bind_mode_nodes = builder.Add(ckz_bind_mode_binary)
vnl_128_mode_nodes = builder.Add(vnl_128_mode_binary)
style_nodes = builder.Add(style_binary)
# If we are generating a VS project, make sure to add the modes in, and the build folder for linter.
if builder.options.generator == 'vs':
binary.sources += ckz_mode_binary.sources
binary.sources += ckz_bind_mode_binary.sources
binary.sources += vnl_128_mode_binary.sources
binary.sources += style_binary.sources
binary.compiler.cxxincludes += [os.path.join(builder.buildPath, MMSPlugin.plugin_name, f'{binary.compiler.target.platform}-{cxx.target.arch}')]
MMSPlugin.binaries += [nodes]
MMSPlugin.mode_binaries += [ckz_mode_nodes]
MMSPlugin.mode_binaries += [ckz_bind_mode_nodes]
MMSPlugin.mode_binaries += [vnl_128_mode_nodes]
MMSPlugin.style_binaries += [style_nodes]
# vim: filetype=python expandtab shiftwidth=2 tabstop=8 textwidth=99