build: modernize meson usage

Since we require meson 1.3(.2), we can modernize the usage a bit,
as well as improve some logic

- use / instead of join_paths
- use option.allowed() instead of !option.disable()
- use cxx.get_supported_arguments
- use fs.copyfile instead of configure_file
- show a summary at the end of the configuration
This commit is contained in:
Dirk-Jan C. Binnema
2026-08-02 10:14:17 +03:00
committed by Seth Ladygo
parent 04079aee7c
commit ac52584562
12 changed files with 114 additions and 85 deletions

View File

@ -1,4 +1,4 @@
## Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@ compile_scm=configure_file(
install: false
)
run_command('chmod', '+x', compile_scm, check: true)
scm_compiler=join_paths(meson.current_build_dir(), 'compile-scm')
scm_compiler=meson.current_build_dir() / 'compile-scm'
#
# NOTE: snarfing works but you get:
@ -53,12 +53,9 @@ if do_snarf
snarf_args=['-o', '@OUTPUT@', '@INPUT@', '-I' + meson.current_source_dir() + '/..',
'-I' + meson.current_source_dir() + '/../lib',
'-I' + meson.current_build_dir() + '/..']
snarf_args += '-I' + join_paths(glib_dep.get_pkgconfig_variable('includedir'),
'glib-2.0')
snarf_args += '-I' + join_paths(glib_dep.get_pkgconfig_variable('libdir'),
'glib-2.0', 'include')
snarf_args += '-I' + join_paths(guile_dep.get_pkgconfig_variable('includedir'),
'guile', '3.0')
snarf_args += '-I' + glib_dep.get_variable(pkgconfig: 'includedir') / 'glib-2.0'
snarf_args += '-I' + glib_dep.get_variable(pkgconfig: 'libdir') / 'glib-2.0' / 'include'
snarf_args += '-I' + guile_dep.get_variable(pkgconfig: 'includedir') / 'guile' / '3.0'
snarf_gen=generator(snarf,
output: '@BASENAME@.x',
arguments: snarf_args)
@ -83,32 +80,32 @@ if makeinfo.found()
output: 'mu-guile.info',
install: true,
install_dir: infodir,
depends: fdl_texi,
command: [makeinfo,
'-o', join_paths(meson.current_build_dir(), 'mu-guile.info'),
join_paths(meson.current_source_dir(), 'mu-guile.texi'),
'-I', join_paths(meson.current_build_dir(), '..')])
'-o', meson.current_build_dir() / 'mu-guile.info',
meson.current_source_dir() / 'mu-guile.texi',
'-I', meson.current_build_dir() / '..'])
if install_info.found()
infodir = join_paths(get_option('prefix') / get_option('infodir'))
meson.add_install_script(install_info_script, infodir, 'mu-guile.info')
endif
endif
guile_scm_dir=join_paths(datadir, 'guile', 'site', '3.0')
guile_scm_dir=datadir / 'guile' / 'site' / '3.0'
install_data(['mu.scm'], install_dir: guile_scm_dir)
guile_scm_mu_dir=join_paths(guile_scm_dir, 'mu')
guile_scm_mu_dir=guile_scm_dir / 'mu'
foreach mod : ['script.scm', 'message.scm', 'stats.scm', 'plot.scm']
install_data(join_paths('mu', mod), install_dir: guile_scm_mu_dir)
install_data('mu' / mod, install_dir: guile_scm_mu_dir)
endforeach
mu_guile_scripts=[
join_paths('scripts', 'find-dups.scm'),
join_paths('scripts', 'msgs-count.scm'),
join_paths('scripts', 'histogram.scm')]
mu_guile_script_dir=join_paths(datadir, 'mu', 'scripts')
'scripts' / 'find-dups.scm',
'scripts' / 'msgs-count.scm',
'scripts' / 'histogram.scm']
mu_guile_script_dir=datadir / 'mu' / 'scripts'
install_data(mu_guile_scripts, install_dir: mu_guile_script_dir)
guile_builddir=meson.current_build_dir()
if not get_option('tests').disabled()
if get_option('tests').allowed()
subdir('tests')
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2025-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -18,9 +18,9 @@
# guile test; they don't work with ASAN.
#
if get_option('b_sanitize') == 'none'
guile_load_path = join_paths(meson.project_source_root(), 'guile')
guile_load_path = meson.project_source_root() / 'guile'
guile_extensions_path = ':'.join([
join_paths(meson.project_build_root(), 'guile'),
meson.project_build_root() / 'guile',
meson.current_build_dir()])
test('test-mu-guile',

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2021-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -92,6 +92,6 @@ list_maildirs = executable('list-maildirs', 'mu-scanner.cc',
dependencies: [glib_dep, config_h_dep,
lib_mu_utils_dep])
if not get_option('tests').disabled()
if get_option('tests').allowed()
subdir('tests')
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -43,6 +43,6 @@ lib_mu_message_dep = declare_dependency(
include_directories:
include_directories(['.', '..']))
if not get_option('tests').disabled()
if get_option('tests').allowed()
subdir('tests')
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2021-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -139,8 +139,8 @@ test('test-store-query',
#
# benchmarks
#
bench_maildirs=join_paths(meson.current_build_dir(), 'maildirs')
bench_store=join_paths(meson.current_build_dir(), 'store')
bench_maildirs=meson.current_build_dir() / 'maildirs'
bench_store=meson.current_build_dir() / 'store'
bench_indexer_exe = executable(
'bench-indexer',
'bench-indexer.cc',

View File

@ -1,4 +1,4 @@
## Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -14,7 +14,7 @@
## along with this program; if not, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
thirdparty=join_paths('..', '..', 'thirdparty')
thirdparty='..' / '..' / 'thirdparty'
srcs = [
'mu-command-handler.cc',
@ -28,7 +28,7 @@ srcs = [
'mu-utils.cc',
]
if not get_option('tests').disabled()
if get_option('tests').allowed()
test_srcs = [ 'mu-test-utils.cc' ]
else
test_srcs = []
@ -62,6 +62,6 @@ html2text = executable('mu-html2text',
cpp_args: ['-DBUILD_HTML_TO_TEXT'],
install: false)
if not get_option('tests').disabled()
if get_option('tests').allowed()
subdir('tests')
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2021-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -30,15 +30,15 @@ incs=[
'muhome.inc',
'prefooter.inc',
]
inc_targets=[]
foreach inc: incs
# configure the .in ones
if inc.substring(-3) == '.in'
configure_file(input: inc,
output: '@BASENAME@',
configuration: man_data)
else # and copy the rest
configure_file(input: inc, output:'@BASENAME@.inc',
copy:true)
else # and copy the rest (at build time)
inc_targets += fs.copyfile(inc)
endif
endforeach
@ -69,7 +69,7 @@ man_orgs = [
foreach src : man_orgs
# meson makes in tricky to use the results of e.g. configure_file
# in custom_commands..., so this is admittedly a little hacky.
org = join_paths(meson.current_build_dir(), src)
org = meson.current_build_dir() / src
man = '@BASENAME@'
section = src.substring(-5, -4)
@ -95,7 +95,7 @@ foreach src : man_orgs
' (replace-regexp-in-string zwsp "" text))))',
' (org-export-to-file \'man "@0@"))'])
expr = expr_tmpl.format(org.substring(0,-4))
sectiondir = join_paths(mandir, 'man' + section)
sectiondir = mandir / ('man' + section)
custom_target(src + '-to-man',
build_by_default: true,
@ -104,6 +104,7 @@ foreach src : man_orgs
install: true,
install_dir: sectiondir,
depend_files: incs,
depends: inc_targets,
command: [emacs,
'--no-init-file',
'--batch',

View File

@ -20,11 +20,13 @@ project('mu', ['c', 'cpp'],
version: '1.14.3-pre5',
meson_version: '>= 1.3.2',
license: 'GPL-3.0-or-later',
default_options : [
'buildtype=debugoptimized',
'warning_level=3',
'c_std=c11',
'cpp_std=c++20'])
default_options : {
'buildtype': 'debugoptimized',
'warning_level': '3',
'c_std': 'c11',
'cpp_std': 'c++20'})
fs = import('fs')
# hard-code the date here (for reproducibility); we derive the dates used in
# e.g. documentation from this.
@ -39,7 +41,7 @@ infodir = prefixdir / get_option('infodir')
# allow for configuring lispdir, as with autotools.
if get_option('lispdir') == ''
mu4e_lispdir= datadir / join_paths('emacs', 'site-lisp', 'mu4e')
mu4e_lispdir= datadir / 'emacs' / 'site-lisp' / 'mu4e'
else
mu4e_lispdir= get_option('lispdir') / 'mu4e'
endif
@ -88,11 +90,8 @@ if get_option('buildtype') == 'debug'
endif
# extra arguments, if available
foreach extra_arg : extra_flags + extra_cpp_flags
if cxx.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'cpp')
endif
endforeach
add_project_arguments(cxx.get_supported_arguments(extra_flags + extra_cpp_flags),
language: 'cpp')
# some clang don't have charconv, but we need it.
# https://github.com/djcb/mu/issues/2347
@ -171,7 +170,7 @@ if pthread_setname_np_check
config_h_data.set('HAVE_PTHREAD_SETNAME_NP', 1)
endif
if not get_option('tests').disabled()
if get_option('tests').allowed()
# only needed for tests
cp=find_program('cp')
ln=find_program('ln')
@ -254,8 +253,8 @@ endif
#
# use Compact Language Detector2 if we can find it
#
cld2_dep = meson.get_compiler('cpp').find_library('cld2', required: get_option('cld2'))
if not get_option('cld2').disabled() and cld2_dep.found()
cld2_dep = cxx.find_library('cld2', required: get_option('cld2'))
if get_option('cld2').allowed() and cld2_dep.found()
config_h_data.set('HAVE_CLD2', 1)
else
message('CLD2 not found or disabled; no support for language detection')
@ -288,7 +287,7 @@ else
if not install_info.found()
message('install-info not found')
else
install_info_script=join_paths(build_aux, 'meson-install-info.sh')
install_info_script=build_aux / 'meson-install-info.sh'
endif
endif
@ -318,13 +317,13 @@ version_texi_data.set('UPDATEDYEAR', mu_year)
configure_file(input: build_aux / 'version.texi.in',
output: 'version.texi',
configuration: version_texi_data)
configure_file(input: build_aux / 'fdl.texi',
output: 'fdl.texi', copy:true)
# build-time copy; texinfo targets must declare 'depends: fdl_texi'
fdl_texi = fs.copyfile(build_aux / 'fdl.texi')
################################################################################
# install some data files
install_data('NEWS.org', 'IDEAS.org',
install_dir : join_paths(datadir, 'doc', 'mu'))
install_dir : datadir / 'doc' / 'mu')
################################################################################
# subdirs
@ -337,7 +336,7 @@ mu_scm_dep = declare_dependency()
if guile_dep.found()
# modern guile support
if not get_option('scm').disabled()
if get_option('scm').allowed()
config_h_data.set('BUILD_SCM', 1)
subdir('scm')
else
@ -345,7 +344,7 @@ if guile_dep.found()
endif
# old-style guile-support (deprecated)
if not get_option('guile').disabled()
if get_option('guile').allowed()
message('old-style guile support is deprecated')
config_h_data.set('BUILD_GUILE', 1)
config_h_data.set_quoted('GUILE_BINARY',
@ -381,6 +380,37 @@ if gmime_dep.version() == '3.2.13'
warning('See: https://github.com/jstedfast/gmime/issues/133')
endif
################################################################################
# summary
summary({'prefix' : prefixdir,
'buildtype' : get_option('buildtype'),
'c compiler' : cc.get_id() + ' ' + cc.version(),
'c++ compiler' : cxx.get_id() + ' ' + cxx.version()},
section: 'Build')
summary({'glib' : glib_dep.version(),
'gmime' : gmime_dep.version(),
'xapian' : xapian_dep.version(),
'fmt' : fmt_dep.type_name() == 'internal' ? 'embedded' : fmt_dep.version(),
'CLI11' : cli11_dep.type_name() == 'internal' ? 'embedded' : cli11_dep.version(),
'guile' : guile_dep.found() ? guile_dep.version() : 'not found'},
section: 'Dependencies')
summary({'language detection (cld2)' : get_option('cld2').allowed() and cld2_dep.found(),
'scm scripting' : guile_dep.found() and get_option('scm').allowed(),
'guile (old-style, deprecated)': guile_dep.found() and get_option('guile').allowed(),
'readline' : get_option('readline').enabled(),
'tests' : get_option('tests').allowed(),
'info docs (makeinfo)' : makeinfo.found(),
'mu4e, man-pages (emacs)' : emacs.found()},
section: 'Features', bool_yn: true)
if emacs.found()
summary({'emacs version': emacs.version(),
'mu4e lispdir' : mu4e_lispdir},
section: 'Mu4e')
endif
# Local Variables:
# indent-tabs-mode: nil
# End:

View File

@ -1,4 +1,4 @@
## Copyright (C) 2021-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2021-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -37,9 +37,9 @@ mu = executable(
],
dependencies: [ glib_dep, gmime_dep, cli11_dep,
lib_mu_dep, mu_scm_dep, thread_dep, config_h_dep ],
cpp_args: ['-DMU_SCRIPTS_DIR="'+ join_paths(datadir, 'mu', 'scripts') + '"'],
cpp_args: ['-DMU_SCRIPTS_DIR="' + datadir / 'mu' / 'scripts' + '"'],
install: true)
#
if not get_option('tests').disabled()
if get_option('tests').allowed()
subdir('tests')
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -127,7 +127,7 @@ test('test-options',
install: false,
build_by_default: false,
cpp_args: ['-DBUILD_TESTS',
'-DMU_SCRIPTS_DIR="'+ join_paths(datadir, 'mu', 'scripts') + '"'],
'-DMU_SCRIPTS_DIR="' + datadir / 'mu' / 'scripts' + '"'],
dependencies: [glib_dep, config_h_dep, cli11_dep, lib_mu_dep]))
gmime_test = executable(

View File

@ -26,7 +26,7 @@ mu4e_meta = configure_file(
configuration: {
'VERSION' : meson.project_version(),
'MU_VERSION_EXTRA' : version_extra,
'MU_DOC_DIR' : join_paths(datadir, 'doc', 'mu'),
'MU_DOC_DIR' : datadir / 'doc' / 'mu',
})
mu4e_pkg_desc = configure_file(
@ -97,7 +97,7 @@ endif
# byte compile the sources that can be byte-compiled. This may exclude mu4e-dbus.el
foreach src : mu4e_bc_srcs
target_name= '@BASENAME@.elc'
target_path = join_paths(meson.current_build_dir(), target_name)
target_path = meson.current_build_dir() / target_name
target_func = '(setq byte-compile-dest-file-function(lambda(_) "' + target_path + '"))'
custom_target(src.underscorify() + '_el',
@ -122,15 +122,16 @@ endforeach
# hack-around for native compile issue: copy sources to builddir.
# see: https://debbugs.gnu.org/db/47/47987.html
mu4e_el_copies=[]
foreach src : mu4e_srcs
configure_file(input: src, output:'@BASENAME@.el', copy:true,
install_mode: 'r--r--r--')
# seems meson ignores 'install_mode' for copy (1.5.1, 1.6.1)
mu4e_el_copies += fs.copyfile(src)
endforeach
# this depends on the above hack: all mu4e elisp files needs to be in builddir
mu4e_autoloads = configure_file(
mu4e_autoloads = custom_target('mu4e-autoloads',
output: 'mu4e-autoloads.el',
build_by_default: true,
depends: mu4e_el_copies,
install: true,
install_dir: mu4e_lispdir,
command: [emacs,
@ -144,7 +145,7 @@ mu4e_autoloads = configure_file(
install_data(mu4e_srcs, install_dir: mu4e_lispdir)
# install mu4e-about.org
install_data('mu4e-about.org', install_dir : join_paths(datadir, 'doc', 'mu'))
install_data('mu4e-about.org', install_dir : datadir / 'doc' / 'mu')
if makeinfo.found()
custom_target('mu4e_info',
@ -152,12 +153,12 @@ if makeinfo.found()
output: 'mu4e.info',
install_dir: infodir,
install: true,
depends: fdl_texi,
command: [makeinfo,
'-o', join_paths(meson.current_build_dir(), 'mu4e.info'),
join_paths(meson.current_source_dir(), 'mu4e.texi'),
'-I', join_paths(meson.current_build_dir(), '..')])
'-o', meson.current_build_dir() / 'mu4e.info',
meson.current_source_dir() / 'mu4e.texi',
'-I', meson.current_build_dir() / '..'])
if install_info.found()
infodir = join_paths(get_option('prefix') / get_option('infodir'))
meson.add_install_script(install_info_script, infodir, 'mu4e.info')
endif
endif

View File

@ -1,4 +1,4 @@
## Copyright (C) 2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
## Copyright (C) 2025-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@ -13,8 +13,8 @@
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software Foundation,
## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
mu_scm_dir=join_paths(datadir, 'mu', 'scm')
mu_scm_dir_arg='-DMU_SCM_DIR="' + mu_scm_dir + '"'
mu_scm_dir=datadir / 'mu' / 'scm'
mu_scm_dir_arg=f'-DMU_SCM_DIR="@mu_scm_dir@"'
lib_mu_scm=static_library(
'mu-scm', [
@ -49,20 +49,20 @@ if makeinfo.found()
output: 'mu-scm.info',
install: true,
install_dir: infodir,
depends: fdl_texi,
command: [makeinfo,
'-o', join_paths(meson.current_build_dir(), 'mu-scm.info'),
join_paths(meson.current_source_dir(), 'mu-scm.texi'),
'-I', join_paths(meson.current_build_dir(), '..')])
'-o', meson.current_build_dir() / 'mu-scm.info',
meson.current_source_dir() / 'mu-scm.texi',
'-I', meson.current_build_dir() / '..'])
if install_info.found()
infodir = join_paths(get_option('prefix') / get_option('infodir'))
meson.add_install_script(install_info_script, infodir, 'mu-scm.info')
endif
endif
if not get_option('tests').disabled()
if get_option('tests').allowed()
srcdir=meson.current_source_dir()
def_srcdir='-DMU_SCM_SRCDIR="' + srcdir + '"'
def_srcdir=f'-DMU_SCM_SRCDIR="@srcdir@"'
test('test-scm',
executable('test-scm',