(self)
Populate self.compilers, which is the list of compilers that this
        target will use for compiling all its sources.
        We also add compilers that were used by extracted objects to simplify
        dynamic linker determination.
Populate self.compilers, which is the list of compilers that this
        target will use for compiling all its sources.
        We also add compilers that were used by extracted objects to simplify
        dynamic linker determination.
Populate self . compilers which is the list of compilers that this target will use for compiling all its sources . We also add compilers that were used by extracted objects to simplify dynamic linker determination .
def process_compilers(self):
        '''
        Populate self.compilers, which is the list of compilers that this
        target will use for compiling all its sources.
        We also add compilers that were used by extracted objects to simplify
        dynamic linker determination.
        '''
        if not self.sources and not self.generated and not self.objects:
            return
        # Populate list of compilers
        compilers = self.environment.coredata.compilers[self.for_machine]
        # Pre-existing sources
        sources = list(self.sources)
        # All generated sources
        for gensrc in self.generated:
            for s in gensrc.get_outputs():
                # Generated objects can't be compiled, so don't use them for
                # compiler detection. If our target only has generated objects,
                # we will fall back to using the first c-like compiler we find,
                # which is what we need.
                if not is_object(s):
                    sources.append(s)
        for d in self.external_deps:
            for s in d.sources:
                if isinstance(s, (str, File)):
                    sources.append(s)

        # Sources that were used to create our extracted objects
        for o in self.objects:
            if not isinstance(o, ExtractedObjects):
                continue
            for s in o.srclist:
                # Don't add Vala sources since that will pull in the Vala
                # compiler even though we will never use it since we are
                # dealing with compiled C code.
                if not s.endswith(lang_suffixes['vala']):
                    sources.append(s)
        if sources:
            # For each source, try to add one compiler that can compile it.
            #
            # If it has a suffix that belongs to a known language, we must have
            # a compiler for that language.
            #
            # Otherwise, it's ok if no compilers can compile it, because users
            # are expected to be able to add arbitrary non-source files to the
            # sources list
            for s in sources:
                for lang, compiler in compilers.items():
                    if compiler.can_compile(s):
                        if lang not in self.compilers:
                            self.compilers[lang] = compiler
                        break
                else:
                    if is_known_suffix(s):
                        raise MesonException('No {} machine compiler for "{}"'.
                                             format(self.for_machine.get_lower_case_name(), s))

            # Re-sort according to clink_langs
            self.compilers = OrderedDict(sorted(self.compilers.items(),
                                                key=lambda t: sort_clink(t[0])))

        # If all our sources are Vala, our target also needs the C compiler but
        # it won't get added above.
        if 'vala' in self.compilers and 'c' not in self.compilers:
            self.compilers['c'] = compilers['c']
        if 'cython' in self.compilers:
            key = OptionKey('language', machine=self.for_machine, lang='cython')
            if key in self.option_overrides_compiler:
                value = self.option_overrides_compiler[key]
            else:
                value = self.environment.coredata.options[key].value

            try:
                self.compilers[value] = compilers[value]
            except KeyError:
                # TODO: it would be nice to not have to do this here, but we
                # have two problems to work around:
                # 1. If this is set via an override we have no way to know
                #    before now that we need a compiler for the non-default language
                # 2. Because Cython itself initializes the `cython_language`
                #    option, we have no good place to insert that you need it
                #    before now, so we just have to do it here.
                comp = detect_compiler_for(self.environment, value, self.for_machine)

                # This is copied verbatim from the interpreter
                if self.for_machine == MachineChoice.HOST or self.environment.is_cross_build():
                    logger_fun = mlog.log
                else:
                    logger_fun = mlog.debug
                logger_fun(comp.get_display_language(), 'compiler for the', self.for_machine.get_lower_case_name(), 'machine:',
                           mlog.bold(' '.join(comp.get_exelist())), comp.get_version_string())
                if comp.linker is not None:
                    logger_fun(comp.get_display_language(), 'linker for the', self.for_machine.get_lower_case_name(), 'machine:',
                               mlog.bold(' '.join(comp.linker.get_exelist())), comp.linker.id, comp.linker.version)
                if comp is None:
                    raise MesonException(f'Cannot find required compiler {value}')
                self.compilers[value] = comp
