-
Notifications
You must be signed in to change notification settings - Fork 20
/
AMBuilder
90 lines (75 loc) · 3.5 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
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os, sys
projectName = 'sourcetvmanager'
# smsdk_ext.cpp will be automatically added later
sourceFiles = [
'extension.cpp',
'commonhooks.cpp',
'natives.cpp',
'forwards.cpp',
'hltvserverwrapper.cpp',
'hltvdirectorwrapper.cpp',
'hltvclientwrapper.cpp',
]
# SM 1.10+ compilation changes
if os.path.isfile(os.path.join(Extension.sm_root, 'public', 'libudis86', 'decode.c')):
sourceFiles += [
os.path.join(Extension.sm_root, 'public', 'libudis86', 'decode.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'itab.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-att.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn-intel.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'syn.c'),
os.path.join(Extension.sm_root, 'public', 'libudis86', 'udis86.c')
]
###############
# Make sure to edit PackageScript, which copies your files to their appropriate locations
# Simple extensions do not need to modify past this point.
project = builder.LibraryProject(projectName + '.ext')
if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')):
# Use the copy included in the project
project.sources += [os.path.join('sdk', 'smsdk_ext.cpp')]
else:
# Use the copy included with SM 1.6 and newer
project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')]
project.sources += sourceFiles
for sdk_name in ['css', 'tf2', 'dods', 'hl2dm', 'csgo', 'l4d', 'l4d2']:
if sdk_name not in Extension.sdks:
continue
sdk = Extension.sdks[sdk_name]
for cxx in Extension.all_targets:
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
continue
binary = Extension.HL2Config(project, cxx, projectName + '.ext.' + sdk.ext, sdk, builder)
Extension.AddCDetour(binary)
compiler = binary.compiler
compiler.defines += ['HAVE_STRING_H'];
if sdk.name == 'csgo':
compiler.cxxincludes += [
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf')
]
if compiler.target.platform == 'linux':
if compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk.path, 'lib', 'linux64', 'release', 'libprotobuf.a')
else:
lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a')
elif compiler.target.platform == 'windows':
msvc_ver = compiler.version
vs_year = ''
if msvc_ver == 1800:
vs_year = '2013'
elif 1900 <= msvc_ver < 2000:
vs_year = '2015'
else:
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
winFolder = 'win64' if compiler.target.arch == 'x86_64' else 'win32'
config = 'debug' if 'DEBUG' in compiler.defines else 'release'
lib_path = os.path.join(sdk.path, 'lib', winFolder, config, 'vs' + vs_year, 'libprotobuf.lib')
compiler.linkflags.insert(0, binary.Dep(lib_path))
binary.sources += [
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'),
]
Extension.extensions = builder.Add(project)