]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: use summary()
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 6 Dec 2022 18:54:43 +0000 (19:54 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 7 Dec 2022 11:53:20 +0000 (12:53 +0100)
https://mesonbuild.com/Reference-manual_functions.html#summary
- has nicer output
- less code in meson files
- allows defining summary parts closer to where they originate

Also short pieces of meson code are moved around.

etc/config/meson.build
meson.build
modules/dnstap/meson.build
modules/http/meson.build
systemd/meson.build
tests/meson.build
utils/cache_gc/meson.build
utils/client/meson.build

index ca888084913709cd272bf094a6caf55fc686fd59..828a87003bbc5d8f8b0e69d4bea4fcfcb82b8505 100644 (file)
@@ -33,3 +33,6 @@ if install_kresd_conf
     install_dir: etc_dir,
   )
 endif
+
+summary({'install kresd.conf': install_kresd_conf,
+        }, section: 'Paths', bool_yn: true)
index 60f656d4edbe48ea48c11ede9334a5427905d2c3..ed43541c85e7ef2a34d976742dab2af00a9979c4 100644 (file)
@@ -61,6 +61,23 @@ systemd_tmpfiles_dir = prefix / 'lib' / 'tmpfiles.d'
 systemd_sysusers_dir = prefix / 'lib' / 'sysusers.d'
 mod_inc_dir = include_directories('.', 'contrib/')
 
+summary({'prefix': prefix,
+         'lib_dir': lib_dir,
+         'sbin_dir': sbin_dir,
+         'etc_dir': etc_dir,
+        }, section: 'Paths')
+
+## Root hints
+root_hints = etc_dir / get_option('root_hints')
+if root_hints == etc_dir / 'root.hints'
+  install_root_hints = true
+else
+  install_root_hints = false
+endif
+
+summary({'root.hints': root_hints,
+        }, section: 'Paths')
+
 ## Trust anchors
 managed_ta = get_option('managed_ta') == 'enabled'
 keyfile_default = etc_dir / get_option('keyfile_default')
@@ -72,14 +89,10 @@ if get_option('install_root_keys') == 'auto'
   install_root_keys = managed_ta
 endif
 
-
-## Root hints
-root_hints = etc_dir / get_option('root_hints')
-if root_hints == etc_dir / 'root.hints'
-  install_root_hints = true
-else
-  install_root_hints = false
-endif
+summary({'keyfile_default': keyfile_default,
+         'managed_ta': managed_ta,
+         'install_root_keys': install_root_keys,
+        }, section: 'Trust anchors', bool_yn: true)
 
 ## Additional options
 user = get_option('user')
@@ -112,10 +125,6 @@ endif
 ### XDP: not configurable - we just check if libknot supports it
 xdp = meson.get_compiler('c').has_header('libknot/xdp/xdp.h')
 
-### Systemd
-systemd_files = get_option('systemd_files')
-libsystemd = dependency('libsystemd', required: systemd_files == 'enabled')
-
 ### Allocator
 # use empty name to disable the dependency, but still compile the dependent kresd
 malloc_name = get_option('malloc') == 'disabled' ? '' : 'jemalloc'
@@ -127,6 +136,17 @@ malloc = meson.get_compiler('c').find_library(
   # Fortunately it seems unlikely that dynamic wouldn't be found and static would be.
 )
 
+summary({'sendmmsg': sendmmsg,
+         'XDP (in libknot)': xdp,
+         'doh2 (serving)': nghttp2.found(),
+         'capabilities': capng.found(),
+         'malloc': malloc.found() ? malloc_name : 'libc default',
+        }, section: 'Features', bool_yn: true)
+
+### Systemd; it gets own summary section defined later
+systemd_files = get_option('systemd_files')
+libsystemd = dependency('libsystemd', required: systemd_files == 'enabled')
+
 message('---------------------------')
 
 ## Compiler args
@@ -293,65 +313,3 @@ run_target(
   command: pylint_run,
 )
 
