Package pygccxml :: Package msvc :: Module config |

# Source Code for Module pygccxml.msvc.config

     1  import os
     2  import sys
     3  import comtypes
     4  from .. import utils
     5  import comtypes.client
     6  import _winreg as win_registry
     7  from distutils import msvccompiler
     8
     9 -class binaries_searcher_t:
    10
    11 -    def get_msbsc_path( self ):
    12          relative_path = os.path.dirname( sys.modules[__name__].__file__)
    13          absolute_path = os.path.abspath (relative_path)
    14          return os.path.join( absolute_path, 'msbsc70.dll' )
    15
    16 -    def get_msvcr70_path( self ):
    17          relative_path = os.path.dirname( sys.modules[__name__].__file__)
    18          absolute_path = os.path.abspath (relative_path)
    19          return os.path.join( absolute_path, 'msvcr70.dll' )
    20
    21
    22 -    def get_msvcr_path( self ):
    23          vss_installed = self.__get_installed_vs_dirs()
    24          for f in utils.files_walker( vss_installed, ["*.dll"], ):
    25              f_path, f_name = os.path.split( f.upper() )
    26              if f_name.startswith( 'MSVCR' ):
    27                  return f
    28          else:
    29              raise RuntimeError( 'Unable to find msvcrXX.dll. Search path is: %s' % vss_installed  )
    30
    31 -    def get_msdia_path( self ):
    32          vss_installed = self.__get_installed_vs_dirs()
    33          msdia_dlls = self.__get_msdia_dll_paths( vss_installed )
    34          if 1 == len(msdia_dlls):
    35              return msdia_dlls[0]
    36          else:
    37              #TODO find the highest version and use it.
    38              pass
    39
    40 -    def __get_msdia_dll_paths( self, vss_installed ):
    41          msdia_dlls = []
    42          for vs in vss_installed:
    43              debug_dir = os.path.join( vs, 'Common7', 'Packages', 'Debugger' )
    44              files = filter( lambda f: f.startswith( 'msdia' ) and f.endswith( '.dll' )
    45                              , os.listdir( debug_dir ) )
    46              if not files:
    47                  continue
    48              msdia_dlls.extend([ os.path.join( debug_dir, f ) for f in files ])
    49          if not msdia_dlls:
    50              raise RuntimeError( 'pygccxml unable to find out msdiaXX.dll location' )
    51          return msdia_dlls
    52
    53 -    def __get_installed_vs_dirs( self ):
    54          vs_reg_path = 'Software\Microsoft\VisualStudio\SxS\VS7'
    55          values = self.read_values( win_registry.HKEY_LOCAL_MACHINE, vs_reg_path )
    56          return [ values.values()[0] ]
    57
    58 -    def read_keys(self, base, key):
    59          return msvccompiler.read_keys(base, key)
    60
    61 -    def read_values(self, base, key):
    62          return msvccompiler.read_values(base, key)
    63
    64  bs = binaries_searcher_t()
    65
    66  msdia_path = bs.get_msdia_path()
    67  print 'msdia path: ', msdia_path
    68
    69  msbsc_path = bs.get_msbsc_path()
    70  print 'msbsc path: ', msbsc_path
    71
    72  msvcr_path = bs.get_msvcr_path()
    73  print 'msvcr path: ', msvcr_path
    74