-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAMBuildScript
179 lines (146 loc) · 3.97 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
172
173
174
175
176
177
178
179
import os
#
# Detect Metamod and HLSDK
#
def detectMetamod():
metamod_path = builder.options.metamod_path
if not len(metamod_path):
metamod_path = os.getenv('METAMOD', '')
if len(metamod_path):
metamod_path = os.path.join(builder.originalCwd, metamod_path)
if not os.path.exists(os.path.join(metamod_path, 'metamod')):
raise Exception('Metamod path does not exist: {0}'.format(metamod_path))
else:
try_paths = [
os.path.join(builder.sourcePath, '..', 'metamod'),
os.path.join(builder.sourcePath, '..', 'metamod-am'),
os.path.join(builder.sourcePath, '..', 'metamod-hl1'),
]
for try_path in try_paths:
if os.path.exists(os.path.join(try_path, 'metamod')):
metamod_path = os.path.normpath(try_path)
break
if not metamod_path:
raise Exception('Could not find the source code to Metamod! Try passing --metamod to configure.py.')
return metamod_path
def detectHlsdk():
hlsdk_path = builder.options.hlsdk_path
if not len(hlsdk_path):
hlsdk_path = os.getenv('HLSDK', '')
if len(hlsdk_path):
hlsdk_path = os.path.join(builder.originalCwd, hlsdk_path)
if not os.path.exists(hlsdk_path):
raise Exception('Metamod path does not exist: {0}'.format(hlsdk_path))
else:
try_paths = [
os.path.join(builder.sourcePath, '..', 'hlsdk'),
]
for try_path in try_paths:
if os.path.exists(try_path):
hlsdk_path = os.path.normpath(try_path)
break
if not hlsdk_path:
raise Exception('Could not find the HLSDK! Try passing --hlsdk to configure.py.')
return hlsdk_path
metamod_path = detectMetamod()
hlsdk_path = detectHlsdk()
#
# Compiler settings
#
cxx = builder.DetectCompilers()
cxx.defines += [
'HAVE_STDINT_H'
]
if cxx.like('gcc'):
cxx.cflags += [
'-Wall',
#'-Werror',
'-Wno-write-strings',
'-Wno-error=unused-result',
'-Wno-error=unused-variable',
'-Wno-unused-value',
'-fno-strict-aliasing',
'-fPIC',
'-msse2',
'-m32'
]
cxx.cxxflags += [
'-std=gnu++14',
'-fno-exceptions',
'-fno-rtti'
]
cxx.linkflags += [
'-m32'
]
if builder.options.opt == '1':
cxx.cflags += ['-O2']
elif cxx.like('msvc'):
cxx.cflags += [
'/W3'
]
cxx.cxxflags += [
'/std:c++14',
'/arch:SSE2',
'/EHsc'
]
cxx.linkflags += [
'/MACHINE:X86',
'/SUBSYSTEM:WINDOWS',
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'kernel32.lib'
]
if builder.options.opt == '1':
cxx.cflags += ['/O2']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
if builder.options.debug == '1':
cxx.cflags += ['/MTd', '/Od', '/RTC1']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
else:
cxx.cflags += ['/MT']
# Optimization
if builder.options.opt == '1':
cxx.defines += ['NDEBUG']
# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']
cxx.includes += [
os.path.join(metamod_path, 'metamod'),
os.path.join(hlsdk_path, 'common'),
os.path.join(hlsdk_path, 'public'),
os.path.join(hlsdk_path, 'engine'),
os.path.join(hlsdk_path, 'dlls'),
os.path.join(hlsdk_path, 'game_shared'),
os.path.join(hlsdk_path, 'pm_shared'),
]
name = 'admin_mm'
if builder.target_platform == 'linux':
name += ''
binary = cxx.Library(name)
binary.sources += [
'S-line/dlls/adminmod/dll.cpp',
'S-line/dlls/adminmod/h_export.cpp',
'S-line/dlls/adminmod/util.cpp',
'S-line/dlls/adminmod/admin_commands.cpp',
'S-line/dlls/adminmod/users.cpp',
'S-line/dlls/adminmod/cbase.cpp',
'S-line/dlls/adminmod/timer.cpp',
'S-line/dlls/adminmod/CLinkList.cpp',
'S-line/dlls/adminmod/CPlugin.cpp',
'S-line/dlls/adminmod/admin_mod.cpp',
'S-line/dlls/adminmod/version.cpp',
'S-line/dlls/adminmod/sutils.cpp',
'S-line/dlls/adminmod/statics.cpp',
'S-line/dlls/adminmod/authid.cpp',
'S-line/dlls/adminmod/amutil.cpp',
'S-line/dlls/adminmod/AmFSNode.cpp'
]
#builder.RunBuildScripts(
# [
# 'Bsp2Rbn/AMBuilder',
# ],
# #{ 'AMXX': AMXX }
#)
#
# Run scripts, add binaries
#
builder.Add(binary)