diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-30 21:12:44 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-03-30 21:12:44 +0300 |
commit | c060be551f4f4e54daa57125fa6bdb0a5615681e (patch) | |
tree | ba30afdebda3eadc0d798e285a8eb323ae0b4984 | |
parent | 8d5c51fa553c1607d624f77688538486e4539acd (diff) | |
download | meson-c060be551f4f4e54daa57125fa6bdb0a5615681e.zip meson-c060be551f4f4e54daa57125fa6bdb0a5615681e.tar.gz meson-c060be551f4f4e54daa57125fa6bdb0a5615681e.tar.bz2 |
Detect SDL2 with sdl2-config if it exists.
-rw-r--r-- | dependencies.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dependencies.py b/dependencies.py index 457c2c6..9b42b7b 100644 --- a/dependencies.py +++ b/dependencies.py @@ -675,6 +675,51 @@ class AppleFrameworks(Dependency): def found(self): return mesonlib.is_osx() +# There are three different ways of depending on SDL2: +# sdl2-config, pkg-config and OSX framework +class SDL2Dependency(Dependency): + def __init__(self, kwargs): + Dependency.__init__(self) + self.is_found = False + self.cargs = [] + self.linkargs = [] + sdlconf = shutil.which('sdl2-config') + if sdlconf: + pc = subprocess.Popen(['sdl2-config', '--cflags'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + (stdo, _) = pc.communicate() + self.cargs = stdo.decode().split() + pc = subprocess.Popen(['sdl2-config', '--libs'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + (stdo, _) = pc.communicate() + self.linkargs = stdo.decode().split() + self.is_found = True + mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'), '(%s)' % sdlconf) + return + try: + pcdep = PkgConfigDependency('sdl2', kwargs) + if pcdep.found(): + self.is_found = True + self.cargs = pcdep.get_compile_args() + self.linkargs = pcdep.get_link_args() + return + except Exception: + pass + if mesonlib.is_osx(): + fwdep = ExtraFrameworkDependency('sdl2', kwargs.get('required', True)) + if fwdep.found(): + self.is_found = True + self.cargs = fwdep.get_compile_args() + self.linkargs = fwdep.get_link_args() + return + + def get_compile_args(self): + return self.cargs + + def get_link_args(self): + return self.linkargs + + def found(self): + return self.is_found + class ExtraFrameworkDependency(Dependency): def __init__(self, name, required): Dependency.__init__(self) @@ -750,4 +795,5 @@ packages = {'boost': BoostDependency, 'gnustep': GnuStepDependency, 'appleframeworks': AppleFrameworks, 'wxwidgets' : WxDependency, + 'sdl2' : SDL2Dependency, } |