Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import glob | |
| 6 import json | 7 import json |
| 7 import os | 8 import os |
| 8 import pipes | 9 import pipes |
| 9 import shutil | 10 import shutil |
| 10 import subprocess | 11 import subprocess |
| 11 import sys | 12 import sys |
| 12 | 13 |
| 13 | 14 |
| 14 script_dir = os.path.dirname(os.path.realpath(__file__)) | 15 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 15 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) | 16 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 GYP_MSVS_VERSION.""" | 145 GYP_MSVS_VERSION.""" |
| 145 vs_version = GetVisualStudioVersion() | 146 vs_version = GetVisualStudioVersion() |
| 146 if vs_version == '2013': | 147 if vs_version == '2013': |
| 147 return '120' | 148 return '120' |
| 148 elif vs_version == '2015': | 149 elif vs_version == '2015': |
| 149 return '140' | 150 return '140' |
| 150 else: | 151 else: |
| 151 raise ValueError('Unexpected GYP_MSVS_VERSION') | 152 raise ValueError('Unexpected GYP_MSVS_VERSION') |
| 152 | 153 |
| 153 | 154 |
| 154 def _CopyRuntimeImpl(target, source): | 155 def _CopyRuntimeImpl(target, source, verbose = True): |
|
M-A Ruel
2016/02/08 20:19:14
verbose=True
brucedawson
2016/02/08 21:00:31
Done.
| |
| 155 """Copy |source| to |target| if it doesn't already exist or if it | 156 """Copy |source| to |target| if it doesn't already exist or if it |
| 156 needs to be updated. | 157 needs to be updated. |
| 157 """ | 158 """ |
| 158 if (os.path.isdir(os.path.dirname(target)) and | 159 if (os.path.isdir(os.path.dirname(target)) and |
| 159 (not os.path.isfile(target) or | 160 (not os.path.isfile(target) or |
| 160 os.stat(target).st_mtime != os.stat(source).st_mtime)): | 161 os.stat(target).st_mtime != os.stat(source).st_mtime)): |
| 161 print 'Copying %s to %s...' % (source, target) | 162 if verbose: |
| 163 print 'Copying %s to %s...' % (source, target) | |
| 162 if os.path.exists(target): | 164 if os.path.exists(target): |
| 163 os.unlink(target) | 165 os.unlink(target) |
| 164 shutil.copy2(source, target) | 166 shutil.copy2(source, target) |
| 165 | 167 |
| 166 | 168 |
| 167 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): | 169 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): |
| 168 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't | 170 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
| 169 exist, but the target directory does exist.""" | 171 exist, but the target directory does exist.""" |
| 170 for file_part in ('p', 'r'): | 172 for file_part in ('p', 'r'): |
| 171 dll = dll_pattern % file_part | 173 dll = dll_pattern % file_part |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 183 source = os.path.join(source_dir, dll) | 185 source = os.path.join(source_dir, dll) |
| 184 _CopyRuntimeImpl(target, source) | 186 _CopyRuntimeImpl(target, source) |
| 185 | 187 |
| 186 | 188 |
| 187 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): | 189 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): |
| 188 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target | 190 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target |
| 189 directory does exist. Handles VS 2013 and VS 2015.""" | 191 directory does exist. Handles VS 2013 and VS 2015.""" |
| 190 suffix = "d.dll" if debug else ".dll" | 192 suffix = "d.dll" if debug else ".dll" |
| 191 if GetVisualStudioVersion() == '2015': | 193 if GetVisualStudioVersion() == '2015': |
| 192 _CopyRuntime2015(target_dir, source_dir, '%s140' + suffix) | 194 _CopyRuntime2015(target_dir, source_dir, '%s140' + suffix) |
| 193 if debug: | 195 ucrt_src_dir = os.path.join(source_dir, "api-ms-win-*.dll") |
|
M-A Ruel
2016/02/08 20:19:14
single quote
brucedawson
2016/02/08 21:00:31
Done.
| |
| 194 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbased.dll'), | 196 print 'Copying %s to %s...' % (ucrt_src_dir, target_dir) |
| 195 os.path.join(source_dir, 'ucrtbased.dll')) | 197 for ucrt_src_file in glob.glob(ucrt_src_dir): |
| 198 file_part = os.path.split(ucrt_src_file)[1] | |
|
M-A Ruel
2016/02/08 20:19:14
os.path.basename()
brucedawson
2016/02/08 21:00:31
Much better. Done.
| |
| 199 ucrt_dst_file = os.path.join(target_dir, file_part) | |
| 200 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, verbose = False) | |
|
M-A Ruel
2016/02/08 20:19:14
remove "verbose = "
brucedawson
2016/02/08 21:00:31
Done.
| |
| 201 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), | |
| 202 os.path.join(source_dir, 'ucrtbase' + suffix)) | |
| 196 else: | 203 else: |
| 197 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) | 204 _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix) |
| 198 | 205 |
| 199 # Copy the PGO runtime library to the release directories. | 206 # Copy the PGO runtime library to the release directories. |
| 200 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): | 207 if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'): |
| 201 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), | 208 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), |
| 202 'VC', 'bin') | 209 'VC', 'bin') |
| 203 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') | 210 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') |
| 204 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' | 211 pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' |
| 205 if target_cpu == "x86": | 212 if target_cpu == "x86": |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 'copy_dlls': CopyDlls, | 360 'copy_dlls': CopyDlls, |
| 354 } | 361 } |
| 355 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 362 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
| 356 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 363 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
| 357 return 1 | 364 return 1 |
| 358 return commands[sys.argv[1]](*sys.argv[2:]) | 365 return commands[sys.argv[1]](*sys.argv[2:]) |
| 359 | 366 |
| 360 | 367 |
| 361 if __name__ == '__main__': | 368 if __name__ == '__main__': |
| 362 sys.exit(main()) | 369 sys.exit(main()) |
| OLD | NEW |