#NEWLINE# def __init__( self , name , environment , kwargs ) : #NEWLINE# #INDENT# Dependency . __init__ ( self ) #NEWLINE# self . is_libtool = False #NEWLINE# self . required = kwargs . get ( 'required' , True ) #NEWLINE# self . static = kwargs . get ( 'static' , False ) #NEWLINE# if ( not isinstance ( self . static , bool ) ) : #NEWLINE# #INDENT# raise DependencyException ( 'Static keyword must be boolean' ) #NEWLINE# #UNINDENT# if ( ( 'native' in kwargs ) and environment . is_cross_build ( ) ) : #NEWLINE# #INDENT# want_cross = ( not kwargs [ 'native' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# want_cross = environment . is_cross_build ( ) #NEWLINE# #UNINDENT# self . name = name #NEWLINE# if ( PkgConfigDependency . pkgconfig_found is None ) : #NEWLINE# #INDENT# self . check_pkgconfig ( ) #NEWLINE# #UNINDENT# self . is_found = False #NEWLINE# if ( not PkgConfigDependency . pkgconfig_found ) : #NEWLINE# #INDENT# if self . required : #NEWLINE# #INDENT# raise DependencyException ( 'Pkg-config not found.' ) #NEWLINE# #UNINDENT# self . cargs = [ ] #NEWLINE# self . libs = [ ] #NEWLINE# return #NEWLINE# #UNINDENT# if ( environment . is_cross_build ( ) and want_cross ) : #NEWLINE# #INDENT# if ( 'pkgconfig' not in environment . cross_info . config [ 'binaries' ] ) : #NEWLINE# #INDENT# raise DependencyException ( 'Pkg-config binary missing from cross file.' ) #NEWLINE# #UNINDENT# pkgbin = environment . cross_info . config [ 'binaries' ] [ 'pkgconfig' ] #NEWLINE# self . type_string = 'Cross' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pkgbin = 'pkg-config' #NEWLINE# self . type_string = 'Native' #NEWLINE# #UNINDENT# mlog . debug ( ( 'Determining dependency %s with pkg-config executable %s.' % ( name , pkgbin ) ) ) #NEWLINE# self . pkgbin = pkgbin #NEWLINE# p = subprocess . Popen ( [ pkgbin , '--modversion' , name ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# out = p . communicate ( ) [ 0 ] #NEWLINE# if ( p . returncode != 0 ) : #NEWLINE# #INDENT# if self . required : #NEWLINE# #INDENT# raise DependencyException ( ( '%s dependency %s not found.' % ( self . type_string , name ) ) ) #NEWLINE# #UNINDENT# self . modversion = 'none' #NEWLINE# self . cargs = [ ] #NEWLINE# self . libs = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . modversion = out . decode ( ) . strip ( ) #NEWLINE# mlog . log ( ( '%s dependency' % self . type_string ) , mlog . bold ( name ) , 'found:' , mlog . green ( 'YES' ) , self . modversion ) #NEWLINE# self . version_requirement = kwargs . get ( 'version' , None ) #NEWLINE# if ( self . version_requirement is None ) : #NEWLINE# #INDENT# self . is_found = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not isinstance ( self . version_requirement , str ) ) : #NEWLINE# #INDENT# raise DependencyException ( 'Version argument must be string.' ) #NEWLINE# #UNINDENT# self . is_found = mesonlib . version_compare ( self . modversion , self . version_requirement ) #NEWLINE# if ( ( not self . is_found ) and self . required ) : #NEWLINE# #INDENT# raise DependencyException ( ( 'Invalid version of a dependency, needed %s %s found %s.' % ( name , self . version_requirement , self . modversion ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not self . is_found ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# p = subprocess . Popen ( [ pkgbin , '--cflags' , name ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# out = p . communicate ( ) [ 0 ] #NEWLINE# if ( p . returncode != 0 ) : #NEWLINE# #INDENT# raise DependencyException ( ( 'Could not generate cargs for %s:\n\n%s' % ( name , out . decode ( errors = 'ignore' ) ) ) ) #NEWLINE# #UNINDENT# self . cargs = out . decode ( ) . split ( ) #NEWLINE# libcmd = [ pkgbin , '--libs' ] #NEWLINE# if self . static : #NEWLINE# #INDENT# libcmd . append ( '--static' ) #NEWLINE# #UNINDENT# p = subprocess . Popen ( ( libcmd + [ self ] ) , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# out = p . communicate ( ) [ 0 ] #NEWLINE# if ( p . returncode != 0 ) : #NEWLINE# #INDENT# raise DependencyException ( ( 'Could not generate libs for %s:\n\n%s' % ( name , out . decode ( errors = 'ignore' ) ) ) ) #NEWLINE# #UNINDENT# self . libs = [ ] #NEWLINE# for lib in out . decode ( ) . split ( ) : #NEWLINE# #INDENT# if lib . endswith ( '.la' ) : #NEWLINE# #INDENT# shared_libname = self . extract_libtool_shlib ( lib ) #NEWLINE# shared_lib = os . path . join ( os . path . dirname ( lib ) , shared_libname ) #NEWLINE# if ( not os . path . exists ( shared_lib ) ) : #NEWLINE# #INDENT# shared_lib = os . path . join ( os . path . dirname ( lib ) , '.libs' , shared_libname ) #NEWLINE# #UNINDENT# if ( not os . path . exists ( shared_lib ) ) : #NEWLINE# #INDENT# raise DependencyException ( ( 'Got a libtools specific "%s" dependenciesbut we could not compute the actual sharedlibrary path' % lib ) ) #NEWLINE# #UNINDENT# lib = shared_lib #NEWLINE# self . is_libtool = True #NEWLINE# #UNINDENT# self . libs . append ( lib )