@ -266,6 +266,15 @@ class ExternalDependency(Dependency):
return new
return new
def log_details ( self ) :
return ' '
def log_info ( self ) :
return ' '
def log_tried ( self ) :
return ' '
class NotFoundDependency ( Dependency ) :
class NotFoundDependency ( Dependency ) :
def __init__ ( self , environment ) :
def __init__ ( self , environment ) :
@ -391,11 +400,9 @@ class ConfigToolDependency(ExternalDependency):
else :
else :
mlog . log ( ' Found ' , mlog . bold ( self . tool_name ) , repr ( req_version ) ,
mlog . log ( ' Found ' , mlog . bold ( self . tool_name ) , repr ( req_version ) ,
mlog . red ( ' NO ' ) )
mlog . red ( ' NO ' ) )
mlog . log ( ' Dependency ' , mlog . bold ( self . name ) , ' found: ' , mlog . red ( ' NO ' ) )
return False
return False
mlog . log ( ' Found {} : ' . format ( self . tool_name ) , mlog . bold ( shutil . which ( self . config ) ) ,
mlog . log ( ' Found {} : ' . format ( self . tool_name ) , mlog . bold ( shutil . which ( self . config ) ) ,
' ( {} ) ' . format ( version ) )
' ( {} ) ' . format ( version ) )
mlog . log ( ' Dependency ' , mlog . bold ( self . name ) , ' found: ' , mlog . green ( ' YES ' ) )
return True
return True
def get_config_value ( self , args , stage ) :
def get_config_value ( self , args , stage ) :
@ -423,6 +430,9 @@ class ConfigToolDependency(ExternalDependency):
mlog . debug ( ' Got config-tool variable {} : {} ' . format ( variable_name , variable ) )
mlog . debug ( ' Got config-tool variable {} : {} ' . format ( variable_name , variable ) )
return variable
return variable
def log_tried ( self ) :
return self . type_name
class PkgConfigDependency ( ExternalDependency ) :
class PkgConfigDependency ( ExternalDependency ) :
# The class's copy of the pkg-config path. Avoids having to search for it
# The class's copy of the pkg-config path. Avoids having to search for it
@ -464,17 +474,12 @@ class PkgConfigDependency(ExternalDependency):
if self . required :
if self . required :
raise DependencyException ( ' Pkg-config not found. ' )
raise DependencyException ( ' Pkg-config not found. ' )
return
return
if self . want_cross :
self . type_string = ' Cross '
else :
self . type_string = ' Native '
mlog . debug ( ' Determining dependency {!r} with pkg-config executable '
mlog . debug ( ' Determining dependency {!r} with pkg-config executable '
' {!r} ' . format ( name , self . pkgbin . get_path ( ) ) )
' {!r} ' . format ( name , self . pkgbin . get_path ( ) ) )
ret , self . version = self . _call_pkgbin ( [ ' --modversion ' , name ] )
ret , self . version = self . _call_pkgbin ( [ ' --modversion ' , name ] )
if ret != 0 :
if ret != 0 :
return
return
found_msg = [ self . type_string + ' dependency ' , mlog . bold ( name ) , ' found: ' ]
if self . version_reqs is None :
if self . version_reqs is None :
self . is_found = True
self . is_found = True
else :
else :
@ -485,14 +490,6 @@ class PkgConfigDependency(ExternalDependency):
( self . is_found , not_found , found ) = \
( self . is_found , not_found , found ) = \
version_compare_many ( self . version , self . version_reqs )
version_compare_many ( self . version , self . version_reqs )
if not self . is_found :
if not self . is_found :
found_msg + = [ mlog . red ( ' NO ' ) ,
' found {!r} but need: ' . format ( self . version ) ,
' , ' . join ( [ " ' {} ' " . format ( e ) for e in not_found ] ) ]
if found :
found_msg + = [ ' ; matched: ' ,
' , ' . join ( [ " ' {} ' " . format ( e ) for e in found ] ) ]
if not self . silent :
mlog . log ( * found_msg )
if self . required :
if self . required :
m = ' Invalid version of dependency, need {!r} {!r} found {!r} . '
m = ' Invalid version of dependency, need {!r} {!r} found {!r} . '
raise DependencyException ( m . format ( name , not_found , self . version ) )
raise DependencyException ( m . format ( name , not_found , self . version ) )
@ -503,7 +500,6 @@ class PkgConfigDependency(ExternalDependency):
self . _set_cargs ( )
self . _set_cargs ( )
# Fetch the libraries and library paths needed for using this
# Fetch the libraries and library paths needed for using this
self . _set_libs ( )
self . _set_libs ( )
found_msg + = [ mlog . green ( ' YES ' ) , self . version ]
except DependencyException as e :
except DependencyException as e :
if self . required :
if self . required :
raise
raise
@ -511,12 +507,7 @@ class PkgConfigDependency(ExternalDependency):
self . compile_args = [ ]
self . compile_args = [ ]
self . link_args = [ ]
self . link_args = [ ]
self . is_found = False
self . is_found = False
found_msg + = [ mlog . red ( ' NO ' ) , ' ; reason: {} ' . format ( str ( e ) ) ]
self . reason = e
# Print the found message only at the very end because fetching cflags
# and libs can also fail if other needed pkg-config files aren't found.
if not self . silent :
mlog . log ( * found_msg )
def __repr__ ( self ) :
def __repr__ ( self ) :
s = ' < {0} {1} : {2} {3} > '
s = ' < {0} {1} : {2} {3} > '
@ -705,8 +696,8 @@ class PkgConfigDependency(ExternalDependency):
variable = ' '
variable = ' '
if ret != 0 :
if ret != 0 :
if self . required :
if self . required :
raise DependencyException ( ' %s dependency %s not found. ' %
raise DependencyException ( ' dependency %s not found. ' %
( self . type_string , self . name ) )
( self . name ) )
else :
else :
variable = out . strip ( )
variable = out . strip ( )
@ -790,6 +781,9 @@ class PkgConfigDependency(ExternalDependency):
# a path rather than the raw dlname
# a path rather than the raw dlname
return os . path . basename ( dlname )
return os . path . basename ( dlname )
def log_tried ( self ) :
return self . type_name
class DubDependency ( ExternalDependency ) :
class DubDependency ( ExternalDependency ) :
class_dubbin = None
class_dubbin = None
@ -811,7 +805,6 @@ class DubDependency(ExternalDependency):
if self . required :
if self . required :
raise DependencyException ( ' DUB not found. ' )
raise DependencyException ( ' DUB not found. ' )
self . is_found = False
self . is_found = False
mlog . log ( ' Dependency ' , mlog . bold ( name ) , ' found: ' , mlog . red ( ' NO ' ) )
return
return
mlog . debug ( ' Determining dependency {!r} with DUB executable '
mlog . debug ( ' Determining dependency {!r} with DUB executable '
@ -822,7 +815,6 @@ class DubDependency(ExternalDependency):
if ret != 0 :
if ret != 0 :
self . is_found = False
self . is_found = False
mlog . log ( ' Dependency ' , mlog . bold ( name ) , ' found: ' , mlog . red ( ' NO ' ) )
return
return
j = json . loads ( res )
j = json . loads ( res )
@ -834,7 +826,6 @@ class DubDependency(ExternalDependency):
msg + = [ mlog . bold ( j [ ' compiler ' ] ) , ' and we are using ' , mlog . bold ( comp ) ]
msg + = [ mlog . bold ( j [ ' compiler ' ] ) , ' and we are using ' , mlog . bold ( comp ) ]
mlog . error ( * msg )
mlog . error ( * msg )
self . is_found = False
self . is_found = False
mlog . log ( ' Dependency ' , mlog . bold ( name ) , ' found: ' , mlog . red ( ' NO ' ) )
return
return
self . version = package [ ' version ' ]
self . version = package [ ' version ' ]
@ -842,7 +833,6 @@ class DubDependency(ExternalDependency):
break
break
# Check if package version meets the requirements
# Check if package version meets the requirements
found_msg = [ ' Dependency ' , mlog . bold ( name ) , ' found: ' ]
if self . version_reqs is None :
if self . version_reqs is None :
self . is_found = True
self . is_found = True
else :
else :
@ -853,21 +843,11 @@ class DubDependency(ExternalDependency):
( self . is_found , not_found , found ) = \
( self . is_found , not_found , found ) = \
version_compare_many ( self . version , self . version_reqs )
version_compare_many ( self . version , self . version_reqs )
if not self . is_found :
if not self . is_found :
found_msg + = [ mlog . red ( ' NO ' ) ,
' found {!r} but need: ' . format ( self . version ) ,
' , ' . join ( [ " ' {} ' " . format ( e ) for e in not_found ] ) ]
if found :
found_msg + = [ ' ; matched: ' ,
' , ' . join ( [ " ' {} ' " . format ( e ) for e in found ] ) ]
if not self . silent :
mlog . log ( * found_msg )
if self . required :
if self . required :
m = ' Invalid version of dependency, need {!r} {!r} found {!r} . '
m = ' Invalid version of dependency, need {!r} {!r} found {!r} . '
raise DependencyException ( m . format ( name , not_found , self . version ) )
raise DependencyException ( m . format ( name , not_found , self . version ) )
return
return
found_msg + = [ mlog . green ( ' YES ' ) , self . version ]
if self . pkg [ ' targetFileName ' ] . endswith ( ' .a ' ) :
if self . pkg [ ' targetFileName ' ] . endswith ( ' .a ' ) :
self . static = True
self . static = True
@ -889,12 +869,8 @@ class DubDependency(ExternalDependency):
if not found :
if not found :
self . is_found = False
self . is_found = False
mlog . log ( ' Dependency ' , mlog . bold ( name ) , ' found: ' , mlog . red ( ' NO ' ) )
return
return
if not self . silent :
mlog . log ( * found_msg )
def get_compiler ( self ) :
def get_compiler ( self ) :
return self . compiler
return self . compiler
@ -1216,10 +1192,6 @@ class ExtraFrameworkDependency(ExternalDependency):
if self . found ( ) :
if self . found ( ) :
self . compile_args = [ ' -I ' + os . path . join ( self . path , self . name , ' Headers ' ) ]
self . compile_args = [ ' -I ' + os . path . join ( self . path , self . name , ' Headers ' ) ]
self . link_args = [ ' -F ' + self . path , ' -framework ' , self . name . split ( ' . ' ) [ 0 ] ]
self . link_args = [ ' -F ' + self . path , ' -framework ' , self . name . split ( ' . ' ) [ 0 ] ]
mlog . log ( ' Dependency ' , mlog . bold ( name ) , ' found: ' , mlog . green ( ' YES ' ) ,
os . path . join ( self . path , self . name ) )
else :
mlog . log ( ' Dependency ' , name , ' found: ' , mlog . red ( ' NO ' ) )
def detect ( self , name , path ) :
def detect ( self , name , path ) :
lname = name . lower ( )
lname = name . lower ( )
@ -1242,6 +1214,12 @@ class ExtraFrameworkDependency(ExternalDependency):
def get_version ( self ) :
def get_version ( self ) :
return ' unknown '
return ' unknown '
def log_info ( self ) :
return os . path . join ( self . path , self . name )
def log_tried ( self ) :
return ' framework '
def get_dep_identifier ( name , kwargs , want_cross ) :
def get_dep_identifier ( name , kwargs , want_cross ) :
# Need immutable objects since the identifier will be used as a dict key
# Need immutable objects since the identifier will be used as a dict key
@ -1277,6 +1255,8 @@ def find_external_dependency(name, env, kwargs):
pkg_exc = None
pkg_exc = None
pkgdep = [ ]
pkgdep = [ ]
details = ' '
for c in candidates :
for c in candidates :
# try this dependency method
# try this dependency method
try :
try :
@ -1288,11 +1268,33 @@ def find_external_dependency(name, env, kwargs):
if not pkg_exc :
if not pkg_exc :
pkg_exc = e
pkg_exc = e
else :
else :
details = d . log_details ( )
if details :
details = ' ( ' + details + ' ) '
if ' language ' in kwargs :
details + = ' for ' + d . language + ' '
# if the dependency was found
# if the dependency was found
if d . found ( ) :
if d . found ( ) :
info = d . log_info ( )
if info :
info = ' , ' + info
mlog . log ( ' Dependency ' , mlog . bold ( name ) , details + ' found: ' , mlog . green ( ' YES ' ) , d . version + info )
return d
return d
# otherwise, the dependency could not be found
# otherwise, the dependency could not be found
tried_methods = [ d . log_tried ( ) for d in pkgdep if d . log_tried ( ) ]
if tried_methods :
tried = ' {} ' . format ( mlog . format_list ( tried_methods ) )
else :
tried = ' '
mlog . log ( ' Dependency ' , mlog . bold ( name ) , details + ' found: ' , mlog . red ( ' NO ' ) ,
' (tried {} ) ' . format ( tried ) if tried else ' ' )
if required :
if required :
# if exception(s) occurred, re-raise the first one (on the grounds that
# if exception(s) occurred, re-raise the first one (on the grounds that
# it came from a preferred dependency detection method)
# it came from a preferred dependency detection method)
@ -1301,8 +1303,7 @@ def find_external_dependency(name, env, kwargs):
# we have a list of failed ExternalDependency objects, so we can report
# we have a list of failed ExternalDependency objects, so we can report
# the methods we tried to find the dependency
# the methods we tried to find the dependency
tried_methods = ' , ' . join ( [ d . type_name for d in pkgdep ] )
raise DependencyException ( ' Dependency " %s " not found, tried %s ' % ( name , tried ) )
raise DependencyException ( ' Dependency " %s " not found, tried %s ' % ( name , tried_methods ) )
# return the last failed dependency object
# return the last failed dependency object
if pkgdep :
if pkgdep :