AMBuildScript
author Dr!fter <drifter01620@gmail.com>
Sat Aug 16 22:29:47 2014 -0400 (2014-08-16)
changeset 79 c782ba2e5b1b
parent 73 dd05779903ed
child 81 a01509fee076
permissions -rw-r--r--
Set temporary enviroment variables.
[email protected]
     1
# vim: set ts=2 sw=2 tw=99 noet ft=python:
[email protected]
     2
import os
[email protected]
     3
import sys
[email protected]
     4
from ambuild.command import SymlinkCommand
[email protected]
     5
[email protected]
     6
class Stripper:
[email protected]
     7
	def __init__(self):
[email protected]
     8
		self.compiler = Cpp.Compiler()
[email protected]
     9
[email protected]
    10
		#Build SDK info
[email protected]
    11
		self.sdkInfo = { }
[email protected]
    12
		self.sdkInfo['ep1'] =   {'sdk': 'HL2SDK',          'ext': '14.ep1',   'def': '1',
[email protected]
    13
		                         'name': 'EPISODEONE',     'platform': ['windows', 'linux']}
[email protected]
    14
		
[email protected]
    15
		self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM',    'ext': '16.darkm', 'def': '2',
[email protected]
    16
		                         'name': 'DARKMESSIAH',    'platform': ['windows']}
[email protected]
    17
					 
[email protected]
    18
		self.sdkInfo['ep2'] =   {'sdk': 'HL2SDKOB',        'ext': '16.ep2',   'def': '3',
[email protected]
    19
		                         'name': 'ORANGEBOX',      'platform': ['windows', 'linux']}
[email protected]
    20
								 
[email protected]
    21
		self.sdkInfo['bgt'] =   {'sdk': 'HL2SDK-BGT',      'ext': '16.bgt', 'def': '4',
[email protected]
    22
		                         'name': 'BLOODYGOODTIME', 'platform': ['windows']}
[email protected]
    23
[email protected]
    24
		self.sdkInfo['css'] =   {'sdk': 'HL2SDKCSS',       'ext': '16.css',   'def': '6',
[email protected]
    25
		                         'name': 'CSS',            'platform': ['windows', 'linux', 'darwin']}
[email protected]
    26
								 
[email protected]
    27
		self.sdkInfo['hl2dm'] = {'sdk': 'HL2SDKHL2DM',     'ext': '16.hl2dm', 'def': '7',
[email protected]
    28
		                         'name': 'HL2DM',          'platform': ['windows', 'linux', 'darwin']}
[email protected]
    29
								 
[email protected]
    30
		self.sdkInfo['dods'] =  {'sdk': 'HL2SDKDODS',      'ext': '16.dods',  'def': '8',
[email protected]
    31
		                         'name': 'DODS',           'platform': ['windows', 'linux', 'darwin']}
[email protected]
    32
								 
[email protected]
    33
		self.sdkInfo['tf2'] =   {'sdk': 'HL2SDKTF2',       'ext': '16.tf2',   'def': '9',
[email protected]
    34
		                         'name': 'TF2',            'platform': ['windows', 'linux', 'darwin']}
[email protected]
    35
								 
[email protected]
    36
		self.sdkInfo['l4d'] =   {'sdk': 'HL2SDKL4D',       'ext': '16.l4d',   'def': '10',
[email protected]
    37
		                         'name': 'LEFT4DEAD',      'platform': ['windows', 'linux', 'darwin']}
[email protected]
    38
								 
[email protected]
    39
		self.sdkInfo['nd'] =    {'sdk': 'HL2SDKND',        'ext': '16.nd',    'def': '11',
[email protected]
    40
		                         'name': 'NUCLEARDAWN',    'platform': ['windows', 'linux', 'darwin']}
[email protected]
    41
								 
[email protected]
    42
		self.sdkInfo['l4d2'] =  {'sdk': 'HL2SDKL4D2',      'ext': '16.l4d2',  'def': '12',
[email protected]
    43
		                         'name': 'LEFT4DEAD2',     'platform': ['windows', 'linux', 'darwin']}
[email protected]
    44
								 
[email protected]
    45
		self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM',    'ext': '16.swarm', 'def': '13',
[email protected]
    46
		                         'name': 'ALIENSWARM',     'platform': ['windows']}
[email protected]
    47
								 
[email protected]
    48
		self.sdkInfo['csgo'] =  {'sdk': 'HL2SDKCSGO',     'ext': '16.csgo',   'def': '15',
[email protected]
    49
		                         'name': 'CSGO',           'platform': ['windows', 'linux', 'darwin']}
