dependencies/curses: Add support for using the ncurses config tools

These are mostly duplicated with pkg-config, but maybe someone has one
but not another, and they're easy to turn on with the
ConfigToolDependency.
pull/7757/head
Dylan Baker 5 years ago
parent 354c1c1d09
commit 7d11d7cf68
  1. 4
      docs/markdown/Dependencies.md
  2. 4
      docs/markdown/snippets/curses-dependency-improvements.md
  3. 21
      mesonbuild/dependencies/misc.py
  4. 2
      test cases/frameworks/31 curses/meson.build
  5. 6
      test cases/frameworks/31 curses/meson_options.txt
  6. 10
      test cases/frameworks/31 curses/test.json

@ -623,7 +623,9 @@ Curses (and ncurses) are a cross platform pain in the butt. Meson wraps up
these dependencies in the `curses` dependency. This covers both `ncurses`
(preferred) and other curses implementations.
`method` may be `auto` or `pkg-config`
`method` may be `auto`, `pkg-config`, or `config-tool`
*New in 0.56.0* The `config-tool` method.
<hr>
<a name="footnote1">1</a>: They may appear to be case-insensitive, if the

@ -0,0 +1,4 @@
## Improvements for the builtin curses dependency
This method has been extended to use config-tools for lookup as well as
pkg-config.

@ -404,7 +404,23 @@ class ShadercDependency(ExternalDependency):
return [DependencyMethods.SYSTEM, DependencyMethods.PKGCONFIG]
@factory_methods({DependencyMethods.PKGCONFIG})
class CursesConfigToolDependency(ConfigToolDependency):
"""Use the curses config tools."""
tool = 'curses-config'
# ncurses5.4-config is for macOS Catalina
tools = ['ncursesw6-config', 'ncursesw5-config', 'ncurses6-config', 'ncurses5-config', 'ncurses5.4-config']
def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None):
super().__init__(name, env, kwargs, language)
if not self.is_found:
return
self.compile_args = self.get_config_value(['--cflags'], 'compile_args')
self.link_args = self.get_config_value(['--libs'], 'link_args')
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL})
def curses_factory(env: 'Environment', for_machine: 'MachineChoice',
kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List[T.Callable[[], 'Dependency']]:
candidates = [] # type: T.List[T.Callable[[], Dependency]]
@ -414,6 +430,9 @@ def curses_factory(env: 'Environment', for_machine: 'MachineChoice',
for pkg in pkgconfig_files:
candidates.append(functools.partial(PkgConfigDependency, pkg, env, kwargs))
if DependencyMethods.CONFIG_TOOL in methods:
candidates.append(functools.partial(CursesConfigToolDependency, 'curses', env, kwargs))
return candidates

@ -1,6 +1,6 @@
project('curses', 'c')
curses = dependency('curses', required: false)
curses = dependency('curses', required: false, method : get_option('method'))
if not curses.found()
error('MESON_SKIP_TEST: Curses library not found')
endif

@ -0,0 +1,6 @@
option(
'method',
type : 'combo',
choices : ['pkg-config', 'config-tool'],
value : 'pkg-config',
)

@ -0,0 +1,10 @@
{
"matrix": {
"options": {
"method": [
{ "val": "pkg-config" },
{ "val": "config-tool" }
]
}
}
}
Loading…
Cancel
Save