def process_compilers ( self ) : if not self . sources and not self . generated and not self . objects : return # Populate list of compilers compilers = self . environment . coredata . compilers [ self . for_machine ] # Pre-existing sources sources = list ( self . sources ) # All generated sources for gensrc in self . generated : for s in gensrc . get_outputs ( ) : # Generated objects can't be compiled, so don't use them for # compiler detection. If our target only has generated objects, # we will fall back to using the first c-like compiler we find, # which is what we need. if not is_object ( s ) : sources . append ( s ) for d in self . external_deps : for s in d . sources : if isinstance ( s , ( str , File ) ) : sources . append ( s ) # Sources that were used to create our extracted objects for o in self . objects : if not isinstance ( o , ExtractedObjects ) : continue for s in o . srclist : # Don't add Vala sources since that will pull in the Vala # compiler even though we will never use it since we are # dealing with compiled C code. if not s . endswith ( lang_suffixes [ 'vala' ] ) : sources . append ( s ) if sources : # For each source, try to add one compiler that can compile it. # # If it has a suffix that belongs to a known language, we must have # a compiler for that language. # # Otherwise, it's ok if no compilers can compile it, because users # are expected to be able to add arbitrary non-source files to the # sources list for s in sources : for lang , compiler in compilers . items ( ) : if compiler . can_compile ( s ) : if lang not in self . compilers : self . compilers [ lang ] = compiler break else : if is_known_suffix ( s ) : raise MesonException ( 'No {} machine compiler for "{}"' . format ( self . for_machine . get_lower_case_name ( ) , s ) ) # Re-sort according to clink_langs self . compilers = OrderedDict ( sorted ( self . compilers . items ( ) , key = lambda t : sort_clink ( t [ 0 ] ) ) ) # If all our sources are Vala, our target also needs the C compiler but # it won't get added above. if 'vala' in self . compilers and 'c' not in self . compilers : self . compilers [ 'c' ] = compilers [ 'c' ] if 'cython' in self . compilers : key = OptionKey ( 'language' , machine = self . for_machine , lang = 'cython' ) if key in self . option_overrides_compiler : value = self . option_overrides_compiler [ key ] else : value = self . environment . coredata . options [ key ] . value try : self . compilers [ value ] = compilers [ value ] except KeyError : # TODO: it would be nice to not have to do this here, but we # have two problems to work around: # 1. If this is set via an override we have no way to know #    before now that we need a compiler for the non-default language # 2. Because Cython itself initializes the `cython_language` #    option, we have no good place to insert that you need it #    before now, so we just have to do it here. comp = detect_compiler_for ( self . environment , value , self . for_machine ) # This is copied verbatim from the interpreter if self . for_machine == MachineChoice . HOST or self . environment . is_cross_build ( ) : logger_fun = mlog . log else : logger_fun = mlog . debug logger_fun ( comp . get_display_language ( ) , 'compiler for the' , self . for_machine . get_lower_case_name ( ) , 'machine:' , mlog . bold ( ' ' . join ( comp . get_exelist ( ) ) ) , comp . get_version_string ( ) ) if comp . linker is not None : logger_fun ( comp . get_display_language ( ) , 'linker for the' , self . for_machine . get_lower_case_name ( ) , 'machine:' , mlog . bold ( ' ' . join ( comp . linker . get_exelist ( ) ) ) , comp . linker . id , comp . linker . version ) if comp is None : raise MesonException ( f'Cannot find required compiler {value}' ) self . compilers [ value ] = comp