talkatu/talkatu

Modernize and simplify Meson files

17 months ago, Elliott Sales de Andrade
ad000db4fe9a
Parents 2cd429762a7d
Children 49b6af8df5de
Modernize and simplify Meson files

Use f-strings and some better loops.

Remove `TALKATU_UNUSED` which duplicated `G_GNUC_UNUSED`, and is also unused.

Also remove checks for old Meson which I thought I looked for before, but didn't find.

Testing Done:
Compiled and ran `ninja test`

Reviewed at https://reviews.imfreedom.org/r/2038/
--- a/meson.build Fri Nov 04 22:28:50 2022 -0500
+++ b/meson.build Sat Nov 05 02:24:35 2022 -0500
@@ -24,7 +24,7 @@
version_conf.set('TALKATU_VERSION', meson.project_version())
LOCALE_DIR = get_option('prefix') / get_option('localedir')
-add_project_arguments('-DLOCALEDIR="@0@"'.format(LOCALE_DIR), language : 'c')
+add_project_arguments(f'-DLOCALEDIR="@LOCALE_DIR@"', language : 'c')
devenv = environment()
@@ -52,8 +52,7 @@
###############################################################################
GETTEXT_PACKAGE = 'talkatu'
-add_project_arguments('-DGETTEXT_PACKAGE="@0@"'.format(GETTEXT_PACKAGE),
- language : 'c')
+add_project_arguments(f'-DGETTEXT_PACKAGE="@GETTEXT_PACKAGE@"', language : 'c')
if get_option('nls')
i18n = import('i18n')
@@ -95,23 +94,10 @@
endif
endif
-# check if we're using gcc
-if compiler.get_id() == 'gcc' or host_machine.system() == 'darwin'
- add_project_arguments(
- '-DTALKATU_UNUSED=__attribute__((unused))',
- '-ggdb',
- language : 'c'
- )
-else
- add_project_arguments(
- '-DTALKATU_UNUSED=',
- language : 'c'
- )
-endif
-
toplevel_inc = include_directories('.')
bpenv = environment()
+doc_targets = []
###############################################################################
# Subdirectories
@@ -125,17 +111,13 @@
# doc alias target
###############################################################################
if get_option('doc')
- doc_targets = [talkatu_doc]
-
alias_target('doc', doc_targets)
endif
###############################################################################
# devenv
###############################################################################
-if meson.version().version_compare('>=0.58.0')
- meson.add_devenv(devenv)
-endif
+meson.add_devenv(devenv)
###############################################################################
# Install stuff
--- a/talkatu/meson.build Fri Nov 04 22:28:50 2022 -0500
+++ b/talkatu/meson.build Sat Nov 05 02:24:35 2022 -0500
@@ -133,22 +133,14 @@
###############################################################################
# talkatu.h
###############################################################################
-TALKATU_H_INCLUDES = ''
+TALKATU_H_INCLUDES = []
-foreach header : TALKATU_HEADERS
- TALKATU_H_INCLUDES = '@0@\n#include <talkatu/@1@>'.format(
- TALKATU_H_INCLUDES,
- header)
-endforeach
-
-foreach header : ['talkatuenums.h', 'talkatuversion.h']
- TALKATU_H_INCLUDES = '@0@\n#include <talkatu/@1@>'.format(
- TALKATU_H_INCLUDES,
- header)
+foreach header : TALKATU_HEADERS + ['talkatuenums.h', 'talkatuversion.h']
+ TALKATU_H_INCLUDES += f'#include <talkatu/@header@>'
endforeach
conf = configuration_data()
-conf.set('TALKATU_H_INCLUDES', TALKATU_H_INCLUDES)
+conf.set('TALKATU_H_INCLUDES', '\n'.join(TALKATU_H_INCLUDES))
talkatu_h = configure_file(
input : 'talkatu.h.in',
output : 'talkatu.h',
@@ -202,7 +194,7 @@
includes : ['GModule-2.0', 'GObject-2.0', 'Gtk-4.0'],
install : true,
namespace : 'Talkatu',
- nsversion : '@0@.0'.format(TALKATU_MAJOR_VERSION),
+ nsversion : f'@TALKATU_MAJOR_VERSION@.0',
symbol_prefix : 'talkatu',
)
TALKATU_GENERATED_TARGETS += talkatu_gir
@@ -220,9 +212,7 @@
dependencies : [GLIB, GOBJECT, GTK4]
)
-if meson.version().version_compare('>=0.54.0')
- meson.override_dependency('talkatu', talkatu_dep)
-endif
+meson.override_dependency('talkatu', talkatu_dep)
###############################################################################
# Install Stuff
--- a/talkatu/reference/meson.build Fri Nov 04 22:28:50 2022 -0500
+++ b/talkatu/reference/meson.build Sat Nov 05 02:24:35 2022 -0500
@@ -1,32 +1,34 @@
+if not get_option('doc')
+ subdir_done()
+endif
+
talkatu_doc_content_files = []
-if get_option('doc')
- talkatu_toml = configure_file(
- input : 'talkatu.toml.in',
- output : 'talkatu.toml',
- configuration : version_conf,
- install : true,
- install_dir : docs_dir / 'talkatu',
- )
+talkatu_toml = configure_file(
+ input : 'talkatu.toml.in',
+ output : 'talkatu.toml',
+ configuration : version_conf,
+ install : true,
+ install_dir : docs_dir / 'talkatu',
+)
- talkatu_doc = custom_target('talkatu-doc',
- input : [ talkatu_toml, talkatu_gir[0] ],
- output : 'talkatu',
- 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 : [ talkatu_doc_content_files ],
- build_by_default : true,
- install : true,
- install_dir : docs_dir,
- )
-endif
-
+talkatu_doc = custom_target('talkatu-doc',
+ input : [ talkatu_toml, talkatu_gir[0] ],
+ output : 'talkatu',
+ 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 : [ talkatu_doc_content_files ],
+ build_by_default : true,
+ install : true,
+ install_dir : docs_dir,
+)
+doc_targets += talkatu_doc
--- a/talkatu/tests/meson.build Fri Nov 04 22:28:50 2022 -0500
+++ b/talkatu/tests/meson.build Sat Nov 05 02:24:35 2022 -0500
@@ -1,6 +1,8 @@
-TEST_WRAPPER = find_program('./test-wrapper.py', required : true)
+if not get_option('tests')
+ subdir_done()
+endif
-if get_option('tests')
+TEST_WRAPPER = find_program('./test-wrapper.py', required : true)
testenv = environment()
testenv.set('XDG_CONFIG_HOME', meson.current_build_dir() / 'config')
@@ -34,5 +36,3 @@
)
test('html-renderer', TEST_WRAPPER, args : e, is_parallel : false,
env : testenv)
-
-endif
--- a/vapi/meson.build Fri Nov 04 22:28:50 2022 -0500
+++ b/vapi/meson.build Sat Nov 05 02:24:35 2022 -0500
@@ -1,14 +1,16 @@
-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
- talkatu_vapi = gnome.generate_vapi('talkatu',
- sources : talkatu_gir[0],
- packages : [ 'gtk4' ],
- install : true,
- gir_dirs : meson.current_build_dir() / '..' / 'talkatu',
- )
-endif # vala
+add_languages('vala', native : false)
+
+talkatu_vapi = gnome.generate_vapi('talkatu',
+ sources : talkatu_gir[0],
+ packages : [ 'gtk4' ],
+ install : true,
+ gir_dirs : meson.current_build_dir() / '..' / 'talkatu',
+)