Merge pull request #3 from alliedmodders/search-paths
Add search path configuration options.
This commit is contained in:
commit
53a8d5ac30
@ -44,7 +44,8 @@ def ResolveEnvPath(env, folder):
|
||||
path = os.environ[env]
|
||||
if os.path.isdir(path):
|
||||
return path
|
||||
else:
|
||||
return None
|
||||
|
||||
head = os.getcwd()
|
||||
oldhead = None
|
||||
while head != None and head != oldhead:
|
||||
@ -53,8 +54,12 @@ def ResolveEnvPath(env, folder):
|
||||
return path
|
||||
oldhead = head
|
||||
head, tail = os.path.split(head)
|
||||
|
||||
return None
|
||||
|
||||
def Normalize(path):
|
||||
return os.path.abspath(os.path.normpath(path))
|
||||
|
||||
class SMConfig(object):
|
||||
def __init__(self):
|
||||
self.sdks = {}
|
||||
@ -89,31 +94,46 @@ class SMConfig(object):
|
||||
for sdk_name in PossibleSDKs:
|
||||
sdk = PossibleSDKs[sdk_name]
|
||||
if builder.target_platform in sdk.platform:
|
||||
if builder.options.hl2sdk_root:
|
||||
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
|
||||
else:
|
||||
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
|
||||
if sdk_path is None:
|
||||
if sdk_path is None or not os.path.isdir(sdk_path):
|
||||
if use_all or sdk_name in sdk_list:
|
||||
raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
|
||||
continue
|
||||
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
|
||||
|
||||
if len(self.sdks) < 1:
|
||||
raise Exception('At least one SDK must be available.')
|
||||
|
||||
|
||||
if builder.options.mms_path:
|
||||
self.mms_root = builder.options.mms_path
|
||||
else:
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
|
||||
if not self.mms_root:
|
||||
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
|
||||
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.mysql_path:
|
||||
self.mysql_root = builder.options.mysql_path
|
||||
else:
|
||||
for i in range(7):
|
||||
self.mysql_root = ResolveEnvPath('MYSQL5', 'mysql-5.' + str(i))
|
||||
if self.mysql_root:
|
||||
break
|
||||
if not self.mysql_root:
|
||||
if not self.mysql_root or not os.path.isdir(self.mysql_root):
|
||||
raise Exception('Could not find a path to MySQL!')
|
||||
self.mysql_root = Normalize(self.mysql_root)
|
||||
|
||||
def configure(self):
|
||||
builder.AddConfigureFile('pushbuild.txt')
|
||||
|
@ -14,6 +14,12 @@ except:
|
||||
|
||||
run = run.PrepareBuild(sourcePath=sys.path[0])
|
||||
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',
|
||||
help='Enable debugging symbols')
|
||||
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||
|
Loading…
Reference in New Issue
Block a user