Repository navigation
Expand file tree
/
Copy pathAMBuildScript
More file actions
131 lines (106 loc) · 3.57 KB
/
Copy pathAMBuildScript
File metadata and controls
131 lines (106 loc) · 3.57 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
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
from ambuild2 import util
class SDKConfig(object):
def __init__(self):
self.libs = []
self.targets = []
if builder.options.targets:
target_archs = builder.options.targets.split(',')
else:
target_archs = ['x86_64']
for arch in target_archs:
cxx = builder.DetectCxx(target_arch = arch)
self.targets.append(cxx)
@property
def tag(self):
if builder.options.debug == '1':
return 'Debug'
return 'Release'
def configure_cxx(self, cxx):
if cxx.like('gcc'):
self.configure_gcc(cxx)
elif cxx.family == 'msvc':
self.configure_msvc(cxx)
# Optimization
if builder.options.opt == '1':
cxx.defines += ['NDEBUG']
# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']
cxx.defines += ['X64BITS', 'PLATFORM_64BITS', '_LIB']
# Platform-specifics
if cxx.target.platform == 'linux':
self.configure_linux(cxx)
elif cxx.target.platform == 'windows':
self.configure_windows(cxx)
def configure_gcc(self, cxx):
cxx.cflags += [
'-Wall',
'-Werror',
'-Wno-overloaded-virtual',
'-Wno-non-virtual-dtor',
'-Wno-delete-non-virtual-dtor',
'-Wno-invalid-offsetof',
'-Wno-unknown-pragmas',
'-Wno-unused',
'-Wno-narrowing',
'-Wno-register',
'-fPIC'
]
cxx.defines += [
'COMPILER_GCC'
]
cxx.cxxflags += [
'-std=c++20'
]
if builder.options.opt == '1':
cxx.cflags += ['-O3']
if builder.options.debug == '1':
cxx.cflags += ['-g3']
def configure_msvc(self, cxx):
cxx.defines += ['COMPILER_MSVC', 'COMPILER_MSVC64']
cxx.cxxflags += [
'/std:c++20'
]
if builder.options.opt == '1':
cxx.cflags += ['/Ox', '/Zo']
if builder.options.debug == '1':
cxx.cflags += ['/MTd', '/Od', '/RTC1']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
# The game is built without iterator debugging, which changes the layout of STL types,
# like the strings in protobuf messages that plugins share with the game
cxx.defines += ['_ITERATOR_DEBUG_LEVEL=0']
def configure_linux(self, cxx):
cxx.defines += ['_LINUX', 'LINUX', 'POSIX', 'GNUC']
cxx.cflags += ['-march=nocona', '-mmmx', '-msse', '-msse2']
# Set of defines required by the HL2SDK
cxx.defines += [
'_finite=finite',
'stricmp=strcasecmp', '_stricmp=strcasecmp',
'strnicmp=strncasecmp', '_strnicmp=strncasecmp',
'strcmpi=strcasecmp',
'_vsnprintf=vsnprintf',
'_alloca=alloca'
]
def configure_windows(self, cxx):
cxx.defines += ['_WINDOWS', 'WINDOWS', 'WIN32', 'WIN64', '_CRT_SECURE_NO_DEPRECATE', '_CRT_NONSTDC_NO_DEPRECATE']
def configure(self):
for cxx in self.targets:
self.configure_cxx(cxx)
def ConfigureLibrary(self, project, compiler, context):
binary = project.Configure(compiler, project.name, '{0} - {1}'.format(self.tag, compiler.target.arch))
binary.compiler.cxxincludes += [
os.path.join(context.sourcePath, 'public'),
os.path.join(context.sourcePath, 'public', 'tier0'),
os.path.join(context.sourcePath, 'public', 'tier1')
]
return binary
HL2SDK = SDKConfig()
HL2SDK.configure()
BuildScripts = ['interfaces/AMBuilder', 'mathlib/AMBuilder', 'thirdparty/protobuf-3.21.8/AMBuilder', 'PackageScript']
if builder.options.hl2sdk_manifests:
BuildScripts += ['CheckScript']
# Turn off the 'lib' prefix for all platform, we will add it if we need to
util.StaticLibPrefix = ''
builder.Build(BuildScripts, { 'HL2SDK': HL2SDK })