| OLD | NEW |
| 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\8.1\... | 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 8 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 os | 24 import os |
| 25 import shutil | 25 import shutil |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 with open(final_from, 'rb') as unpatched_f: | 99 with open(final_from, 'rb') as unpatched_f: |
| 100 unpatched_contents = unpatched_f.read() | 100 unpatched_contents = unpatched_f.read() |
| 101 os.write(handle, | 101 os.write(handle, |
| 102 unpatched_contents.replace('warning(disable: 4127)', | 102 unpatched_contents.replace('warning(disable: 4127)', |
| 103 'warning(disable: 4127 4702)')) | 103 'warning(disable: 4127 4702)')) |
| 104 result.append((patched, dest)) | 104 result.append((patched, dest)) |
| 105 else: | 105 else: |
| 106 result.append((final_from, dest)) | 106 result.append((final_from, dest)) |
| 107 | 107 |
| 108 # Just copy the whole SDK. | 108 # Just copy the whole SDK. |
| 109 sdk_path = r'C:\Program Files (x86)\Windows Kits\8.1' | 109 sdk_path = r'C:\Program Files (x86)\Windows Kits\10' |
| 110 for root, _, files in os.walk(sdk_path): | 110 for root, _, files in os.walk(sdk_path): |
| 111 for f in files: | 111 for f in files: |
| 112 combined = os.path.normpath(os.path.join(root, f)) | 112 combined = os.path.normpath(os.path.join(root, f)) |
| 113 to = os.path.join('win_sdk', combined[len(sdk_path) + 1:]) | 113 to = os.path.join('win_sdk', combined[len(sdk_path) + 1:]) |
| 114 result.append((combined, to)) | 114 result.append((combined, to)) |
| 115 | 115 |
| 116 if VS_VERSION == '2015': | 116 if VS_VERSION == '2015': |
| 117 for ucrt_path in ( | 117 for ucrt_path in ( |
| 118 (r'C:\Program Files (x86)\Windows Kits\10\Include', 'Include'), | 118 (r'C:\Program Files (x86)\Windows Kits\10\Include', 'Include'), |
| 119 (r'C:\Program Files (x86)\Windows Kits\10\Lib', 'Lib'), | 119 (r'C:\Program Files (x86)\Windows Kits\10\Lib', 'Lib'), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 environment. | 168 environment. |
| 169 | 169 |
| 170 This is normally generated by a full install of the SDK, but we | 170 This is normally generated by a full install of the SDK, but we |
| 171 do it here manually since we do not do a full install.""" | 171 do it here manually since we do not do a full install.""" |
| 172 with open(os.path.join( | 172 with open(os.path.join( |
| 173 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f: | 173 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f: |
| 174 f.write('@echo off\n' | 174 f.write('@echo off\n' |
| 175 ':: Generated by win_toolchain\\package_from_installed.py.\n' | 175 ':: Generated by win_toolchain\\package_from_installed.py.\n' |
| 176 # Common to x86 and x64 | 176 # Common to x86 and x64 |
| 177 'set PATH=%~dp0..\\..\\Common7\\IDE;%PATH%\n' | 177 'set PATH=%~dp0..\\..\\Common7\\IDE;%PATH%\n' |
| 178 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\um;' | 178 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\um;' |
| 179 '%~dp0..\\..\\win_sdk\\Include\\shared;' | 179 '%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\shared;' |
| 180 '%~dp0..\\..\\win_sdk\\Include\\winrt;' | 180 '%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\winrt;' |
| 181 '%~dp0..\\..\\ucrt\\Include\\10.0.10056.0\\ucrt;' | |
| 182 '%~dp0..\\..\\VC\\include;' | 181 '%~dp0..\\..\\VC\\include;' |
| 183 '%~dp0..\\..\\VC\\atlmfc\\include\n' | 182 '%~dp0..\\..\\VC\\atlmfc\\include\n' |
| 184 'if "%1"=="/x64" goto x64\n') | 183 'if "%1"=="/x64" goto x64\n') |
| 185 | 184 |
| 186 # x86. Always use amd64_x86 cross, not x86 on x86. | 185 # x86. Always use amd64_x86 cross, not x86 on x86. |
| 187 f.write('set PATH=%~dp0..\\..\\win_sdk\\bin\\x86;' | 186 f.write('set PATH=%~dp0..\\..\\win_sdk\\bin\\x86;' |
| 188 '%~dp0..\\..\\VC\\bin\\amd64_x86;' | 187 '%~dp0..\\..\\VC\\bin\\amd64_x86;' |
| 189 '%~dp0..\\..\\VC\\bin\\amd64;' # Needed for mspdb1x0.dll. | 188 '%~dp0..\\..\\VC\\bin\\amd64;' # Needed for mspdb1x0.dll. |
| 190 '%PATH%\n') | 189 '%PATH%\n') |
| 191 f.write('set LIB=%~dp0..\\..\\VC\\lib;' | 190 f.write('set LIB=%~dp0..\\..\\VC\\lib;' |
| 192 '%~dp0..\\..\\win_sdk\\Lib\\winv6.3\\um\\x86;' | 191 '%~dp0..\\..\\win_sdk\\Lib\\10.0.10240.0\\um\\x86;' |
| 193 '%~dp0..\\..\\ucrt\\Lib\\10.0.10056.0\\ucrt\\x86;' | |
| 194 '%~dp0..\\..\\VC\\atlmfc\\lib\n' | 192 '%~dp0..\\..\\VC\\atlmfc\\lib\n' |
| 195 'goto :EOF\n') | 193 'goto :EOF\n') |
| 196 | 194 |
| 197 # x64. | 195 # x64. |
| 198 f.write(':x64\n' | 196 f.write(':x64\n' |
| 199 'set PATH=%~dp0..\\..\\win_sdk\\bin\\x64;' | 197 'set PATH=%~dp0..\\..\\win_sdk\\bin\\x64;' |
| 200 '%~dp0..\\..\\VC\\bin\\amd64;' | 198 '%~dp0..\\..\\VC\\bin\\amd64;' |
| 201 '%PATH%\n') | 199 '%PATH%\n') |
| 202 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' | 200 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' |
| 203 '%~dp0..\\..\\win_sdk\\Lib\\winv6.3\\um\\x64;' | 201 '%~dp0..\\..\\win_sdk\\Lib\\10.0.10240.0\\um\\x64;' |
| 204 '%~dp0..\\..\\ucrt\\Lib\\10.0.10056.0\\ucrt\\x64;' | |
| 205 '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n') | 202 '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n') |
| 206 | 203 |
| 207 | 204 |
| 208 def AddEnvSetup(files): | 205 def AddEnvSetup(files): |
| 209 """We need to generate this file in the same way that the "from pieces" | 206 """We need to generate this file in the same way that the "from pieces" |
| 210 script does, so pull that in here.""" | 207 script does, so pull that in here.""" |
| 211 tempdir = tempfile.mkdtemp() | 208 tempdir = tempfile.mkdtemp() |
| 212 os.makedirs(os.path.join(tempdir, 'win_sdk', 'bin')) | 209 os.makedirs(os.path.join(tempdir, 'win_sdk', 'bin')) |
| 213 GenerateSetEnvCmd(tempdir) | 210 GenerateSetEnvCmd(tempdir) |
| 214 files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.cmd'), | 211 files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.cmd'), |
| 215 'win_sdk\\bin\\SetEnv.cmd')) | 212 'win_sdk\\bin\\SetEnv.cmd')) |
| 216 vs_version_file = os.path.join(tempdir, 'VS_VERSION') | 213 vs_version_file = os.path.join(tempdir, 'VS_VERSION') |
| 217 with open(vs_version_file, 'wb') as version: | 214 with open(vs_version_file, 'wb') as version: |
| 218 print >>version, VS_VERSION | 215 print >>version, VS_VERSION |
| 219 files.append((vs_version_file, 'VS_VERSION')) | 216 files.append((vs_version_file, 'VS_VERSION')) |
| 220 | 217 |
| 221 | 218 |
| 222 def RenameToSha1(output): | 219 def RenameToSha1(output): |
| 223 """Determine the hash in the same way that the unzipper does to rename the | 220 """Determine the hash in the same way that the unzipper does to rename the |
| 224 # .zip file.""" | 221 # .zip file.""" |
| 225 print 'Extracting to determine hash...' | 222 print 'Extracting to determine hash...' |
| 226 tempdir = tempfile.mkdtemp() | 223 tempdir = tempfile.mkdtemp() |
| 227 old_dir = os.getcwd() | 224 old_dir = os.getcwd() |
| 228 os.chdir(tempdir) | 225 os.chdir(tempdir) |
| 229 rel_dir = 'vs_files' | 226 if VS_VERSION == '2013': |
| 227 rel_dir = 'vs2013_files' |
| 228 else: |
| 229 rel_dir = 'vs_files' |
| 230 with zipfile.ZipFile( | 230 with zipfile.ZipFile( |
| 231 os.path.join(old_dir, output), 'r', zipfile.ZIP_DEFLATED, True) as zf: | 231 os.path.join(old_dir, output), 'r', zipfile.ZIP_DEFLATED, True) as zf: |
| 232 zf.extractall(rel_dir) | 232 zf.extractall(rel_dir) |
| 233 print 'Hashing...' | 233 print 'Hashing...' |
| 234 sha1 = get_toolchain_if_necessary.CalculateHash(rel_dir) | 234 sha1 = get_toolchain_if_necessary.CalculateHash(rel_dir) |
| 235 os.chdir(old_dir) | 235 os.chdir(old_dir) |
| 236 shutil.rmtree(tempdir) | 236 shutil.rmtree(tempdir) |
| 237 final_name = sha1 + '.zip' | 237 final_name = sha1 + '.zip' |
| 238 os.rename(output, final_name) | 238 os.rename(output, final_name) |
| 239 print 'Renamed %s to %s.' % (output, final_name) | 239 print 'Renamed %s to %s.' % (output, final_name) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 270 sys.stdout.write('\rWrote to %s.%s\n' % (output, ' '*50)) | 270 sys.stdout.write('\rWrote to %s.%s\n' % (output, ' '*50)) |
| 271 sys.stdout.flush() | 271 sys.stdout.flush() |
| 272 | 272 |
| 273 RenameToSha1(output) | 273 RenameToSha1(output) |
| 274 | 274 |
| 275 return 0 | 275 return 0 |
| 276 | 276 |
| 277 | 277 |
| 278 if __name__ == '__main__': | 278 if __name__ == '__main__': |
| 279 sys.exit(main()) | 279 sys.exit(main()) |
| OLD | NEW |