OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Extracts a Windows toolchain suitable for building Chrome from various | 5 # Extracts a Windows toolchain suitable for building Chrome from various |
6 # downloadable pieces. | 6 # downloadable pieces. |
7 | 7 |
8 | 8 |
9 import ctypes | 9 import ctypes |
10 from optparse import OptionParser | 10 from optparse import OptionParser |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 sys.stdout.write('Cleaning up temporaries...\n') | 50 sys.stdout.write('Cleaning up temporaries...\n') |
51 for temp in g_temp_dirs: | 51 for temp in g_temp_dirs: |
52 # shutil.rmtree errors out on read only attributes. | 52 # shutil.rmtree errors out on read only attributes. |
53 RunOrDie('rmdir /s/q "%s"' % temp) | 53 RunOrDie('rmdir /s/q "%s"' % temp) |
54 g_temp_dirs = [] | 54 g_temp_dirs = [] |
55 | 55 |
56 | 56 |
57 def Download(url, local_path): | 57 def Download(url, local_path): |
58 """Download a large-ish binary file and print some status information while | 58 """Download a large-ish binary file and print some status information while |
59 doing so.""" | 59 doing so.""" |
60 sys.stdout.write('Downloading %s...' % url) | 60 sys.stdout.write('Downloading %s...\n' % url) |
61 req = urllib2.urlopen(url) | 61 req = urllib2.urlopen(url) |
62 content_length = int(req.headers.get('Content-Length', 0)) | 62 content_length = int(req.headers.get('Content-Length', 0)) |
63 bytes_read = 0 | 63 bytes_read = 0 |
| 64 terminator = '\r' if sys.stdout.isatty() else '\n' |
64 with open(local_path, 'wb') as file: | 65 with open(local_path, 'wb') as file: |
65 while True: | 66 while True: |
66 chunk = req.read(1024 * 1024) | 67 chunk = req.read(1024 * 1024) |
67 if not chunk: | 68 if not chunk: |
68 break | 69 break |
69 bytes_read += len(chunk) | 70 bytes_read += len(chunk) |
70 file.write(chunk) | 71 file.write(chunk) |
71 sys.stdout.write('.') | 72 sys.stdout.write('... %d/%d%s' % (bytes_read, content_length, terminator)) |
| 73 sys.stdout.flush() |
72 sys.stdout.write('\n') | 74 sys.stdout.write('\n') |
73 if content_length and content_length != bytes_read: | 75 if content_length and content_length != bytes_read: |
74 raise SystemExit('Got incorrect number of bytes downloading %s' % url) | 76 raise SystemExit('Got incorrect number of bytes downloading %s' % url) |
75 | 77 |
76 | 78 |
77 def DownloadSDK71Iso(): | 79 def DownloadSDK71Iso(): |
78 sdk7_temp_dir = TempDir() | 80 sdk7_temp_dir = TempDir() |
79 target_path = os.path.join(sdk7_temp_dir, 'GRMSDKX_EN_DVD.iso') | 81 target_path = os.path.join(sdk7_temp_dir, 'GRMSDKX_EN_DVD.iso') |
80 Download( | 82 Download( |
81 ('http://download.microsoft.com/download/' | 83 ('http://download.microsoft.com/download/' |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ex_path=ex_path, | 219 ex_path=ex_path, |
218 update_path=update_path, | 220 update_path=update_path, |
219 wdk_iso=wdk_iso) | 221 wdk_iso=wdk_iso) |
220 | 222 |
221 | 223 |
222 def ExtractIso(iso_path): | 224 def ExtractIso(iso_path): |
223 """Use 7zip to extract the contents of the given .iso (or self-extracting | 225 """Use 7zip to extract the contents of the given .iso (or self-extracting |
224 .exe).""" | 226 .exe).""" |
225 target_path = TempDir() | 227 target_path = TempDir() |
226 sys.stdout.write('Extracting %s...\n' % iso_path) | 228 sys.stdout.write('Extracting %s...\n' % iso_path) |
| 229 sys.stdout.flush() |
227 # TODO(scottmg): Do this (and exe) manually with python code. | 230 # TODO(scottmg): Do this (and exe) manually with python code. |
228 # Note that at the beginning of main() we set the working directory to 7z's | 231 # Note that at the beginning of main() we set the working directory to 7z's |
229 # location. | 232 # location. |
230 RunOrDie('7z x "%s" -y "-o%s" >nul' % (iso_path, target_path)) | 233 RunOrDie('7z x "%s" -y "-o%s" >nul' % (iso_path, target_path)) |
231 return target_path | 234 return target_path |
232 | 235 |
233 | 236 |
234 ExtractExe = ExtractIso | 237 ExtractExe = ExtractIso |
235 | 238 |
236 | 239 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 " gclient runhooks (or gclient sync if you haven't pulled deps yet)\n" | 705 " gclient runhooks (or gclient sync if you haven't pulled deps yet)\n" |
703 ' ninja -C out\Debug chrome\n\n' | 706 ' ninja -C out\Debug chrome\n\n' |
704 'Note that this script intentionally does not modify any global\n' | 707 'Note that this script intentionally does not modify any global\n' |
705 'settings like the registry, or system environment variables, so you\n' | 708 'settings like the registry, or system environment variables, so you\n' |
706 'will need to run the above env.bat whenever you start a new\n' | 709 'will need to run the above env.bat whenever you start a new\n' |
707 'shell.\n\n' % target_dir) | 710 'shell.\n\n' % target_dir) |
708 | 711 |
709 | 712 |
710 if __name__ == '__main__': | 713 if __name__ == '__main__': |
711 main() | 714 main() |
OLD | NEW |