parameters: ()
docstring: Returns appropriate values for .build_tool and .uses_msbuild fields
    of TestGypBase for Visual Studio.
  
    We use the value specified by GYP_MSVS_VERSION.  If not specified, we
    search for likely deployment paths.
docstring_summary: Returns appropriate values for .build_tool and .uses_msbuild fields
    of TestGypBase for Visual Studio.
docstring_tokens: Returns appropriate values for . build_tool and . uses_msbuild fields of TestGypBase for Visual Studio .
function: def FindVisualStudioInstallation():
    """
    Returns appropriate values for .build_tool and .uses_msbuild fields
    of TestGypBase for Visual Studio.
  
    We use the value specified by GYP_MSVS_VERSION.  If not specified, we
    search for likely deployment paths.
    """
    msvs_version = 'auto'
    for flag in (f for f in sys.argv if f.startswith('msvs_version=')):
      msvs_version = flag.split('=')[-1]
    msvs_version = os.environ.get('GYP_MSVS_VERSION', msvs_version)
  
    override_build_tool = os.environ.get('GYP_BUILD_TOOL')
    if override_build_tool:
      return override_build_tool, True, override_build_tool, msvs_version
  
    if msvs_version == 'auto' or msvs_version >= '2017':
      msbuild_exes = []
      top_vs_info = VSSetup_PowerShell()
      if top_vs_info:
        inst_path = top_vs_info['InstallationPath']
        args2 = ['cmd.exe', '/d', '/c',
                 'cd', '/d', inst_path,
                 '&', 'dir', '/b', '/s', 'msbuild.exe']
        msbuild_exes = subprocess.check_output(args2).strip().splitlines()
      if len(msbuild_exes):
        msbuild_path = str(msbuild_exes[0].decode('utf-8'))
        os.environ['GYP_MSVS_VERSION'] = top_vs_info['CatalogVersion']
        os.environ['GYP_BUILD_TOOL'] = msbuild_path
        return msbuild_path, True, msbuild_path, msvs_version
  
    possible_roots = ['%s:\\Program Files%s' % (chr(drive), suffix)
                      for drive in range(ord('C'), ord('Z') + 1)
                      for suffix in ['', ' (x86)']]
    possible_paths = {
      '2015': r'Microsoft Visual Studio 14.0\Common7\IDE\devenv.com',
      '2013': r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com',
      '2012': r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com',
      '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com',
      '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com',
      '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'
    }
  
    # Check that the path to the specified GYP_MSVS_VERSION exists.
    if msvs_version in possible_paths:
      path = possible_paths[msvs_version]
      for r in possible_roots:
        build_tool = os.path.join(r, path)
        if os.path.exists(build_tool):
          uses_msbuild = msvs_version >= '2010'
          msbuild_path = FindMSBuildInstallation(msvs_version)
          return build_tool, uses_msbuild, msbuild_path, msvs_version
      else:
        print('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" '
              'but corresponding "%s" was not found.' % (msvs_version, path))
    print('Error: could not find MSVS version %s' % msvs_version)
    sys.exit(1)
function_tokens: def FindVisualStudioInstallation ( ) : msvs_version = 'auto' for flag in ( f for f in sys . argv if f . startswith ( 'msvs_version=' ) ) : msvs_version = flag . split ( '=' ) [ - 1 ] msvs_version = os . environ . get ( 'GYP_MSVS_VERSION' , msvs_version ) override_build_tool = os . environ . get ( 'GYP_BUILD_TOOL' ) if override_build_tool : return override_build_tool , True , override_build_tool , msvs_version if msvs_version == 'auto' or msvs_version >= '2017' : msbuild_exes = [ ] top_vs_info = VSSetup_PowerShell ( ) if top_vs_info : inst_path = top_vs_info [ 'InstallationPath' ] args2 = [ 'cmd.exe' , '/d' , '/c' , 'cd' , '/d' , inst_path , '&' , 'dir' , '/b' , '/s' , 'msbuild.exe' ] msbuild_exes = subprocess . check_output ( args2 ) . strip ( ) . splitlines ( ) if len ( msbuild_exes ) : msbuild_path = str ( msbuild_exes [ 0 ] . decode ( 'utf-8' ) ) os . environ [ 'GYP_MSVS_VERSION' ] = top_vs_info [ 'CatalogVersion' ] os . environ [ 'GYP_BUILD_TOOL' ] = msbuild_path return msbuild_path , True , msbuild_path , msvs_version possible_roots = [ '%s:\\Program Files%s' % ( chr ( drive ) , suffix ) for drive in range ( ord ( 'C' ) , ord ( 'Z' ) + 1 ) for suffix in [ '' , ' (x86)' ] ] possible_paths = { '2015' : r'Microsoft Visual Studio 14.0\Common7\IDE\devenv.com' , '2013' : r'Microsoft Visual Studio 12.0\Common7\IDE\devenv.com' , '2012' : r'Microsoft Visual Studio 11.0\Common7\IDE\devenv.com' , '2010' : r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com' , '2008' : r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com' , '2005' : r'Microsoft Visual Studio 8\Common7\IDE\devenv.com' } # Check that the path to the specified GYP_MSVS_VERSION exists. if msvs_version in possible_paths : path = possible_paths [ msvs_version ] for r in possible_roots : build_tool = os . path . join ( r , path ) if os . path . exists ( build_tool ) : uses_msbuild = msvs_version >= '2010' msbuild_path = FindMSBuildInstallation ( msvs_version ) return build_tool , uses_msbuild , msbuild_path , msvs_version else : print ( 'Warning: Environment variable GYP_MSVS_VERSION specifies "%s" ' 'but corresponding "%s" was not found.' % ( msvs_version , path ) ) print ( 'Error: could not find MSVS version %s' % msvs_version ) sys . exit ( 1 )