Merge pull request #3 from alliedmodders/search-paths

Add search path configuration options.
This commit is contained in:
David Anderson 2014-05-26 21:39:22 -07:00
commit 53a8d5ac30
2 changed files with 50 additions and 24 deletions

View File

@ -44,17 +44,22 @@ def ResolveEnvPath(env, folder):
path = os.environ[env] path = os.environ[env]
if os.path.isdir(path): if os.path.isdir(path):
return path return path
else: return None
head = os.getcwd()
oldhead = None head = os.getcwd()
while head != None and head != oldhead: oldhead = None
path = os.path.join(head, folder) while head != None and head != oldhead:
if os.path.isdir(path): path = os.path.join(head, folder)
return path if os.path.isdir(path):
oldhead = head return path
head, tail = os.path.split(head) oldhead = head
head, tail = os.path.split(head)
return None return None
def Normalize(path):
return os.path.abspath(os.path.normpath(path))
class SMConfig(object): class SMConfig(object):
def __init__(self): def __init__(self):
self.sdks = {} self.sdks = {}
@ -89,31 +94,46 @@ class SMConfig(object):
for sdk_name in PossibleSDKs: for sdk_name in PossibleSDKs:
sdk = PossibleSDKs[sdk_name] sdk = PossibleSDKs[sdk_name]
if builder.target_platform in sdk.platform: if builder.target_platform in sdk.platform:
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder) if builder.options.hl2sdk_root:
if sdk_path is None: sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
else:
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
if sdk_path is None or not os.path.isdir(sdk_path):
if use_all or sdk_name in sdk_list: if use_all or sdk_name in sdk_list:
raise Exception('Could not find a valid path for {0}'.format(sdk.envvar)) raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
continue continue
if use_all or use_present or sdk_name in sdk_list: if use_all or use_present or sdk_name in sdk_list:
sdk.path = sdk_path sdk.path = Normalize(sdk_path)
self.sdks[sdk_name] = sdk self.sdks[sdk_name] = sdk
if len(self.sdks) < 1: if len(self.sdks) < 1:
raise Exception('At least one SDK must be available.') raise Exception('At least one SDK must be available.')
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
if not self.mms_root: if builder.options.mms_path:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central') self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
if not self.mms_root: if not self.mms_root:
raise Exception('Could not find a source copy of Metamod:Source') self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
if not self.mms_root or not os.path.isdir(self.mms_root):
raise Exception('Could not find a source copy of Metamod:Source')
self.mms_root = Normalize(self.mms_root)
if builder.options.hasMySql: if builder.options.hasMySql:
for i in range(7): if builder.options.mysql_path:
self.mysql_root = ResolveEnvPath('MYSQL5', 'mysql-5.' + str(i)) self.mysql_root = builder.options.mysql_path
if self.mysql_root: else:
break for i in range(7):
if not self.mysql_root: self.mysql_root = ResolveEnvPath('MYSQL5', 'mysql-5.' + str(i))
if self.mysql_root:
break
if not self.mysql_root or not os.path.isdir(self.mysql_root):
raise Exception('Could not find a path to MySQL!') raise Exception('Could not find a path to MySQL!')
self.mysql_root = Normalize(self.mysql_root)
def configure(self): def configure(self):
builder.AddConfigureFile('pushbuild.txt') builder.AddConfigureFile('pushbuild.txt')
@ -348,9 +368,9 @@ class SMConfig(object):
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32'] compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
else: else:
compiler.defines += ['COMPILER_GCC'] compiler.defines += ['COMPILER_GCC']
# For everything after Swarm, this needs to be defined for entity networking # For everything after Swarm, this needs to be defined for entity networking
# to work properly with sendprop value changes. # to work properly with sendprop value changes.
if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']: if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']:
compiler.defines += ['NETWORK_VARS_ENABLED'] compiler.defines += ['NETWORK_VARS_ENABLED']

View File

@ -14,6 +14,12 @@ except:
run = run.PrepareBuild(sourcePath=sys.path[0]) run = run.PrepareBuild(sourcePath=sys.path[0])
run.default_build_folder = 'obj-' + run.target_platform run.default_build_folder = 'obj-' + run.target_platform
run.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
run.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None,
help='Path to MySQL 5')
run.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
help='Path to Metamod:Source')
run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
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',