diff options
author | Mark Lobodzinski <mark@lunarg.com> | 2018-05-10 11:00:09 -0600 |
---|---|---|
committer | Mark Lobodzinski <mark@lunarg.com> | 2018-05-11 19:56:45 -0600 |
commit | 52913ec007a73cea5e916df949563f97f0166b5a (patch) | |
tree | e31408b69716f95d3af47b571cbccdadd901d5b3 | |
parent | 1094a18d1543e4347eda3ff8528d388a69d0bf5a (diff) | |
download | vulkan-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.
-rw-r--r-- | layers/CMakeLists.txt | 19 | ||||
-rw-r--r-- | scripts/external_revision_generator.py | 15 |
2 files changed, 18 insertions, 16 deletions
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index b6068ed00..ace4b8bfd 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -44,15 +44,11 @@ macro(run_vk_xml_generate dependency output) endmacro() # Define macro used for generating header files containing commit IDs for external dependencies -macro(run_external_revision_generate source_dir symbol_name output) +macro(run_external_revision_generate symbol_name output) add_custom_command(OUTPUT ${output} - # NOTE: If you modify this call to use --rev_file instead of --git_dir (to read the commit ID from a file instead of - # parsing from a Git repository), you probably also want to add the revision file to the list of DEPENDS on the - # subsequent line (to ensure that the script is re-run when the revision file is modified). - # COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/external_revision_generator.py --git_dir ${source_dir} -s ${symbol_name} -o ${output} - COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/external_revision_generator.py --rev_file ${source_dir} -s ${symbol_name} -o ${output} - DEPENDS ${SCRIPTS_DIR}/external_revision_generator.py ${source_dir}/.git/HEAD ${source_dir}/.git/index - ) + COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/external_revision_generator.py --from_uuid -s ${symbol_name} -o ${output} + DEPENDS ${SCRIPTS_DIR}/external_revision_generator.py + ) endmacro() # Custom targets for generated validation layer helper file dependencies @@ -82,14 +78,9 @@ run_vk_xml_generate(helper_file_generator.py vk_object_types.h) run_vk_xml_generate(helper_file_generator.py vk_extension_helper.h) run_vk_xml_generate(helper_file_generator.py vk_typemap_helper.h) if(BUILD_LAYERS) - #run_external_revision_generate(${EXTERNAL_SOURCE_ROOT}/glslang/External/spirv-tools SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h) - #run_external_revision_generate(${SPIRV_TOOLS_INCLUDE_DIR} SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h) - #### TODO LUGMAL FIX THIS!!!! run_external_revision_generate(${SPIRV_TOOLS_INCLUDE_DIR}/.. SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h) + run_external_revision_generate(SPIRV_TOOLS_COMMIT_ID spirv_tools_commit_id.h) endif() - - - # Layer Utils Library # For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search # path that can't be easily modified to point it to the same directory that contains the layers. 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.") |