Make WxDependency a ConfigToolDependency

pull/2512/head
Dylan Baker 8 years ago
parent f0248b0342
commit 061cf99cd6
  1. 63
      mesonbuild/dependencies/ui.py
  2. 2
      run_unittests.py

@ -23,13 +23,13 @@ from collections import OrderedDict
from .. import mlog from .. import mlog
from .. import mesonlib from .. import mesonlib
from ..mesonlib import MesonException, Popen_safe, version_compare from ..mesonlib import MesonException, Popen_safe, extract_as_list, for_windows
from ..mesonlib import extract_as_list, for_windows
from ..environment import detect_cpu from ..environment import detect_cpu
from .base import DependencyException, DependencyMethods from .base import DependencyException, DependencyMethods
from .base import ExternalDependency, ExternalProgram from .base import ExternalDependency, ExternalProgram
from .base import ExtraFrameworkDependency, PkgConfigDependency from .base import ExtraFrameworkDependency, PkgConfigDependency
from .base import ConfigToolDependency
class GLDependency(ExternalDependency): class GLDependency(ExternalDependency):
@ -426,49 +426,20 @@ class SDL2Dependency(ExternalDependency):
return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG] return [DependencyMethods.PKGCONFIG, DependencyMethods.SDLCONFIG]
class WxDependency(ExternalDependency): class WxDependency(ConfigToolDependency):
wx_found = None
def __init__(self, environment, kwargs): tools = ['wx-config-3.0', 'wx-config']
super().__init__('wx', environment, None, kwargs) tool_name = 'wx-config'
self.version = 'none'
if WxDependency.wx_found is None:
self.check_wxconfig()
else:
self.wxc = WxDependency.wx_found
if not WxDependency.wx_found:
mlog.log("Neither wx-config-3.0 nor wx-config found; can't detect dependency")
return
# FIXME: This should print stdout and stderr using mlog.debug def __init__(self, environment, kwargs):
p, out = Popen_safe([self.wxc, '--version'])[0:2] super().__init__('WxWidgets', environment, None, kwargs)
if p.returncode != 0: if not self.is_found:
mlog.log('Dependency wxwidgets found:', mlog.red('NO'))
else:
self.version = out.strip()
# FIXME: Support multiple version reqs like PkgConfigDependency
version_req = kwargs.get('version', None)
if version_req is not None:
if not version_compare(self.version, version_req, strict=True):
mlog.log('Wxwidgets version %s does not fullfill requirement %s' %
(self.version, version_req))
return return
mlog.log('Dependency wxwidgets found:', mlog.green('YES'))
self.is_found = True
self.requested_modules = self.get_requested(kwargs) self.requested_modules = self.get_requested(kwargs)
# wx-config seems to have a cflags as well but since it requires C++, # wx-config seems to have a cflags as well but since it requires C++,
# this should be good, at least for now. # this should be good, at least for now.
p, out = Popen_safe([self.wxc, '--cxxflags'])[0:2] self.compile_args = self.get_config_value(['--cxxflags'], 'compile_args')
# FIXME: this error should only be raised if required is true self.link_args = self.get_config_value(['--libs'], 'link_args')
if p.returncode != 0:
raise DependencyException('Could not generate cargs for wxwidgets.')
self.compile_args = out.split()
# FIXME: this error should only be raised if required is true
p, out = Popen_safe([self.wxc, '--libs'] + self.requested_modules)[0:2]
if p.returncode != 0:
raise DependencyException('Could not generate libs for wxwidgets.')
self.link_args = out.split()
def get_requested(self, kwargs): def get_requested(self, kwargs):
if 'modules' not in kwargs: if 'modules' not in kwargs:
@ -479,20 +450,6 @@ class WxDependency(ExternalDependency):
raise DependencyException('wxwidgets module argument is not a string') raise DependencyException('wxwidgets module argument is not a string')
return candidates return candidates
def check_wxconfig(self):
for wxc in ['wx-config-3.0', 'wx-config']:
try:
p, out = Popen_safe([wxc, '--version'])[0:2]
if p.returncode == 0:
mlog.log('Found wx-config:', mlog.bold(shutil.which(wxc)),
'(%s)' % out.strip())
self.wxc = wxc
WxDependency.wx_found = wxc
return
except (FileNotFoundError, PermissionError):
pass
WxDependency.wxconfig_found = False
mlog.log('Found wx-config:', mlog.red('NO'))
class VulkanDependency(ExternalDependency): class VulkanDependency(ExternalDependency):
def __init__(self, environment, kwargs): def __init__(self, environment, kwargs):

@ -1661,7 +1661,7 @@ class FailureTests(BasePlatformTests):
raise unittest.SkipTest('wx-config or wx-config-3.0 found') raise unittest.SkipTest('wx-config or wx-config-3.0 found')
self.assertMesonRaises("dependency('wxwidgets')", self.dnf) self.assertMesonRaises("dependency('wxwidgets')", self.dnf)
self.assertMesonOutputs("dependency('wxwidgets', required : false)", self.assertMesonOutputs("dependency('wxwidgets', required : false)",
"nor wx-config found") "No wx-config found;")
def test_wx_dependency(self): def test_wx_dependency(self):
if not shutil.which('wx-config-3.0') and not shutil.which('wx-config'): if not shutil.which('wx-config-3.0') and not shutil.which('wx-config'):

Loading…
Cancel
Save