@ -390,13 +390,6 @@ class BuildTarget(Target):
msg = ' Bad source of type {!r} in target {!r} . ' . format ( type ( s ) . __name__ , self . name )
msg = ' Bad source of type {!r} in target {!r} . ' . format ( type ( s ) . __name__ , self . name )
raise InvalidArguments ( msg )
raise InvalidArguments ( msg )
@staticmethod
def can_compile_sources ( compiler , sources ) :
for s in sources :
if compiler . can_compile ( s ) :
return True
return False
@staticmethod
@staticmethod
def can_compile_remove_sources ( compiler , sources ) :
def can_compile_remove_sources ( compiler , sources ) :
removed = False
removed = False
@ -442,13 +435,15 @@ class BuildTarget(Target):
if not s . endswith ( lang_suffixes [ ' vala ' ] ) :
if not s . endswith ( lang_suffixes [ ' vala ' ] ) :
sources . append ( s )
sources . append ( s )
if sources :
if sources :
# Add compilers based on the above sources
# For each source, try to add one compiler that can compile it.
for lang , compiler in compilers . items ( ) :
# It's ok if no compilers can do so, because users are expected to
# We try to be conservative because sometimes people add files
# be able to add arbitrary non-source files to the sources list.
# in the list of sources that we can't determine the type based
for s in sources :
# just on the suffix.
for lang , compiler in compilers . items ( ) :
if self . can_compile_sources ( compiler , sources ) :
if compiler . can_compile ( s ) :
self . compilers [ lang ] = compiler
if lang not in self . compilers :
self . compilers [ lang ] = compiler
break
else :
else :
# No source files, target consists of only object files of unknown
# No source files, target consists of only object files of unknown
# origin. Just add the first clike compiler that we have and hope
# origin. Just add the first clike compiler that we have and hope