| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 import _winreg | 5 import _winreg |
| 6 import os | 6 import os |
| 7 import shutil | 7 import shutil |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 to be turned into a string in the target C program.""" | 37 to be turned into a string in the target C program.""" |
| 38 path = '"' + path + '"' | 38 path = '"' + path + '"' |
| 39 return path.replace('\\', '\\\\').replace('"', '\\"') | 39 return path.replace('\\', '\\\\').replace('"', '\\"') |
| 40 | 40 |
| 41 | 41 |
| 42 def main(): | 42 def main(): |
| 43 # Switch to our own dir. | 43 # Switch to our own dir. |
| 44 os.chdir(BASE_DIR) | 44 os.chdir(BASE_DIR) |
| 45 | 45 |
| 46 link = FindInPath('link.exe') | 46 link = FindInPath('link.exe') |
| 47 if not link: | 47 mt = FindInPath('mt.exe') |
| 48 print("Couldn't find link.exe in PATH. Must run from Administrator " | 48 if not link or not mt: |
| 49 "Visual Studio Command Prompt.") | 49 print("Couldn't find link.exe or mt.exe in PATH. " |
| 50 "Must run from Administrator Visual Studio Command Prompt.") |
| 50 return 1 | 51 return 1 |
| 51 | 52 |
| 52 link_backup = os.path.join(os.path.split(link)[0], 'link.exe.split_link.exe') | 53 link_backup = os.path.join(os.path.split(link)[0], 'link.exe.split_link.exe') |
| 53 | 54 |
| 54 # Don't re-backup link.exe, so only copy link.exe to backup if it's | 55 # Don't re-backup link.exe, so only copy link.exe to backup if it's |
| 55 # not there already. | 56 # not there already. |
| 56 if not os.path.exists(link_backup): | 57 if not os.path.exists(link_backup): |
| 57 try: | 58 try: |
| 58 print 'Saving original link.exe...' | 59 print 'Saving original link.exe...' |
| 59 shutil.copyfile(link, link_backup) | 60 shutil.copyfile(link, link_backup) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 python, script_path)) | 77 python, script_path)) |
| 77 | 78 |
| 78 # Copy shim into place. | 79 # Copy shim into place. |
| 79 print 'Copying split_link.exe over link.exe...' | 80 print 'Copying split_link.exe over link.exe...' |
| 80 try: | 81 try: |
| 81 shutil.copyfile('split_link.exe', link) | 82 shutil.copyfile('split_link.exe', link) |
| 82 _winreg.SetValue(_winreg.HKEY_CURRENT_USER, | 83 _winreg.SetValue(_winreg.HKEY_CURRENT_USER, |
| 83 'Software\\Chromium\\split_link_installed', | 84 'Software\\Chromium\\split_link_installed', |
| 84 _winreg.REG_SZ, | 85 _winreg.REG_SZ, |
| 85 link_backup) | 86 link_backup) |
| 87 _winreg.SetValue(_winreg.HKEY_CURRENT_USER, |
| 88 'Software\\Chromium\\split_link_mt_path', |
| 89 _winreg.REG_SZ, |
| 90 mt) |
| 86 except IOError: | 91 except IOError: |
| 87 print("Wasn't able to copy split_link.exe over %s. " | 92 print("Wasn't able to copy split_link.exe over %s. " |
| 88 "Not running with Administrator privileges?" % link) | 93 "Not running with Administrator privileges?" % link) |
| 89 return 1 | 94 return 1 |
| 90 | 95 |
| 91 return 0 | 96 return 0 |
| 92 | 97 |
| 93 | 98 |
| 94 if __name__ == '__main__': | 99 if __name__ == '__main__': |
| 95 sys.exit(main()) | 100 sys.exit(main()) |
| OLD | NEW |