gplugin/gplugin

Flatten Meson files

18 months ago, Elliott Sales de Andrade
77e88ad17495
Parents bdae2f4577c5
Children 8f3ab5e34d52
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 GTK4.found()
-
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')
endif
-
-endif
--- 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'))
-
-if GTK4.found()
+if not GTK4.found()
+ subdir_done()
+endif
###############################################################################
# Build Info
@@ -147,5 +148,3 @@
# subdirectories
###############################################################################
subdir('reference')
-
-endif # gtk4
--- 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 @@
-if get_option('doc')
- gplugin_gtk4_toml = configure_file(
- input : 'gplugin-gtk4.toml.in',
- output : 'gplugin-gtk4.toml',
- configuration : version_conf,
- install : true,
- 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',
- command : [
- gidocgen,
- 'generate',
- '--quiet',
- '--fatal-warnings',
- '--add-include-path=@0@'.format(meson.project_build_root() / 'gplugin'),
- '--config=@INPUT0@',
- '--output-dir=@OUTPUT@',
- '--no-namespace-dir',
- '--content-dir=@0@'.format(meson.current_source_dir()),
- '@INPUT1@'
- ],
- depends : [ gplugin_gir[0] ],
- build_by_default : true,
- install : true,
- install_dir : docs_dir,
- )
+if not get_option('doc')
+ subdir_done()
endif
+gplugin_gtk4_toml = configure_file(
+ input : 'gplugin-gtk4.toml.in',
+ output : 'gplugin-gtk4.toml',
+ configuration : version_conf,
+ install : true,
+ 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',
+ command : [
+ gidocgen,
+ 'generate',
+ '--quiet',
+ '--fatal-warnings',
+ '--add-include-path=@0@'.format(meson.project_build_root() / 'gplugin'),
+ '--config=@INPUT0@',
+ '--output-dir=@OUTPUT@',
+ '--no-namespace-dir',
+ '--content-dir=@0@'.format(meson.current_source_dir()),
+ '@INPUT1@'
+ ],
+ depends : [ gplugin_gir[0] ],
+ build_by_default : true,
+ install : 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')
+ subdir_done()
+endif
+
gplugin_doc_content_files = [
'embedding.md',
'genie.md',
@@ -7,33 +11,32 @@
'vala.md',
]
-if get_option('doc')
- gplugin_toml = configure_file(
- input : 'gplugin.toml.in',
- output : 'gplugin.toml',
- configuration : version_conf,
- install : true,
- install_dir : docs_dir / 'gplugin',
- )
+gplugin_toml = configure_file(
+ input : 'gplugin.toml.in',
+ output : 'gplugin.toml',
+ configuration : version_conf,
+ install : true,
+ install_dir : docs_dir / 'gplugin',
+)
- gplugin_doc = custom_target('gplugin-doc',
- input : [ gplugin_toml, gplugin_gir[0] ],
- output : 'gplugin',
- command : [
- gidocgen,
- 'generate',
- '--quiet',
- '--fatal-warnings',
- '--config=@INPUT0@',
- '--output-dir=@OUTPUT@',
- '--no-namespace-dir',
- '--content-dir=@0@'.format(meson.current_source_dir()),
- '@INPUT1@'
- ],
- depend_files : [ gplugin_doc_content_files ],
- build_by_default : true,
- install : true,
- install_dir : docs_dir,
- )
-endif
+gplugin_doc = custom_target('gplugin-doc',
+ input : [ gplugin_toml, gplugin_gir[0] ],
+ output : 'gplugin',
+ command : [
+ gidocgen,
+ 'generate',
+ '--quiet',
+ '--fatal-warnings',
+ '--config=@INPUT0@',
+ '--output-dir=@OUTPUT@',
+ '--no-namespace-dir',
+ '--content-dir=@0@'.format(meson.current_source_dir()),
+ '@INPUT1@'
+ ],
+ depend_files : [ gplugin_doc_content_files ],
+ build_by_default : true,
+ install : 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 @@
subdir('valgrind')
-
--- 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 get_option('lua')
if not get_option('introspection')
error('Lua plugin requires GObject Introspection.')
@@ -48,20 +47,26 @@
if not LUA_FOUND
error('No usable Lua library was found')
endif
-
- # now add the library
- shared_library('gplugin-lua',
- GPLUGIN_LUA_SOURCES,
- GPLUGIN_LUA_HEADERS,
- name_prefix : '',
- c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Lua"'],
- dependencies : [LUA, gplugin_dep],
- install : true,
- install_dir : get_option('libdir') / 'gplugin'
- )
-
- # Add the loader's path to our environment variable
- devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
endif # lua
+summary('Lua', LUA, section : 'Loader Support', bool_yn : true)
+
+if not LUA.found()
+ subdir_done()
+endif
+
+# now add the library
+shared_library('gplugin-lua',
+ GPLUGIN_LUA_SOURCES,
+ GPLUGIN_LUA_HEADERS,
+ name_prefix : '',
+ c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Lua"'],
+ dependencies : [LUA, gplugin_dep],
+ install : true,
+ install_dir : get_option('libdir') / 'gplugin'
+)
+
+# Add the loader's path to our environment variable
+devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_build_dir())
+
subdir('tests')
--- 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 @@
-if get_option('lua')
-
e = executable('test-lua-loader', 'test-lua-loader.c',
c_args : [
'-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')
-
-endif # lua
--- 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'
+doc_targets = []
###############################################################################
# Subdirectories
###############################################################################
subdir('gplugin')
subdir('gplugin-gtk4')
-subdir('gplugin-gtk4-viewer')
+subdir('gplugin-gtk4-viewer', if_found: GTK4)
subdir('gplugin-query')
subdir('po')
@@ -131,11 +132,6 @@
subdir('vala')
if get_option('doc')
- doc_targets = [gplugin_doc]
- if GTK4.found()
- doc_targets += gplugin_gtk4_doc
- endif
-
alias_target('doc', doc_targets)
endif
@@ -148,7 +144,7 @@
summary({
'api reference' : get_option('doc'),
- 'GTK4 widgets' : GTK4.found(),
+ 'GTK4 widgets' : GTK4,
'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 get_option('python3')
if not get_option('introspection')
error('Python3 plugin requires GObject Introspection.')
@@ -29,13 +28,10 @@
['python-3.7', '>=3.7'],
['python-3.7m', '>=3.7'],
]
- PYTHON_FOUND = false
PYGOBJECT_WORKS = false
foreach _PYTHON : _PYTHONS
PYTHON3 = dependency(_PYTHON[0], version : _PYTHON[1], required : false)
if PYTHON3.found()
- PYTHON_FOUND = true
-
python3_gi_test = compiler.run(files('gplugin-python3-test-pygobject.c'),
dependencies : [GLIB, PYTHON3, PYGOBJECT],
name : 'Python3 GI')
@@ -49,42 +45,48 @@
endif
endforeach
- if not PYTHON_FOUND
+ if not PYTHON3.found()
error('failed to find a usable python')
endif
if not PYGOBJECT_WORKS
error('found a usable python but pygobject does not work with it')
endif
-
- # Now add our libraries
- gplugin_python3_inc = include_directories('.')
- gplugin_python3 = shared_library('gplugin-python3',
- GPLUGIN_PYTHON3_SOURCES,
- GPLUGIN_PYTHON3_HEADERS,
- name_prefix : '',
- c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Python3"'],
- dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
- install : true,
- 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())
endif # python3
+summary('Python3', PYTHON3, section : 'Loader Support', bool_yn : true)
+
+if not PYTHON3.found()
+ subdir_done()
+endif
+
+# Now add our libraries
+gplugin_python3_inc = include_directories('.')
+gplugin_python3 = shared_library('gplugin-python3',
+ GPLUGIN_PYTHON3_SOURCES,
+ GPLUGIN_PYTHON3_HEADERS,
+ name_prefix : '',
+ c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="GPlugin-Python3"'],
+ dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
+ install : true,
+ 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())
+
subdir('tests')
--- 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('.'),
c_args : [
@@ -21,5 +19,3 @@
# Add the test plugins path to our environment variable
devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
-
-endif # python3
--- 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 @@
-if get_option('rs')
- add_languages('rust')
+if not get_option('rs')
+ subdir_done()
+endif
- subdir('tests')
-endif # rs
+add_languages('rust')
+subdir('tests')
--- 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 @@
-if get_option('rs')
-
e = executable('test-rust-loading', 'test-rust-loading.c',
include_directories : include_directories('.'),
c_args: [
@@ -10,6 +8,3 @@
test('Rust loading', e)
subdir('plugins')
-
-endif # rs
-
--- 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 get_option('vapi')
- if not get_option('introspection')
- error('Vala generation requires GObject Introspection.')
- endif
+if not get_option('vapi')
+ subdir_done()
+endif
- add_languages('vala', native: false)
+if not get_option('introspection')
+ error('Vala generation requires GObject Introspection.')
+endif
- gplugin_vapi = gnome.generate_vapi('gplugin',
- sources : gplugin_gir[0],
- install : true,
- )
+add_languages('vala', native: false)
- if get_option('gtk4').allowed()
- gplugin_gtk4_vapi = gnome.generate_vapi('gplugin-gtk4',
- sources : gplugin_gtk4_gir[0],
- packages : [ 'gtk4' ],
- install : true,
- gir_dirs : meson.current_build_dir() / '..' / 'gplugin',
- )
- endif
+gplugin_vapi = gnome.generate_vapi('gplugin',
+ sources : gplugin_gir[0],
+ install : true,
+)
- subdir('tests')
-endif # vala
+if get_option('gtk4').allowed()
+ gplugin_gtk4_vapi = gnome.generate_vapi('gplugin-gtk4',
+ sources : gplugin_gtk4_gir[0],
+ packages : [ 'gtk4' ],
+ install : true,
+ gir_dirs : meson.current_build_dir() / '..' / 'gplugin',
+ )
+endif
+
+subdir('tests')
--- 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 @@
-if get_option('vapi')
-
e = executable('test-vala-loading', 'test-vala-loading.c',
include_directories : include_directories('.'),
c_args : [
@@ -20,5 +18,3 @@
subdir('genie-plugins')
subdir('plugins')
-
-endif # vapi