Fix commit build rule to use empty hash (and not throw error) if git is not available.
Bug: dawn:549
Change-Id: I75ab6eb0273ddcb2dc571d5c91d35422793fdffc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85745
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/generator/dawn_version_generator.py b/generator/dawn_version_generator.py
index 462cb31..1907e88 100644
--- a/generator/dawn_version_generator.py
+++ b/generator/dawn_version_generator.py
@@ -28,11 +28,17 @@
cwd=dawnDir)
if result.returncode == 0:
return result.stdout.decode('utf-8').strip()
+ # No hash was available (possibly) because the directory was not a git checkout. Dawn should
+ # explicitly handle its absenece and disable features relying on the hash, i.e. caching.
return ''
def get_gitHead(dawnDir):
- return [os.path.join(dawnDir, '.git', 'HEAD')]
+ return os.path.join(dawnDir, '.git', 'HEAD')
+
+
+def gitExists(dawnDir):
+ return os.path.exists(get_gitHead(dawnDir))
def unpackGitRef(packed, resolved):
@@ -89,8 +95,10 @@
help='The Dawn root directory path to use')
def get_dependencies(self, args):
- dawn_dir = os.path.abspath(args.dawn_dir)
- return get_gitHead(dawn_dir) + get_gitResolvedHead(dawn_dir)
+ dawnDir = os.path.abspath(args.dawn_dir)
+ if gitExists(dawnDir):
+ return [get_gitHead(dawnDir)] + get_gitResolvedHead(dawnDir)
+ return []
def get_file_renders(self, args):
params = compute_params(args)