| 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 # Some of the files in this directory are exceedingly long (and exceed |
| 114 #_MAX_PATH for any moderately long root), so exclude them. We don't need |
| 115 # them anyway. |
| 116 tail = combined[len(sdk_path) + 1:] |
| 117 if tail.startswith('References\\'): |
| 118 continue |
| 119 to = os.path.join('win_sdk', tail) |
| 114 result.append((combined, to)) | 120 result.append((combined, to)) |
| 115 | 121 |
| 116 if VS_VERSION == '2015': | 122 if VS_VERSION == '2015': |
| 117 for ucrt_path in ( | 123 for ucrt_path in ( |
| 118 (r'C:\Program Files (x86)\Windows Kits\10\Include', 'Include'), | 124 (r'C:\Program Files (x86)\Windows Kits\10\Include', 'Include'), |
| 119 (r'C:\Program Files (x86)\Windows Kits\10\Lib', 'Lib'), | 125 (r'C:\Program Files (x86)\Windows Kits\10\Lib', 'Lib'), |
| 120 (r'C:\Program Files (x86)\Windows Kits\10\Source', 'Source')): | 126 (r'C:\Program Files (x86)\Windows Kits\10\Source', 'Source')): |
| 121 src, target = ucrt_path | 127 src, target = ucrt_path |
| 122 for root, _, files in os.walk(src): | 128 for root, _, files in os.walk(src): |
| 123 for f in files: | 129 for f in files: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 environment. | 174 environment. |
| 169 | 175 |
| 170 This is normally generated by a full install of the SDK, but we | 176 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.""" | 177 do it here manually since we do not do a full install.""" |
| 172 with open(os.path.join( | 178 with open(os.path.join( |
| 173 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f: | 179 target_dir, r'win_sdk\bin\SetEnv.cmd'), 'w') as f: |
| 174 f.write('@echo off\n' | 180 f.write('@echo off\n' |
| 175 ':: Generated by win_toolchain\\package_from_installed.py.\n' | 181 ':: Generated by win_toolchain\\package_from_installed.py.\n' |
| 176 # Common to x86 and x64 | 182 # Common to x86 and x64 |
| 177 'set PATH=%~dp0..\\..\\Common7\\IDE;%PATH%\n' | 183 'set PATH=%~dp0..\\..\\Common7\\IDE;%PATH%\n' |
| 178 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\um;' | 184 'set INCLUDE=%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\um;' |
| 179 '%~dp0..\\..\\win_sdk\\Include\\shared;' | 185 '%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\shared;' |
| 180 '%~dp0..\\..\\win_sdk\\Include\\winrt;' | 186 '%~dp0..\\..\\win_sdk\\Include\\10.0.10240.0\\winrt;' |
| 181 '%~dp0..\\..\\ucrt\\Include\\10.0.10056.0\\ucrt;' | |
| 182 '%~dp0..\\..\\VC\\include;' | 187 '%~dp0..\\..\\VC\\include;' |
| 183 '%~dp0..\\..\\VC\\atlmfc\\include\n' | 188 '%~dp0..\\..\\VC\\atlmfc\\include\n' |
| 184 'if "%1"=="/x64" goto x64\n') | 189 'if "%1"=="/x64" goto x64\n') |
| 185 | 190 |
| 186 # x86. Always use amd64_x86 cross, not x86 on x86. | 191 # x86. Always use amd64_x86 cross, not x86 on x86. |
| 187 f.write('set PATH=%~dp0..\\..\\win_sdk\\bin\\x86;' | 192 f.write('set PATH=%~dp0..\\..\\win_sdk\\bin\\x86;' |
| 188 '%~dp0..\\..\\VC\\bin\\amd64_x86;' | 193 '%~dp0..\\..\\VC\\bin\\amd64_x86;' |
| 189 '%~dp0..\\..\\VC\\bin\\amd64;' # Needed for mspdb1x0.dll. | 194 '%~dp0..\\..\\VC\\bin\\amd64;' # Needed for mspdb1x0.dll. |
| 190 '%PATH%\n') | 195 '%PATH%\n') |
| 191 f.write('set LIB=%~dp0..\\..\\VC\\lib;' | 196 f.write('set LIB=%~dp0..\\..\\VC\\lib;' |
| 192 '%~dp0..\\..\\win_sdk\\Lib\\winv6.3\\um\\x86;' | 197 '%~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' | 198 '%~dp0..\\..\\VC\\atlmfc\\lib\n' |
| 195 'goto :EOF\n') | 199 'goto :EOF\n') |
| 196 | 200 |
| 197 # x64. | 201 # x64. |
| 198 f.write(':x64\n' | 202 f.write(':x64\n' |
| 199 'set PATH=%~dp0..\\..\\win_sdk\\bin\\x64;' | 203 'set PATH=%~dp0..\\..\\win_sdk\\bin\\x64;' |
| 200 '%~dp0..\\..\\VC\\bin\\amd64;' | 204 '%~dp0..\\..\\VC\\bin\\amd64;' |
| 201 '%PATH%\n') | 205 '%PATH%\n') |
| 202 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' | 206 f.write('set LIB=%~dp0..\\..\\VC\\lib\\amd64;' |
| 203 '%~dp0..\\..\\win_sdk\\Lib\\winv6.3\\um\\x64;' | 207 '%~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') | 208 '%~dp0..\\..\\VC\\atlmfc\\lib\\amd64\n') |
| 206 | 209 |
| 207 | 210 |
| 208 def AddEnvSetup(files): | 211 def AddEnvSetup(files): |
| 209 """We need to generate this file in the same way that the "from pieces" | 212 """We need to generate this file in the same way that the "from pieces" |
| 210 script does, so pull that in here.""" | 213 script does, so pull that in here.""" |
| 211 tempdir = tempfile.mkdtemp() | 214 tempdir = tempfile.mkdtemp() |
| 212 os.makedirs(os.path.join(tempdir, 'win_sdk', 'bin')) | 215 os.makedirs(os.path.join(tempdir, 'win_sdk', 'bin')) |
| 213 GenerateSetEnvCmd(tempdir) | 216 GenerateSetEnvCmd(tempdir) |
| 214 files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.cmd'), | 217 files.append((os.path.join(tempdir, 'win_sdk', 'bin', 'SetEnv.cmd'), |
| 215 'win_sdk\\bin\\SetEnv.cmd')) | 218 'win_sdk\\bin\\SetEnv.cmd')) |
| 216 vs_version_file = os.path.join(tempdir, 'VS_VERSION') | 219 vs_version_file = os.path.join(tempdir, 'VS_VERSION') |
| 217 with open(vs_version_file, 'wb') as version: | 220 with open(vs_version_file, 'wb') as version: |
| 218 print >>version, VS_VERSION | 221 print >>version, VS_VERSION |
| 219 files.append((vs_version_file, 'VS_VERSION')) | 222 files.append((vs_version_file, 'VS_VERSION')) |
| 220 | 223 |
| 221 | 224 |
| 222 def RenameToSha1(output): | 225 def RenameToSha1(output): |
| 223 """Determine the hash in the same way that the unzipper does to rename the | 226 """Determine the hash in the same way that the unzipper does to rename the |
| 224 # .zip file.""" | 227 # .zip file.""" |
| 225 print 'Extracting to determine hash...' | 228 print 'Extracting to determine hash...' |
| 226 tempdir = tempfile.mkdtemp() | 229 tempdir = tempfile.mkdtemp() |
| 227 old_dir = os.getcwd() | 230 old_dir = os.getcwd() |
| 228 os.chdir(tempdir) | 231 os.chdir(tempdir) |
| 229 rel_dir = 'vs_files' | 232 if VS_VERSION == '2013': |
| 233 rel_dir = 'vs2013_files' |
| 234 else: |
| 235 rel_dir = 'vs_files' |
| 230 with zipfile.ZipFile( | 236 with zipfile.ZipFile( |
| 231 os.path.join(old_dir, output), 'r', zipfile.ZIP_DEFLATED, True) as zf: | 237 os.path.join(old_dir, output), 'r', zipfile.ZIP_DEFLATED, True) as zf: |
| 232 zf.extractall(rel_dir) | 238 zf.extractall(rel_dir) |
| 233 print 'Hashing...' | 239 print 'Hashing...' |
| 234 sha1 = get_toolchain_if_necessary.CalculateHash(rel_dir) | 240 sha1 = get_toolchain_if_necessary.CalculateHash(rel_dir) |
| 235 os.chdir(old_dir) | 241 os.chdir(old_dir) |
| 236 shutil.rmtree(tempdir) | 242 shutil.rmtree(tempdir) |
| 237 final_name = sha1 + '.zip' | 243 final_name = sha1 + '.zip' |
| 238 os.rename(output, final_name) | 244 os.rename(output, final_name) |
| 239 print 'Renamed %s to %s.' % (output, final_name) | 245 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)) | 276 sys.stdout.write('\rWrote to %s.%s\n' % (output, ' '*50)) |
| 271 sys.stdout.flush() | 277 sys.stdout.flush() |
| 272 | 278 |
| 273 RenameToSha1(output) | 279 RenameToSha1(output) |
| 274 | 280 |
| 275 return 0 | 281 return 0 |
| 276 | 282 |
| 277 | 283 |
| 278 if __name__ == '__main__': | 284 if __name__ == '__main__': |
| 279 sys.exit(main()) | 285 sys.exit(main()) |
| OLD | NEW |