1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
7 # Copyright (c) 2016 The Khronos Group Inc.
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
29 sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
30 from fetch_kc_cts import SHA1
32 sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
33 from build.common import *
36 EXTERNAL_DIR = os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
38 def computeChecksum (data):
39 return hashlib.sha256(data).hexdigest()
42 def __init__(self, baseDir, extractDir):
43 self.baseDir = baseDir
44 self.extractDir = extractDir
47 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
48 if os.path.exists(fullDstPath):
49 shutil.rmtree(fullDstPath, ignore_errors=False)
51 class GitRepo (Source):
52 def __init__(self, url, revision, baseDir, extractDir = "src"):
53 Source.__init__(self, baseDir, extractDir)
55 self.revision = revision
58 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
60 if not os.path.exists(fullDstPath):
61 execute(["git", "clone", "--no-checkout", self.url, fullDstPath])
63 pushWorkingDir(fullDstPath)
65 execute(["git", "fetch", self.url, "+refs/heads/*:refs/remotes/origin/*"])
66 execute(["git", "checkout", self.revision])
69 def compare_rev(self):
70 fullDstPath = os.path.join(EXTERNAL_DIR, self.baseDir, self.extractDir)
71 pushWorkingDir(fullDstPath)
73 out = subprocess.check_output(["git", "rev-parse", "HEAD"])
74 if out.replace('\n', '') != SHA1:
75 raise Exception ("KC CTS checkout revision %s in external/fetch_kc_cts.py doesn't match KC CTS master HEAD revision %s" % (SHA1, out))
81 "git@gitlab.khronos.org:opengl/kc-cts.git",
86 if __name__ == "__main__":