(self, tempfilename)
VS writes its dependency in a locale dependent format.
        Detect the search prefix to use.
VS writes its dependency in a locale dependent format.
        Detect the search prefix to use.
VS writes its dependency in a locale dependent format . Detect the search prefix to use .
def detect_vs_dep_prefix(self, tempfilename):
        '''VS writes its dependency in a locale dependent format.
        Detect the search prefix to use.'''
        # TODO don't hard-code host
        for compiler in self.environment.coredata.compilers.host.values():
            # Have to detect the dependency format

            # IFort on windows is MSVC like, but doesn't have /showincludes
            if isinstance(compiler, FortranCompiler):
                continue
            if isinstance(compiler, PGICCompiler) and mesonlib.is_windows():
                # for the purpose of this function, PGI doesn't act enough like MSVC
                return open(tempfilename, 'a', encoding='utf-8')
            if isinstance(compiler, VisualStudioLikeCompiler):
                break
        else:
            # None of our compilers are MSVC, we're done.
            return open(tempfilename, 'a', encoding='utf-8')
        filename = os.path.join(self.environment.get_scratch_dir(),
                                'incdetect.c')
        with open(filename, 'w', encoding='utf-8') as f:
            f.write(dedent('''\
                #include<stdio.h>
                int dummy;
            '''))

        # The output of cl dependency information is language
        # and locale dependent. Any attempt at converting it to
        # Python strings leads to failure. We _must_ do this detection
        # in raw byte mode and write the result in raw bytes.
        pc = subprocess.Popen(compiler.get_exelist() +
                              ['/showIncludes', '/c', 'incdetect.c'],
                              cwd=self.environment.get_scratch_dir(),
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (stdout, stderr) = pc.communicate()

        # We want to match 'Note: including file: ' in the line
        # 'Note: including file: d:\MyDir\include\stdio.h', however
        # different locales have different messages with a different
        # number of colons. Match up to the the drive name 'd:\'.
        # When used in cross compilation, the path separator is a
        # forward slash rather than a backslash so handle both; i.e.
        # the path is /MyDir/include/stdio.h.
        # With certain cross compilation wrappings of MSVC, the paths
        # use backslashes, but without the leading drive name, so
        # allow the path to start with any path separator, i.e.
        # \MyDir\include\stdio.h.
        matchre = re.compile(rb"^(.*\s)([a-zA-Z]:\\|[\\\/]).*stdio.h$")

        def detect_prefix(out):
            for line in re.split(rb'\r?\n', out):
                match = matchre.match(line)
                if match:
                    with open(tempfilename, 'ab') as binfile:
                        binfile.write(b'msvc_deps_prefix = ' + match.group(1) + b'\n')
                    return open(tempfilename, 'a', encoding='utf-8')
            return None

        # Some cl wrappers (e.g. Squish Coco) output dependency info
        # to stderr rather than stdout
        result = detect_prefix(stdout) or detect_prefix(stderr)
        if result:
            return result

        raise MesonException('Could not determine vs dep dependency prefix string.')
def detect_vs_dep_prefix ( self , tempfilename ) : # TODO don't hard-code host for compiler in self . environment . coredata . compilers . host . values ( ) : # Have to detect the dependency format # IFort on windows is MSVC like, but doesn't have /showincludes if isinstance ( compiler , FortranCompiler ) : continue if isinstance ( compiler , PGICCompiler ) and mesonlib . is_windows ( ) : # for the purpose of this function, PGI doesn't act enough like MSVC return open ( tempfilename , 'a' , encoding = 'utf-8' ) if isinstance ( compiler , VisualStudioLikeCompiler ) : break else : # None of our compilers are MSVC, we're done. return open ( tempfilename , 'a' , encoding = 'utf-8' ) filename = os . path . join ( self . environment . get_scratch_dir ( ) , 'incdetect.c' ) with open ( filename , 'w' , encoding = 'utf-8' ) as f : f . write ( dedent ( '''\
                #include<stdio.h>
                int dummy;
            ''' ) ) # The output of cl dependency information is language # and locale dependent. Any attempt at converting it to # Python strings leads to failure. We _must_ do this detection # in raw byte mode and write the result in raw bytes. pc = subprocess . Popen ( compiler . get_exelist ( ) + [ '/showIncludes' , '/c' , 'incdetect.c' ] , cwd = self . environment . get_scratch_dir ( ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) ( stdout , stderr ) = pc . communicate ( ) # We want to match 'Note: including file: ' in the line # 'Note: including file: d:\MyDir\include\stdio.h', however # different locales have different messages with a different # number of colons. Match up to the the drive name 'd:\'. # When used in cross compilation, the path separator is a # forward slash rather than a backslash so handle both; i.e. # the path is /MyDir/include/stdio.h. # With certain cross compilation wrappings of MSVC, the paths # use backslashes, but without the leading drive name, so # allow the path to start with any path separator, i.e. # \MyDir\include\stdio.h. matchre = re . compile ( rb"^(.*\s)([a-zA-Z]:\\|[\\\/]).*stdio.h$" ) def detect_prefix ( out ) : for line in re . split ( rb'\r?\n' , out ) : match = matchre . match ( line ) if match : with open ( tempfilename , 'ab' ) as binfile : binfile . write ( b'msvc_deps_prefix = ' + match . group ( 1 ) + b'\n' ) return open ( tempfilename , 'a' , encoding = 'utf-8' ) return None # Some cl wrappers (e.g. Squish Coco) output dependency info # to stderr rather than stdout result = detect_prefix ( stdout ) or detect_prefix ( stderr ) if result : return result raise MesonException ( 'Could not determine vs dep dependency prefix string.' )