-
-# Summary message
-# NOTE: ternary operator in format() not supported
-# https://github.com/mesonbuild/meson/issues/2404
-s_managed_ta = managed_ta ? 'enabled' : 'disabled'
-s_install_root_keys = install_root_keys ? 'enabled' : 'disabled'
-s_build_client = build_client ? 'enabled' : 'disabled'
-s_build_utils = build_utils ? 'enabled' : 'disabled'
-s_build_dnstap = build_dnstap ? 'enabled' : 'disabled'
-s_build_unit_tests = build_unit_tests ? 'enabled' : 'disabled'
-s_build_config_tests = build_config_tests ? 'enabled' : 'disabled'
-s_build_extra_tests = build_extra_tests ? 'enabled' : 'disabled'
-s_install_kresd_conf = install_kresd_conf ? 'enabled' : 'disabled'
-s_sendmmsg = sendmmsg ? 'enabled': 'disabled'
-s_xdp = xdp ? 'enabled': 'disabled'
-s_openssl = openssl.found() ? 'present': 'missing'
-s_capng = capng.found() ? 'enabled': 'disabled'
-s_malloc = malloc.found() ? 'jemalloc' : 'libc default'
-s_doh2 = nghttp2.found() ? 'enabled': 'disabled'
-message('''
-
-======================= SUMMARY =======================
-
-  paths
-    prefix:             @0@'''.format(prefix) + '''
-    lib_dir:            @0@'''.format(lib_dir) + '''
-    sbin_dir:           @0@'''.format(sbin_dir) + '''
-    etc_dir:            @0@'''.format(etc_dir) + '''
-    root.hints:         @0@'''.format(root_hints) + '''
-
-  trust_anchors
-    keyfile_default:    @0@'''.format(keyfile_default) + '''
-    managed_ta:         @0@'''.format(s_managed_ta) + '''
-    install_root_keys:  @0@'''.format(s_install_root_keys) + '''
-
-  systemd:
-    files:              @0@'''.format(systemd_files) + '''
-    work_dir:           @0@'''.format(systemd_work_dir) + '''
-    cache_dir:          @0@'''.format(systemd_cache_dir) + '''
-
-  optional components
-    client:             @0@'''.format(s_build_client) + '''
-    utils:              @0@'''.format(s_build_utils) + '''
-    dnstap:             @0@'''.format(s_build_dnstap) + '''
-    unit_tests:         @0@'''.format(s_build_unit_tests) + '''
-    config_tests:       @0@'''.format(s_build_config_tests) + '''
-    extra_tests:        @0@'''.format(s_build_extra_tests) + '''
-
-  additional
-    user:               @0@'''.format(user) + '''
-    group:              @0@'''.format(group) + '''
-    install_kresd_conf: @0@'''.format(s_install_kresd_conf) + '''
-    sendmmsg:           @0@'''.format(s_sendmmsg) + '''
-    XDP (in libknot):   @0@'''.format(s_xdp) + '''
-    openssl debug:      @0@'''.format(s_openssl) + '''
-    capng:              @0@'''.format(s_capng) + '''
-    malloc:             @0@'''.format(s_malloc) + '''
-    doh2:               @0@'''.format(s_doh2) + '''
-
-=======================================================
-
-''')
index e8a94bf116bb29e17a35a19cc44b440fa51aa8bc..5157025b5f5258cea71043aaf80ca5a052393216 100644 (file)
@@ -55,3 +55,6 @@ if build_dnstap
     install_dir: modules_dir,
   )
 endif
+
+summary({'dnstap module': build_dnstap,
+        }, section: 'Optional components', bool_yn: true)
index 6705143c3b39251c006d0485640c6a7fb2e90d09..a08314261ba2a866193c84ac474e07d334fdc4e1 100644 (file)
@@ -59,3 +59,6 @@ if openssl.found()
     ],
   )
 endif
+
+summary({'openssl debug lib': openssl.found(),
+        }, section: 'Optional components', bool_yn: true)
index 6ca0bac1309623dbddd1fbd3d6213a3aa76fb040..2373b33de16c4926b02514babdcd93b85c4cc00d 100644 (file)
@@ -63,4 +63,9 @@ if systemd_files == 'enabled'
     install_dir: systemd_sysusers_dir,
   )
 
+  summary({'work_dir': systemd_work_dir,
+           'cache_dir': systemd_cache_dir,
+           'user': user,
+           'group': group,
+          }, section: 'Systemd service settings')
 endif
index 818169dfcb24d5d9cdaf17fbf7479f8faeeb086f..e41c61fd62281d7281dd06dddff4263287309f6e 100644 (file)
@@ -59,3 +59,9 @@ if build_extra_tests
   endforeach
   message('--------------------------------')
 endif
+
+
+summary({'unit tests': build_unit_tests,
+         'config tests': build_config_tests,
+         'extra tests': build_extra_tests,
+        }, section: 'Tests built', bool_yn: true)
index 02ab6c639399017d6150a6a772d35f15721c1aed..18ad0d5f85b4759133692896ce0c8095aebe76dc 100644 (file)
@@ -24,8 +24,10 @@ if build_utils
     install_dir: get_option('sbindir'),
   )
 
-integr_tests += [
-  ['gc_cache_overflow', meson.current_source_dir() / 'test.integr'],
-]
-
+  integr_tests += [
+    ['gc_cache_overflow', meson.current_source_dir() / 'test.integr'],
+  ]
 endif
+
+summary({'kres-cache-gc': build_utils,
+        }, section: 'Optional components', bool_yn: true)
index 761c2cdd3e3e6860fd963fbe86afe48e998ed06a..3193b1ae21c9695b79658fdd23624e1193ef49fa 100644 (file)
@@ -35,3 +35,6 @@ if build_client
     install_dir: get_option('sbindir'),
   )
 endif
+
+summary({'kresc': build_client,
+        }, section: 'Optional components', bool_yn: true)