From: GregF Date: Thu, 8 Feb 2018 22:56:54 +0000 (-0700) Subject: Upgrade update_glslang_sources.py to work with gitlab branch X-Git-Tag: upstream/11.4.0~857^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=484cbd04847d472dc5140c2a7071ca1685e7a98f;p=platform%2Fupstream%2Fglslang.git Upgrade update_glslang_sources.py to work with gitlab branch --site gitlab must be added to command for gitlab capability. Default is github. --- diff --git a/update_glslang_sources.py b/update_glslang_sources.py index 331a301..550bc2b 100755 --- a/update_glslang_sources.py +++ b/update_glslang_sources.py @@ -28,8 +28,12 @@ import sys 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. -SITE_TO_HOST = { 'github' : 'github.com' } +SITE_TO_HOST = { 'github' : 'https://github.com/', + 'gitlab' : 'git@gitlab.khronos.org:' } VERBOSE = True @@ -82,14 +86,11 @@ class GoodCommit(object): self.subdir = json['subdir'] if ('subdir' in json) else '.' self.commit = json['commit'] - def GetUrl(self, style='https'): + def GetUrl(self): """Returns the URL for the repository.""" host = SITE_TO_HOST[self.site] - sep = '/' if (style is 'https') else ':' - return '{style}://{host}{sep}{subrepo}'.format( - style=style, + return '{host}{subrepo}'.format( host=host, - sep=sep, subrepo=self.subrepo) def AddRemote(self): @@ -120,9 +121,10 @@ class GoodCommit(object): command_output(['git', 'checkout', self.commit], self.subdir) -def GetGoodCommits(): +def GetGoodCommits(site): """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']] @@ -130,10 +132,12 @@ def main(): parser = argparse.ArgumentParser(description='Get Glslang source dependencies at a known-good commit') parser.add_argument('--dir', dest='dir', default='.', 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() - commits = GetGoodCommits() + commits = GetGoodCommits(args.site) distutils.dir_util.mkpath(args.dir) print('Change directory to {d}'.format(d=args.dir))