1.1 --- a/AMBuildScript Fri Mar 22 20:47:35 2013 -0400
1.2 +++ b/AMBuildScript Sat Mar 23 23:12:16 2013 -0500
1.3 @@ -10,31 +10,44 @@
1.4 #Build SDK info
1.5 self.possibleSdks = { }
1.6 self.possibleSdks['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1',
1.7 - 'name': 'EPISODEONE', 'platform': ['windows', 'linux']}
1.8 + 'name': 'EPISODEONE', 'platform': ['windows', 'linux'],
1.9 + 'dir': 'hl2sdk'}
1.10 self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3',
1.11 - 'name': 'ORANGEBOX', 'platform': ['windows', 'linux']}
1.12 - self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6',
1.13 - 'name': 'CSS', 'platform': ['windows', 'linux', 'darwin']}
1.14 + 'name': 'ORANGEBOX', 'platform': ['windows', 'linux'],
1.15 + 'dir': 'hl2sdk-ob'}
1.16 + self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6',
1.17 + 'name': 'CSS', 'platform': ['windows', 'linux', 'darwin'],
1.18 + 'dir': 'hl2sdk-css'}
1.19 self.possibleSdks['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '7',
1.20 - 'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']}
1.21 + 'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin'],
1.22 + 'dir': 'hl2sdk-ob-valve'}
1.23 self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '8',
1.24 - 'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin']}
1.25 + 'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin'],
1.26 + 'dir': 'hl2sdk-l4d'}
1.27 self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '9',
1.28 - 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin']}
1.29 + 'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin'],
1.30 + 'dir': 'hl2sdk-l4d2'}
1.31 self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2',
1.32 - 'name': 'DARKMESSIAH', 'platform': ['windows']}
1.33 + 'name': 'DARKMESSIAH', 'platform': ['windows'],
1.34 + 'dir': 'hl2sdk-darkm'}
1.35 self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '10',
1.36 - 'name': 'ALIENSWARM', 'platform': ['windows']}
1.37 + 'name': 'ALIENSWARM', 'platform': ['windows'],
1.38 + 'dir': 'hl2sdk-swarm'}
1.39 self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4',
1.40 - 'name': 'BLOODYGOODTIME', 'platform': ['windows']}
1.41 + 'name': 'BLOODYGOODTIME', 'platform': ['windows'],
1.42 + 'dir': 'hl2sdk-bgt'}
1.43 self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5',
1.44 - 'name': 'EYE', 'platform': ['windows']}
1.45 - self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
1.46 - 'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin']}
1.47 - self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
1.48 - 'name': 'DOTA', 'platform': ['windows']}
1.49 - # self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11',
1.50 - # 'name': 'PORTAL2', 'platform': ['windows']}
1.51 + 'name': 'EYE', 'platform': ['windows'],
1.52 + 'dir': 'hl2sdk-eye'}
1.53 + self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
1.54 + 'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin'],
1.55 + 'dir': 'hl2sdk-csgo'}
1.56 + self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
1.57 + 'name': 'DOTA', 'platform': ['windows'],
1.58 + 'dir': 'hl2sdk-dota'}
1.59 + # self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11',
1.60 + # 'name': 'PORTAL2', 'platform': ['windows'],
1.61 + # 'dir': 'hl2sdk-portal2'}
1.62
1.63 self.sdkInfo = { }
1.64
1.65 @@ -42,62 +55,32 @@
1.66 #Detect compilers
1.67 self.compiler.DetectAll(AMBuild)
1.68
1.69 - #Detect variables
1.70 - envvars = {}
1.71 - if AMBuild.target['platform'] != 'darwin':
1.72 - envvars['HL2SDK'] = 'hl2sdk'
1.73 - envvars['HL2SDKOB'] = 'hl2sdk-ob'
1.74 -
1.75 - envvars['HL2SDKCSS'] = 'hl2sdk-css'
1.76 - envvars['HL2SDKOBVALVE'] = 'hl2sdk-ob-valve'
1.77 - envvars['HL2SDKL4D'] = 'hl2sdk-l4d'
1.78 - envvars['HL2SDKL4D2'] = 'hl2sdk-l4d2'
1.79 - envvars['HL2SDKCSGO'] = 'hl2sdk-csgo'
1.80 -
1.81 - #Dark Messiah is Windows-only
1.82 - if AMBuild.target['platform'] == 'windows':
1.83 - envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
1.84 - envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
1.85 - envvars['HL2SDK-BGT'] = 'hl2sdk-bgt'
1.86 - envvars['HL2SDK-EYE'] = 'hl2sdk-eye'
1.87 - envvars['HL2SDKDOTA'] = 'hl2sdk-dota'
1.88 + #Look for SDK directories
1.89 + for sdk in self.possibleSdks:
1.90 + #Get list of SDKs to build against or 'all' or 'present'
1.91 + sdkList = AMBuild.options.sdks.split(',')
1.92 + #Build against all supported SDKs?
1.93 + useAll = sdkList[0] == 'all'
1.94 + #Build against supported SDKs that exist?
1.95 + usePresent = sdkList[0] == 'present'
1.96
1.97 - # Finds if a dict with `key` set to `value` is present on the dict of dicts `dictionary`
1.98 - def findDictByKey(dictionary, key, value):
1.99 - for index in dictionary:
1.100 - elem = dictionary[index]
1.101 - if elem[key] == value:
1.102 - return (elem, index)
1.103 - return None
1.104 -
1.105 - for i in envvars:
1.106 - if i in os.environ:
1.107 - path = os.environ[i]
1.108 - if not os.path.isdir(path):
1.109 - raise Exception('Path for {0} was not found: {1}'.format(i, path))
1.110 - elif i.startswith('HL2SDK'):
1.111 - (info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
1.112 + info = self.possibleSdks[sdk]
1.113 + if AMBuild.target['platform'] in info['platform']:
1.114 + env = info['sdk']
1.115 + dir = info['dir']
1.116 + sdkPath = self.ResolveEnvPath(env, dir)
1.117 + if sdkPath == None:
1.118 + if useAll or sdk in sdkList:
1.119 + raise Exception('Could not find a valid path for {0}'.format(env))
1.120 + else:
1.121 + continue
1.122 + if useAll or usePresent or sdk in sdkList:
1.123 self.sdkInfo[sdk] = info
1.124 - else:
1.125 - head = os.getcwd()
1.126 - oldhead = None
1.127 - while head != None and head != oldhead:
1.128 - path = os.path.join(head, envvars[i])
1.129 - if os.path.isdir(path):
1.130 - break
1.131 - oldhead = head
1.132 - head, tail = os.path.split(head)
1.133 - if i.startswith('HL2SDK'):
1.134 - if head != None and head != oldhead:
1.135 - (info, sdk) = findDictByKey(self.possibleSdks, 'sdk', i)
1.136 - self.sdkInfo[sdk] = info
1.137 - elif head == None or head == oldhead:
1.138 - raise Exception('Could not find a valid path for {0}'.format(i))
1.139 - AMBuild.cache.CacheVariable(i, path)
1.140 -
1.141 + AMBuild.cache.CacheVariable(env, sdkPath)
1.142 +
1.143 if len(self.sdkInfo) < 1:
1.144 raise Exception('At least one SDK must be available.')
1.145 -
1.146 +
1.147 AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
1.148
1.149 #Set up defines
1.150 @@ -390,6 +373,22 @@
1.151
1.152 return compiler
1.153
1.154 + def ResolveEnvPath(self, env, defaultDir):
1.155 + if env in os.environ:
1.156 + path = os.environ[env]
1.157 + if os.path.isdir(path):
1.158 + return path
1.159 + else:
1.160 + head = os.getcwd()
1.161 + oldhead = None
1.162 + while head != None and head != oldhead:
1.163 + path = os.path.join(head, defaultDir)
1.164 + if os.path.isdir(path):
1.165 + return path
1.166 + oldhead = head
1.167 + head, tail = os.path.split(head)
1.168 + return None
1.169 +
1.170 mms = MMS()
1.171 globals = {
1.172 'MMS': mms