OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Copies necessary add-in files into place to install the add-in. | 6 """Copies necessary add-in files into place to install the add-in. |
7 | 7 |
8 This script will copy the necessary files for the Visual Studio add-in | 8 This script will copy the necessary files for the Visual Studio add-in |
9 to where Visual Studio can find them. It assumes the current directory | 9 to where Visual Studio can find them. It assumes the current directory |
10 contains the necessary files to copy. | 10 contains the necessary files to copy. |
11 """ | 11 """ |
12 | 12 |
13 import create_ppapi_platform | 13 import create_ppapi_platform |
14 import ctypes | 14 import ctypes |
15 import os | 15 import os |
16 import optparse | 16 import optparse |
17 import platform | 17 import platform |
18 import shutil | 18 import shutil |
19 import sys | 19 import sys |
20 import time | 20 import time |
21 | 21 |
22 NACL32_PLATFORM = 'NaCl32' | 22 NACL32_PLATFORM = 'NaCl32' |
23 NACL64_PLATFORM = 'NaCl64' | 23 NACL64_PLATFORM = 'NaCl64' |
24 NACLARM_PLATFORM = 'NaClARM' | 24 NACLARM_PLATFORM = 'NaClARM' |
25 PNACL_PLATFORM = 'PNaCl' | 25 PNACL_PLATFORM = 'PNaCl' |
26 NACL_PLATFORM_OLD = 'NaCl' | 26 NACL_PLATFORM_OLD = 'NaCl' |
27 PEPPER_PLATFORM = 'PPAPI' | 27 PEPPER_PLATFORM = 'PPAPI' |
28 | 28 |
29 DEFAULT_VS_DIRECTORIES = ('%USERPROFILE%\\My Documents\\Visual Studio 2010', | 29 DEFAULT_VS_DIRECTORIES = ['%USERPROFILE%\\My Documents\\Visual Studio 2010', |
30 '%USERPROFILE%\\My Documents\\Visual Studio 2012') | 30 '%USERPROFILE%\\My Documents\\Visual Studio 2012'] |
31 | 31 |
32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
33 | 33 |
34 ADDIN_FILES = ['NativeClientVSAddIn.AddIn', 'NativeClientVSAddIn.dll'] | 34 ADDIN_FILES = ['NativeClientVSAddIn.AddIn', 'NativeClientVSAddIn.dll'] |
35 | 35 |
36 options = None | 36 options = None |
37 | 37 |
38 if sys.version_info < (2, 6, 2): | 38 if sys.version_info < (2, 6, 2): |
39 print "\n\nWARNING: Python version 2.6.2 or greater is required. " \ | 39 print "\n\nWARNING: Python version 2.6.2 or greater is required. " \ |
40 "Current version is %s\n\n" % (sys.version_info[:3],) | 40 "Current version is %s\n\n" % (sys.version_info[:3],) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return False | 79 return False |
80 | 80 |
81 | 81 |
82 def UninstallAddin(vsuser_path): | 82 def UninstallAddin(vsuser_path): |
83 addin_dir = os.path.join(vsuser_path, 'Addins') | 83 addin_dir = os.path.join(vsuser_path, 'Addins') |
84 for file_name in ADDIN_FILES: | 84 for file_name in ADDIN_FILES: |
85 UninstallFile(os.path.join(addin_dir, file_name)) | 85 UninstallFile(os.path.join(addin_dir, file_name)) |
86 | 86 |
87 | 87 |
88 def InstallAddin(vsuser_path): | 88 def InstallAddin(vsuser_path): |
89 vsuser_path = os.path.expandvars(vsuser_path) | |
90 | |
91 vsname = os.path.basename(vsuser_path) | 89 vsname = os.path.basename(vsuser_path) |
92 if '2012' in vsname: | 90 if '2012' in vsname: |
93 vs_version = '2012' | 91 vs_version = '2012' |
94 elif '2010' in vsname: | 92 elif '2010' in vsname: |
95 vs_version = '2010' | 93 vs_version = '2010' |
96 else: | 94 else: |
97 raise InstallError("Unable to determine valid VS version (2010 or 2012) " | 95 raise InstallError("Unable to determine valid VS version (2010 or 2012) " |
98 "from path: %s" % vsuser_path) | 96 "from path: %s" % vsuser_path) |
99 | 97 |
100 # Ensure install directories exist. | 98 # Ensure install directories exist. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 raise InstallError('Environment Variable NACL_SDK_ROOT is not set') | 299 raise InstallError('Environment Variable NACL_SDK_ROOT is not set') |
302 if chrome_path is None: | 300 if chrome_path is None: |
303 raise InstallError('Environment Variable CHROME_PATH is not set') | 301 raise InstallError('Environment Variable CHROME_PATH is not set') |
304 | 302 |
305 # If uninstalling then redirect to uninstall program. | 303 # If uninstalling then redirect to uninstall program. |
306 if options.uninstall: | 304 if options.uninstall: |
307 Uninstall() | 305 Uninstall() |
308 print "\nUninstall complete!\n" | 306 print "\nUninstall complete!\n" |
309 return 0 | 307 return 0 |
310 | 308 |
| 309 # Verify that at least on Visual Studio user path exists, then |
| 310 # filter out any that don't. |
| 311 options.vsuser_path = [os.path.expandvars(p) for p in options.vsuser_path] |
| 312 if not any(os.path.exists(p) for p in options.vsuser_path): |
| 313 raise InstallError('Failed to find any suitable location to install the' |
| 314 ' Addin. Tried:\n\t' + '\n\t'.join(options.vsuser_path)) |
| 315 options.vsuser_path = [p for p in options.vsuser_path if os.path.exists(p)] |
| 316 |
311 try: | 317 try: |
312 InstallMSBuild() | 318 InstallMSBuild() |
313 | 319 |
314 for vsuser_path in options.vsuser_path: | 320 for vsuser_path in options.vsuser_path: |
315 InstallAddin(vsuser_path) | 321 InstallAddin(vsuser_path) |
316 except: | 322 except: |
317 print "\nException occured! Rolling back install...\n" | 323 print "\nException occured! Rolling back install...\n" |
318 Uninstall() | 324 Uninstall() |
319 raise | 325 raise |
320 else: | 326 else: |
(...skipping 16 matching lines...) Expand all Loading... |
337 print e | 343 print e |
338 print("The install script failed to write to the files mentioned above") | 344 print("The install script failed to write to the files mentioned above") |
339 if ctypes.windll.shell32.IsUserAnAdmin() != 1: | 345 if ctypes.windll.shell32.IsUserAnAdmin() != 1: |
340 print("Please try running as administrator.") | 346 print("Please try running as administrator.") |
341 else: | 347 else: |
342 print("Please check for any running programs that might " | 348 print("Please check for any running programs that might " |
343 "have them locked.") | 349 "have them locked.") |
344 else: | 350 else: |
345 raise | 351 raise |
346 sys.exit(rtn) | 352 sys.exit(rtn) |
OLD | NEW |