[email protected]
    50
								 
[email protected]
    51
		if AMBuild.mode == 'config':
[email protected]
    52
			#Detect compilers
[email protected]
    53
			self.compiler.DetectAll(AMBuild)
[email protected]
    54
[email protected]
    55
			#Detect variables
[email protected]
    56
			envvars = { 'MMSOURCE110':   'mmsource-1.10',
[email protected]
    57
						'HL2SDKHL2DM': 	'hl2sdk-hl2dm',
[email protected]
    58
						'HL2SDKDODS': 	'hl2sdk-dods',
[email protected]
    59
						'HL2SDKTF2': 	'hl2sdk-tf2',
[email protected]
    60
						'HL2SDKND': 	'hl2sdk-nd',
[email protected]
    61
						'HL2SDKL4D': 	'hl2sdk-l4d',
[email protected]
    62
						'HL2SDKL4D2': 	'hl2sdk-l4d2',
[email protected]
    63
						'HL2SDKCSGO': 	'hl2sdk-csgo',
[email protected]
    64
						'HL2SDKCSS':    'hl2sdk-css',
[email protected]
    65
			}
[email protected]
    66
[email protected]
    67
			if AMBuild.target['platform'] != 'darwin':
[email protected]
    68
				envvars['HL2SDK'] = 'hl2sdk'
[email protected]
    69
				envvars['HL2SDKOB'] = 'hl2sdk-ob'
[email protected]
    70
[email protected]
    71
			#Dark Messiah is Windows-only
[email protected]
    72
			if AMBuild.target['platform'] == 'windows':
[email protected]
    73
				envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
[email protected]
    74
				envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
[email protected]
    75
				envvars['HL2SDK-BGT']   = 'hl2sdk-bgt'
[email protected]
    76
[email protected]
    77
			#Must have a path for each envvar (file a bug if you don't like this)
[email protected]
    78
			for i in envvars:
[email protected]
    79
				if i in os.environ:
[email protected]
    80
					path = os.environ[i]
[email protected]
    81
					if not os.path.isdir(path):
[email protected]
    82
						raise Exception('Path for {0} was not found: {1}'.format(i, path))
[email protected]
    83
				else:
[email protected]
    84
					head = os.getcwd()
[email protected]
    85
					oldhead = None
[email protected]
    86
					while head != None and head != oldhead:
[email protected]
    87
						path = os.path.join(head, envvars[i])
[email protected]
    88
						if os.path.isdir(path):
[email protected]
    89
							break
[email protected]
    90
						oldhead = head
[email protected]
    91
						head, tail = os.path.split(head)
[email protected]
    92
					if head == None or head == oldhead:
[email protected]
    93
						raise Exception('Could not find a valid path for {0}'.format(i))
[email protected]
    94
				AMBuild.cache.CacheVariable(i, path)
[email protected]
    95
[email protected]
    96
			#Set up defines
[email protected]
    97
			cxx = self.compiler.cxx
[email protected]
    98
			if isinstance(cxx, Cpp.CompatGCC):
[email protected]
    99
				if isinstance(cxx, Cpp.GCC):
[email protected]
   100
					self.vendor = 'gcc'
[email protected]
   101
				elif isinstance(cxx, Cpp.Clang):
[email protected]
   102
					self.vendor = 'clang'
[email protected]
   103
				self.compiler.AddToListVar('CDEFINES', 'POSIX')
[email protected]
   104
				self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
[email protected]
   105
				self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
[email protected]
   106
				self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
[email protected]
   107
				self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
[email protected]
   108
				self.compiler.AddToListVar('CFLAGS', '-pipe')
[email protected]
   109
				self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
[email protected]
   110
				if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
[email protected]
   111
					self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
[email protected]
   112
					self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
[email protected]
   113
				self.compiler.AddToListVar('CFLAGS', '-Wall')
[email protected]
   114
				self.compiler.AddToListVar('CFLAGS', '-Werror')
[email protected]
   115
				self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized')
[email protected]
   116
				self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
[email protected]
   117
				self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
[email protected]
   118
				self.compiler.AddToListVar('CFLAGS', '-msse')
[email protected]
   119
				self.compiler.AddToListVar('CFLAGS', '-m32')
[email protected]
   120
				self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
[email protected]
   121
				self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
[email protected]
   122
				self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
[email protected]
   123
				self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
[email protected]
   124
				self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
[email protected]
   125
				self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
