(env: 'Environment', for_machine: MachineChoice, name: str,
                          display_name: str, default_names: T.List[str],
                          allow_default_for_cross: bool = True)
Find an external program, chcking the cross file plus any default options.
Find an external program, chcking the cross file plus any default options.
Find an external program chcking the cross file plus any default options .
def find_external_program(env: 'Environment', for_machine: MachineChoice, name: str,
                          display_name: str, default_names: T.List[str],
                          allow_default_for_cross: bool = True) -> T.Generator['ExternalProgram', None, None]:
    """Find an external program, chcking the cross file plus any default options."""
    # Lookup in cross or machine file.
    potential_cmd = env.lookup_binary_entry(for_machine, name)
    if potential_cmd is not None:
        mlog.debug(f'{display_name} binary for {for_machine} specified from cross file, native file, '
                   f'or env var as {potential_cmd}')
        yield ExternalProgram.from_entry(name, potential_cmd)
        # We never fallback if the user-specified option is no good, so
        # stop returning options.
        return
    mlog.debug(f'{display_name} binary missing from cross or native file, or env var undefined.')
    # Fallback on hard-coded defaults, if a default binary is allowed for use
    # with cross targets, or if this is not a cross target
    if allow_default_for_cross or not (for_machine is MachineChoice.HOST and env.is_cross_build(for_machine)):
        for potential_path in default_names:
            mlog.debug(f'Trying a default {display_name} fallback at', potential_path)
            yield ExternalProgram(potential_path, silent=True)
    else:
        mlog.debug('Default target is not allowed for cross use')
def find_external_program ( env : 'Environment' , for_machine : MachineChoice , name : str , display_name : str , default_names : T . List [ str ] , allow_default_for_cross : bool = True ) -> T . Generator [ 'ExternalProgram' , None , None ] : # Lookup in cross or machine file. potential_cmd = env . lookup_binary_entry ( for_machine , name ) if potential_cmd is not None : mlog . debug ( f'{display_name} binary for {for_machine} specified from cross file, native file, ' f'or env var as {potential_cmd}' ) yield ExternalProgram . from_entry ( name , potential_cmd ) # We never fallback if the user-specified option is no good, so # stop returning options. return mlog . debug ( f'{display_name} binary missing from cross or native file, or env var undefined.' ) # Fallback on hard-coded defaults, if a default binary is allowed for use # with cross targets, or if this is not a cross target if allow_default_for_cross or not ( for_machine is MachineChoice . HOST and env . is_cross_build ( for_machine ) ) : for potential_path in default_names : mlog . debug ( f'Trying a default {display_name} fallback at' , potential_path ) yield ExternalProgram ( potential_path , silent = True ) else : mlog . debug ( 'Default target is not allowed for cross use' )