OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 ''' |
| 8 Usage: python commit_hash.py SKIA_DIR OUTPUT_FILE |
| 9 ''' |
| 10 |
| 11 import os |
| 12 import subprocess |
| 13 import sys |
| 14 |
| 15 assert len(sys.argv) == 3 |
| 16 |
| 17 template = '''#include "skia/ext/skia_commit_hash.h" |
| 18 namespace skia { |
| 19 const char* CommitHash() { return "%s"; } |
| 20 } |
| 21 ''' |
| 22 |
| 23 try: |
| 24 commit = subprocess.check_output( |
| 25 ['git', 'rev-parse', '--short=12', 'HEAD'], |
| 26 cwd=sys.argv[1]).strip() |
| 27 except (subprocess.CalledProcessError, OSError), e: |
| 28 commit = 'UNKNOWN' |
| 29 |
| 30 with open(sys.argv[2], 'w') as o: |
| 31 o.write(template % commit) |
OLD | NEW |