]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Meson: Use builtin feature to handle coverage
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 8 Aug 2023 13:04:39 +0000 (15:04 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Wed, 20 Mar 2024 12:28:33 +0000 (13:28 +0100)
meson.build
meson/code-coverage/meson.build
meson_options.txt

index e03adcbcdeb27e12f4f6a435572dce489768a1a7..31a8b0916507ebc090021fe80063a1d75bcda57a 100644 (file)
@@ -66,8 +66,7 @@ subdir('meson/gss-tsig')                 # GSS-TSIG
 subdir('meson/auth-tools')               # Tools
 subdir('meson/ixfrdist')                 # Ixfrdist
 subdir('meson/systemd')                  # Systemd and unit file handling
-# TODO Use meson's -Db_coverage option?
-# subdir('meson/code-coverage')            # Code coverage
+subdir('meson/code-coverage')            # Code coverage
 subdir('meson/auto-var-init')            # Automatic Variable Initialization
 # TODO Use meson's -Db_sanitize option?
 # subdir('meson/sanitizers')               # Sanitizers
index bdfbe842fb886ba1fd4bd64f0975c46bbee8b823..acbcb509b7c212f47103dc781aeff57a8bd5cdac 100644 (file)
@@ -1,18 +1,15 @@
 # Code coverage
 
-code_coverage = get_option('code-coverage')
+coverage = get_option('b_coverage')
 
-if code_coverage
-  args = ['-U_FORTIFY_SOURCE', '-g', '-O0', '-fprofile-arcs', '-ftest-coverage']
+if coverage
+  if get_option('buildtype') != 'debug'
+    warning('Coverage is enabled, using `builtype=debug` would produce better reports')
+  endif
 
-  foreach arg: args
-    if not cxx.has_argument(arg)
-      error('Compiler does not support ' + arg + ', which is needed for code coverage')
-      break
-    endif
-  endforeach
-
-  add_global_arguments(args, language: ['cpp'])
+  if cxx.has_argument('-U_FORTIFY_SOURCE')
+    add_global_arguments('-U_FORTIFY_SOURCE', language: ['c', 'cpp'])
+  endif
 endif
 
-summary('Code Coverage', code_coverage, bool_yn: true, section: 'Configuration')
+summary('Code Coverage', coverage, bool_yn: true, section: 'Configuration')
index 09e295c45d13c1a32759c2188f1ee4a06c5316b0..63de43de5341aa3e0d95e9a4d2a15d5081261f72 100644 (file)
@@ -46,8 +46,6 @@ option('tools-ixfrdist', type: 'boolean', value: false, description: 'Build ixfr
 option('lua-records', type: 'boolean', value: true, description: 'Support Lua records')
 option('systemd-service-user', type: 'string', value: 'pdns', description: 'Systemd service user (setuid and unit file; user is not created)')
 option('systemd-service-group', type: 'string', value: 'pdns', description: 'Systemd service group (setgid and unit file; group is not created)')
-# TODO Use meson's -Db_coverage option?
-# option('code-coverage', type: 'boolean', value: false, description: 'Enable code coverage')
 option('auto-var-init', type: 'combo', value: 'disabled', choices: ['zero', 'pattern', 'disabled'], description: 'Enable initialization of automatic variables')
 # TODO Use meson's -Db_sanitize option?
 # option('sanitizer-address', type: 'boolean', value: false, description: 'Enable the Address Sanitizer')