aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2018-05-10 11:00:09 -0600
committerMark Lobodzinski <mark@lunarg.com>2018-05-11 19:56:45 -0600
commit52913ec007a73cea5e916df949563f97f0166b5a (patch)
treee31408b69716f95d3af47b571cbccdadd901d5b3 /scripts
parent1094a18d1543e4347eda3ff8528d388a69d0bf5a (diff)
downloadvulkan-validation-layers-52913ec007a73cea5e916df949563f97f0166b5a.tar.gz
layers: Add from_uuid option to ext_rev_generator
It will not be unusual to build the repo while pointing to a spirv- tools installation without git information. Modified the script and layer cmake files to use a UUID as the basis for the spirv tools commit id header file.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/external_revision_generator.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/external_revision_generator.py b/scripts/external_revision_generator.py
index 9ba9156b0..a7992fdc4 100644
--- a/scripts/external_revision_generator.py
+++ b/scripts/external_revision_generator.py
@@ -23,6 +23,7 @@
import argparse
import hashlib
import subprocess
+import uuid
def generate(symbol_name, commit_id, output_header_file):
# Write commit ID to output header file
@@ -64,7 +65,8 @@ def generate(symbol_name, commit_id, output_header_file):
header_file.write(contents)
def get_commit_id_from_git(git_binary, source_dir):
- return subprocess.check_output([git_binary, "rev-parse", "HEAD"], cwd=source_dir).decode('utf-8').strip()
+ value = subprocess.check_output([git_binary, "rev-parse", "HEAD"], cwd=source_dir).decode('utf-8').strip()
+ return value
def is_sha1(str):
try: str_as_int = int(str, 16)
@@ -82,6 +84,12 @@ def get_commit_id_from_file(rev_file):
sha1.update(rev_contents.encode('utf-8'))
return sha1.hexdigest()
+def get_commit_id_from_uuid():
+ unique_uuid = str(uuid.uuid4())
+ sha1 = hashlib.sha1();
+ sha1.update(unique_uuid.encode())
+ return sha1.hexdigest()
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--symbol_name", metavar="SYMBOL_NAME", required=True, help="C symbol name")
@@ -89,6 +97,7 @@ def main():
rev_method_group = parser.add_mutually_exclusive_group(required=True)
rev_method_group.add_argument("--git_dir", metavar="SOURCE_DIR", help="git working copy directory")
rev_method_group.add_argument("--rev_file", metavar="REVISION_FILE", help="source revision file path (must contain a SHA1 hash")
+ rev_method_group.add_argument("--from_uuid", action='store_true', help="base SHA1 on a dynamically generated UUID")
args = parser.parse_args()
# We can either parse the latest Git commit ID out of the specified repository (preferred where possible),
@@ -99,11 +108,13 @@ def main():
try:
commit_id = get_commit_id_from_git('git', args.git_dir)
except WindowsError:
- # Call git.bat on Windows for compatiblity.
+ # Call git.bat on Windows for compatibility.
commit_id = get_commit_id_from_git('git.bat', args.git_dir)
elif args.rev_file is not None:
# Read the commit ID from a file.
commit_id = get_commit_id_from_file(args.rev_file)
+ elif args.from_uuid is not None:
+ commit_id = get_commit_id_from_uuid()
if not is_sha1(commit_id):
raise ValueError("commit ID for " + args.symbol_name + " must be a SHA1 hash.")