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