@ -480,7 +480,7 @@ class ExternalProgramHolder(InterpreterObject, ObjectHolder):
return self . held_object . get_path ( )
return self . held_object . get_path ( )
def found ( self ) :
def found ( self ) :
return self . held_object . found ( )
return isinstance ( self . held_object , build . Executable ) or self . held_object . found ( )
def get_command ( self ) :
def get_command ( self ) :
return self . held_object . get_command ( )
return self . held_object . get_command ( )
@ -1780,9 +1780,8 @@ class MesonMain(InterpreterObject):
if not os . path . exists ( abspath ) :
if not os . path . exists ( abspath ) :
raise InterpreterException ( ' Tried to override %s with a file that does not exist. ' % name )
raise InterpreterException ( ' Tried to override %s with a file that does not exist. ' % name )
exe = dependencies . ExternalProgram ( abspath )
exe = dependencies . ExternalProgram ( abspath )
if not isinstance ( exe , dependencies . ExternalProgram ) :
if not isinstance ( exe , ( dependencies . ExternalProgram , build . Executable ) ) :
# FIXME, make this work if the exe is an Executable target.
raise InterpreterException ( ' Second argument must be an external program or executable. ' )
raise InterpreterException ( ' Second argument must be an external program. ' )
self . interpreter . add_find_program_override ( name , exe )
self . interpreter . add_find_program_override ( name , exe )
@noPosargs
@noPosargs
@ -2184,6 +2183,11 @@ external dependencies (including libraries) must go to "dependencies".''')
' or configure_file(), or a compiler object; not {!r} '
' or configure_file(), or a compiler object; not {!r} '
if isinstance ( cmd , ExternalProgramHolder ) :
if isinstance ( cmd , ExternalProgramHolder ) :
cmd = cmd . held_object
cmd = cmd . held_object
if isinstance ( cmd , build . Executable ) :
progname = node . args . arguments [ 0 ] . value
msg = ' Program {!r} was overridden with the compiled executable {!r} ' \
' and therefore cannot be used during configuration '
raise InterpreterException ( msg . format ( progname , cmd . description ( ) ) )
elif isinstance ( cmd , CompilerHolder ) :
elif isinstance ( cmd , CompilerHolder ) :
cmd = cmd . compiler . get_exelist ( ) [ 0 ]
cmd = cmd . compiler . get_exelist ( ) [ 0 ]
prog = ExternalProgram ( cmd , silent = True )
prog = ExternalProgram ( cmd , silent = True )
@ -2758,7 +2762,7 @@ external dependencies (including libraries) must go to "dependencies".''')
exe = self . build . find_overrides [ name ]
exe = self . build . find_overrides [ name ]
if not silent :
if not silent :
mlog . log ( ' Program ' , mlog . bold ( name ) , ' found: ' , mlog . green ( ' YES ' ) ,
mlog . log ( ' Program ' , mlog . bold ( name ) , ' found: ' , mlog . green ( ' YES ' ) ,
' (overridden: %s ) ' % ' ' . join ( exe . command ) )
' (overridden: %s ) ' % exe . description ( ) )
return ExternalProgramHolder ( exe )
return ExternalProgramHolder ( exe )
return None
return None