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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 # ninja -C out/Debug && out/Debug/dm | 29 # ninja -C out/Debug && out/Debug/dm |
30 | 30 |
31 import fnmatch | 31 import fnmatch |
32 import hashlib | 32 import hashlib |
33 import os | 33 import os |
34 import subprocess | 34 import subprocess |
35 import sys | 35 import sys |
36 | 36 |
37 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) | 37 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) |
38 | 38 |
39 skia_opt_deps = [arg for arg in sys.argv[1:] if arg.startswith('--deps=')] | |
40 | |
41 skia_out = os.environ.get("SKIA_OUT") | 39 skia_out = os.environ.get("SKIA_OUT") |
42 if skia_out: | 40 if skia_out: |
43 skia_out = os.path.abspath(skia_out) | 41 skia_out = os.path.abspath(skia_out) |
44 hash_path = os.path.join(skia_out, 'gyp_hash') | 42 hash_path = os.path.join(skia_out, 'gyp_hash') |
45 else: | 43 else: |
46 hash_path = os.path.join('out', 'gyp_hash') | 44 hash_path = os.path.join('out', 'gyp_hash') |
47 | 45 |
48 os.chdir(skia_dir) | 46 os.chdir(skia_dir) |
49 | 47 |
50 if not os.path.isfile('DEPS'): | 48 if 0 != subprocess.call(['python', 'bin/sync'] + sys.argv[1:]): |
51 sys.stderr.write('DEPS file missing') | 49 sys.stderr.write('sync failed.') |
52 exit(1) | 50 exit(1) |
53 | 51 |
54 deps_hasher = hashlib.sha1() | |
55 with open('DEPS', 'r') as f: | |
56 deps_hasher.update(f.read()) | |
57 deps_hasher.update(repr(skia_opt_deps)) | |
58 deps_hash = deps_hasher.hexdigest() | |
59 current_deps_hash = None | |
60 if os.path.isfile('.deps_sha1'): | |
61 with open('.deps_sha1', 'r') as f: | |
62 current_deps_hash = f.read().strip() | |
63 | |
64 default_gclient_config = ''' | |
65 solutions = [ | |
66 { "name" : ".", | |
67 "url" : "https://skia.googlesource.com/skia.git", | |
68 "deps_file" : "DEPS", | |
69 "managed" : False, | |
70 "custom_deps" : { | |
71 }, | |
72 "safesync_url": "", | |
73 }, | |
74 ] | |
75 cache_dir = None | |
76 ''' | |
77 | |
78 # Must use gclient.bat rather than gclient on windows (at least on mingw) | |
79 gclient = 'gclient' | |
80 if sys.platform == 'win32' or sys.platform == 'cygwin': | |
81 gclient = 'gclient.bat' | |
82 | |
83 if current_deps_hash != deps_hash: | |
84 # `gclient sync` is very slow, so skip whenever we can. | |
85 try: | |
86 subprocess.call([gclient, '--version']) | |
87 except: | |
88 sys.stdout.write('gclient missing from $PATH, please install ' + | |
89 'depot_tools\n https://skia.org/user/quick/desktop\n') | |
90 exit(1) | |
91 if not os.path.isfile('.gclient'): | |
92 with open('.gclient', 'w') as o: | |
93 o.write(default_gclient_config) | |
94 gclient_sync_command = [gclient, 'sync'] + skia_opt_deps | |
95 try: | |
96 sys.stdout.write('%r\n' % gclient_sync_command) | |
97 subprocess.check_call(gclient_sync_command) | |
98 except: | |
99 sys.stderr.write('\n`gclient sync` failed.\n') | |
100 try: | |
101 os.remove('.deps_sha1') # Unknown state. | |
102 except: | |
103 pass | |
104 exit(1) | |
105 # Only write hash after a successful sync. | |
106 with open('.deps_sha1', 'w') as o: | |
107 o.write(deps_hash) | |
108 | |
109 hasher = hashlib.sha1() | 52 hasher = hashlib.sha1() |
110 | 53 |
111 for var in ['AR', 'AR_host', 'AR_target', | 54 for var in ['AR', 'AR_host', 'AR_target', |
112 'CC', 'CC_host', 'CC_target', | 55 'CC', 'CC_host', 'CC_target', |
113 'CFLAGS', 'CFLAGS_host', | 56 'CFLAGS', 'CFLAGS_host', |
114 'CPPFLAGS', 'CPPFLAGS_host', | 57 'CPPFLAGS', 'CPPFLAGS_host', |
115 'CXX', 'CXX_host', 'CXX_target', | 58 'CXX', 'CXX_host', 'CXX_target', |
116 'GYP_DEFINES', 'GYP_GENERATORS', | 59 'GYP_DEFINES', 'GYP_GENERATORS', |
117 'NM', 'NM_host', 'NM_target', | 60 'NM', 'NM_host', 'NM_target', |
118 'READELF', 'READELF_host', 'READELF_target']: | 61 'READELF', 'READELF_host', 'READELF_target']: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return f.read() | 100 return f.read() |
158 return '' | 101 return '' |
159 | 102 |
160 if cat_if_exists(hash_path).strip() != gyp_hash: | 103 if cat_if_exists(hash_path).strip() != gyp_hash: |
161 env = os.environ.copy() | 104 env = os.environ.copy() |
162 if skia_out: | 105 if skia_out: |
163 env['SKIA_OUT'] = skia_out | 106 env['SKIA_OUT'] = skia_out |
164 subprocess.call(['python', './gyp_skia'], env=env) | 107 subprocess.call(['python', './gyp_skia'], env=env) |
165 with open(hash_path, 'w') as o: | 108 with open(hash_path, 'w') as o: |
166 o.write(gyp_hash) | 109 o.write(gyp_hash) |
OLD | NEW |