Upgrade build scripts to AMBuild 2 (bug 5970, r=ds).
authorDavid Anderson <dvander@alliedmods.net>
Mon Nov 18 09:46:46 2013 -0800 (2013-11-18)
changeset 870004b1437bd14
parent 869 77495cf8aa58
child 871 d1853b81049e
Upgrade build scripts to AMBuild 2 (bug 5970, r=ds).
AMBuildScript
configure.py
core-legacy/AMBuilder
core/AMBuilder
loader/AMBuilder
support/buildbot/PackageScript
support/buildbot/Versioning
support/buildbot/bootstrap.pl
support/buildbot/generate_headers.py
support/buildbot/startbuild.pl
     1.1 --- a/AMBuildScript	Thu Oct 24 13:30:44 2013 -0400
     1.2 +++ b/AMBuildScript	Mon Nov 18 09:46:46 2013 -0800
     1.3 @@ -1,450 +1,370 @@
     1.4 -# vim: set ts=2 sw=2 tw=99 noet ft=python:
     1.5 -import os
     1.6 -import sys
     1.7 -from ambuild.command import SymlinkCommand
     1.8 -
     1.9 -class MMS:
    1.10 -	def __init__(self):
    1.11 -		self.compiler = Cpp.Compiler()
    1.12 -
    1.13 -		#Build SDK info
    1.14 -		self.possibleSdks = { }
    1.15 -		self.possibleSdks['ep1'] =   {'sdk': 'HL2SDK',          'ext': '1.ep1',      'def': '1',
    1.16 -		                         'name': 'EPISODEONE',     'platform': ['windows', 'linux'],
    1.17 -		                         'dir': 'hl2sdk'}
    1.18 -		self.possibleSdks['ep2'] =   {'sdk': 'HL2SDKOB',        'ext': '2.ep2',      'def': '3',
    1.19 -		                         'name': 'ORANGEBOX',      'platform': ['windows', 'linux'],
    1.20 -		                         'dir': 'hl2sdk-ob'}
    1.21 -		self.possibleSdks['css'] =   {'sdk': 'HL2SDKCSS',       'ext': '2.css',     'def': '6',
    1.22 -		                         'name': 'CSS',            'platform': ['windows', 'linux', 'darwin'],
    1.23 -		                         'dir': 'hl2sdk-css'}
    1.24 -		self.possibleSdks['hl2dm'] = {'sdk': 'HL2SDKHL2DM',     'ext': '2.hl2dm',   'def': '7',
    1.25 -		                         'name': 'HL2DM',          'platform': ['windows', 'linux', 'darwin'],
    1.26 -		                         'dir': 'hl2sdk-hl2dm'}
    1.27 -		self.possibleSdks['dods'] =  {'sdk': 'HL2SDKDODS',      'ext': '2.dods',    'def': '8',
    1.28 -		                         'name': 'DODS',           'platform': ['windows', 'linux', 'darwin'],
    1.29 -		                         'dir': 'hl2sdk-dods'}
    1.30 -		self.possibleSdks['sdk2013'] =  {'sdk': 'HL2SDK2013',   'ext': '2.sdk2013', 'def': '9',
    1.31 -		                         'name': 'SDK2013',        'platform': ['windows', 'linux', 'darwin'],
    1.32 -		                         'dir': 'hl2sdk-2013'}
    1.33 -		self.possibleSdks['tf2'] =   {'sdk': 'HL2SDKTF2',       'ext': '2.tf2',     'def': '10',
    1.34 -		                         'name': 'TF2',            'platform': ['windows', 'linux', 'darwin'],
    1.35 -		                         'dir': 'hl2sdk-tf2'}
    1.36 -		self.possibleSdks['l4d'] =   {'sdk': 'HL2SDKL4D',       'ext': '2.l4d',     'def': '11',
    1.37 -		                         'name': 'LEFT4DEAD',      'platform': ['windows', 'linux', 'darwin'],
    1.38 -		                         'dir': 'hl2sdk-l4d'}
    1.39 -		self.possibleSdks['nd'] =    {'sdk': 'HL2SDKND',        'ext': '2.nd',      'def': '12',
    1.40 -		                         'name': 'NUCLEARDAWN',    'platform': ['windows', 'linux', 'darwin'],
    1.41 -		                         'dir': 'hl2sdk-nd'}
    1.42 -		self.possibleSdks['l4d2'] =  {'sdk': 'HL2SDKL4D2',      'ext': '2.l4d2',    'def': '13',
    1.43 -		                         'name': 'LEFT4DEAD2',     'platform': ['windows', 'linux', 'darwin'],
    1.44 -		                         'dir': 'hl2sdk-l4d2'}
    1.45 -		self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM',    'ext': '2.darkm',   'def': '2',
    1.46 -		                         'name': 'DARKMESSIAH',    'platform': ['windows'],
    1.47 -		                          'dir': 'hl2sdk-darkm'}
    1.48 -		self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM',    'ext': '2.swarm',   'def': '14',
    1.49 -		                         'name': 'ALIENSWARM',     'platform': ['windows'],
    1.50 -		                         'dir': 'hl2sdk-swarm'}
    1.51 -		self.possibleSdks['bgt'] =   {'sdk': 'HL2SDK-BGT',      'ext': '2.bgt',     'def': '4',
    1.52 -		                         'name': 'BLOODYGOODTIME', 'platform': ['windows'],
    1.53 -		                         'dir': 'hl2sdk-bgt'}
    1.54 -		self.possibleSdks['eye'] =   {'sdk': 'HL2SDK-EYE',      'ext': '2.eye',     'def': '5',
    1.55 -		                         'name': 'EYE',            'platform': ['windows'],
    1.56 -		                         'dir': 'hl2sdk-eye'}
    1.57 -		self.possibleSdks['csgo'] =  {'sdk': 'HL2SDKCSGO',     'ext': '2.csgo',     'def': '18',
    1.58 -		                         'name': 'CSGO',           'platform': ['windows', 'linux', 'darwin'],
    1.59 -		                         'dir': 'hl2sdk-csgo'}
    1.60 -		self.possibleSdks['dota'] =  {'sdk': 'HL2SDKDOTA',     'ext': '2.dota',     'def': '19',
    1.61 -		                         'name': 'DOTA',           'platform': ['windows'],
    1.62 -		                         'dir': 'hl2sdk-dota'}
    1.63 -		self.possibleSdks['portal2'] = {'sdk': 'HL2SDKPORTAL2','ext': '2.portal2',  'def': '15',
    1.64 -		                         'name': 'PORTAL2',        'platform': [],
    1.65 -		                         'dir': 'hl2sdk-portal2'}
    1.66 -		self.possibleSdks['blade'] =   {'sdk': 'HL2SDKBLADE',  'ext': '2.blade',    'def': '16',
    1.67 -		                         'name': 'BLADE',          'platform': ['windows', 'linux'],
    1.68 -		                         'dir': 'hl2sdk-blade'}
    1.69 -		self.possibleSdks['insurgency'] = {'sdk': 'HL2SDKINSURGENCY', 'ext': '2.insurgency', 'def': '17',
    1.70 -		                         'name': 'INSURGENCY',     'platform': ['windows', 'linux', 'darwin'],
    1.71 -		                         'dir': 'hl2sdk-insurgency'}
    1.72 -		
    1.73 -		self.sdkInfo = { }
    1.74 -		
    1.75 -		if AMBuild.mode == 'config':
    1.76 -			#Detect compilers
    1.77 -			self.compiler.DetectAll(AMBuild)
    1.78 -
    1.79 -			#Look for SDK directories
    1.80 -			for sdk in self.possibleSdks:
    1.81 -				#Get list of SDKs to build against or 'all' or 'present'
    1.82 -				sdkList = AMBuild.options.sdks.split(',')
    1.83 -				#Build against all supported SDKs?
    1.84 -				useAll = sdkList[0] == 'all'
    1.85 -				#Build against supported SDKs that exist?
    1.86 -				usePresent = sdkList[0] == 'present'
    1.87 -
    1.88 -				info = self.possibleSdks[sdk]
    1.89 -				if AMBuild.target['platform'] in info['platform']:
    1.90 -					env = info['sdk']
    1.91 -					dir = info['dir']
    1.92 -					sdkPath = self.ResolveEnvPath(env, dir)
    1.93 -					if sdkPath == None:
    1.94 -						if useAll or sdk in sdkList:
    1.95 -							raise Exception('Could not find a valid path for {0}'.format(env))
    1.96 -						else:
    1.97 -							continue
    1.98 -					if useAll or usePresent or sdk in sdkList:
    1.99 -						self.sdkInfo[sdk] = info
   1.100 -						AMBuild.cache.CacheVariable(env, sdkPath)
   1.101 -
   1.102 -			if len(self.sdkInfo) < 1:
   1.103 -				raise Exception('At least one SDK must be available.')
   1.104 -				
   1.105 -			AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
   1.106 +# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
   1.107 +import os, sys
   1.108  
   1.109 -			#Set up defines
   1.110 -			cxx = self.compiler.cxx
   1.111 -			if isinstance(cxx, Cpp.CompatGCC):
   1.112 -				if isinstance(cxx, Cpp.GCC):
   1.113 -					self.vendor = 'gcc'
   1.114 -				elif isinstance(cxx, Cpp.Clang):
   1.115 -					self.vendor = 'clang'
   1.116 -				self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp')
   1.117 -				self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp')
   1.118 -				self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf')
   1.119 -				self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf')
   1.120 -				self.compiler.AddToListVar('CFLAGS', '-pipe')
   1.121 -				self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing')
   1.122 -				if (self.vendor == 'gcc' and cxx.majorVersion >= 4) or self.vendor == 'clang':
   1.123 -					self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden')
   1.124 -					self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden')
   1.125 -				self.compiler.AddToListVar('CFLAGS', '-Wall')
   1.126 -				self.compiler.AddToListVar('CFLAGS', '-Werror')
   1.127 -				self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized')
   1.128 -				self.compiler.AddToListVar('CFLAGS', '-Wno-unused')
   1.129 -				self.compiler.AddToListVar('CFLAGS', '-Wno-switch')
   1.130 -				self.compiler.AddToListVar('CFLAGS', '-msse')
   1.131 -				self.compiler.AddToListVar('CFLAGS', '-m32')
   1.132 -				self.compiler.AddToListVar('POSTLINKFLAGS', '-m32')
   1.133 -				self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions')
   1.134 -				self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti')
   1.135 -				self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics')
   1.136 -				self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor')
   1.137 -				self.compiler.AddToListVar('CXXFLAGS', '-Wno-overloaded-virtual')
   1.138 -				if (self.vendor == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \
   1.139 -						(self.vendor == 'clang' and cxx.majorVersion >= 3):
   1.140 -					self.compiler.AddToListVar('CXXFLAGS', '-Wno-delete-non-virtual-dtor')
   1.141 -				self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H')
   1.142 -				self.compiler.AddToListVar('CDEFINES', 'GNUC')
   1.143 -				if self.vendor == 'gcc':
   1.144 -					self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse')
   1.145 -			elif isinstance(cxx, Cpp.MSVC):
   1.146 -				self.vendor = 'msvc'
   1.147 -				if AMBuild.options.debug == '1':
   1.148 -					self.compiler.AddToListVar('CFLAGS', '/MTd')
   1.149 -					self.compiler.AddToListVar('POSTLINKFLAGS', '/NODEFAULTLIB:libcmt')
   1.150 -				else:
   1.151 -					self.compiler.AddToListVar('CFLAGS', '/MT')
   1.152 -				self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE')
   1.153 -				self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_WARNINGS')
   1.154 -				self.compiler.AddToListVar('CDEFINES', '_CRT_NONSTDC_NO_DEPRECATE')
   1.155 -				self.compiler.AddToListVar('CXXFLAGS', '/EHsc')
   1.156 -				self.compiler.AddToListVar('CXXFLAGS', '/GR-')
   1.157 -				self.compiler.AddToListVar('CFLAGS', '/W3')
   1.158 -				self.compiler.AddToListVar('CFLAGS', '/nologo')
   1.159 -				self.compiler.AddToListVar('CFLAGS', '/Zi')
   1.160 -				self.compiler.AddToListVar('CXXFLAGS', '/TP')
   1.161 -				self.compiler.AddToListVar('POSTLINKFLAGS', '/DEBUG')
   1.162 -				self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X86')
   1.163 -				self.compiler.AddToListVar('POSTLINKFLAGS', '/SUBSYSTEM:WINDOWS')
   1.164 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'kernel32.lib')
   1.165 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'user32.lib')
   1.166 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'gdi32.lib')
   1.167 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'winspool.lib')
   1.168 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'comdlg32.lib')
   1.169 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'advapi32.lib')
   1.170 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'shell32.lib')
   1.171 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'ole32.lib')
   1.172 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'oleaut32.lib')
   1.173 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'uuid.lib')
   1.174 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'odbc32.lib')
   1.175 -				self.compiler.AddToListVar('POSTLINKFLAGS', 'odbccp32.lib')
   1.176 -
   1.177 -			#Optimization
   1.178 -			if AMBuild.options.opt == '1':
   1.179 -				self.compiler.AddToListVar('CDEFINES', 'NDEBUG')
   1.180 -				if self.vendor == 'gcc' or self.vendor == 'clang':
   1.181 -					self.compiler.AddToListVar('CFLAGS', '-O3')
   1.182 -				elif self.vendor == 'msvc':
   1.183 -					self.compiler.AddToListVar('CFLAGS', '/Ox')
   1.184 -					self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF')
   1.185 -					self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:REF')
   1.186 -
   1.187 -			#Debugging
   1.188 -			if AMBuild.options.debug == '1':
   1.189 -				self.compiler.AddToListVar('CDEFINES', 'DEBUG')
   1.190 -				self.compiler.AddToListVar('CDEFINES', '_DEBUG')
   1.191 -				if self.vendor == 'gcc' or self.vendor == 'clang':
   1.192 -					self.compiler.AddToListVar('CFLAGS', '-g3')
   1.193 -				elif self.vendor == 'msvc':
   1.194 -					self.compiler.AddToListVar('CFLAGS', '/Od')
   1.195 -					self.compiler.AddToListVar('CFLAGS', '/RTC1')
   1.196 -			
   1.197 -			#This needs to be after our optimization flags which could otherwise disable it.
   1.198 -			if self.vendor == 'msvc':
   1.199 -				# Don't omit frame pointer
   1.200 -				self.compiler.AddToListVar('CFLAGS', '/Oy-')
   1.201 -
   1.202 -			#Platform-specifics
   1.203 -			if AMBuild.target['platform'] == 'linux':
   1.204 -				self.compiler.AddToListVar('CDEFINES', '_LINUX')
   1.205 -				self.compiler.AddToListVar('CDEFINES', 'POSIX')
   1.206 -				if self.vendor == 'gcc':
   1.207 -					self.compiler.AddToListVar('POSTLINKFLAGS', '-static-libgcc')
   1.208 -				if self.vendor == 'clang':
   1.209 -					self.compiler.AddToListVar('POSTLINKFLAGS', '-lgcc_eh')
   1.210 -			elif AMBuild.target['platform'] == 'darwin':
   1.211 -				self.compiler.AddToListVar('CDEFINES', 'OSX')
   1.212 -				self.compiler.AddToListVar('CDEFINES', '_OSX')
   1.213 -				self.compiler.AddToListVar('CDEFINES', 'POSIX')
   1.214 -				self.compiler.AddToListVar('POSTLINKFLAGS', '-mmacosx-version-min=10.5')
   1.215 -				self.compiler.AddToListVar('POSTLINKFLAGS', ['-arch', 'i386'])
   1.216 -				self.compiler.AddToListVar('POSTLINKFLAGS', '-lstdc++')
   1.217 +class SDK(object):
   1.218 +  def __init__(self, sdk, ext, aDef, name, platform, dir):
   1.219 +    if dir == 'ep1':
   1.220 +      folder = 'hl2sdk'
   1.221 +    else:
   1.222 +      folder = 'hl2sdk-' + dir
   1.223 +    self.envvar = sdk
   1.224 +    self.ext = ext
   1.225 +    self.code = aDef
   1.226 +    self.define = name
   1.227 +    self.platform = platform
   1.228 +    self.folder = folder # Default folder name.
   1.229 +    self.name = dir
   1.230 +    self.path = None # Actual path
   1.231  
   1.232 -				# For OS X dylib versioning
   1.233 -				import re
   1.234 -				productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
   1.235 -				productContents = productFile.read()
   1.236 -				productFile.close()
   1.237 -				m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
   1.238 -				if m == None:
   1.239 -					self.version = '1.0.0'
   1.240 -				else:
   1.241 -					major, minor, release = m.groups()
   1.242 -					self.version = '{0}.{1}.{2}'.format(major, minor, release)
   1.243 -				AMBuild.cache.CacheVariable('version', self.version)
   1.244 -			elif AMBuild.target['platform'] == 'windows':
   1.245 -				self.compiler.AddToListVar('CDEFINES', 'WIN32')
   1.246 -				self.compiler.AddToListVar('CDEFINES', '_WINDOWS')
   1.247 -
   1.248 -			#Finish up
   1.249 -			self.compiler.AddToListVar('CDEFINES', 'MMS_GENERATED_BUILD')
   1.250 -			self.compiler.AddToListVar('CINCLUDES',
   1.251 -			                           os.path.join(AMBuild.outputFolder, 'includes'))
   1.252 -			self.compiler.ToConfig(AMBuild, 'compiler')
   1.253 -			AMBuild.cache.CacheVariable('vendor', self.vendor)
   1.254 -			self.targetMap = { }
   1.255 -			AMBuild.cache.CacheVariable('targetMap', self.targetMap)
   1.256 -		else:
   1.257 -			self.sdkInfo = AMBuild.cache['sdkInfo']
   1.258 -			self.compiler.FromConfig(AMBuild, 'compiler')
   1.259 -			self.targetMap = AMBuild.cache['targetMap']
   1.260 -
   1.261 -		if AMBuild.target['platform'] == 'windows':
   1.262 -			self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'public'))
   1.263 -			self.compiler.AddToListVar('RCINCLUDES',
   1.264 -			                           os.path.join(AMBuild.outputFolder, 'includes'))
   1.265 -
   1.266 -	def DefaultCompiler(self):
   1.267 -		compiler = self.compiler.Clone()
   1.268 -		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public'))
   1.269 -		return compiler
   1.270 -
   1.271 -	def JobMatters(self, jobname):
   1.272 -		file = sys._getframe().f_code.co_filename
   1.273 -		if AMBuild.mode == 'config':
   1.274 -			self.targetMap[jobname] = file
   1.275 -			return True
   1.276 -		if len(AMBuild.args) == 0:
   1.277 -			return True
   1.278 -		if not jobname in AMBuild.args:
   1.279 -			return False
   1.280 -
   1.281 -	def AutoVersion(self, folder, binary):
   1.282 -		if AMBuild.target['platform'] == 'windows':
   1.283 -			env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'MMS_GENERATED_BUILD']}
   1.284 -			binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env)
   1.285 -		elif AMBuild.target['platform'] == 'darwin' and isinstance(binary, Cpp.LibraryBuilder):
   1.286 -			binary.compiler['POSTLINKFLAGS'].extend(['-compatibility_version', '1.0.0'])
   1.287 -			binary.compiler['POSTLINKFLAGS'].extend(['-current_version', AMBuild.cache['version']])
   1.288 -		else:
   1.289 -			return
   1.290 +WinOnly = ['windows']
   1.291 +WinLinux = ['windows', 'linux']
   1.292 +WinLinuxMac = ['windows', 'linux', 'mac']
   1.293  
   1.294 -	def PreSetupHL2Job(self, job, builder, sdk):
   1.295 -		info = self.sdkInfo[sdk]
   1.296 -		sdkPath = AMBuild.cache[info['sdk']]
   1.297 -		if AMBuild.target['platform'] == 'linux':
   1.298 -			if sdk == 'ep1':
   1.299 -				staticLibs = os.path.join(sdkPath, 'linux_sdk')
   1.300 -			elif sdk == 'sdk2013':
   1.301 -				staticLibs = os.path.join(sdkPath, 'lib', 'public', 'linux32')
   1.302 -			else:
   1.303 -				staticLibs = os.path.join(sdkPath, 'lib', 'linux')
   1.304 -			workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
   1.305 -			libs = []
   1.306 -			if sdk in ['css', 'hl2dm', 'dods', 'tf2', 'l4d2']:
   1.307 -				libs = ['tier1_i486.a', 'libvstdlib_srv.so', 'libtier0_srv.so']
   1.308 -			elif sdk in ['l4d', 'nd', 'blade', 'insurgency', 'csgo']:
   1.309 -				libs = ['tier1_i486.a', 'libvstdlib.so', 'libtier0.so']
   1.310 -				if sdk in ['blade', 'insurgency', 'csgo']:
   1.311 -					libs.insert(0, 'interfaces_i486.a')
   1.312 -			elif sdk == 'sdk2013':
   1.313 -				libs = ['tier1.a', 'libvstdlib_srv.so', 'libtier0_srv.so']
   1.314 -			else:
   1.315 -				libs = ['tier1_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']
   1.316 -			
   1.317 -			for lib in libs:
   1.318 -				link = os.path.join(workFolder, lib)
   1.319 -				target = os.path.join(staticLibs, lib)
   1.320 -				try:
   1.321 -					os.lstat(link)
   1.322 -				except:
   1.323 -					job.AddCommand(SymlinkCommand(link, target))
   1.324 -		elif AMBuild.target['platform'] == 'darwin':
   1.325 -			if sdk == 'sdk2013':
   1.326 -				staticLibs = os.path.join(sdkPath, 'lib', 'public', 'osx32')
   1.327 -				libs = ['tier1.a', 'libvstdlib.dylib', 'libtier0.dylib']
   1.328 -			else:
   1.329 -				staticLibs = os.path.join(sdkPath, 'lib', 'mac')
   1.330 -				libs = ['tier1_i486.a', 'libvstdlib.dylib', 'libtier0.dylib']
   1.331 -			workFolder = os.path.join(AMBuild.outputFolder, job.workFolder)
   1.332 -			if sdk in ['insurgency', 'csgo']:
   1.333 -				libs.append('interfaces_i486.a')
   1.334 -			for lib in libs:
   1.335 -				link = os.path.join(workFolder, lib)
   1.336 -				target = os.path.join(staticLibs, lib)
   1.337 -				try:
   1.338 -					os.lstat(link)
   1.339 -				except:
   1.340 -					job.AddCommand(SymlinkCommand(link, target))
   1.341 -		elif AMBuild.target['platform'] == 'windows':
   1.342 -			libs = ['tier0', 'tier1', 'vstdlib']
   1.343 -			if sdk in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
   1.344 -				libs.append('interfaces')
   1.345 -			for lib in libs:
   1.346 -				libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib'
   1.347 -				builder.RebuildIfNewer(libPath)
   1.348 -				builder['POSTLINKFLAGS'].append(libPath)
   1.349 -
   1.350 -	def PostSetupHL2Job(self, job, builder, sdk):
   1.351 -		if AMBuild.target['platform'] in ['linux', 'darwin']:
   1.352 -			if sdk == 'sdk2013':
   1.353 -				builder.AddObjectFiles(['tier1.a'])
   1.354 -			else:
   1.355 -				builder.AddObjectFiles(['tier1_i486.a'])
   1.356 -			
   1.357 -			if( sdk in ['blade', 'insurgency', 'csgo', 'dota'] ):
   1.358 -				builder.AddObjectFiles(['interfaces_i486.a'])
   1.359 -
   1.360 -	def DefaultHL2Compiler(self, path, sdk, noLink = False):
   1.361 -		compiler = self.DefaultCompiler()
   1.362 -
   1.363 -		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path))
   1.364 -		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path, 'sourcehook'))
   1.365 -		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'loader'))
   1.366 -
   1.367 -		info = self.possibleSdks
   1.368 -		compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info])
   1.369 -
   1.370 -		paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],
   1.371 -						 ['public', 'tier0'], ['public', 'tier1']]
   1.372 -		if sdk == 'ep1' or sdk == 'darkm':
   1.373 -			paths.append(['public', 'dlls'])
   1.374 -			paths.append(['game_shared'])
   1.375 -		else:
   1.376 -			paths.append(['public', 'game', 'server'])
   1.377 -			paths.append(['game', 'shared'])
   1.378 -			paths.append(['common'])
   1.379 -
   1.380 -		info = self.sdkInfo[sdk]
   1.381 -		sdkPath = AMBuild.cache[info['sdk']]
   1.382 -
   1.383 -		compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def'])
   1.384 -		
   1.385 -		if sdk == 'sdk2013' and isinstance(compiler.cxx, Cpp.CompatGCC):
   1.386 -			# The 2013 SDK already has these in public/tier0/basetypes.h
   1.387 -			compiler['CDEFINES'].remove('stricmp=strcasecmp')
   1.388 -			compiler['CDEFINES'].remove('_stricmp=strcasecmp')
   1.389 -			compiler['CDEFINES'].remove('_snprintf=snprintf')
   1.390 -			compiler['CDEFINES'].remove('_vsnprintf=vsnprintf')
   1.391 -
   1.392 -		if sdk in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
   1.393 -			if AMBuild.target['platform'] == 'windows':
   1.394 -				compiler['CDEFINES'].extend(['COMPILER_MSVC', 'COMPILER_MSVC32'])
   1.395 -			else:
   1.396 -				compiler['CDEFINES'].extend(['COMPILER_GCC'])
   1.397 -		
   1.398 -		if sdk == 'sdk2013' and AMBuild.target['platform'] == 'darwin':
   1.399 -			compiler['POSTLINKFLAGS'].append('-liconv')
   1.400 -		
   1.401 -		if sdk in ['css','hl2dm','dods','sdk2013','tf2','l4d2']:
   1.402 -			if AMBuild.target['platform'] == 'linux' or AMBuild.target['platform'] == 'darwin':
   1.403 -				compiler['CDEFINES'].append('NO_MALLOC_OVERRIDE')
   1.404 -
   1.405 -		if AMBuild.target['platform'] == 'linux':
   1.406 -			if sdk == 'ep1':
   1.407 -				staticLibs = os.path.join(sdkPath, 'linux_sdk')
   1.408 -			elif sdk == 'sdk2013':
   1.409 -				staticLibs = os.path.join(sdkPath, 'lib', 'public', 'linux32')
   1.410 -			else:
   1.411 -				staticLibs = os.path.join(sdkPath, 'lib', 'linux')
   1.412 -		elif AMBuild.target['platform'] == 'darwin':
   1.413 -			if sdk == 'sdk2013':
   1.414 -				staticLibs = os.path.join(sdkPath, 'lib', 'public', 'osx32')
   1.415 -			else:
   1.416 -				staticLibs = os.path.join(sdkPath, 'lib', 'mac')
   1.417 -
   1.418 -
   1.419 -		for i in paths:
   1.420 -			compiler['CXXINCLUDES'].append(os.path.join(sdkPath, *i))
   1.421 -
   1.422 -		if not noLink:
   1.423 -			if AMBuild.target['platform'] == 'linux':
   1.424 -				compiler['POSTLINKFLAGS'][0:0] = ['-lm']
   1.425 -				if sdk in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'l4d2']:
   1.426 -					compiler['POSTLINKFLAGS'][0:0] = ['libtier0_srv.so']
   1.427 -					compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib_srv.so']
   1.428 -				elif sdk in ['l4d', 'nd', 'blade', 'insurgency', 'csgo']:
   1.429 -					compiler['POSTLINKFLAGS'][0:0] = ['libtier0.so']
   1.430 -					compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.so']
   1.431 -				else:
   1.432 -					compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so']
   1.433 -					compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so']				
   1.434 -			elif AMBuild.target['platform'] == 'darwin':
   1.435 -				compiler['POSTLINKFLAGS'][0:0] = ['libtier0.dylib']
   1.436 -				compiler['POSTLINKFLAGS'][0:0] = ['libvstdlib.dylib']
   1.437 -
   1.438 -		return compiler
   1.439 -
   1.440 -	def ResolveEnvPath(self, env, defaultDir):
   1.441 -		if env in os.environ:
   1.442 -			path = os.environ[env]
   1.443 -			if os.path.isdir(path):
   1.444 -				return path
   1.445 -		else:
   1.446 -			head = os.getcwd()
   1.447 -			oldhead = None
   1.448 -			while head != None and head != oldhead:
   1.449 -				path = os.path.join(head, defaultDir)
   1.450 -				if os.path.isdir(path):
   1.451 -					return path
   1.452 -				oldhead = head
   1.453 -				head, tail = os.path.split(head)
   1.454 -		return None
   1.455 -
   1.456 -mms = MMS()
   1.457 -globals = {
   1.458 -	'MMS': mms
   1.459 +PossibleSDKs = {
   1.460 +  'ep1':  SDK('HL2SDK', '1.ep1', '1', 'EPISODEONE', WinLinux, 'ep1'),
   1.461 +  'ep2':  SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'ob'),
   1.462 +  'css':  SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
   1.463 +  'hl2dm':  SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
   1.464 +  'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
   1.465 +  'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, '2013'),
   1.466 +  'tf2':  SDK('HL2SDKTF2', '2.tf2', '10', 'TF2', WinLinuxMac, 'tf2'),
   1.467 +  'l4d':  SDK('HL2SDKL4D', '2.l4d', '11', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
   1.468 +  'nd': SDK('HL2SDKND', '2.nd', '12', 'NUCLEARDAWN', WinLinuxMac, 'nd'),
   1.469 +  'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '13', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
   1.470 +  'darkm':  SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
   1.471 +  'swarm':  SDK('HL2SDK-SWARM', '2.swarm', '14', 'ALIENSWARM', WinOnly, 'swarm'),
   1.472 +  'bgt':  SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
   1.473 +  'eye':  SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
   1.474 +  'csgo': SDK('HL2SDKCSGO', '2.csgo', '18', 'CSGO', WinLinuxMac, 'csgo'),
   1.475 +  'dota': SDK('HL2SDKDOTA', '2.dota', '19', 'DOTA', WinOnly, 'dota'),
   1.476 +  'portal2':  SDK('HL2SDKPORTAL2', '2.portal2', '15', 'PORTAL2', [], 'portal2'),
   1.477 +  'blade':  SDK('HL2SDKBLADE', '2.blade', '16', 'BLADE', WinLinux, 'blade'),
   1.478 +  'insurgency':  SDK('HL2SDKINSURGENCY', '2.insurgency', '17', 'INSURGENCY', WinLinuxMac, 'insurgency'),
   1.479  }
   1.480  
   1.481 -AMBuild.Include(os.path.join('support', 'buildbot', 'Versioning'), globals)
   1.482 +def ResolveEnvPath(env, folder):
   1.483 +  if env in os.environ:
   1.484 +    path = os.environ[env]
   1.485 +    if os.path.isdir(path):
   1.486 +      return path
   1.487 +  else:
   1.488 +    head = os.getcwd()
   1.489 +    oldhead = None
   1.490 +    while head != None and head != oldhead:
   1.491 +      path = os.path.join(head, folder)
   1.492 +      if os.path.isdir(path):
   1.493 +        return path
   1.494 +      oldhead = head
   1.495 +      head, tail = os.path.split(head)
   1.496 +  return None
   1.497 +
   1.498 +class MMSConfig(object):
   1.499 +  def __init__(self):
   1.500 +    self.sdks = {}
   1.501 +    self.binaries = []
   1.502 +    self.generated_headers = None
   1.503 +
   1.504 +  def detectProductVersion(self):
   1.505 +    builder.AddConfigureFile('product.version')
   1.506 +
   1.507 +    # For OS X dylib versioning
   1.508 +    import re
   1.509 +    with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp:
   1.510 +      productContents = fp.read()
   1.511 +    m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
   1.512 +    if m == None:
   1.513 +      self.productVersion = '1.0.0'
   1.514 +    else:
   1.515 +      major, minor, release = m.groups()
   1.516 +      self.productVersion = '{0}.{1}.{2}'.format(major, minor, release)
   1.517 +
   1.518 +  def detectSDKs(self):
   1.519 +    sdk_list = builder.options.sdks.split(',')
   1.520 +    use_all = sdk_list[0] == 'all'
   1.521 +    use_present = sdk_list[0] == 'present'
   1.522 +
   1.523 +    for sdk_name in PossibleSDKs:
   1.524 +      sdk = PossibleSDKs[sdk_name]
   1.525 +      if builder.target_platform in sdk.platform:
   1.526 +        sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
   1.527 +        if sdk_path is None:
   1.528 +          if use_all or sdk_name in sdk_list:
   1.529 +            raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
   1.530 +          continue
   1.531 +        if use_all or use_present or sdk_name in sdk_list:
   1.532 +          sdk.path = sdk_path
   1.533 +          self.sdks[sdk_name] = sdk
   1.534 +
   1.535 +    if len(self.sdks) < 1:
   1.536 +      raise Exception('At least one SDK must be available.')
   1.537 +
   1.538 +  def configure(self):
   1.539 +    cfg = builder.DetectCompilers()
   1.540 +    cxx = cfg.cxx
   1.541 +
   1.542 +    if cxx.behavior == 'gcc':
   1.543 +      cfg.defines += [
   1.544 +        'stricmp=strcasecmp',
   1.545 +        '_stricmp=strcasecmp',
   1.546 +        '_snprintf=snprintf',
   1.547 +        '_vsnprintf=vsnprintf',
   1.548 +        'HAVE_STDINT_H',
   1.549 +        'GNUC',
   1.550 +      ]
   1.551 +      cfg.cflags += [
   1.552 +        '-pipe',
   1.553 +        '-fno-strict-aliasing',
   1.554 +        '-Wall',
   1.555 +        '-Werror',
   1.556 +        '-Wno-uninitialized',
   1.557 +        '-Wno-unused',
   1.558 +        '-Wno-switch',
   1.559 +        '-msse',
   1.560 +        '-m32',
   1.561 +      ]
   1.562 +      if (cxx.name == 'gcc' and cxx.majorVersion >= 4) or cxx.name == 'clang':
   1.563 +        cfg.cflags += ['-fvisibility=hidden']
   1.564 +        cfg.cxxflags += ['-fvisibility-inlines-hidden']
   1.565 +      cfg.linkflags += ['-m32']
   1.566 +      cfg.cxxflags += [
   1.567 +        '-fno-exceptions',
   1.568 +        '-fno-rtti',
   1.569 +        '-fno-threadsafe-statics',
   1.570 +        '-Wno-non-virtual-dtor',
   1.571 +        '-Wno-overloaded-virtual',
   1.572 +      ]
   1.573 +      if (cxx.name == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \
   1.574 +          (cxx.name == 'clang' and cxx.majorVersion >= 3):
   1.575 +        cfg.cxxflags += ['-Wno-delete-non-virtual-dtor']
   1.576 +      if cxx.name == 'gcc':
   1.577 +        cfg.cflags += ['-mfpmath=sse']
   1.578 +
   1.579 +    elif cxx.name == 'msvc':
   1.580 +      if builder.options.debug == '1':
   1.581 +        cfg.cflags += ['/MTd']
   1.582 +        cfg.linkflags += ['/NODEFAULTLIB:libcmt']
   1.583 +      else:
   1.584 +        cfg.cflags += ['/MT']
   1.585 +      cfg.defines += [
   1.586 +        '_CRT_SECURE_NO_DEPRECATE',
   1.587 +        '_CRT_SECURE_NO_WARNINGS',
   1.588 +        '_CRT_NONSTDC_NO_DEPRECATE',
   1.589 +      ]
   1.590 +      cfg.cflags += [
   1.591 +        '/W3',
   1.592 +        '/Zi',
   1.593 +      ]
   1.594 +      cfg.cxxflags += ['/TP']
   1.595 +      cfg.linkflags += [
   1.596 +        '/MACHINE:X86',
   1.597 +        '/SUBSYSTEM:WINDOWS',
   1.598 +        'kernel32.lib',
   1.599 +        'user32.lib',
   1.600 +        'gdi32.lib',
   1.601 +        'winspool.lib',
   1.602 +        'comdlg32.lib',
   1.603 +        'advapi32.lib',
   1.604 +        'shell32.lib',
   1.605 +        'ole32.lib',
   1.606 +        'oleaut32.lib',
   1.607 +        'uuid.lib',
   1.608 +        'odbc32.lib',
   1.609 +        'odbccp32.lib',
   1.610 +      ] 
   1.611 +
   1.612 +    # Optimization
   1.613 +    if builder.options.opt == '1':
   1.614 +      cfg.defines += ['NDEBUG']
   1.615 +      if cxx.behavior == 'gcc':
   1.616 +        cfg.cflags += ['-O3']
   1.617 +      elif cxx.behavior == 'msvc':
   1.618 +        cfg.cflags += ['/Ox']
   1.619 +        cfg.linkflags += ['/OPT:ICF', '/OPT:REF']
   1.620 +
   1.621 +    # Debugging
   1.622 +    if builder.options.debug == '1':
   1.623 +      cfg.defines += ['DEBUG', '_DEBUG']
   1.624 +      if cxx.behavior == 'gcc':
   1.625 +        cfg.cflags += ['-g3']
   1.626 +      elif cxx.behavior == 'msvc':
   1.627 +        cfg.cflags += ['/Od, /RTC1']
   1.628 +
   1.629 +    # This needs to be after our optimization flags which could otherwise disable it.
   1.630 +    if cxx.name == 'msvc':
   1.631 +      # Don't omit the frame pointer.
   1.632 +      cfg.cflags += ['/Oy-']
   1.633  
   1.634 -FileList = [
   1.635 -		['loader', 'AMBuilder'],
   1.636 -		['core', 'AMBuilder'],
   1.637 -		['core-legacy', 'AMBuilder'],
   1.638 -		['support', 'buildbot', 'PackageScript']
   1.639 -	]
   1.640 +    # Platform-specifics
   1.641 +    if builder.target_platform == 'linux':
   1.642 +      cfg.defines += ['_LINUX', 'POSIX']
   1.643 +      if cxx.name == 'gcc':
   1.644 +        cfg.linkflags += ['-static-libgcc']
   1.645 +      elif cxx.name == 'clang':
   1.646 +        cfg.linkflags += ['-lgcc_eh']
   1.647 +    elif builder.target_platform == 'mac':
   1.648 +      cfg.defines += ['OSX', '_OSX', 'POSIX']
   1.649 +      cfg.linkflags += [
   1.650 +        '-mmacosx-version-min=10.5',
   1.651 +        '-arch', 'i386',
   1.652 +        '-lstdc++',
   1.653 +      ]
   1.654 +    elif builder.target_platform == 'windows':
   1.655 +      cfg.defines += ['WIN32', '_WINDOWS']
   1.656 +
   1.657 +    # Finish up.
   1.658 +    cfg.defines += ['MMS_GENERATED_BUILD']
   1.659 +    cfg.includes += [os.path.join(builder.buildPath, 'includes')]
   1.660 +    cfg.cxxincludes += [os.path.join(builder.sourcePath, 'public')]
   1.661 +
   1.662 +  def HL2Compiler(self, context, sdk):
   1.663 +    compiler = context.compiler.clone()
   1.664 +    compiler.cxxincludes += [
   1.665 +      os.path.join(context.currentSourcePath),
   1.666 +      os.path.join(context.currentSourcePath, 'sourcehook'),
   1.667 +      os.path.join(context.sourcePath, 'loader'),
   1.668 +    ]
   1.669 +
   1.670 +    defines = ['SE_' + self.sdks[i].define + '=' + self.sdks[i].code for i in self.sdks]
   1.671 +    compiler.defines += defines
   1.672 +    paths = [['public'],
   1.673 +             ['public', 'engine'],
   1.674 +             ['public', 'mathlib'],
   1.675 +             ['public', 'vstdlib'],
   1.676 +             ['public', 'tier0'], ['public', 'tier1']]
   1.677 +    if sdk.name == 'ep1' or sdk.name == 'darkm':
   1.678 +      paths.append(['public', 'dlls'])
   1.679 +      paths.append(['game_shared'])
   1.680 +    else:
   1.681 +      paths.append(['public', 'game', 'server'])
   1.682 +      paths.append(['game', 'shared'])
   1.683 +      paths.append(['common'])
   1.684 +
   1.685 +    compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
   1.686 +
   1.687 +    if sdk.name == '2013' and compiler.cxx.behavior == 'gcc':
   1.688 +      # The 2013 SDK already has these in public/tier0/basetypes.h
   1.689 +      compiler.defines.remove('stricmp=strcasecmp')
   1.690 +      compiler.defines.remove('_stricmp=strcasecmp')
   1.691 +      compiler.defines.remove('_snprintf=snprintf')
   1.692 +      compiler.defines.remove('_vsnprintf=vsnprintf')
   1.693 +
   1.694 +    if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
   1.695 +      if compiler.cc.behavior == 'msvc':
   1.696 +        compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
   1.697 +      else:
   1.698 +        compiler.defines += ['COMPILER_GCC']
   1.699 +
   1.700 +    if sdk.name in ['css', 'hl2dm', 'dods', '2013', 'tf2', 'l4d2']:
   1.701 +      if builder.target_platform in ['linux', 'mac']:
   1.702 +        compiler.defines += ['NO_MALLOC_OVERRIDE']
   1.703 +
   1.704 +    for path in paths:
   1.705 +      compiler.cxxincludes += [os.path.join(sdk.path, *path)]
   1.706 +
   1.707 +    compiler.sourcedeps += MMS.generated_headers
   1.708 +
   1.709 +    return compiler
   1.710 +
   1.711 +  def LibraryBuilder(self, compiler, name):
   1.712 +    binary = compiler.Library(name)
   1.713 +    if builder.target_platform == 'windows':
   1.714 +      binary.sources += ['version.rc']
   1.715 +      binary.compiler.rcdefines += [
   1.716 +        'BINARY_NAME="{0}"'.format(binary.outputFile),
   1.717 +        'MMS_GENERATED_BUILD'
   1.718 +      ]
   1.719 +    elif builder.target_platform == 'mac':
   1.720 +      binary.compiler.postlink += [
   1.721 +        '-compatibility_version', '1.0.0',
   1.722 +        '-current_version', self.productVersion
   1.723 +      ]
   1.724 +    return binary
   1.725  
   1.726 -for parts in FileList:
   1.727 -	AMBuild.Include(os.path.join(*parts), globals)
   1.728 +  def Library(self, context, name):
   1.729 +    compiler = context.compiler.clone()
   1.730 +    return self.LibraryBuilder(compiler, name)
   1.731 +
   1.732 +  def HL2Library(self, context, name, sdk):
   1.733 +    compiler = self.HL2Compiler(context, sdk)
   1.734 +
   1.735 +    if builder.target_platform == 'linux':
   1.736 +      if sdk.name == 'ep1':
   1.737 +        lib_folder = os.path.join(sdk.path, 'linux_sdk')
   1.738 +      elif sdk.name == '2013':
   1.739 +        lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
   1.740 +      else:
   1.741 +        lib_folder = os.path.join(sdk.path, 'lib', 'linux')
   1.742 +    elif builder.target_platform == 'mac':
   1.743 +      if sdk.name == '2013':
   1.744 +        lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
   1.745 +      else:
   1.746 +        lib_folder = os.path.join(sdk.path, 'lib', 'mac')
   1.747 +
   1.748 +    if builder.target_platform in ['linux', 'mac']:
   1.749 +      if sdk.name == '2013':
   1.750 +        compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1.a'))]
   1.751 +      else:
   1.752 +        compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1_i486.a'))]
   1.753 +
   1.754 +      if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']:
   1.755 +        compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
   1.756 +
   1.757 +    binary = self.LibraryBuilder(compiler, name)
   1.758  
   1.759 +    dynamic_libs = []
   1.760 +    if builder.target_platform == 'linux':
   1.761 +      compiler.linkflags[0:0] = ['-lm']
   1.762 +      if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', '2013', 'l4d2']:
   1.763 +        dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
   1.764 +      elif sdk.name in ['l4d', 'nd', 'blade', 'insurgency', 'csgo']:
   1.765 +        dynamic_libs = ['libtier0.so', 'libvstdlib.so']
   1.766 +      else:
   1.767 +        dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
   1.768 +    elif builder.target_platform == 'mac':
   1.769 +      binary.compiler.linkflags.append('-liconv')
   1.770 +      dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
   1.771 +    elif builder.target_platform == 'windows':
   1.772 +      libs = ['tier0', 'tier1', 'vstdlib']
   1.773 +      if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
   1.774 +        libs.append('interfaces')
   1.775 +      for lib in libs:
   1.776 +        lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
   1.777 +        binary.compiler.linkflags.append(binary.Dep(lib_path))
   1.778 +
   1.779 +    for library in dynamic_libs:
   1.780 +      source_path = os.path.join(lib_folder, library)
   1.781 +      output_path = os.path.join(binary.localFolder, library)
   1.782 +
   1.783 +      def make_linker(source_path, output_path):
   1.784 +        def link(context, binary):
   1.785 +          cmd_node, (output,) = context.AddSymlink(source_path, output_path)
   1.786 +          return output
   1.787 +        return link
   1.788 +
   1.789 +      linker = make_linker(source_path, output_path)
   1.790 +      binary.compiler.linkflags[0:0] = [binary.Dep(library, linker)]
   1.791 +
   1.792 +    return binary
   1.793 +
   1.794 +MMS = MMSConfig()
   1.795 +MMS.detectProductVersion()
   1.796 +MMS.detectSDKs()
   1.797 +MMS.configure()
   1.798 +
   1.799 +MMS.generated_headers = builder.RunScript(
   1.800 +  'support/buildbot/Versioning',
   1.801 +  { 'MMS': MMS }
   1.802 +)
   1.803 +
   1.804 +builder.RunBuildScripts(
   1.805 +  [
   1.806 +    'loader/AMBuilder',
   1.807 +    'core-legacy/AMBuilder',
   1.808 +    'core/AMBuilder',
   1.809 +    'support/buildbot/PackageScript',
   1.810 +  ],
   1.811 +  {
   1.812 +    'MMS': MMS
   1.813 +  }
   1.814 +)
   1.815 +
     2.1 --- a/configure.py	Thu Oct 24 13:30:44 2013 -0400
     2.2 +++ b/configure.py	Mon Nov 18 09:46:46 2013 -0800
     2.3 @@ -1,8 +1,19 @@
     2.4 -# vim: set ts=2 sw=2 tw=99 noet:
     2.5 +# vim: set sts=2 ts=8 sw=2 tw=99 et:
     2.6  import sys
     2.7 -import ambuild.runner as runner
     2.8 +try:
     2.9 +	from ambuild2 import run
    2.10 +except:
    2.11 +	try:
    2.12 +		import ambuild
    2.13 +		sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
    2.14 +		sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
    2.15 +	except:
    2.16 +		sys.stderr.write('AMBuild must be installed to build this project.\n')
    2.17 +		sys.stderr.write('http://www.alliedmods.net/ambuild\n')
    2.18 +	sys.exit(1)
    2.19  
    2.20 -run = runner.Runner()
    2.21 +run = run.PrepareBuild(sourcePath=sys.path[0])
    2.22 +run.default_build_folder = 'obj-' + run.target_platform
    2.23  run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
    2.24                         help='Enable debugging symbols')
    2.25  run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
    2.26 @@ -10,4 +21,4 @@
    2.27  run.options.add_option('-s', '--sdks', default='all', dest='sdks',
    2.28                         help='Build against specified SDKs; valid args are "all", "present", or '
    2.29                              'comma-delimited list of engine names (default: %default)')
    2.30 -run.Configure(sys.path[0])
    2.31 +run.Configure()
     3.1 --- a/core-legacy/AMBuilder	Thu Oct 24 13:30:44 2013 -0400
     3.2 +++ b/core-legacy/AMBuilder	Mon Nov 18 09:46:46 2013 -0800
     3.3 @@ -1,31 +1,20 @@
     3.4 -# vim: set ts=2 sw=2 tw=99 noet ft=python: 
     3.5 +# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 
     3.6  import os
     3.7  
     3.8 -try:
     3.9 -	sdk = MMS.sdkInfo['ep1']
    3.10 -	
    3.11 -	if AMBuild.target['platform'] in sdk['platform']:
    3.12 -		compiler = MMS.DefaultHL2Compiler('core-legacy', 'ep1')
    3.13 -
    3.14 -		name = 'metamod.' + sdk['ext']
    3.15 -
    3.16 -		extension = AMBuild.AddJob(name)
    3.17 -		binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
    3.18 -		MMS.PreSetupHL2Job(extension, binary, 'ep1')
    3.19 -		files = [
    3.20 -			'sourcemm.cpp',
    3.21 -			'concommands.cpp',
    3.22 -			'oslink.cpp',
    3.23 -			'util.cpp',
    3.24 -			'CSmmAPI.cpp',
    3.25 -			'CPlugin.cpp',
    3.26 -			'gamedll_bridge.cpp',
    3.27 -			'vsp_bridge.cpp',
    3.28 -			'sourcehook/sourcehook.cpp'
    3.29 -			]
    3.30 -		binary.AddSourceFiles('core-legacy', files)
    3.31 -		MMS.PostSetupHL2Job(extension, binary, 'ep1')
    3.32 -		MMS.AutoVersion('core-legacy', binary)
    3.33 -		binary.SendToJob()
    3.34 -except KeyError:
    3.35 -	pass
    3.36 +if 'ep1' in MMS.sdks:
    3.37 +  sdk = MMS.sdks['ep1']
    3.38 +  name = 'metamod.' + sdk.ext
    3.39 +  binary = MMS.HL2Library(builder, name, sdk)
    3.40 +  binary.sources += [
    3.41 +    'sourcemm.cpp',
    3.42 +    'concommands.cpp',
    3.43 +    'oslink.cpp',
    3.44 +    'util.cpp',
    3.45 +    'CSmmAPI.cpp',
    3.46 +    'CPlugin.cpp',
    3.47 +    'gamedll_bridge.cpp',
    3.48 +    'vsp_bridge.cpp',
    3.49 +    'sourcehook/sourcehook.cpp',
    3.50 +  ]
    3.51 +  nodes = builder.Add(binary)
    3.52 +  MMS.binaries += [nodes]
     4.1 --- a/core/AMBuilder	Thu Oct 24 13:30:44 2013 -0400
     4.2 +++ b/core/AMBuilder	Mon Nov 18 09:46:46 2013 -0800
     4.3 @@ -1,37 +1,30 @@
     4.4 -# vim: set ts=2 sw=2 tw=99 noet ft=python: 
     4.5 +# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 
     4.6  import os
     4.7  
     4.8 -for i in MMS.sdkInfo:
     4.9 -	sdk = MMS.sdkInfo[i]
    4.10 -	if AMBuild.target['platform'] not in sdk['platform'] or i == 'ep1':
    4.11 -		continue
    4.12 +for sdk_name in MMS.sdks:
    4.13 +  sdk = MMS.sdks[sdk_name]
    4.14 +  if sdk.name == 'ep1':
    4.15 +    continue
    4.16  
    4.17 -	name = 'metamod.' + sdk['ext']
    4.18 -
    4.19 -	compiler = MMS.DefaultHL2Compiler('core', i)
    4.20 +  name = 'metamod.' + sdk.ext
    4.21 +  binary = MMS.HL2Library(builder, name, sdk)
    4.22  
    4.23 -	extension = AMBuild.AddJob(name)
    4.24 -	binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
    4.25 -	MMS.PreSetupHL2Job(extension, binary, i)
    4.26 -	files = [
    4.27 -		'metamod.cpp',
    4.28 -		'metamod_console.cpp',
    4.29 -		'metamod_oslink.cpp',
    4.30 -		'metamod_plugins.cpp',
    4.31 -		'metamod_util.cpp',
    4.32 -		'provider/console.cpp',
    4.33 -		'provider/provider_ep2.cpp',
    4.34 -		'sourcehook/sourcehook.cpp',
    4.35 -		'sourcehook/sourcehook_hookmangen.cpp',
    4.36 -		'sourcehook/sourcehook_impl_chookidman.cpp',
    4.37 -		'sourcehook/sourcehook_impl_chookmaninfo.cpp',
    4.38 -		'sourcehook/sourcehook_impl_cproto.cpp',
    4.39 -		'sourcehook/sourcehook_impl_cvfnptr.cpp',
    4.40 -		'gamedll_bridge.cpp',
    4.41 -		'vsp_bridge.cpp'
    4.42 -		]
    4.43 -	binary.AddSourceFiles('core', files)
    4.44 -	MMS.PostSetupHL2Job(extension, binary, i)
    4.45 -	MMS.AutoVersion('core', binary)
    4.46 -	binary.SendToJob()
    4.47 -
    4.48 +  binary.sources += [
    4.49 +    'metamod.cpp',
    4.50 +    'metamod_console.cpp',
    4.51 +    'metamod_oslink.cpp',
    4.52 +    'metamod_plugins.cpp',
    4.53 +    'metamod_util.cpp',
    4.54 +    'provider/console.cpp',
    4.55 +    'provider/provider_ep2.cpp',
    4.56 +    'sourcehook/sourcehook.cpp',
    4.57 +    'sourcehook/sourcehook_hookmangen.cpp',
    4.58 +    'sourcehook/sourcehook_impl_chookidman.cpp',
    4.59 +    'sourcehook/sourcehook_impl_chookmaninfo.cpp',
    4.60 +    'sourcehook/sourcehook_impl_cproto.cpp',
    4.61 +    'sourcehook/sourcehook_impl_cvfnptr.cpp',
    4.62 +    'gamedll_bridge.cpp',
    4.63 +    'vsp_bridge.cpp'
    4.64 +  ]
    4.65 +  nodes = builder.Add(binary)
    4.66 +  MMS.binaries += [nodes]
     5.1 --- a/loader/AMBuilder	Thu Oct 24 13:30:44 2013 -0400
     5.2 +++ b/loader/AMBuilder	Mon Nov 18 09:46:46 2013 -0800
     5.3 @@ -1,31 +1,22 @@
     5.4 -# vim: set ts=2 sw=2 tw=99 noet ft=python: 
     5.5 +# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: 
     5.6  import os.path
     5.7  
     5.8 -compiler = MMS.DefaultCompiler()
     5.9 -compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'core', 'sourcehook'))
    5.10 -compiler2 = compiler.Clone()
    5.11 -
    5.12 -files = [
    5.13 -	'loader.cpp',
    5.14 -	'gamedll.cpp',
    5.15 -	'serverplugin.cpp',
    5.16 -	'utility.cpp'
    5.17 -	]
    5.18 +def configure_library(name, linux_defines):
    5.19 +  binary = MMS.Library(builder, name)
    5.20 +  binary.compiler.cxxincludes += [os.path.join(builder.sourcePath, 'core', 'sourcehook')]
    5.21 +  binary.sources += [
    5.22 +    'loader.cpp',
    5.23 +    'gamedll.cpp',
    5.24 +    'serverplugin.cpp',
    5.25 +    'utility.cpp',
    5.26 +  ]
    5.27  
    5.28 -name = 'server'
    5.29 -loader = AMBuild.AddJob(name)
    5.30 -binary = Cpp.LibraryBuilder(name, AMBuild, loader, compiler)
    5.31 -if AMBuild.target['platform'] == 'linux':
    5.32 -	compiler['CDEFINES'].extend(['LIB_PREFIX=\"lib\"', 'LIB_SUFFIX=\".so\"'])
    5.33 -binary.AddSourceFiles('loader', files)
    5.34 -MMS.AutoVersion('loader', binary)
    5.35 -binary.SendToJob()
    5.36 +  if builder.target_platform == 'linux':
    5.37 +    binary.compiler.defines += linux_defines
    5.38  
    5.39 -if AMBuild.target['platform'] == 'linux':
    5.40 -	name = 'server_i486'
    5.41 -	loader = AMBuild.AddJob(name)
    5.42 -	binary = Cpp.LibraryBuilder(name, AMBuild, loader, compiler2)
    5.43 -	compiler2['CDEFINES'].extend(['LIB_PREFIX=\"\"', 'LIB_SUFFIX=\"_i486.so\"'])
    5.44 -	binary.AddSourceFiles('loader', files)
    5.45 -	MMS.AutoVersion('loader', binary)
    5.46 -	binary.SendToJob()
    5.47 +  nodes = builder.Add(binary)
    5.48 +  MMS.binaries += [nodes]
    5.49 +
    5.50 +configure_library('server', ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"'])
    5.51 +if builder.target_platform == 'linux':
    5.52 +  configure_library('server_i486', ['LIB_PREFIX=""', 'LIB_SUFFIX="_i486.so"'])
     6.1 --- a/support/buildbot/PackageScript	Thu Oct 24 13:30:44 2013 -0400
     6.2 +++ b/support/buildbot/PackageScript	Mon Nov 18 09:46:46 2013 -0800
     6.3 @@ -1,114 +1,25 @@
     6.4  # vim: set ts=2 sw=2 tw=99 noet ft=python: 
     6.5  import os
     6.6 -import shutil
     6.7 -import ambuild.osutil as osutil
     6.8 -from ambuild.command import Command
     6.9  
    6.10 -job = AMBuild.AddJob('package')
    6.11 -
    6.12 -class DestroyPath(Command):
    6.13 -	def __init__(self, folder):
    6.14 -		Command.__init__(self)
    6.15 -		self.folder = folder
    6.16 -
    6.17 -	def destroy(self, path):
    6.18 -		entries = os.listdir(path)
    6.19 -		for entry in entries:
    6.20 -			newpath = os.path.join(path, entry)
    6.21 -			if os.path.isdir(newpath):
    6.22 -				self.destroy(newpath)
    6.23 -				os.rmdir(newpath)
    6.24 -			elif os.path.isfile(newpath):
    6.25 -				os.remove(newpath)
    6.26 -
    6.27 -	def run(self, runner, job):
    6.28 -		runner.PrintOut('rm -rf {0}/*'.format(self.folder))
    6.29 -		self.destroy(self.folder)
    6.30 -
    6.31 -class CreateFolders(Command):
    6.32 -	def __init__(self, folders):
    6.33 -		Command.__init__(self)
    6.34 -		self.folders = folders
    6.35 -	
    6.36 -	def run(self, runner, job):
    6.37 -		for folder in self.folders:
    6.38 -			path = os.path.join(*folder)
    6.39 -			runner.PrintOut('mkdir {0}'.format(path))
    6.40 -			os.makedirs(path)
    6.41 +builder.SetBuildFolder('package')
    6.42  
    6.43 -#Shallow folder copy
    6.44 -class CopyFolder(Command):
    6.45 -	def __init__(self, fromList, toList, excludes = []):
    6.46 -		Command.__init__(self)
    6.47 -		self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
    6.48 -		self.toPath = os.path.join(*toList) 
    6.49 -		self.excludes = excludes
    6.50 -	
    6.51 -	def run(self, runner, job):
    6.52 -		entries = os.listdir(self.fromPath)
    6.53 -		for entry in entries:
    6.54 -			if entry in self.excludes:
    6.55 -				continue
    6.56 -			path = os.path.join(self.fromPath, entry)
    6.57 -			if not os.path.isfile(path):
    6.58 -				continue
    6.59 -			runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
    6.60 -			shutil.copy(path, self.toPath)
    6.61 -
    6.62 -#Single file copy
    6.63 -class CopyFile(Command):
    6.64 -	def __init__(self, fromFile, toPath):
    6.65 -		Command.__init__(self)
    6.66 -		self.fromFile = fromFile
    6.67 -		self.toPath = toPath
    6.68 +addons_folder = builder.AddFolder('addons')
    6.69 +metamod_folder = builder.AddFolder(os.path.join('addons', 'metamod'))
    6.70 +bin_folder = builder.AddFolder(os.path.join('addons', 'metamod', 'bin'))
    6.71  
    6.72 -	def run(self, runner, job):
    6.73 -		runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
    6.74 -		shutil.copy(self.fromFile, self.toPath)
    6.75 -
    6.76 -
    6.77 -folders = [['addons', 'metamod', 'bin']]
    6.78 -
    6.79 -#Setup
    6.80 -job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
    6.81 -job.AddCommand(CreateFolders(folders))
    6.82 -
    6.83 -#Copy Files
    6.84 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metamod.vdf'),
    6.85 -                        os.path.join('addons')))
    6.86 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'metaplugins.ini'),
    6.87 -                        os.path.join('addons', 'metamod')))
    6.88 -job.AddCommand(CopyFile(os.path.join(AMBuild.sourceFolder, 'support', 'README.txt'),
    6.89 -                        os.path.join('addons', 'metamod')))
    6.90 -
    6.91 -bincopies = []
    6.92 -
    6.93 -def AddNormalLibrary(name, dest):
    6.94 -	dest = os.path.join('addons', 'metamod', dest)
    6.95 -	bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
    6.96 -	pdb_list.append(name + '\\' + name + '.pdb')
    6.97 -
    6.98 -def AddHL2Library(name, dest):
    6.99 -	for i in MMS.sdkInfo:
   6.100 -		sdk = MMS.sdkInfo[i]
   6.101 -		if AMBuild.target['platform'] not in sdk['platform']:
   6.102 -			continue
   6.103 -		AddNormalLibrary(name + '.' + sdk['ext'], dest)
   6.104 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'metamod.vdf'), addons_folder)
   6.105 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'metaplugins.ini'), metamod_folder)
   6.106 +builder.AddCopy(os.path.join(builder.sourcePath, 'support', 'README.txt'), metamod_folder)
   6.107  
   6.108  pdb_list = []
   6.109 +for task in MMS.binaries:
   6.110 +	builder.AddCopy(task.binary, bin_folder)
   6.111  
   6.112 -# Copy loader binaries
   6.113 -AddNormalLibrary('server', 'bin')
   6.114 -if AMBuild.target['platform'] == 'linux':
   6.115 -	AddNormalLibrary('server_i486', 'bin')
   6.116 -
   6.117 -AddHL2Library('metamod', 'bin')
   6.118 +	if task.debug:
   6.119 +		pdb_list.extend(task.debug)
   6.120  
   6.121 -job.AddCommandGroup(bincopies)
   6.122 +# Generate PDB info.
   6.123 +with open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt') as fp:
   6.124 +	for line in pdb_list:
   6.125 +		fp.write(line.path + '\n')
   6.126  
   6.127 -if AMBuild.target['platform'] == 'windows':
   6.128 -	pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
   6.129 -	for pdb in pdb_list:
   6.130 -		pdblog.write(pdb + '\n')
   6.131 -	pdblog.close()
   6.132 -
     7.1 --- a/support/buildbot/Versioning	Thu Oct 24 13:30:44 2013 -0400
     7.2 +++ b/support/buildbot/Versioning	Mon Nov 18 09:46:46 2013 -0800
     7.3 @@ -1,57 +1,30 @@
     7.4 -# vim: set ts=2 sw=2 tw=99 noet ft=python: 
     7.5 -import os
     7.6 -import re
     7.7 -import subprocess
     7.8 -from ambuild.cache import Cache
     7.9 -import ambuild.command as command
    7.10 +# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: 
    7.11 +import os, sys
    7.12  
    7.13 -#Quickly try to ascertain the current repository revision
    7.14 -def GetVersion():
    7.15 -	args = ['hg', 'parent', '-R', AMBuild.sourceFolder]
    7.16 -	p = command.RunDirectCommand(AMBuild, args)
    7.17 -	m = re.match('changeset:\s+(\d+):(.+)', p.stdoutText)
    7.18 -	if m == None:
    7.19 -		raise Exception('Could not determine repository version')
    7.20 -	return m.groups()
    7.21 +builder.SetBuildFolder('/')
    7.22  
    7.23 -def PerformReversioning():
    7.24 -	rev, cset = GetVersion()
    7.25 -	cacheFile = os.path.join(AMBuild.outputFolder, '.ambuild', 'hgcache')
    7.26 -	cache = Cache(cacheFile)
    7.27 -	if os.path.isfile(cacheFile):
    7.28 -		cache.LoadCache()
    7.29 -		if cache.HasVariable('cset') and cache['cset'] == cset:
    7.30 -			return False
    7.31 -	cache.CacheVariable('cset', cset)
    7.32 +includes = builder.AddFolder('includes')
    7.33  
    7.34 -	productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r')
    7.35 -	productContents = productFile.read()
    7.36 -	productFile.close()
    7.37 -	m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents)
    7.38 -	if m == None:
    7.39 -		raise Exception('Could not detremine product version')
    7.40 -	major, minor, release, tag = m.groups()
    7.41 -
    7.42 -	incFolder = os.path.join(AMBuild.outputFolder, 'includes')
    7.43 -	if not os.path.isdir(incFolder):
    7.44 -		os.makedirs(incFolder)
    7.45 -	incFile = open(os.path.join(incFolder, 'metamod_version_auto.h'), 'w')
    7.46 -	incFile.write("""
    7.47 -#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_
    7.48 -#define _METAMOD_AUTO_VERSION_INFORMATION_H_
    7.49 +argv = [
    7.50 +  sys.executable,
    7.51 +  os.path.join(builder.sourcePath, 'support', 'buildbot', 'generate_headers.py'),
    7.52 +  os.path.join(builder.sourcePath),
    7.53 +  os.path.join(builder.buildPath, 'includes')
    7.54 +]
    7.55 +outputs = [
    7.56 +  os.path.join(builder.buildFolder, 'includes', 'metamod_version_auto.h')
    7.57 +]
    7.58  
    7.59 -#define MMS_BUILD_STRING 		\"{0}\"
    7.60 -#define MMS_BUILD_UNIQUEID		\"{1}:{2}\" MMS_BUILD_STRING
    7.61 -#define MMS_FULL_VERSION		\"{3}.{4}.{5}\" MMS_BUILD_STRING
    7.62 -#define MMS_FILE_VERSION		{6},{7},{8},0
    7.63 -
    7.64 -#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
    7.65 +sources = [
    7.66 +  os.path.join(builder.sourcePath, 'product.version'),
    7.67  
    7.68 -""".format(tag, rev, cset, major, minor, release, major, minor, release))
    7.69 -	incFile.close()
    7.70 +  # This is a hack, but we need some way to only run this script when HG changes.
    7.71 +  os.path.join(builder.sourcePath, '.hg', 'dirstate'),
    7.72 +]
    7.73 +cmd_node, output_nodes = builder.AddCommand(
    7.74 +  inputs=sources,
    7.75 +  argv=argv,
    7.76 +  outputs=outputs
    7.77 +)
    7.78  
    7.79 -	cache.WriteCache()
    7.80 -
    7.81 -PerformReversioning()
    7.82 -
    7.83 -
    7.84 +rvalue = output_nodes
     8.1 --- a/support/buildbot/bootstrap.pl	Thu Oct 24 13:30:44 2013 -0400
     8.2 +++ b/support/buildbot/bootstrap.pl	Mon Nov 18 09:46:46 2013 -0800
     8.3 @@ -19,27 +19,7 @@
     8.4  
     8.5  my $reconf = 0;
     8.6  
     8.7 -#Create output folder if it doesn't exist.
     8.8 -if (!(-d 'OUTPUT')) {
     8.9 -	$reconf = 1;
    8.10 -} else {
    8.11 -	if (-f 'OUTPUT/sentinel') {
    8.12 -		my @s = stat('OUTPUT/sentinel');
    8.13 -		my $mtime = $s[9];
    8.14 -		my @files = ('build/pushbuild.txt', 'build/AMBuildScript', 'build/product.version');
    8.15 -		my ($i);
    8.16 -		for ($i = 0; $i <= $#files; $i++) {
    8.17 -			if (IsNewer($files[$i], $mtime)) {
    8.18 -				$reconf = 1;
    8.19 -				last;
    8.20 -			}
    8.21 -		}
    8.22 -	} else {
    8.23 -		$reconf = 1;
    8.24 -	}
    8.25 -}
    8.26 -
    8.27 -if ($reconf) {
    8.28 +if (!(-f 'OUTPUT/.ambuild2/graph')) {
    8.29  	rmtree('OUTPUT');
    8.30  	mkdir('OUTPUT') or die("Failed to create output folder: $!\n");
    8.31  	chdir('OUTPUT');
    8.32 @@ -54,7 +34,7 @@
    8.33  		} elsif ($^O eq "darwin") {
    8.34  			$result = `CC=clang CXX=clang python3 ../build/configure.py --enable-optimize`;
    8.35  		} else {
    8.36 -			$result = `C:\\Python31\\Python.exe ..\\build\\configure.py --enable-optimize`;
    8.37 +			$result = `C:\\Python27\\Python.exe ..\\build\\configure.py --enable-optimize`;
    8.38  		}
    8.39  	}
    8.40  	print "$result\n";
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/support/buildbot/generate_headers.py	Mon Nov 18 09:46:46 2013 -0800
     9.3 @@ -0,0 +1,45 @@
     9.4 +# vim: set ts=8 sts=2 sw=2 tw=99 et:
     9.5 +import re
     9.6 +import os, sys
     9.7 +import subprocess
     9.8 +
     9.9 +argv = sys.argv[1:]
    9.10 +if len(argv) < 2:
    9.11 +  sys.stderr.write('Usage: generate_headers.py <source_path> <output_folder>\n')
    9.12 +  sys.exit(1)
    9.13 +
    9.14 +SourceFolder = os.path.abspath(os.path.normpath(argv[0]))
    9.15 +OutputFolder = os.path.normpath(argv[1])
    9.16 +
    9.17 +def get_hg_version():
    9.18 +  argv = ['hg', 'parent', '-R', SourceFolder]
    9.19 +  text = subprocess.check_output(argv)
    9.20 +  m = re.match('changeset:\s+(\d+):(.+)', text)
    9.21 +  if m == None:
    9.22 +    raise Exception('Could not determine repository version')
    9.23 +  return m.groups()
    9.24 +
    9.25 +def output_version_header():
    9.26 +  rev, cset = get_hg_version()
    9.27 +  with open(os.path.join(SourceFolder, 'product.version')) as fp:
    9.28 +    productContents = fp.read()
    9.29 +  m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents)
    9.30 +  if m == None:
    9.31 +    raise Exception('Could not detremine product version')
    9.32 +  major, minor, release, tag = m.groups()
    9.33 +
    9.34 +  with open(os.path.join(OutputFolder, 'metamod_version_auto.h'), 'w') as fp:
    9.35 +    fp.write("""#ifndef _METAMOD_AUTO_VERSION_INFORMATION_H_
    9.36 +#define _METAMOD_AUTO_VERSION_INFORMATION_H_
    9.37 +
    9.38 +#define MMS_BUILD_STRING     \"{0}\"
    9.39 +#define MMS_BUILD_UNIQUEID    \"{1}:{2}\" MMS_BUILD_STRING
    9.40 +#define MMS_FULL_VERSION    \"{3}.{4}.{5}\" MMS_BUILD_STRING
    9.41 +#define MMS_FILE_VERSION    {6},{7},{8},0
    9.42 +
    9.43 +#endif /* _METAMOD_AUTO_VERSION_INFORMATION_H_ */
    9.44 +
    9.45 +""".format(tag, rev, cset, major, minor, release, major, minor, release))
    9.46 +
    9.47 +output_version_header()
    9.48 +
    10.1 --- a/support/buildbot/startbuild.pl	Thu Oct 24 13:30:44 2013 -0400
    10.2 +++ b/support/buildbot/startbuild.pl	Mon Nov 18 09:46:46 2013 -0800
    10.3 @@ -10,11 +10,7 @@
    10.4  
    10.5  chdir('../../../OUTPUT');
    10.6  
    10.7 -if ($^O eq "linux" || $^O eq "darwin") {
    10.8 -	system("python3 build.py 2>&1");
    10.9 -} else {
   10.10 -	system("C:\\Python31\\python.exe build.py 2>&1");
   10.11 -}
   10.12 +system("build.py 2>&1");
   10.13  
   10.14  if ($? != 0)
   10.15  {