bug 1517806 - make mozdebug's Visual Studio detection with vswhere more useful. r=ahal,froydnj
authorTed Mielczarek <ted@mielczarek.org>
Mon, 01 Apr 2019 14:22:56 +0000
changeset 469852 58a63a9525b874c59da463c70a5c25ad846471a8
parent 469851 902bff64318d963ea1d5505eebd0f66b11d55f28
child 469853 46235152b24e33c652c4e94430897369bbb2090b
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal, froydnj
bugs1517806
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1517806 - make mozdebug's Visual Studio detection with vswhere more useful. r=ahal,froydnj mozdebug has code to locate Visual Studio using vswhere.exe, but it only works if vswhere is in PATH. We have a copy vendored in the source tree, so this change adds support for using that binary when available. Additionally the code parsing the output of vswhere appeared to be using a key that does not exist in the JSON output, so this change fixes that to match the documentation: https://github.com/Microsoft/vswhere/wiki#examples . Differential Revision: https://phabricator.services.mozilla.com/D16542
testing/mozbase/mozdebug/mozdebug/mozdebug.py
--- a/testing/mozbase/mozdebug/mozdebug/mozdebug.py
+++ b/testing/mozbase/mozdebug/mozdebug/mozdebug.py
@@ -94,16 +94,28 @@ def _windbg_installation_paths():
     for suffix in programFilesSuffixes:
         windowsKitsPrefix = os.path.join(programFiles + suffix,
                                          'Windows Kits')
         for version in windowsKitsVersions:
             yield os.path.join(windowsKitsPrefix, version,
                                'Debuggers', 'x64', 'windbg.exe')
 
 
+def _vswhere_path():
+    try:
+        import buildconfig
+        path = os.path.join(buildconfig.topsrcdir, 'build', 'win32', 'vswhere.exe')
+        if os.path.isfile(path):
+            return path
+    except ImportError:
+        pass
+    # Hope it's available on PATH!
+    return 'vswhere.exe'
+
+
 def get_debugger_path(debugger):
     '''
     Get the full path of the debugger.
 
     :param debugger: The name of the debugger.
     '''
 
     if mozinfo.os == 'mac' and debugger == 'lldb':
@@ -120,19 +132,20 @@ def get_debugger_path(debugger):
         except Exception:
             # Just default to find_executable instead.
             pass
 
     if mozinfo.os == 'win' and debugger == 'devenv.exe':
         # Attempt to use vswhere to find the path.
         try:
             encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
-            vsinfo = check_output(['vswhere.exe', '-format', 'json'])
+            vswhere = _vswhere_path()
+            vsinfo = check_output([vswhere, '-format', 'json', '-latest'])
             vsinfo = json.loads(vsinfo.decode(encoding, 'replace'))
-            return vsinfo[0]["productPath"]
+            return os.path.join(vsinfo[0]['installationPath'], 'Common7', 'IDE', 'devenv.exe')
         except Exception:
             # Just default to find_executable instead.
             pass
 
     return find_executable(debugger)
 
 
 def get_debugger_info(debugger, debuggerArgs=None, debuggerInteractive=False):