OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 # Copyright 2016 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 # This script will update Skia's dependencies as necessary. |
| 9 |
| 10 # Depends on: Python, Git, and depot_tools. |
| 11 |
| 12 # To retreive and use all optional deps: |
| 13 # |
| 14 # python bin/sync --deps=all |
| 15 |
| 16 import hashlib |
| 17 import os |
| 18 import subprocess |
| 19 import sys |
| 20 |
| 21 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) |
| 22 |
| 23 skia_opt_deps = [arg for arg in sys.argv[1:] if arg.startswith('--deps=')] |
| 24 |
| 25 os.chdir(skia_dir) |
| 26 |
| 27 if not os.path.isfile('DEPS'): |
| 28 sys.stderr.write('DEPS file missing') |
| 29 exit(1) |
| 30 |
| 31 deps_hasher = hashlib.sha1() |
| 32 with open('DEPS', 'r') as f: |
| 33 deps_hasher.update(f.read()) |
| 34 deps_hasher.update(repr(skia_opt_deps)) |
| 35 deps_hash = deps_hasher.hexdigest() |
| 36 current_deps_hash = None |
| 37 if os.path.isfile('.deps_sha1'): |
| 38 with open('.deps_sha1', 'r') as f: |
| 39 current_deps_hash = f.read().strip() |
| 40 |
| 41 default_gclient_config = ''' |
| 42 solutions = [ |
| 43 { "name" : ".", |
| 44 "url" : "https://skia.googlesource.com/skia.git", |
| 45 "deps_file" : "DEPS", |
| 46 "managed" : False, |
| 47 "custom_deps" : { |
| 48 }, |
| 49 "safesync_url": "", |
| 50 }, |
| 51 ] |
| 52 cache_dir = None |
| 53 ''' |
| 54 |
| 55 # Must use gclient.bat rather than gclient on windows (at least on mingw) |
| 56 gclient = 'gclient' |
| 57 if sys.platform == 'win32' or sys.platform == 'cygwin': |
| 58 gclient = 'gclient.bat' |
| 59 |
| 60 if current_deps_hash != deps_hash: |
| 61 # `gclient sync` is very slow, so skip whenever we can. |
| 62 try: |
| 63 subprocess.call([gclient, '--version']) |
| 64 except: |
| 65 sys.stdout.write('gclient missing from $PATH, please install ' + |
| 66 'depot_tools\n https://skia.org/user/quick/desktop\n') |
| 67 exit(1) |
| 68 if not os.path.isfile('.gclient'): |
| 69 with open('.gclient', 'w') as o: |
| 70 o.write(default_gclient_config) |
| 71 gclient_sync_command = [gclient, 'sync'] + skia_opt_deps |
| 72 try: |
| 73 sys.stdout.write('%r\n' % gclient_sync_command) |
| 74 subprocess.check_call(gclient_sync_command) |
| 75 except: |
| 76 sys.stderr.write('\n`gclient sync` failed.\n') |
| 77 try: |
| 78 os.remove('.deps_sha1') # Unknown state. |
| 79 except: |
| 80 pass |
| 81 exit(1) |
| 82 # Only write hash after a successful sync. |
| 83 with open('.deps_sha1', 'w') as o: |
| 84 o.write(deps_hash) |
OLD | NEW |