diff options
Diffstat (limited to 'dependencies.py')
-rw-r--r-- | dependencies.py | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/dependencies.py b/dependencies.py index c276458..50c53d9 100644 --- a/dependencies.py +++ b/dependencies.py @@ -39,6 +39,7 @@ class CustomRule: class Dependency(): def __init__(self): self.name = "null" + self.is_found = False def get_compile_args(self): return [] @@ -47,7 +48,7 @@ class Dependency(): return [] def found(self): - return False + return self.is_found def get_sources(self): """Source files that need to be added to the target. @@ -593,7 +594,6 @@ class GnuStepDependency(Dependency): try: gp = subprocess.Popen([confprog, '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - gp.communicate() except FileNotFoundError: self.args = None @@ -675,6 +675,31 @@ class AppleFrameworks(Dependency): def found(self): return mesonlib.is_osx() +class GLDependency(Dependency): + def __init__(self, kwargs): + Dependency.__init__(self) + self.is_found = False + self.cargs = [] + self.linkargs = [] + try: + pcdep = PkgConfigDependency('gl', kwargs) + if pcdep.found(): + self.is_found = True + self.cargs = pcdep.get_compile_args() + self.linkargs = pcdep.get_link_args() + except Exception: + pass + if mesonlib.is_osx(): + self.is_found = True + self.linkargs = ['-framework', 'OpenGL'] + return + if mesonlib.is_windows(): + self.is_found = True + return + + def get_link_args(self): + return self.linkargs + # There are three different ways of depending on SDL2: # sdl2-config, pkg-config and OSX framework class SDL2Dependency(Dependency): @@ -746,10 +771,14 @@ class ExtraFrameworkDependency(Dependency): return def get_compile_args(self): - return ['-I' + os.path.join(self.path, self.name, 'Headers')] + if self.found(): + return ['-I' + os.path.join(self.path, self.name, 'Headers')] + return [] def get_link_args(self): - return ['-F' + self.path, '-framework', self.name.split('.')[0]] + if self.found(): + return ['-F' + self.path, '-framework', self.name.split('.')[0]] + return [] def found(self): return self.name is not None @@ -782,9 +811,13 @@ def find_external_dependency(name, kwargs): except Exception as e: pkg_exc = e if mesonlib.is_osx(): - return ExtraFrameworkDependency(name, required) + fwdep = ExtraFrameworkDependency(name, required) + if required and not fwdep.found(): + raise DependencyException('Dependency "%s" not found' % name) + return fwdep if pkg_exc is not None: raise pkg_exc + mlog.log('Dependency', mlog.bold(name), 'found:', mlog.red('NO')) return pkgdep # This has to be at the end so the classes it references @@ -797,4 +830,5 @@ packages = {'boost': BoostDependency, 'appleframeworks': AppleFrameworks, 'wxwidgets' : WxDependency, 'sdl2' : SDL2Dependency, + 'gl' : GLDependency, } |