OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
8 | 8 |
9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 '\rRemoving old toolchain in %ds... (Ctrl-C to cancel)' % i) | 138 '\rRemoving old toolchain in %ds... (Ctrl-C to cancel)' % i) |
139 sys.stdout.flush() | 139 sys.stdout.flush() |
140 time.sleep(1) | 140 time.sleep(1) |
141 print | 141 print |
142 | 142 |
143 | 143 |
144 def main(): | 144 def main(): |
145 if not sys.platform.startswith(('cygwin', 'win32')): | 145 if not sys.platform.startswith(('cygwin', 'win32')): |
146 return 0 | 146 return 0 |
147 | 147 |
148 if len(sys.argv) != 1: | 148 if len(sys.argv) < 2: |
149 print >> sys.stderr, 'Unexpected arguments.' | 149 print >> sys.stderr, 'Usage: get_toolchain_if_necessary.py sha1...' |
iannucci
2014/02/21 23:53:08
Probably want to note that we'll get the first sha
| |
150 return 1 | 150 |
151 desired_hashes = set(sys.argv[1:]) | |
151 | 152 |
152 # Move to depot_tools\win_toolchain where we'll store our files, and where | 153 # Move to depot_tools\win_toolchain where we'll store our files, and where |
153 # the downloader script is. | 154 # the downloader script is. |
154 os.chdir(os.path.normpath(os.path.join(BASEDIR))) | 155 os.chdir(os.path.normpath(os.path.join(BASEDIR))) |
155 toolchain_dir = '.' | 156 toolchain_dir = '.' |
156 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) | 157 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) |
157 | 158 |
158 sha1path = os.path.join(toolchain_dir, 'toolchain_vs2013.hash') | |
159 desired_hashes = set() | |
160 if os.path.isfile(sha1path): | |
161 with open(sha1path, 'rb') as f: | |
162 desired_hashes = set(f.read().strip().splitlines()) | |
163 | |
164 # If the current hash doesn't match what we want in the file, nuke and pave. | 159 # If the current hash doesn't match what we want in the file, nuke and pave. |
165 # Typically this script is only run when the .sha1 one file is updated, but | 160 # Typically this script is only run when the .sha1 one file is updated, but |
166 # directly calling "gclient runhooks" will also run it, so we cache | 161 # directly calling "gclient runhooks" will also run it, so we cache |
167 # based on timestamps to make that case fast. | 162 # based on timestamps to make that case fast. |
168 current_hash = CalculateHash(target_dir) | 163 current_hash = CalculateHash(target_dir) |
169 if current_hash not in desired_hashes: | 164 if current_hash not in desired_hashes: |
170 should_get_pro = (os.path.isfile(os.path.join(BASEDIR, '.vspro')) or | 165 should_get_pro = (os.path.isfile(os.path.join(BASEDIR, '.vspro')) or |
171 HaveSrcInternalAccess()) | 166 HaveSrcInternalAccess()) |
172 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' % | 167 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' % |
173 ('Pro' if should_get_pro else 'Express')) | 168 ('Pro' if should_get_pro else 'Express')) |
(...skipping 19 matching lines...) Expand all Loading... | |
193 'Wanted one of \'%s\', got \'%s\'.' % ( | 188 'Wanted one of \'%s\', got \'%s\'.' % ( |
194 desired_hashes, current_hash)) | 189 desired_hashes, current_hash)) |
195 return 1 | 190 return 1 |
196 SaveTimestampsAndHash(target_dir, current_hash) | 191 SaveTimestampsAndHash(target_dir, current_hash) |
197 | 192 |
198 return 0 | 193 return 0 |
199 | 194 |
200 | 195 |
201 if __name__ == '__main__': | 196 if __name__ == '__main__': |
202 sys.exit(main()) | 197 sys.exit(main()) |
OLD | NEW |