1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-20 13:54:14 +01:00

Added --sdks option to configure script to specify which SDKs to build againt (bug 5676, r=psychonic).

Valid arguments are "all", "present", or a comma delimited list of engine names.

The "all" option will try to build against all supported SDKs. (This is the default.)
The "present" option will only attempt to build against SDKs that exist on the system.

Examples:

configure.py --sdks=css,csgo,ep2v
configure.py --sdks=l4d
configure.py -s present
This commit is contained in:
Scott Ehlert 2013-03-23 23:12:16 -05:00
parent 42a139baf5
commit 95aad72edc
2 changed files with 71 additions and 69 deletions

View File

@ -10,31 +10,44 @@ class MMS:
#Build SDK info
self.possibleSdks = { }
self.possibleSdks['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1',
'name': 'EPISODEONE', 'platform': ['windows', 'linux']}
'name': 'EPISODEONE', 'platform': ['windows', 'linux'],
'dir': 'hl2sdk'}
self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3',
'name': 'ORANGEBOX', 'platform': ['windows', 'linux']}
self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6',
'name': 'CSS', 'platform': ['windows', 'linux', 'darwin']}
'name': 'ORANGEBOX', 'platform': ['windows', 'linux'],
'dir': 'hl2sdk-ob'}
self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6',
'name': 'CSS', 'platform': ['windows', 'linux', 'darwin'],
'dir': 'hl2sdk-css'}
self.possibleSdks['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '7',
'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin']}
'name': 'ORANGEBOXVALVE', 'platform': ['windows', 'linux', 'darwin'],
'dir': 'hl2sdk-ob-valve'}
self.possibleSdks['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '8',
'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin']}
'name': 'LEFT4DEAD', 'platform': ['windows', 'linux', 'darwin'],
'dir': 'hl2sdk-l4d'}
self.possibleSdks['l4d2'] = {'sdk': 'HL2SDKL4D2', 'ext': '2.l4d2', 'def': '9',
'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin']}
'name': 'LEFT4DEAD2', 'platform': ['windows', 'linux', 'darwin'],
'dir': 'hl2sdk-l4d2'}
self.possibleSdks['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2',
'name': 'DARKMESSIAH', 'platform': ['windows']}
'name': 'DARKMESSIAH', 'platform': ['windows'],
'dir': 'hl2sdk-darkm'}
self.possibleSdks['swarm'] = {'sdk': 'HL2SDK-SWARM', 'ext': '2.swarm', 'def': '10',
'name': 'ALIENSWARM', 'platform': ['windows']}
'name': 'ALIENSWARM', 'platform': ['windows'],
'dir': 'hl2sdk-swarm'}
self.possibleSdks['bgt'] = {'sdk': 'HL2SDK-BGT', 'ext': '2.bgt', 'def': '4',
'name': 'BLOODYGOODTIME', 'platform': ['windows']}
'name': 'BLOODYGOODTIME', 'platform': ['windows'],
'dir': 'hl2sdk-bgt'}
self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5',
'name': 'EYE', 'platform': ['windows']}
self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin']}
self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
'name': 'DOTA', 'platform': ['windows']}
# self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11',
# 'name': 'PORTAL2', 'platform': ['windows']}
'name': 'EYE', 'platform': ['windows'],
'dir': 'hl2sdk-eye'}
self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin'],
'dir': 'hl2sdk-csgo'}
self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
'name': 'DOTA', 'platform': ['windows'],
'dir': 'hl2sdk-dota'}
# self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11',
# 'name': 'PORTAL2', 'platform': ['windows'],
# 'dir': 'hl2sdk-portal2'}
self.sdkInfo = { }
@ -42,62 +55,32 @@ class MMS:
#Detect compilers
self.compiler.DetectAll(AMBuild)
#Detect variables
envvars = {}
if AMBuild.target['platform'] != 'darwin':
envvars['HL2SDK'] = 'hl2sdk'
envvars['HL2SDKOB'] = 'hl2sdk-ob'
#Look for SDK directories
for sdk in self.possibleSdks:
#Get list of SDKs to build against or 'all' or 'present'
sdkList = AMBuild.options.sdks.split(',')
#Build against all supported SDKs?
useAll = sdkList[0] == 'all'
#Build against supported SDKs that exist?
usePresent = sdkList[0] == 'present'
envvars['HL2SDKCSS'] = 'hl2sdk-css'
envvars['HL2SDKOBVALVE'] = 'hl2sdk-ob-valve'
envvars['HL2SDKL4D'] = 'hl2sdk-l4d'
envvars['HL2SDKL4D2'] = 'hl2sdk-l4d2'
envvars['HL2SDKCSGO'] = 'hl2sdk-csgo'
#Dark Messiah is Windows-only
if AMBuild.target['platform'] == 'windows':
envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
envvars['HL2SDK-BGT'] = 'hl2sdk-bgt'
envvars['HL2SDK-EYE'] = 'hl2sdk-eye'
envvars['HL2SDKDOTA'] = 'hl2sdk-dota'
# 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)
info = self.possibleSdks[sdk]
if AMBuild.target['platform'] in info['platform']:
env = info['sdk']
dir = info['dir']
sdkPath = self.ResolveEnvPath(env, dir)
if sdkPath == None:
if useAll or sdk in sdkList:
raise Exception('Could not find a valid path for {0}'.format(env))
else:
continue
if useAll or usePresent or sdk in sdkList:
self.sdkInfo[sdk] = info
else:
head = os.getcwd()
oldhead = None
while head != None and head != oldhead:
path = os.path.join(head, envvars[i])
if os.path.isdir(path):
break
oldhead = head
head, tail = os.path.split(head)
if i.startswith('HL2SDK'):
if head != None and head != oldhead:
(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)
AMBuild.cache.CacheVariable(env, sdkPath)
if len(self.sdkInfo) < 1:
raise Exception('At least one SDK must be available.')
AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
#Set up defines
@ -390,6 +373,22 @@ class MMS:
return compiler
def ResolveEnvPath(self, env, defaultDir):
if env in os.environ:
path = os.environ[env]
if os.path.isdir(path):
return path
else:
head = os.getcwd()
oldhead = None
while head != None and head != oldhead:
path = os.path.join(head, defaultDir)
if os.path.isdir(path):
return path
oldhead = head
head, tail = os.path.split(head)
return None
mms = MMS()
globals = {
'MMS': mms

View File

@ -7,4 +7,7 @@ run.options.add_option('--enable-debug', action='store_const', const='1', dest='
help='Enable debugging symbols')
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization')
run.options.add_option('-s', '--sdks', default='all', dest='sdks',
help='Build against specified SDKs; valid args are "all", "present", or '
'comma-delimited list of engine names (default: %default)')
run.Configure(sys.path[0])