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