Upgrade update_glslang_sources.py to work with gitlab branch

--site gitlab must be added to command for gitlab capability.
Default is github.
This commit is contained in:
GregF 2018-02-08 15:56:54 -07:00
parent 4ee5193b53
commit 484cbd0484

View File

@ -28,8 +28,12 @@ import sys
KNOWN_GOOD_FILE = 'known_good.json' KNOWN_GOOD_FILE = 'known_good.json'
SITE_TO_KNOWN_GOOD_FILE = { 'github' : 'known_good.json',
'gitlab' : 'known_good_khr.json' }
# Maps a site name to its hostname. # Maps a site name to its hostname.
SITE_TO_HOST = { 'github' : 'github.com' } SITE_TO_HOST = { 'github' : 'https://github.com/',
'gitlab' : 'git@gitlab.khronos.org:' }
VERBOSE = True VERBOSE = True
@ -82,14 +86,11 @@ class GoodCommit(object):
self.subdir = json['subdir'] if ('subdir' in json) else '.' self.subdir = json['subdir'] if ('subdir' in json) else '.'
self.commit = json['commit'] self.commit = json['commit']
def GetUrl(self, style='https'): def GetUrl(self):
"""Returns the URL for the repository.""" """Returns the URL for the repository."""
host = SITE_TO_HOST[self.site] host = SITE_TO_HOST[self.site]
sep = '/' if (style is 'https') else ':' return '{host}{subrepo}'.format(
return '{style}://{host}{sep}{subrepo}'.format(
style=style,
host=host, host=host,
sep=sep,
subrepo=self.subrepo) subrepo=self.subrepo)
def AddRemote(self): def AddRemote(self):
@ -120,9 +121,10 @@ class GoodCommit(object):
command_output(['git', 'checkout', self.commit], self.subdir) command_output(['git', 'checkout', self.commit], self.subdir)
def GetGoodCommits(): def GetGoodCommits(site):
"""Returns the latest list of GoodCommit objects.""" """Returns the latest list of GoodCommit objects."""
with open(KNOWN_GOOD_FILE) as known_good: known_good_file = SITE_TO_KNOWN_GOOD_FILE[site]
with open(known_good_file) as known_good:
return [GoodCommit(c) for c in json.loads(known_good.read())['commits']] return [GoodCommit(c) for c in json.loads(known_good.read())['commits']]
@ -130,10 +132,12 @@ def main():
parser = argparse.ArgumentParser(description='Get Glslang source dependencies at a known-good commit') parser = argparse.ArgumentParser(description='Get Glslang source dependencies at a known-good commit')
parser.add_argument('--dir', dest='dir', default='.', parser.add_argument('--dir', dest='dir', default='.',
help="Set target directory for Glslang source root. Default is \'.\'.") help="Set target directory for Glslang source root. Default is \'.\'.")
parser.add_argument('--site', dest='site', default='github',
help="Set git server site. Default is github.")
args = parser.parse_args() args = parser.parse_args()
commits = GetGoodCommits() commits = GetGoodCommits(args.site)
distutils.dir_util.mkpath(args.dir) distutils.dir_util.mkpath(args.dir)
print('Change directory to {d}'.format(d=args.dir)) print('Change directory to {d}'.format(d=args.dir))