Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 1 | From f6c7973c03d9ba7dab60c496e768c5e6c4ee824c Mon Sep 17 00:00:00 2001 |
| 2 | From: Carlos Rafael Giani <crg7475@mailbox.org> |
| 3 | Date: Sun, 20 Oct 2019 10:36:44 +0200 |
| 4 | Subject: [PATCH] meson: Add valgrind feature |
| 5 | |
| 6 | This allows for enabling/disabling Valgrind support. Since Valgrind is |
| 7 | an external dependency, such a feature is needed by build environemnts |
| 8 | such as Yocto to make sure builds are deterministic. These changes also |
| 9 | add more Valgrind specific configure log output. |
| 10 | |
| 11 | Upstream-Status: Pending |
| 12 | |
| 13 | Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org> |
| 14 | --- |
| 15 | meson.build | 23 ++++++++++++++++++++++- |
| 16 | meson_options.txt | 1 + |
| 17 | 2 files changed, 23 insertions(+), 1 deletion(-) |
| 18 | |
| 19 | diff --git a/meson.build b/meson.build |
| 20 | index b55ecc5..4751761 100644 |
| 21 | --- a/meson.build |
| 22 | +++ b/meson.build |
| 23 | @@ -199,7 +199,6 @@ check_headers = [ |
| 24 | 'sys/wait.h', |
| 25 | 'ucontext.h', |
| 26 | 'unistd.h', |
| 27 | - 'valgrind/valgrind.h', |
| 28 | 'sys/resource.h', |
| 29 | ] |
| 30 | |
| 31 | @@ -214,6 +213,28 @@ foreach h : check_headers |
| 32 | endif |
| 33 | endforeach |
| 34 | |
| 35 | +valgrind_option = get_option('valgrind') |
| 36 | +if valgrind_option.disabled() |
| 37 | + message('Valgrind support not requested; disabled.') |
| 38 | +else |
| 39 | + valgrind_header = 'valgrind/valgrind.h' |
| 40 | + has_valgrind_header = cc.has_header(valgrind_header) |
| 41 | + if has_valgrind_header |
| 42 | + message('Valgrind support requested, and header ' + valgrind_header + \ |
| 43 | + ' found. Enabled Valgrind support.') |
| 44 | + define = 'HAVE_' + valgrind_header.underscorify().to_upper() |
| 45 | + cdata.set(define, 1) |
| 46 | + else |
| 47 | + if valgrind_option.enabled() |
| 48 | + error('Valgrind support requested and set as required, but header ' + \ |
| 49 | + valgrind_header + ' not found.') |
| 50 | + else |
| 51 | + message('Valgrind support requested, but header ' + valgrind_header + \ |
| 52 | + ' not found. Disabling Valgrind support.') |
| 53 | + endif |
| 54 | + endif |
| 55 | +endif |
| 56 | + |
| 57 | if cc.has_member('struct tm', 'tm_gmtoff', prefix : '#include <time.h>') |
| 58 | cdata.set('HAVE_TM_GMTOFF', 1) |
| 59 | endif |
| 60 | diff --git a/meson_options.txt b/meson_options.txt |
| 61 | index e7ff7ba..8afde39 100644 |
| 62 | --- a/meson_options.txt |
| 63 | +++ b/meson_options.txt |
| 64 | @@ -19,6 +19,7 @@ option('memory-alignment', type: 'combo', |
| 65 | |
| 66 | # Feature options |
| 67 | option('check', type : 'feature', value : 'auto', description : 'Build unit test libraries') |
| 68 | +option('valgrind', type : 'feature', value : 'auto', description : 'Enable Valgrind support') |
| 69 | option('libunwind', type : 'feature', value : 'auto', description : 'Use libunwind to generate backtraces') |
| 70 | option('libdw', type : 'feature', value : 'auto', description : 'Use libdw to generate better backtraces from libunwind') |
| 71 | option('dbghelp', type : 'feature', value : 'auto', description : 'Use dbghelp to generate backtraces') |
| 72 | -- |
| 73 | 2.17.1 |
| 74 | |