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