Use ConfigToolDependency for SDL2

pull/2512/head
Dylan Baker 7 years ago
parent cc28eba8d0
commit 8e53dec314
  1. 14
      mesonbuild/dependencies/base.py
  2. 34
      mesonbuild/dependencies/ui.py
  3. 5
      test cases/frameworks/16 sdl2/meson.build

@ -20,6 +20,7 @@ import sys
import stat
import shlex
import shutil
import textwrap
from enum import Enum
from .. import mlog
@ -45,8 +46,6 @@ class DependencyMethods(Enum):
QMAKE = 'qmake'
# Just specify the standard link arguments, assuming the operating system provides the library.
SYSTEM = 'system'
# Detect using sdl2-config
SDLCONFIG = 'sdlconfig'
# Detect using pcap-config
PCAPCONFIG = 'pcap-config'
# Detect using cups-config
@ -59,6 +58,8 @@ class DependencyMethods(Enum):
SYSCONFIG = 'sysconfig'
# Specify using a "program"-config style tool
CONFIG_TOOL = 'config-tool'
# For backewards compatibility
SDLCONFIG = 'sdlconfig'
class Dependency:
@ -76,6 +77,15 @@ class Dependency:
raise DependencyException('method {!r} is invalid'.format(method))
method = DependencyMethods(method)
# This sets per-too config methods which are deprecated to to the new
# generic CONFIG_TOOL value.
if method in [DependencyMethods.SDLCONFIG]:
mlog.warning(textwrap.dedent("""\
Configuration method {} has been deprecated in favor of
'config-tool'. This will be removed in a future version of
meson.""".format(method)))
method = DependencyMethods.CONFIG_TOOL
# Set the detection method. If the method is set to auto, use any available method.
# If method is set to a specific string, allow only that detection method.
if method == DependencyMethods.AUTO:

@ -373,9 +373,9 @@ class Qt5Dependency(QtBaseDependency):
class SDL2Dependency(ExternalDependency):
def __init__(self, environment, kwargs):
super().__init__('sdl2', environment, None, kwargs)
kwargs['required'] = False
if DependencyMethods.PKGCONFIG in self.methods:
try:
kwargs['required'] = False
pcdep = PkgConfigDependency('sdl2', environment, kwargs)
if pcdep.found():
self.type_name = 'pkgconfig'
@ -386,20 +386,20 @@ class SDL2Dependency(ExternalDependency):
return
except Exception as e:
mlog.debug('SDL 2 not found via pkgconfig. Trying next, error was:', str(e))
if DependencyMethods.SDLCONFIG in self.methods:
sdlconf = shutil.which('sdl2-config')
if sdlconf:
stdo = Popen_safe(['sdl2-config', '--cflags'])[1]
self.compile_args = stdo.strip().split()
stdo = Popen_safe(['sdl2-config', '--libs'])[1]
self.link_args = stdo.strip().split()
stdo = Popen_safe(['sdl2-config', '--version'])[1]
self.version = stdo.strip()
self.is_found = True
mlog.log('Dependency', mlog.bold('sdl2'), 'found:', mlog.green('YES'),
self.version, '(%s)' % sdlconf)
return
mlog.debug('Could not find sdl2-config binary, trying next.')
if DependencyMethods.CONFIG_TOOL in self.methods:
try:
ctdep = ConfigToolDependency.factory(
'sdl2', environment, None, kwargs, ['sdl2-config'], 'sdl2-config')
if ctdep.found():
self.type_name = 'config-tool'
self.config = ctdep.config
self.version = ctdep.version
self.compile_args = ctdep.get_config_value(['--cflags'], 'compile_args')
self.links_args = ctdep.get_config_value(['--libs'], 'link_args')
self.is_found = True
return
except Exception as e:
mlog.debug('SDL 2 not found via sdl2-config. Trying next, error was:', str(e))
if DependencyMethods.EXTRAFRAMEWORK in self.methods:
if mesonlib.is_osx():
fwdep = ExtraFrameworkDependency('sdl2', False, None, self.env,
@ -414,9 +414,9 @@ class SDL2Dependency(ExternalDependency):
def get_methods(self):
if mesonlib.is_osx():
return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG, DependencyMethods.EXTRAFRAMEWORK]
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.EXTRAFRAMEWORK]
else:
return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG]
return [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL]
class WxDependency(ConfigToolDependency):

@ -6,5 +6,8 @@ e = executable('sdl2prog', 'sdl2prog.c', dependencies : sdl2_dep)
test('sdl2test', e)
# Ensure that we can find it with sdl2-config too
# Ensure that we can find it with sdl2-config too, using the legacy method name
configdep = dependency('sdl2', method : 'sdlconfig')
# And the modern method name
configdep = dependency('sdl2', method : 'config-tool')

Loading…
Cancel
Save