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 +