Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: win_toolchain/package_from_installed.py

Issue 1660723002: Updates to package VS 2015 to not require UCRT (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Add blank line per code review Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « win_toolchain/get_toolchain_if_necessary.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """ 5 """
6 From a system-installed copy of the toolchain, packages all the required bits 6 From a system-installed copy of the toolchain, packages all the required bits
7 into a .zip file. 7 into a .zip file.
8 8
9 It assumes default install locations for tools, in particular: 9 It assumes default install locations for tools, in particular:
10 - C:\Program Files (x86)\Microsoft Visual Studio 12.0\... 10 - C:\Program Files (x86)\Microsoft Visual Studio 12.0\...
11 - C:\Program Files (x86)\Windows Kits\10\... 11 - C:\Program Files (x86)\Windows Kits\10\...
12 12
13 1. Start from a fresh Win7 VM image. 13 1. Start from a fresh Win7 VM image.
14 2. Install VS Pro. Deselect everything except MFC. 14 2. Install VS Pro. Deselect everything except MFC.
15 3. Install Windows 10 SDK. Select only the Windows SDK and Debugging Tools for 15 3. Install Windows 10 SDK. Select only the Windows SDK and Debugging Tools for
16 Windows. 16 Windows.
17 4. Run this script, which will build a <sha1>.zip. 17 4. Run this script, which will build a <sha1>.zip.
18 18
19 Express is not yet supported by this script, but patches welcome (it's not too 19 Express is not yet supported by this script, but patches welcome (it's not too
20 useful as the resulting zip can't be redistributed, and most will presumably 20 useful as the resulting zip can't be redistributed, and most will presumably
21 have a Pro license anyway). 21 have a Pro license anyway).
22 """ 22 """
23 23
24 import glob
24 import optparse 25 import optparse
25 import os 26 import os
26 import platform 27 import platform
27 import shutil 28 import shutil
28 import sys 29 import sys
29 import tempfile 30 import tempfile
30 import zipfile 31 import zipfile
31 32
32 import get_toolchain_if_necessary 33 import get_toolchain_if_necessary
33 34
(...skipping 26 matching lines...) Expand all
60 ('VC/redist/Debug_NonRedist/x86/Microsoft.VC120.DebugCRT', 'sys32'), 61 ('VC/redist/Debug_NonRedist/x86/Microsoft.VC120.DebugCRT', 'sys32'),
61 ('VC/redist/Debug_NonRedist/x86/Microsoft.VC120.DebugMFC', 'sys32'), 62 ('VC/redist/Debug_NonRedist/x86/Microsoft.VC120.DebugMFC', 'sys32'),
62 ('VC/redist/x64/Microsoft.VC120.CRT', 'sys64'), 63 ('VC/redist/x64/Microsoft.VC120.CRT', 'sys64'),
63 ('VC/redist/x64/Microsoft.VC120.MFC', 'sys64'), 64 ('VC/redist/x64/Microsoft.VC120.MFC', 'sys64'),
64 ('VC/redist/Debug_NonRedist/x64/Microsoft.VC120.DebugCRT', 'sys64'), 65 ('VC/redist/Debug_NonRedist/x64/Microsoft.VC120.DebugCRT', 'sys64'),
65 ('VC/redist/Debug_NonRedist/x64/Microsoft.VC120.DebugMFC', 'sys64'), 66 ('VC/redist/Debug_NonRedist/x64/Microsoft.VC120.DebugMFC', 'sys64'),
66 ] 67 ]
67 elif VS_VERSION == '2015': 68 elif VS_VERSION == '2015':
68 paths += [ 69 paths += [
69 ('VC/redist/x86/Microsoft.VC140.CRT', 'sys32'), 70 ('VC/redist/x86/Microsoft.VC140.CRT', 'sys32'),
71 ('VC/redist/x86/Microsoft.VC140.CRT', 'win_sdk/bin/x86'),
70 ('VC/redist/x86/Microsoft.VC140.MFC', 'sys32'), 72 ('VC/redist/x86/Microsoft.VC140.MFC', 'sys32'),
71 ('VC/redist/debug_nonredist/x86/Microsoft.VC140.DebugCRT', 'sys32'), 73 ('VC/redist/debug_nonredist/x86/Microsoft.VC140.DebugCRT', 'sys32'),
72 ('VC/redist/debug_nonredist/x86/Microsoft.VC140.DebugMFC', 'sys32'), 74 ('VC/redist/debug_nonredist/x86/Microsoft.VC140.DebugMFC', 'sys32'),
73 ('VC/redist/x64/Microsoft.VC140.CRT', 'sys64'), 75 ('VC/redist/x64/Microsoft.VC140.CRT', 'sys64'),
76 ('VC/redist/x64/Microsoft.VC140.CRT', 'VC/bin/amd64_x86'),
77 ('VC/redist/x64/Microsoft.VC140.CRT', 'VC/bin/amd64'),
78 ('VC/redist/x64/Microsoft.VC140.CRT', 'win_sdk/bin/x64'),
74 ('VC/redist/x64/Microsoft.VC140.MFC', 'sys64'), 79 ('VC/redist/x64/Microsoft.VC140.MFC', 'sys64'),
75 ('VC/redist/debug_nonredist/x64/Microsoft.VC140.DebugCRT', 'sys64'), 80 ('VC/redist/debug_nonredist/x64/Microsoft.VC140.DebugCRT', 'sys64'),
76 ('VC/redist/debug_nonredist/x64/Microsoft.VC140.DebugMFC', 'sys64'), 81 ('VC/redist/debug_nonredist/x64/Microsoft.VC140.DebugMFC', 'sys64'),
77 ] 82 ]
78 else: 83 else:
79 raise ValueError('VS_VERSION %s' % VS_VERSION) 84 raise ValueError('VS_VERSION %s' % VS_VERSION)
80 85
81 if VS_VERSION == '2013': 86 if VS_VERSION == '2013':
82 vs_path = r'C:\Program Files (x86)\Microsoft Visual Studio 12.0' 87 vs_path = r'C:\Program Files (x86)\Microsoft Visual Studio 12.0'
83 else: 88 else:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 'Windows6.1-KB2999226-x64.msu', 149 'Windows6.1-KB2999226-x64.msu',
145 'Windows8-RT-KB2999226-x64.msu', 150 'Windows8-RT-KB2999226-x64.msu',
146 'Windows8.1-KB2999226-x64.msu', 151 'Windows8.1-KB2999226-x64.msu',
147 ] 152 ]
148 153
149 for installer in universal_runtime_installers: 154 for installer in universal_runtime_installers:
150 result.append((os.path.join(os.environ['userprofile'], 'downloads', 155 result.append((os.path.join(os.environ['userprofile'], 'downloads',
151 installer), 156 installer),
152 os.path.join('installers', installer))) 157 os.path.join('installers', installer)))
153 158
154 system_crt_files = [ 159 if VS_VERSION == '2015':
155 # Needed to let debug binaries run. 160 # Copy the x86 ucrt DLLs to all directories with 32-bit binaries that are
156 'ucrtbased.dll', 161 # added to the path by SetEnv.cmd, and to sys32.
157 ] 162 ucrt_paths = glob.glob(os.path.join(sdk_path, r'redist\ucrt\dlls\x86\*'))
158 bitness = platform.architecture()[0] 163 for ucrt_path in ucrt_paths:
159 # When running 64-bit python the x64 DLLs will be in System32 164 ucrt_file = os.path.split(ucrt_path)[1]
160 x64_path = 'System32' if bitness == '64bit' else 'Sysnative' 165 for dest_dir in [ r'win_sdk\bin\x86', 'sys32' ]:
161 x64_path = os.path.join(r'C:\Windows', x64_path) 166 result.append((ucrt_path, os.path.join(dest_dir, ucrt_file)))
162 for system_crt_file in system_crt_files: 167
163 result.append((os.path.join(r'C:\Windows\SysWOW64', system_crt_file), 168 # Copy the x64 ucrt DLLs to all directories with 64-bit binaries that are
164 os.path.join('sys32', system_crt_file))) 169 # added to the path by SetEnv.cmd, and to sys64.
165 result.append((os.path.join(x64_path, system_crt_file), 170 ucrt_paths = glob.glob(os.path.join(sdk_path, r'redist\ucrt\dlls\x64\*'))
166 os.path.join('sys64', system_crt_file))) 171 for ucrt_path in ucrt_paths:
172 ucrt_file = os.path.split(ucrt_path)[1]
173 for dest_dir in [ r'VC\bin\amd64_x86', r'VC\bin\amd64',
174 r'win_sdk\bin\x64', 'sys64']:
175 result.append((ucrt_path, os.path.join(dest_dir, ucrt_file)))
176
177 system_crt_files = [
178 # Needed to let debug binaries run.
179 'ucrtbased.dll',
180 ]
181 bitness = platform.architecture()[0]
182 # When running 64-bit python the x64 DLLs will be in System32
183 x64_path = 'System32' if bitness == '64bit' else 'Sysnative'
184 x64_path = os.path.join(r'C:\Windows', x64_path)
185 for system_crt_file in system_crt_files:
186 result.append((os.path.join(r'C:\Windows\SysWOW64', system_crt_file),
187 os.path.join('sys32', system_crt_file)))
188 result.append((os.path.join(x64_path, system_crt_file),
189 os.path.join('sys64', system_crt_file)))
167 190
168 # Generically drop all arm stuff that we don't need, and 191 # Generically drop all arm stuff that we don't need, and
169 # drop .msi files because we don't need installers. 192 # drop .msi files because we don't need installers.
170 return [(f, t) for f, t in result if 'arm\\' not in f.lower() and 193 return [(f, t) for f, t in result if 'arm\\' not in f.lower() and
171 'arm64\\' not in f.lower() and 194 'arm64\\' not in f.lower() and
172 not f.lower().endswith('.msi')] 195 not f.lower().endswith('.msi')]
173 196
174 197
175 def GenerateSetEnvCmd(target_dir): 198 def GenerateSetEnvCmd(target_dir):
176 """Generate a batch file that gyp expects to exist to set up the compiler 199 """Generate a batch file that gyp expects to exist to set up the compiler
177 environment. 200 environment.
178 201
179 This is normally generated by a full install of the SDK, but we 202 This is normally generated by a full install of the SDK, but we
180 do it here manually since we do not do a full install.""" 203 do it here manually since we do not do a full install."""
181 with open(os.path.join( 204 with open(os.path.join(
182 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f: 205 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f:
183 f.write('@echo off\n' 206 f.write('@echo off\n'
184 ':: Generated by win_toolchain\\package_from_installed.py.\n' 207 ':: Generated by win_toolchain\\package_from_installed.py.\n'
185 # Common to x86 and x64 208 # Common to x86 and x64
186 'set VSINSTALLDIR=%~dp0..\\..\\\n' 209 'set VSINSTALLDIR=%~dp0..\\..\\\n'
187 'set VCINSTALLDIR=%~dp0..\\..\\VC\\\n' 210 'set VCINSTALLDIR=%~dp0..\\..\\VC\\\n'
188 'set PATH=%~dp0..\\..\\Common7\\IDE;%PATH%\n'
189 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\um;' 211 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\um;'
190 '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\shared;' 212 '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\shared;'
191 '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\winrt;'.replace( 213 '%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\winrt;'.replace(
192 'WINVERSION', WIN_VERSION)) 214 'WINVERSION', WIN_VERSION))
193 if VS_VERSION == '2015': 215 if VS_VERSION == '2015':
194 f.write('%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\ucrt;'.replace( 216 f.write('%~dp0..\\..\\win_sdk\\Include\\WINVERSION\\ucrt;'.replace(
195 'WINVERSION', WIN_VERSION)) 217 'WINVERSION', WIN_VERSION))
196 f.write('%~dp0..\\..\\VC\\include;' 218 f.write('%~dp0..\\..\\VC\\include;'
197 '%~dp0..\\..\\VC\\atlmfc\\include\n') 219 '%~dp0..\\..\\VC\\atlmfc\\include\n')
198 220
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 sys.stdout.write('\rWrote to %s.%s\n' % (output, ' '*50)) 343 sys.stdout.write('\rWrote to %s.%s\n' % (output, ' '*50))
322 sys.stdout.flush() 344 sys.stdout.flush()
323 345
324 RenameToSha1(output) 346 RenameToSha1(output)
325 347
326 return 0 348 return 0
327 349
328 350
329 if __name__ == '__main__': 351 if __name__ == '__main__':
330 sys.exit(main()) 352 sys.exit(main())
OLDNEW
« no previous file with comments | « win_toolchain/get_toolchain_if_necessary.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698