From 202344e9a00870bee303cfaf4acb66b8c9946252 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 20 Dec 2022 15:41:44 -0800 Subject: [PATCH] meson: use a feature option for libunwind Reviewed-by: Jesse Natalie Acked-by: Alyssa Rosenzweig Part-of: --- meson.build | 26 ++++++++------------------ meson_options.txt | 4 +--- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index 99a8b5b388e..2dbd3228114 100644 --- a/meson.build +++ b/meson.build @@ -1901,25 +1901,15 @@ if get_option('execmem') pre_args += '-DMESA_EXECMEM' endif -_libunwind = get_option('libunwind') -if _libunwind == 'true' - _libunwind = 'enabled' - warning('libunwind option "true" deprecated, please use "enabled" instead.') -elif _libunwind == 'false' - _libunwind = 'disabled' - warning('libunwind option "false" deprecated, please use "disabled" instead.') -endif -if _libunwind != 'disabled' and not with_platform_android - if host_machine.system() == 'darwin' - dep_unwind = meson.get_compiler('c').find_library('System') - else - dep_unwind = dependency('libunwind', required : _libunwind == 'enabled') - endif - if dep_unwind.found() - pre_args += '-DHAVE_LIBUNWIND' - endif +_libunwind = get_option('libunwind') \ + .require(not with_platform_android, error_message : 'Android requires the use of the backtrace library, not libunwind') +if host_machine.system() == 'darwin' + dep_unwind = meson.get_compiler('c').find_library('System', required : _libunwind) else - dep_unwind = null_dep + dep_unwind = dependency('libunwind', required : _libunwind) +endif +if dep_unwind.found() + pre_args += '-DHAVE_LIBUNWIND' endif if with_osmesa diff --git a/meson_options.txt b/meson_options.txt index da93e9b6f22..e87d78b1197 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -340,9 +340,7 @@ option( ) option( 'libunwind', - type : 'combo', - value : 'auto', - choices : ['auto', 'true', 'false', 'enabled', 'disabled'], + type : 'feature', description : 'Use libunwind for stack-traces' ) option(