[email protected]
   126
				if (self.vendor == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \
[email protected]
   127
						(self.vendor == 'clang' and cxx.majorVersion >= 3):
[email protected]
   128
					self.compiler.AddToListVar('CXXFLAGS', '-Wno-delete-non-virtual-dtor')
[email protected]
   129
				self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H')
[email protected]
   130
				if self.vendor == 'gcc':
[email protected]
   131
					self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
[email protected]
   132
			elif isinstance(cxx, Cpp.MSVC):
[email protected]
   133
				self.vendor = 'msvc'
[email protected]
   134
				if AMBuild.options.debug == '1':
[email protected]
   135
					self.compiler.AddToListVar('CFLAGS', '/MTd')
[email protected]
   136
					self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt')
[email protected]
   137
				else:
[email protected]
   138
					self.compiler.AddToListVar('CFLAGS', '/MT')
[email protected]
   139
				self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE')
[email protected]
   140
				self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_WARNINGS')
[email protected]
   141
				self.compiler.AddToListVar('CDEFINES', '_CRT_NONSTDC_NO_DEPRECATE')
[email protected]
   142
				self.compiler.AddToListVar('CXXFLAGS', '/EHsc')
[email protected]
   143
				self.compiler.AddToListVar('CXXFLAGS', '/GR-')
[email protected]
   144
				self.compiler.AddToListVar('CFLAGS', '/W3')
[email protected]
   145
				self.compiler.AddToListVar('CFLAGS', '/nologo')
[email protected]
   146
				self.compiler.AddToListVar('CFLAGS', '/Zi')
[email protected]
   147
				self.compiler.AddToListVar('CXXFLAGS', '/TP')
[email protected]
   148
				self.compiler.AddToListVar('POSTLINKFLAGS', '/DEBUG')
[email protected]
   149
				self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X86')
[email protected]
   150
				self.compiler.AddToListVar('POSTLINKFLAGS', '/SUBSYSTEM:WINDOWS')
[email protected]
   151
				self.compiler.AddToListVar('POSTLINKFLAGS', 'kernel32.lib')
[email protected]
   152
				self.compiler.AddToListVar('POSTLINKFLAGS', 'user32.lib')
[email protected]
   153
				self.compiler.AddToListVar('POSTLINKFLAGS', 'gdi32.lib')
[email protected]
   154
				self.compiler.AddToListVar('POSTLINKFLAGS', 'winspool.lib')
[email protected]
   155
				self.compiler.AddToListVar('POSTLINKFLAGS', 'comdlg32.lib')
[email protected]
   156
				self.compiler.AddToListVar('POSTLINKFLAGS', 'advapi32.lib')
[email protected]
   157
				self.compiler.AddToListVar('POSTLINKFLAGS', 'shell32.lib')
[email protected]
   158
				self.compiler.AddToListVar('POSTLINKFLAGS', 'ole32.lib')
[email protected]
   159
				self.compiler.AddToListVar('POSTLINKFLAGS', 'oleaut32.lib')
[email protected]
   160
				self.compiler.AddToListVar('POSTLINKFLAGS', 'uuid.lib')
[email protected]
   161
				self.compiler.AddToListVar('POSTLINKFLAGS', 'odbc32.lib')
[email protected]
   162
				self.compiler.AddToListVar('POSTLINKFLAGS', 'odbccp32.lib')
[email protected]
   163
[email protected]
   164
			#Optimization
[email protected]
   165
			if AMBuild.options.opt == '1':
[email protected]
   166
				self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
[email protected]
   167
				if self.vendor == 'gcc' or self.vendor == 'clang':
[email protected]
   168
					self.compiler.AddToListVar('CFLAGS', '-O3')
[email protected]
   169
				elif self.vendor == 'msvc':
[email protected]
   170
					self.compiler.AddToListVar('CFLAGS', '/Ox')
[email protected]
   171
					self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF')
[email protected]
   172
					self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF')
[email protected]
   173
[email protected]
   174
			#Debugging
[email protected]
   175
			if AMBuild.options.debug == '1':
[email protected]
   176
				self.compiler.AddToListVar('CDEFINES', 'DEBUG')
[email protected]
   177
				self.compiler.AddToListVar('CDEFINES', '_DEBUG')
[email protected]
   178
				if self.vendor == 'gcc' or self.vendor == 'clang':
[email protected]
   179
					self.compiler.AddToListVar('CFLAGS', '-g3')
[email protected]
   180
				elif self.vendor == 'msvc':
[email protected]
   181
					self.compiler.AddToListVar('CFLAGS', '/Od')
[email protected]
   182
					self.compiler.AddToListVar('CFLAGS', '/RTC1')
[email protected]
   183
[email protected]
   184
			#Platform-specifics
[email protected]
   185
			if AMBuild.target['platform'] == 'linux':
[email protected]
   186
				self.compiler.AddToListVar('CDEFINES', '_LINUX')
[email protected]
   187
				if self.vendor == 'gcc':
[email protected]
   188
					self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc')
[email protected]
   189
				if self.vendor == 'clang':
[email protected]
   190
					self.compiler.AddToListVar('POSTLINKFLAGS', '-lgcc_eh')
[email protected]
   191
			elif AMBuild.target['platform'] == 'darwin':
[email protected]
   192
				self.compiler.AddToListVar('POSTLINKFLAGS', '-mmacosx-version-min=10.5')
[email protected]
   193
				self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'i386'])
