From e6df54537a105e1ce822444e605f85730d252b35 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Fri, 9 Sep 2011 18:37:09 -0500 Subject: [PATCH] Changed build system so that it no longer requires all SDKs to be available (bug 5023, r=ds). --- AMBuildScript | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index 67c49222..ff727b8a 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -8,25 +8,27 @@ class SM: self.compiler = Cpp.Compiler() #Build SDK info - self.sdkInfo = { } - self.sdkInfo['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1', + self.possibleSdks = { } + self.possibleSdks['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1', 'name': 'EPISODEONE', 'platform': ['windows', 'linux']} - self.sdkInfo['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3', + self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3', 'name': 'ORANGEBOX', 'platform': ['windows', 'linux']} - self.sdkInfo['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '6', + self.possibleSdks['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '6', 'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']} - self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '7', + self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '7', 'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin']} - self.sdkInfo['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '8', + self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '8', 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin']} - self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', + self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', 'name': 'DARKMESSIAH', 'platform': ['windows']} - self.sdkInfo['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '9', + self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '9', 'name': 'ALIENSWARM', 'platform': ['windows']} - self.sdkInfo['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4', - 'name': 'BLOODYGOODTIME', 'platform': ['windows']} - self.sdkInfo['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5', - 'name': 'EYE', 'platform': ['windows']} + self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4', + 'name': 'BLOODYGOODTIME', 'platform': ['windows']} + self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5', + 'name': 'EYE', 'platform': ['windows']} + + self.sdkInfo = { } if AMBuild.mode == 'config': #Detect compilers @@ -51,12 +53,22 @@ class SM: envvars['HL2SDK-BGT'] = 'hl2sdk-bgt' envvars['HL2SDK-EYE'] = 'hl2sdk-eye' - #Must have a path for each envvar (file a bug if you don't like this) + # Finds if a dict with `key` set to `value` is present on the dict of dicts `dictionary` + def findDictByKey(dictionary, key, value): + for index in dictionary: + elem = dictionary[index] + if elem[key] == value: + return (elem, index) + return None + for i in envvars: if i in os.environ: path = os.environ[i] if not os.path.isdir(path): raise Exception('Path for {0} was not found: {1}'.format(i, path)) + elif i.startswith('HL2SDK'): + (info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i) + self.sdkInfo[sdk] = info else: head = os.getcwd() oldhead = None @@ -66,10 +78,18 @@ class SM: break oldhead = head head, tail = os.path.split(head) - if head == None or head == oldhead: + if i.startswith('HL2SDK'): + (info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i) + self.sdkInfo[sdk] = info + elif head == None or head == oldhead: raise Exception('Could not find a valid path for {0}'.format(i)) AMBuild.cache.CacheVariable(i, path) + if len(self.sdkInfo) < 1: + raise Exception('At least one SDK must be available.') + + AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo) + #Set up defines cxx = self.compiler.cxx if isinstance(cxx, Cpp.CompatGCC): @@ -195,6 +215,7 @@ class SM: self.targetMap = { } AMBuild.cache.CacheVariable('targetMap', self.targetMap) else: + self.sdkInfo = AMBuild.cache['sdkInfo'] self.compiler.FromConfig(AMBuild, 'compiler') self.targetMap = AMBuild.cache['targetMap'] @@ -294,7 +315,7 @@ class SM: compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms)) compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms, 'sourcehook')) - info = self.sdkInfo + info = self.possibleSdks compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info]) paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'],