summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-10-19 11:00:43 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-11-23 19:54:48 -0800
commit8e53dec314901ce65d2ccfb6cb7011c1b3fef976 (patch)
tree8a4d8b646b210594e4697cea5796b4b3947d4a31
parentcc28eba8d08b2e270b0313f679dc7d390cc2fe44 (diff)
downloadmeson-8e53dec314901ce65d2ccfb6cb7011c1b3fef976.tar.gz
Use ConfigToolDependency for SDL2
-rw-r--r--mesonbuild/dependencies/base.py14
-rw-r--r--mesonbuild/dependencies/ui.py34
-rw-r--r--test cases/frameworks/16 sdl2/meson.build5
3 files changed, 33 insertions, 20 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 02b59662a..b2bf3b3b1 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -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:
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index 5d7a6f682..1b8145e68 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -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):
diff --git a/test cases/frameworks/16 sdl2/meson.build b/test cases/frameworks/16 sdl2/meson.build
index c79bd46d7..61a34efa0 100644
--- a/test cases/frameworks/16 sdl2/meson.build
+++ b/test cases/frameworks/16 sdl2/meson.build
@@ -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')