[email protected]
   194
				self.compiler.AddToListVar('POSTLINKFLAGS', '-lstdc++')
[email protected]
   195
[email protected]
   196
				# For OS X dylib versioning
[email protected]
   197
				import re
[email protected]
   198
				productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
[email protected]
   199
				productContents = productFile.read()
[email protected]
   200
				productFile.close()
[email protected]
   201
				m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
[email protected]
   202
				if m == None:
[email protected]
   203
					self.version = '1.0.0'
[email protected]
   204
				else:
[email protected]
   205
					major, minor, release = m.groups()
[email protected]
   206
					self.version = '{0}.{1}.{2}'.format(major, minor, release)
[email protected]
   207
				AMBuild.cache.CacheVariable('version', self.version)
[email protected]
   208
			elif AMBuild.target['platform'] == 'windows':
[email protected]
   209
				self.compiler.AddToListVar('CDEFINES', 'WIN32')
[email protected]
   210
				self.compiler.AddToListVar('CDEFINES', '_WINDOWS')
[email protected]
   211
[email protected]
   212
			#Finish up
[email protected]
   213
			self.compiler.AddToListVar('CDEFINES', 'STRIPPER_GENERATED_BUILD')
[email protected]
   214
			self.compiler.AddToListVar('CINCLUDES',
[email protected]
   215
			                           os.path.join(AMBuild.outputFolder, 'includes'))
[email protected]
   216
			self.compiler.ToConfig(AMBuild, 'compiler')
[email protected]
   217
			AMBuild.cache.CacheVariable('vendor', self.vendor)
[email protected]
   218
			self.targetMap = { }
[email protected]
   219
			AMBuild.cache.CacheVariable('targetMap', self.targetMap)
[email protected]
   220
		else:
[email protected]
   221
			self.compiler.FromConfig(AMBuild, 'compiler')
[email protected]
   222
			self.targetMap = AMBuild.cache['targetMap']
[email protected]
   223
[email protected]
   224
		if AMBuild.target['platform'] == 'windows':
[email protected]
   225
			self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'public'))
[email protected]
   226
			self.compiler.AddToListVar('RCINCLUDES',
[email protected]
   227
			                           os.path.join(AMBuild.outputFolder, 'includes'))
[email protected]
   228
		self.mmsPath = AMBuild.cache['MMSOURCE110']
[email protected]
   229
[email protected]
   230
	def DefaultCompiler(self):
[email protected]
   231
		compiler = self.compiler.Clone()
[email protected]
   232
		compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, 'core', 'sourcehook'))
[email protected]
   233
		return compiler
[email protected]
   234
[email protected]
   235
	def JobMatters(self, jobname):
[email protected]
   236
		file = sys._getframe().f_code.co_filename
[email protected]
   237
		if AMBuild.mode == 'config':
[email protected]
   238
			self.targetMap[jobname] = file
[email protected]
   239
			return True
[email protected]
   240
		if len(AMBuild.args) == 0:
[email protected]
   241
			return True
[email protected]
   242
		if not jobname in AMBuild.args:
[email protected]
   243
			return False
[email protected]
   244
[email protected]
   245
	def AutoVersion(self, folder, binary):
[email protected]
   246
		if AMBuild.target['platform'] == 'windows':
[email protected]
   247
			env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'STRIPPER_GENERATED_BUILD']}
[email protected]
   248
			binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env)
[email protected]
   249
		elif AMBuild.target['platform'] == 'darwin' and isinstance(binary, Cpp.LibraryBuilder):
[email protected]
   250
			binary.compiler['POSTLINKFLAGS'].extend(['-compatibility_version', '1.0.0'])
