AMBuildScript
changeset 773 1bff89b1550d
parent 772 bdaa1f0fd8ac
child 774 330fa28bde8e
     1.1 --- a/AMBuildScript	Wed Mar 21 06:55:39 2012 -0500
     1.2 +++ b/AMBuildScript	Wed Mar 21 06:55:46 2012 -0500
     1.3 @@ -8,26 +8,28 @@
     1.4  		self.compiler = Cpp.Compiler()
     1.5  
     1.6  		#Build SDK info
     1.7 +		self.possibleSdks = { }
     1.8 +		self.possibleSdks['ep1'] =   {'sdk': 'HL2SDK',          'ext': '1.ep1',   'def': '1',
     1.9 +		                              'name': 'EPISODEONE',     'platform': ['windows', 'linux']}
    1.10 +		self.possibleSdks['ep2'] =   {'sdk': 'HL2SDKOB',        'ext': '2.ep2',   'def': '3',
    1.11 +		                              'name': 'ORANGEBOX',      'platform': ['windows', 'linux']}
    1.12 +		self.possibleSdks['ep2v'] =  {'sdk': 'HL2SDKOBVALVE',   'ext': '2.ep2v',  'def': '6',
    1.13 +		                              'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']}
    1.14 +		self.possibleSdks['l4d'] =   {'sdk': 'HL2SDKL4D',       'ext': '2.l4d',   'def': '7',
    1.15 +		                              'name': 'LEFT4DEAD',      'platform': ['windows', 'linux', 'darwin']}
    1.16 +		self.possibleSdks['l4d2'] =  {'sdk': 'HL2SDKL4D2',      'ext': '2.l4d2',  'def': '8',
    1.17 +		                              'name': 'LEFT4DEAD2',     'platform': ['windows', 'linux', 'darwin']}
    1.18 +		self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM',    'ext': '2.darkm', 'def': '2',
    1.19 +		                              'name': 'DARKMESSIAH',    'platform': ['windows']}
    1.20 +		self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM',    'ext': '2.swarm', 'def': '9',
    1.21 +		                              'name': 'ALIENSWARM',     'platform': ['windows']}
    1.22 +		self.possibleSdks['bgt'] =   {'sdk': 'HL2SDK-BGT',      'ext': '2.bgt', 'def': '4',
    1.23 +		                              'name': 'BLOODYGOODTIME', 'platform': ['windows']}
    1.24 +		self.possibleSdks['eye'] =   {'sdk': 'HL2SDK-EYE',      'ext': '2.eye', 'def': '5',
    1.25 +		                              'name': 'EYE', 'platform': ['windows']}
    1.26 +		
    1.27  		self.sdkInfo = { }
    1.28 -		self.sdkInfo['ep1'] =   {'sdk': 'HL2SDK',          'ext': '1.ep1',   'def': '1',
    1.29 -		                         'name': 'EPISODEONE',     'platform': ['windows', 'linux']}
    1.30 -		self.sdkInfo['ep2'] =   {'sdk': 'HL2SDKOB',        'ext': '2.ep2',   'def': '3',
    1.31 -		                         'name': 'ORANGEBOX',      'platform': ['windows', 'linux']}
    1.32 -		self.sdkInfo['ep2v'] =  {'sdk': 'HL2SDKOBVALVE',   'ext': '2.ep2v',  'def': '6',
    1.33 -		                         'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']}
    1.34 -		self.sdkInfo['l4d'] =   {'sdk': 'HL2SDKL4D',       'ext': '2.l4d',   'def': '7',
    1.35 -		                         'name': 'LEFT4DEAD',      'platform': ['windows', 'linux', 'darwin']}
    1.36 -		self.sdkInfo['l4d2'] =  {'sdk': 'HL2SDKL4D2',      'ext': '2.l4d2',  'def': '8',
    1.37 -		                         'name': 'LEFT4DEAD2',     'platform': ['windows', 'linux', 'darwin']}
    1.38 -		self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM',    'ext': '2.darkm', 'def': '2',
    1.39 -		                         'name': 'DARKMESSIAH',    'platform': ['windows']}
    1.40 -		self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM',    'ext': '2.swarm', 'def': '9',
    1.41 -		                         'name': 'ALIENSWARM',     'platform': ['windows']}
    1.42 -		self.sdkInfo['bgt'] =   {'sdk': 'HL2SDK-BGT',      'ext': '2.bgt', 'def': '4',
    1.43 -		                         'name': 'BLOODYGOODTIME', 'platform': ['windows']}
    1.44 -		self.sdkInfo['eye'] =   {'sdk': 'HL2SDK-EYE',      'ext': '2.eye', 'def': '5',
    1.45 -		                         'name': 'EYE', 'platform': ['windows']}
    1.46 -
    1.47 +		
    1.48  		if AMBuild.mode == 'config':
    1.49  			#Detect compilers
    1.50  			self.compiler.DetectAll(AMBuild)
    1.51 @@ -49,12 +51,22 @@
    1.52  				envvars['HL2SDK-BGT']   = 'hl2sdk-bgt'
    1.53  				envvars['HL2SDK-EYE']   = 'hl2sdk-eye'
    1.54  
    1.55 -			#Must have a path for each envvar (file a bug if you don't like this)
    1.56 +			# Finds if a dict with `key` set to `value` is present on the dict of dicts `dictionary`
    1.57 +			def findDictByKey(dictionary, key, value):
    1.58 +				for index in dictionary:
    1.59 +					elem = dictionary[index]
    1.60 +					if elem[key] == value:
    1.61 +						return (elem, index)
    1.62 +				return None
    1.63 +			
    1.64  			for i in envvars:
    1.65  				if i in os.environ:
    1.66  					path = os.environ[i]
    1.67  					if not os.path.isdir(path):
    1.68  						raise Exception('Path for {0} was not found: {1}'.format(i, path))
    1.69 +					elif i.startswith('HL2SDK'):
    1.70 +						(info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
    1.71 +						self.sdkInfo[sdk] = info
    1.72  				else:
    1.73  					head = os.getcwd()
    1.74  					oldhead = None
    1.75 @@ -64,9 +76,18 @@
    1.76  							break
    1.77  						oldhead = head
    1.78  						head, tail = os.path.split(head)
    1.79 -					if head == None or head == oldhead:
    1.80 +					if i.startswith('HL2SDK'):
    1.81 +						if head != None and head != oldhead:
    1.82 +							(info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
    1.83 +							self.sdkInfo[sdk] = info
    1.84 +					elif head == None or head == oldhead:
    1.85  						raise Exception('Could not find a valid path for {0}'.format(i))
    1.86  				AMBuild.cache.CacheVariable(i, path)
    1.87 +				
    1.88 +			if len(self.sdkInfo) < 1:
    1.89 +				raise Exception('At least one SDK must be available.')
    1.90 +
    1.91 +			AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
    1.92  
    1.93  			#Set up defines
    1.94  			cxx = self.compiler.cxx
    1.95 @@ -189,6 +210,7 @@
    1.96  			self.targetMap = { }
    1.97  			AMBuild.cache.CacheVariable('targetMap', self.targetMap)
    1.98  		else:
    1.99 +			self.sdkInfo = AMBuild.cache['sdkInfo']
   1.100  			self.compiler.FromConfig(AMBuild, 'compiler')
   1.101  			self.targetMap = AMBuild.cache['targetMap']
   1.102  
   1.103 @@ -277,7 +299,7 @@
   1.104  		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path, 'sourcehook'))
   1.105  		compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'loader'))
   1.106  
   1.107 -		info = self.sdkInfo
   1.108 +		info = self.possibleSdks
   1.109  		compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info])
   1.110  
   1.111  		paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],