Index: skia/commit_hash.py |
diff --git a/skia/commit_hash.py b/skia/commit_hash.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..bfab82271ce43ecce7e627381737166e16a06191 |
--- /dev/null |
+++ b/skia/commit_hash.py |
@@ -0,0 +1,31 @@ |
+#!/usr/bin/python |
+ |
+# Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+''' |
+Usage: python commit_hash.py SKIA_DIR OUTPUT_FILE |
+''' |
+ |
+import os |
+import subprocess |
+import sys |
+ |
+assert len(sys.argv) == 3 |
+ |
+template = '''#include "skia/ext/skia_commit_hash.h" |
+namespace skia { |
+const char* CommitHash() { return "%s"; } |
+} |
+''' |
+ |
+try: |
+ commit = subprocess.check_output( |
+ ['git', 'rev-parse', '--short=12', 'HEAD'], |
+ cwd=sys.argv[1]).strip() |
+except (subprocess.CalledProcessError, OSError), e: |
+ commit = 'UNKNOWN' |
+ |
+with open(sys.argv[2], 'w') as o: |
+ o.write(template % commit) |