[email protected]
   251
			binary.compiler['POSTLINKFLAGS'].extend(['-current_version', AMBuild.cache['version']])
[email protected]
   252
		else:
[email protected]
   253
			return
[email protected]
   254
[email protected]
   255
	def PreSetupHL2Job(self, job, builder, sdk):
[email protected]
   256
		info = self.sdkInfo[sdk]
[email protected]
   257
		sdkPath = AMBuild.cache[info['sdk']]
[email protected]
   258
		if AMBuild.target['platform'] == 'linux':
[email protected]
   259
			if sdk == 'ep1':
[email protected]
   260
				staticLibs = os.path.join(sdkPath, 'linux_sdk')
[email protected]
   261
			else:
[email protected]
   262
				staticLibs = os.path.join(sdkPath, 'lib', 'linux')
[email protected]
   263
			workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
[email protected]
   264
			if sdk in ['tf2', 'css', 'l4d2', 'hl2dm', 'dods', 'nd']:
[email protected]
   265
				libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib_srv.so', 'libtier0_srv.so']
[email protected]
   266
				for lib in libs:
[email protected]
   267
					link = os.path.join(workFolder, lib)
[email protected]
   268
					target = os.path.join(staticLibs, lib)
[email protected]
   269
					try:
[email protected]
   270
						os.lstat(link)
[email protected]
   271
					except:
[email protected]
   272
						job.AddCommand(SymlinkCommand(link, target))
[email protected]
   273
			elif sdk in ['l4d', 'csgo']:
[email protected]
   274
				libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.so', 'libtier0.so']
[email protected]
   275
				if sdk == 'csgo':
[email protected]
   276
					libs.append('interfaces_i486.a')
[email protected]
   277
				for lib in libs:
[email protected]
   278
					link = os.path.join(workFolder, lib)
[email protected]
   279
					target = os.path.join(staticLibs, lib)
[email protected]
   280
					try:
[email protected]
   281
						os.lstat(link)
[email protected]
   282
					except:
[email protected]
   283
						job.AddCommand(SymlinkCommand(link, target))
[email protected]
   284
			else:
[email protected]
   285
				libs = ['tier1_i486.a', 'mathlib_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']
[email protected]
   286
				for lib in libs:
[email protected]
   287
					link = os.path.join(workFolder, lib)
[email protected]
   288
					target = os.path.join(staticLibs, lib)
[email protected]
   289
					try:
[email protected]
   290
						os.lstat(link)
[email protected]
   291
					except:
[email protected]
   292
						job.AddCommand(SymlinkCommand(link, target))
[email protected]
   293
		elif AMBuild.target['platform'] == 'darwin':
[email protected]
   294
			staticLibs = os.path.join(sdkPath, 'lib', 'mac')
[email protected]
   295
			workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
[email protected]
   296
			libs = ['tier1_i486.a', 'mathlib_i486.a', 'libvstdlib.dylib', 'libtier0.dylib']
[email protected]
   297
			if sdk == 'csgo':
[email protected]
   298
				libs.append('interfaces_i486.a')
[email protected]
   299
			for lib in libs:
[email protected]
   300
				link = os.path.join(workFolder, lib)
[email protected]
   301
				target = os.path.join(staticLibs, lib)
[email protected]
   302
				try:
[email protected]
   303
					os.lstat(link)
[email protected]
   304
				except:
[email protected]
   305
					job.AddCommand(SymlinkCommand(link, target))
[email protected]
   306
		elif AMBuild.target['platform'] == 'windows':
[email protected]
   307
			libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
[email protected]
   308
			if sdk in ['swarm', 'csgo']:
[email protected]
   309
				libs.append('interfaces')
[email protected]
   310
			for lib in libs:
[email protected]
   311
				libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib'
[email protected]
   312
				builder.RebuildIfNewer(libPath)
[email protected]
   313
				builder['POSTLINKFLAGS'].append(libPath)
[email protected]
   314
[email protected]
   315
	def PostSetupHL2Job(self, job, builder, sdk):
[email protected]
   316
		if AMBuild.target['platform'] in ['linux', 'darwin']:
[email protected]
   317
			builder.AddObjectFiles(['tier1_i486.a', 'mathlib_i486.a'])
[email protected]
   318
			if sdk == 'csgo':
[email protected]
   319
				builder.AddObjectFiles(['interfaces_i486.a'])
[email protected]
   320
[email protected]
   321
	def DefaultHL2Compiler(self, path, sdk, noLink = False, oldMms = '-legacy'):
