diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index f458afeae..eccfe0ac6 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -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.
1: They may appear to be case-insensitive, if the diff --git a/docs/markdown/snippets/curses-dependency-improvements.md b/docs/markdown/snippets/curses-dependency-improvements.md new file mode 100644 index 000000000..bd1d0012a --- /dev/null +++ b/docs/markdown/snippets/curses-dependency-improvements.md @@ -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. diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index c27075838..c1e17d771 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -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 diff --git a/test cases/frameworks/31 curses/meson.build b/test cases/frameworks/31 curses/meson.build index 21483fb6f..66e09576e 100644 --- a/test cases/frameworks/31 curses/meson.build +++ b/test cases/frameworks/31 curses/meson.build @@ -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 diff --git a/test cases/frameworks/31 curses/meson_options.txt b/test cases/frameworks/31 curses/meson_options.txt new file mode 100644 index 000000000..3a587f476 --- /dev/null +++ b/test cases/frameworks/31 curses/meson_options.txt @@ -0,0 +1,6 @@ +option( + 'method', + type : 'combo', + choices : ['pkg-config', 'config-tool'], + value : 'pkg-config', +) diff --git a/test cases/frameworks/31 curses/test.json b/test cases/frameworks/31 curses/test.json new file mode 100644 index 000000000..0de1f73a4 --- /dev/null +++ b/test cases/frameworks/31 curses/test.json @@ -0,0 +1,10 @@ +{ + "matrix": { + "options": { + "method": [ + { "val": "pkg-config" }, + { "val": "config-tool" } + ] + } + } +}