Flatten Meson files
We use a new enough version that we can take advantage of a few shortcuts so that entire files don't need to be wrapped in a huge `if`.
Also, passing the `dependency` object directly to `summary` prints `YES`+the version, instead of just `YES`.
Testing Done:
Configured with all options default, then disabled everything to be sure it didn't break.
Reviewed at https://reviews.imfreedom.org/r/1943/
--- a/gplugin-gtk4-viewer/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/gplugin-gtk4-viewer/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,3 @@
if not get_option('install-gplugin-gtk4-viewer')
summary('gplugin-gtk4-viewer',
'You have disabled installation of gplugin-gtk4-viewer which is a ' +
@@ -32,5 +30,3 @@
install : get_option('install-gplugin-gtk4-viewer'),
install_dir : get_option('mandir') / 'man1')
--- a/gplugin-gtk4/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/gplugin-gtk4/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,6 +1,7 @@
GTK4 = dependency('gtk4', version : '>=4.0.0', required : get_option('gtk4'))
###############################################################################
@@ -147,5 +148,3 @@
###############################################################################
--- a/gplugin-gtk4/reference/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/gplugin-gtk4/reference/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,31 +1,34 @@
- gplugin_gtk4_toml = configure_file(
- input : 'gplugin-gtk4.toml.in',
- output : 'gplugin-gtk4.toml',
- configuration : version_conf,
- install_dir : docs_dir / 'gplugin-gtk4',
- gplugin_gtk4_doc = custom_target('gplugin-gtk4-doc',
- input : [ gplugin_gtk4_toml, gplugin_gtk4_gir[0] ],
- output : 'gplugin-gtk4',
- '--add-include-path=@0@'.format(meson.project_build_root() / 'gplugin'),
- '--output-dir=@OUTPUT@',
- '--content-dir=@0@'.format(meson.current_source_dir()),
- depends : [ gplugin_gir[0] ],
- build_by_default : true,
- install_dir : docs_dir,
+if not get_option('doc') +gplugin_gtk4_toml = configure_file( + input : 'gplugin-gtk4.toml.in', + output : 'gplugin-gtk4.toml', + configuration : version_conf, + install_dir : docs_dir / 'gplugin-gtk4', +gplugin_gtk4_doc = custom_target('gplugin-gtk4-doc', + input : [ gplugin_gtk4_toml, gplugin_gtk4_gir[0] ], + output : 'gplugin-gtk4', + '--add-include-path=@0@'.format(meson.project_build_root() / 'gplugin'), + '--output-dir=@OUTPUT@', + '--content-dir=@0@'.format(meson.current_source_dir()), + depends : [ gplugin_gir[0] ], + build_by_default : true, + install_dir : docs_dir, +doc_targets += gplugin_gtk4_doc --- a/gplugin/reference/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/gplugin/reference/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,3 +1,7 @@
+if not get_option('doc') gplugin_doc_content_files = [
@@ -7,33 +11,32 @@
- gplugin_toml = configure_file(
- input : 'gplugin.toml.in',
- output : 'gplugin.toml',
- configuration : version_conf,
- install_dir : docs_dir / 'gplugin',
+gplugin_toml = configure_file( + input : 'gplugin.toml.in', + output : 'gplugin.toml', + configuration : version_conf, + install_dir : docs_dir / 'gplugin', - gplugin_doc = custom_target('gplugin-doc',
- input : [ gplugin_toml, gplugin_gir[0] ],
- '--output-dir=@OUTPUT@',
- '--content-dir=@0@'.format(meson.current_source_dir()),
- depend_files : [ gplugin_doc_content_files ],
- build_by_default : true,
- install_dir : docs_dir,
+gplugin_doc = custom_target('gplugin-doc', + input : [ gplugin_toml, gplugin_gir[0] ], + '--output-dir=@OUTPUT@', + '--content-dir=@0@'.format(meson.current_source_dir()), + depend_files : [ gplugin_doc_content_files ], + build_by_default : true, + install_dir : docs_dir, +doc_targets += gplugin_doc --- a/gplugin/share/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/gplugin/share/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,2 +1,1 @@
--- a/lua/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/lua/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,4 @@
-summary('lua', get_option('lua'), section : 'Loader Support', bool_yn : true)
+LUA = dependency('', required: false) if not get_option('introspection')
error('Lua plugin requires GObject Introspection.')
@@ -48,20 +47,26 @@
error('No usable Lua library was found')
- shared_library('gplugin-lua',
- c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Lua"'],
- dependencies : [LUA, gplugin_dep],
- install_dir : get_option('libdir') / 'gplugin'
- # Add the loader's path to our environment variable
- devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
+summary('Lua', LUA, section : 'Loader Support', bool_yn : true) +shared_library('gplugin-lua', + c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Lua"'], + dependencies : [LUA, gplugin_dep], + install_dir : get_option('libdir') / 'gplugin' +# Add the loader's path to our environment variable +devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir()) --- a/lua/tests/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/lua/tests/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,3 @@
e = executable('test-lua-loader', 'test-lua-loader.c',
'-DLUA_LOADER_DIR="@0@/.."'.format(meson.current_build_dir()),
@@ -12,5 +10,3 @@
# Add the test plugins path to our environment variable
devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
--- a/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -114,13 +114,14 @@
gidocgen = find_program('gi-docgen', required : get_option('doc'))
docs_dir = get_option('prefix') / get_option('datadir') / 'doc'
###############################################################################
###############################################################################
-subdir('gplugin-gtk4-viewer')
+subdir('gplugin-gtk4-viewer', if_found: GTK4) @@ -131,11 +132,6 @@
- doc_targets = [gplugin_doc]
- doc_targets += gplugin_gtk4_doc
alias_target('doc', doc_targets)
@@ -148,7 +144,7 @@
'api reference' : get_option('doc'),
- 'GTK4 widgets' : GTK4.found(),
'man pages' : get_option('help2man'),
}, bool_yn : true, section : 'Miscellaneous')
--- a/python3/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/python3/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,4 @@
-summary('python3', get_option('python3'), section : 'Loader Support', bool_yn : true)
+PYTHON3 = dependency('', required: false) if not get_option('introspection')
error('Python3 plugin requires GObject Introspection.')
@@ -29,13 +28,10 @@
['python-3.7m', '>=3.7'],
foreach _PYTHON : _PYTHONS
PYTHON3 = dependency(_PYTHON[0], version : _PYTHON[1], required : false)
python3_gi_test = compiler.run(files('gplugin-python3-test-pygobject.c'),
dependencies : [GLIB, PYTHON3, PYGOBJECT],
@@ -49,42 +45,48 @@
error('failed to find a usable python')
error('found a usable python but pygobject does not work with it')
- # Now add our libraries
- gplugin_python3_inc = include_directories('.')
- gplugin_python3 = shared_library('gplugin-python3',
- GPLUGIN_PYTHON3_SOURCES,
- GPLUGIN_PYTHON3_HEADERS,
- c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Python3"'],
- dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
- install_dir : get_option('libdir') / 'gplugin'
- gplugin_python3_dep = declare_dependency(
- include_directories : gplugin_python3_inc,
- link_with : gplugin_python3,
- gplugin_python3_static = static_library('gplugin-python3-static',
- GPLUGIN_PYTHON3_SOURCES,
- GPLUGIN_PYTHON3_HEADERS,
- dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
- gplugin_python3_static_dep = declare_dependency(
- include_directories : gplugin_python3_inc,
- link_with : gplugin_python3_static,
- # Add the loader's path to our environment variable
- devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
+summary('Python3', PYTHON3, section : 'Loader Support', bool_yn : true) +gplugin_python3_inc = include_directories('.') +gplugin_python3 = shared_library('gplugin-python3', + GPLUGIN_PYTHON3_SOURCES, + GPLUGIN_PYTHON3_HEADERS, + c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Python3"'], + dependencies : [PYTHON3, PYGOBJECT, gplugin_dep], + install_dir : get_option('libdir') / 'gplugin' +gplugin_python3_dep = declare_dependency( + include_directories : gplugin_python3_inc, + link_with : gplugin_python3, +gplugin_python3_static = static_library('gplugin-python3-static', + GPLUGIN_PYTHON3_SOURCES, + GPLUGIN_PYTHON3_HEADERS, + dependencies : [PYTHON3, PYGOBJECT, gplugin_dep], +gplugin_python3_static_dep = declare_dependency( + include_directories : gplugin_python3_inc, + link_with : gplugin_python3_static, +# Add the loader's path to our environment variable +devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir()) --- a/python3/tests/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/python3/tests/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,3 @@
-if get_option('python3')
e = executable('test-python3-loader', 'test-python3-loader.c',
include_directories : include_directories('.'),
@@ -21,5 +19,3 @@
# Add the test plugins path to our environment variable
devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
--- a/rust/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/rust/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,6 +1,7 @@
--- a/rust/tests/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/rust/tests/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,3 @@
e = executable('test-rust-loading', 'test-rust-loading.c',
include_directories : include_directories('.'),
@@ -10,6 +8,3 @@
--- a/vala/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/vala/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,23 +1,25 @@
- if not get_option('introspection')
- error('Vala generation requires GObject Introspection.')
+if not get_option('vapi') - add_languages('vala', native: false)
+if not get_option('introspection') + error('Vala generation requires GObject Introspection.') - gplugin_vapi = gnome.generate_vapi('gplugin',
- sources : gplugin_gir[0],
+add_languages('vala', native: false) - if get_option('gtk4').allowed()
- gplugin_gtk4_vapi = gnome.generate_vapi('gplugin-gtk4',
- sources : gplugin_gtk4_gir[0],
- gir_dirs : meson.current_build_dir() / '..' / 'gplugin',
+gplugin_vapi = gnome.generate_vapi('gplugin', + sources : gplugin_gir[0],
+if get_option('gtk4').allowed() + gplugin_gtk4_vapi = gnome.generate_vapi('gplugin-gtk4', + sources : gplugin_gtk4_gir[0], + gir_dirs : meson.current_build_dir() / '..' / 'gplugin', --- a/vala/tests/meson.build Thu Oct 06 22:49:38 2022 -0500
+++ b/vala/tests/meson.build Sun Oct 23 21:40:33 2022 -0500
@@ -1,5 +1,3 @@
e = executable('test-vala-loading', 'test-vala-loading.c',
include_directories : include_directories('.'),
@@ -20,5 +18,3 @@