[email protected]
   322
		compiler = self.DefaultCompiler()
[email protected]
   323
[email protected]
   324
		mms = 'core'
[email protected]
   325
		if sdk == 'ep1':
[email protected]
   326
			mms += oldMms
[email protected]
   327
[email protected]
   328
		compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms))
[email protected]
   329
		compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms, 'sourcehook'))
[email protected]
   330
[email protected]
   331
		info = self.sdkInfo
[email protected]
   332
		compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info])
[email protected]
   333
[email protected]
   334
		paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],
[email protected]
   335
						 ['public', 'tier0'], ['public', 'tier1']]
[email protected]
   336
		if sdk == 'ep1' or sdk == 'darkm':
[email protected]
   337
			paths.append(['public', 'dlls'])
[email protected]
   338
			paths.append(['game_shared'])
[email protected]
   339
		else:
[email protected]
   340
			paths.append(['public', 'game', 'server'])
[email protected]
   341
			paths.append(['game', 'shared'])
[email protected]
   342
			paths.append(['common'])
[email protected]
   343
[email protected]
   344
		info = self.sdkInfo[sdk]
[email protected]
   345
		sdkPath = AMBuild.cache[info['sdk']]
[email protected]
   346
[email protected]
   347
		compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def'])
[email protected]
   348
[email protected]
   349
		if sdk in ['swarm','csgo']:
[email protected]
   350
			if AMBuild.target['platform'] == 'windows':
[email protected]
   351
				compiler['CDEFINES'].extend(['COMPILER_MSVC', 'COMPILER_MSVC32'])
[email protected]
   352
			else:
[email protected]
   353
				compiler['CDEFINES'].extend(['COMPILER_GCC', 'POSIX'])
[email protected]
   354
[email protected]
   355
		if sdk == 'ep1':
[email protected]
   356
			if AMBuild.target['platform'] == 'linux':
[email protected]
   357
				staticLibs = os.path.join(sdkPath, 'linux_sdk')
[email protected]
   358
		else:
[email protected]
   359
			if AMBuild.target['platform'] == 'linux':
[email protected]
   360
				staticLibs = os.path.join(sdkPath, 'lib', 'linux')
[email protected]
   361
			elif AMBuild.target['platform'] == 'darwin':
[email protected]
   362
				staticLibs = os.path.join(sdkPath, 'lib', 'mac')
[email protected]
   363
[email protected]
   364
		for i in paths:
[email protected]
   365
			compiler['CXXINCLUDES'].append(os.path.join(sdkPath, *i))
[email protected]
   366
[email protected]
   367
		if not noLink:
[email protected]
   368
			if AMBuild.target['platform'] == 'linux':
[email protected]
   369
				compiler['POSTLINKFLAGS'][0:0] = ['-lm']
[email protected]
   370
				if sdk in ['tf2', 'css', 'l4d2', 'hl2dm', 'dods', 'nd']:
[email protected]
   371
					compiler['POSTLINKFLAGS'][0:0] = ['libtier0_srv.so']
[email protected]
   372
					compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib_srv.so']
[email protected]
   373
				elif sdk in ['l4d', 'csgo']:
[email protected]
   374
					compiler['POSTLINKFLAGS'][0:0] = ['libtier0.so']
[email protected]
   375
					compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.so']
[email protected]
   376
				else:
[email protected]
   377
					compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so']
[email protected]
   378
					compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so']
[email protected]
   379
			elif AMBuild.target['platform'] == 'darwin':
[email protected]
   380
				compiler['POSTLINKFLAGS'][0:0] = ['libtier0.dylib']
[email protected]
   381
				compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.dylib']
[email protected]
   382
[email protected]
   383
		return compiler
[email protected]
   384
[email protected]
   385
stripper = Stripper()
[email protected]
   386
globals = {
[email protected]
   387
	'Stripper': stripper
[email protected]
   388
}
[email protected]
   389
[email protected]
   390
AMBuild.Include(os.path.join('buildbot', 'Versioning'), globals)
[email protected]
   391
[email protected]
   392
FileList = [
[email protected]
   393
		['AMBuilder'],
[email protected]
   394
		['gameshim', 'AMBuilder'],
[email protected]
   395
		['loader', 'AMBuilder'],
[email protected]
   396
		['PackageScript']
[email protected]
   397
	]
[email protected]
   398
[email protected]
   399
for parts in FileList:
[email protected]
   400
	AMBuild.Include(os.path.join(*parts), globals)
[email protected]
   401