OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2015 Google Inc. | 3 # Copyright 2015 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 # This script will update Skia's dependencies as necessary and run | 8 # This script will update Skia's dependencies as necessary and run |
9 # gyp if needed. | 9 # gyp if needed. |
10 | 10 |
11 # Depends on: Python, Git, and depot_tools. | 11 # Depends on: Python, Git, and depot_tools. |
12 # | 12 # |
13 # Example usage: | 13 # Example usage: |
14 # | 14 # |
15 # git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | 15 # git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
16 # export PATH="${PWD}/depot_tools:${PATH}" | 16 # export PATH="${PWD}/depot_tools:${PATH}" |
17 # git clone https://skia.googlesource.com/skia | 17 # git clone https://skia.googlesource.com/skia |
18 # cd skia | 18 # cd skia |
19 # python bin/sync-and-gyp | 19 # python bin/sync-and-gyp |
20 # ninja -C out/Debug && out/Debug/dm | 20 # ninja -C out/Debug && out/Debug/dm |
21 # | 21 # |
22 # Once changes are made to DEPS or gyp/ or the source, call: | 22 # Once changes are made to DEPS or gyp/ or the source, call: |
23 # | 23 # |
24 # python bin/sync-and-gyp | 24 # python bin/sync-and-gyp |
25 | 25 |
| 26 # To retreive and use all optional deps: |
| 27 # |
| 28 # python bin/sync-and-gyp --deps=all |
| 29 # ninja -C out/Debug && out/Debug/dm |
| 30 |
26 import fnmatch | 31 import fnmatch |
27 import hashlib | 32 import hashlib |
| 33 import os |
28 import subprocess | 34 import subprocess |
29 import os | |
30 import sys | 35 import sys |
31 | 36 |
32 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) | 37 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) |
33 | 38 |
| 39 skia_opt_deps = [arg for arg in sys.argv[1:] if arg.startswith('--deps=')] |
| 40 |
34 skia_out = os.environ.get("SKIA_OUT") | 41 skia_out = os.environ.get("SKIA_OUT") |
35 if skia_out: | 42 if skia_out: |
36 skia_out = os.path.abspath(skia_out) | 43 skia_out = os.path.abspath(skia_out) |
37 hash_path = os.path.join(skia_out, 'gyp_hash') | 44 hash_path = os.path.join(skia_out, 'gyp_hash') |
38 else: | 45 else: |
39 hash_path = os.path.join('out', 'gyp_hash') | 46 hash_path = os.path.join('out', 'gyp_hash') |
40 | 47 |
41 os.chdir(skia_dir) | 48 os.chdir(skia_dir) |
42 | 49 |
43 if not os.path.isfile('DEPS'): | 50 if not os.path.isfile('DEPS'): |
44 sys.stderr.write('DEPS file missing') | 51 sys.stderr.write('DEPS file missing') |
45 exit(1) | 52 exit(1) |
46 | 53 |
47 deps_hasher = hashlib.sha1() | 54 deps_hasher = hashlib.sha1() |
48 with open('DEPS', 'r') as f: | 55 with open('DEPS', 'r') as f: |
49 deps_hasher.update(f.read()) | 56 deps_hasher.update(f.read()) |
| 57 deps_hasher.update(repr(skia_opt_deps)) |
50 deps_hash = deps_hasher.hexdigest() | 58 deps_hash = deps_hasher.hexdigest() |
51 current_deps_hash = None | 59 current_deps_hash = None |
52 if os.path.isfile('.deps_sha1'): | 60 if os.path.isfile('.deps_sha1'): |
53 with open('.deps_sha1', 'r') as f: | 61 with open('.deps_sha1', 'r') as f: |
54 current_deps_hash = f.read().strip() | 62 current_deps_hash = f.read().strip() |
55 | 63 |
56 default_gclient_config = ''' | 64 default_gclient_config = ''' |
57 solutions = [ | 65 solutions = [ |
58 { "name" : ".", | 66 { "name" : ".", |
59 "url" : "https://skia.googlesource.com/skia.git", | 67 "url" : "https://skia.googlesource.com/skia.git", |
60 "deps_file" : "DEPS", | 68 "deps_file" : "DEPS", |
61 "managed" : False, | 69 "managed" : False, |
62 "custom_deps" : { | 70 "custom_deps" : { |
63 }, | 71 }, |
64 "safesync_url": "", | 72 "safesync_url": "", |
65 }, | 73 }, |
66 ] | 74 ] |
67 cache_dir = None | 75 cache_dir = None |
68 ''' | 76 ''' |
69 if current_deps_hash != deps_hash: | 77 if current_deps_hash != deps_hash: |
70 # `gclient sync` is very slow, so skip whenever we can. | 78 # `gclient sync` is very slow, so skip whenever we can. |
71 if not os.path.isfile('.gclient'): | 79 if not os.path.isfile('.gclient'): |
72 with open('.gclient', 'w') as o: | 80 with open('.gclient', 'w') as o: |
73 o.write(default_gclient_config) | 81 o.write(default_gclient_config) |
| 82 gclient_sync_command = ['gclient', 'sync'] + skia_opt_deps |
74 try: | 83 try: |
75 subprocess.check_call(['gclient', 'sync']) | 84 sys.stdout.write('%r\n' % gclient_sync_command) |
| 85 subprocess.check_call(gclient_sync_command) |
76 except: | 86 except: |
77 sys.stderr.write('\n`gclient sync` failed.\n') | 87 sys.stderr.write('\n`gclient sync` failed.\n') |
78 os.remove('.deps_sha1') # Unknown state. | 88 os.remove('.deps_sha1') # Unknown state. |
79 exit(1) | 89 exit(1) |
80 # Only write hash after a successful sync. | 90 # Only write hash after a successful sync. |
81 with open('.deps_sha1', 'w') as o: | 91 with open('.deps_sha1', 'w') as o: |
82 o.write(deps_hash) | 92 o.write(deps_hash) |
83 | 93 |
84 hasher = hashlib.sha1() | 94 hasher = hashlib.sha1() |
85 | 95 |
(...skipping 29 matching lines...) Expand all Loading... |
115 return f.read() | 125 return f.read() |
116 return '' | 126 return '' |
117 | 127 |
118 if cat_if_exists(hash_path).strip() != gyp_hash: | 128 if cat_if_exists(hash_path).strip() != gyp_hash: |
119 env = os.environ.copy() | 129 env = os.environ.copy() |
120 if skia_out: | 130 if skia_out: |
121 env['SKIA_OUT'] = skia_out | 131 env['SKIA_OUT'] = skia_out |
122 subprocess.call(['python', './gyp_skia'], env=env) | 132 subprocess.call(['python', './gyp_skia'], env=env) |
123 with open(hash_path, 'w') as o: | 133 with open(hash_path, 'w') as o: |
124 o.write(gyp_hash) | 134 o.write(gyp_hash) |
OLD | NEW |