mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-07 10:28:30 +00:00
Merge.
This commit is contained in:
commit
8b465be02f
137
AMBuildScript
137
AMBuildScript
@ -10,31 +10,44 @@ class MMS:
|
|||||||
#Build SDK info
|
#Build SDK info
|
||||||
self.possibleSdks = { }
|
self.possibleSdks = { }
|
||||||
self.possibleSdks['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1',
|
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',
|
self.possibleSdks['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3',
|
||||||
'name': 'ORANGEBOX', 'platform': ['windows', 'linux']}
|
'name': 'ORANGEBOX', 'platform': ['windows', 'linux'],
|
||||||
self.possibleSdks['css'] = {'sdk': 'HL2SDKCSS', 'ext': '2.css', 'def': '6',
|
'dir': 'hl2sdk-ob'}
|
||||||
'name': 'CSS', 'platform': ['windows', 'linux', 'darwin']}
|
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',
|
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',
|
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',
|
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',
|
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',
|
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',
|
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',
|
self.possibleSdks['eye'] = {'sdk': 'HL2SDK-EYE', 'ext': '2.eye', 'def': '5',
|
||||||
'name': 'EYE', 'platform': ['windows']}
|
'name': 'EYE', 'platform': ['windows'],
|
||||||
self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
|
'dir': 'hl2sdk-eye'}
|
||||||
'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin']}
|
self.possibleSdks['csgo'] = {'sdk': 'HL2SDKCSGO', 'ext': '2.csgo', 'def': '12',
|
||||||
self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
|
'name': 'CSGO', 'platform': ['windows', 'linux', 'darwin'],
|
||||||
'name': 'DOTA', 'platform': ['windows']}
|
'dir': 'hl2sdk-csgo'}
|
||||||
# self.possibleSdks['portal2'] = {'sdk': 'HL2SDK-PORTAL2', 'ext': '2.portal2', 'def': '11',
|
self.possibleSdks['dota'] = {'sdk': 'HL2SDKDOTA', 'ext': '2.dota', 'def': '13',
|
||||||
# 'name': 'PORTAL2', 'platform': ['windows']}
|
'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 = { }
|
self.sdkInfo = { }
|
||||||
|
|
||||||
@ -42,62 +55,32 @@ class MMS:
|
|||||||
#Detect compilers
|
#Detect compilers
|
||||||
self.compiler.DetectAll(AMBuild)
|
self.compiler.DetectAll(AMBuild)
|
||||||
|
|
||||||
#Detect variables
|
#Look for SDK directories
|
||||||
envvars = {}
|
for sdk in self.possibleSdks:
|
||||||
if AMBuild.target['platform'] != 'darwin':
|
#Get list of SDKs to build against or 'all' or 'present'
|
||||||
envvars['HL2SDK'] = 'hl2sdk'
|
sdkList = AMBuild.options.sdks.split(',')
|
||||||
envvars['HL2SDKOB'] = 'hl2sdk-ob'
|
#Build against all supported SDKs?
|
||||||
|
useAll = sdkList[0] == 'all'
|
||||||
|
#Build against supported SDKs that exist?
|
||||||
|
usePresent = sdkList[0] == 'present'
|
||||||
|
|
||||||
envvars['HL2SDKCSS'] = 'hl2sdk-css'
|
info = self.possibleSdks[sdk]
|
||||||
envvars['HL2SDKOBVALVE'] = 'hl2sdk-ob-valve'
|
if AMBuild.target['platform'] in info['platform']:
|
||||||
envvars['HL2SDKL4D'] = 'hl2sdk-l4d'
|
env = info['sdk']
|
||||||
envvars['HL2SDKL4D2'] = 'hl2sdk-l4d2'
|
dir = info['dir']
|
||||||
envvars['HL2SDKCSGO'] = 'hl2sdk-csgo'
|
sdkPath = self.ResolveEnvPath(env, dir)
|
||||||
|
if sdkPath == None:
|
||||||
#Dark Messiah is Windows-only
|
if useAll or sdk in sdkList:
|
||||||
if AMBuild.target['platform'] == 'windows':
|
raise Exception('Could not find a valid path for {0}'.format(env))
|
||||||
envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm'
|
else:
|
||||||
envvars['HL2SDK-SWARM'] = 'hl2sdk-swarm'
|
continue
|
||||||
envvars['HL2SDK-BGT'] = 'hl2sdk-bgt'
|
if useAll or usePresent or sdk in sdkList:
|
||||||
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)
|
|
||||||
self.sdkInfo[sdk] = info
|
self.sdkInfo[sdk] = info
|
||||||
else:
|
AMBuild.cache.CacheVariable(env, sdkPath)
|
||||||
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)
|
|
||||||
|
|
||||||
if len(self.sdkInfo) < 1:
|
if len(self.sdkInfo) < 1:
|
||||||
raise Exception('At least one SDK must be available.')
|
raise Exception('At least one SDK must be available.')
|
||||||
|
|
||||||
AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
|
AMBuild.cache.CacheVariable('sdkInfo', self.sdkInfo)
|
||||||
|
|
||||||
#Set up defines
|
#Set up defines
|
||||||
@ -390,6 +373,22 @@ class MMS:
|
|||||||
|
|
||||||
return compiler
|
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()
|
mms = MMS()
|
||||||
globals = {
|
globals = {
|
||||||
'MMS': mms
|
'MMS': mms
|
||||||
|
|||||||
@ -7,4 +7,7 @@ run.options.add_option('--enable-debug', action='store_const', const='1', dest='
|
|||||||
help='Enable debugging symbols')
|
help='Enable debugging symbols')
|
||||||
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||||
help='Enable optimization')
|
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])
|
run.Configure(sys.path[0])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user