Skip to content

Commit

Permalink
meson: more fixes and cleanups
Browse files Browse the repository at this point in the history
* bump meson dependency to 0.56 and fix deprecations
* reorder root meson.build
* fix build on clang, passing `-Wno-error=unused-but-set-variable` to
  avoid false positives with cleanup functions
* remove unused project arguments `-DVALENT_COMPILATION` and
  `-DHAVE_CONFIG_H`
* remove application name suffix for devel builds
* fix bogus positional argument on i18n.merge_file()
  see: mesonbuild/meson#9441
* misc style cleanups
  • Loading branch information
andyholmes committed Dec 26, 2021
1 parent 69d2ad1 commit d6c575a
Show file tree
Hide file tree
Showing 30 changed files with 124 additions and 137 deletions.
26 changes: 12 additions & 14 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ subdir('metainfo')
#
desktop_conf = configuration_data()
desktop_conf.set('application_id', application_id)
desktop_file = i18n.merge_file('desktop',
input: configure_file(
input: files('ca.andyholmes.Valent.desktop.in.in'),
output: 'ca.andyholmes.Valent.desktop.in',
configuration: desktop_conf
),
output: '@0@.desktop'.format(application_id),
install: true,
desktop_file = i18n.merge_file(
input: configure_file(
input: files('ca.andyholmes.Valent.desktop.in.in'),
output: 'ca.andyholmes.Valent.desktop.in',
configuration: desktop_conf
),
output: '@0@.desktop'.format(application_id),
install: true,
install_dir: join_paths(datadir, 'applications'),
po_dir: po_dir,
type: 'desktop'
po_dir: po_dir,
type: 'desktop'
)

desktop_utils = find_program('desktop-file-validate', required: false)
Expand All @@ -38,15 +38,13 @@ endif
# Application Icon
#
scalable_icondir = join_paths('icons', 'hicolor', 'scalable', 'apps')
install_data(
join_paths(scalable_icondir, '@0@.svg'.format(application_id)),
install_data(join_paths(scalable_icondir, '@0@.svg'.format(application_id)),
install_dir: join_paths(datadir, scalable_icondir),
rename: '@0@.svg'.format(application_id),
)

symbolic_icondir = join_paths('icons', 'hicolor', 'symbolic', 'apps')
install_data(
join_paths(symbolic_icondir, 'ca.andyholmes.Valent-symbolic.svg'),
install_data(join_paths(symbolic_icondir, 'ca.andyholmes.Valent-symbolic.svg'),
install_dir: join_paths(datadir, symbolic_icondir),
rename: '@0@-symbolic.svg'.format(application_id),
)
Expand Down
18 changes: 9 additions & 9 deletions data/metainfo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
metainfo_conf = configuration_data()
metainfo_conf.set('application_id', application_id)
metainfo_conf.set('gettext_package', meson.project_name())
metainfo_file = i18n.merge_file('metainfo',
input: configure_file(
input: files('ca.andyholmes.Valent.metainfo.xml.in.in'),
output: 'ca.andyholmes.Valent.metainfo.xml.in',
configuration: metainfo_conf,
),
output: '@0@.metainfo.xml'.format(application_id),
install: true,
metainfo_file = i18n.merge_file(
input: configure_file(
input: files('ca.andyholmes.Valent.metainfo.xml.in.in'),
output: 'ca.andyholmes.Valent.metainfo.xml.in',
configuration: metainfo_conf,
),
output: '@0@.metainfo.xml'.format(application_id),
install: true,
install_dir: join_paths(datadir, 'metainfo'),
po_dir: po_dir,
po_dir: po_dir,
)

appstream_util = find_program('appstream-util', required: false)
Expand Down
4 changes: 2 additions & 2 deletions doc/sdk/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2021 Andy Holmes <andrew.g.r.holmes@gmail.com>

libvalent_build = join_paths(meson.build_root(), 'src', 'libvalent')
libvalent_build = join_paths(meson.project_build_root(), 'src', 'libvalent')

# Get gi-docgen
gidocgen_dep = dependency('gi-docgen',
Expand All @@ -25,7 +25,7 @@ valent_toml = configure_file(
# Protocol Docs
protocol_py = find_program('protocol.py')
protocol_doc = custom_target('protocol-doc',
input: join_paths(meson.source_root(), 'doc', 'schemas', 'index.json'),
input: join_paths(meson.project_source_root(), 'doc', 'schemas', 'index.json'),
output: 'protocol.md',
command: [
protocol_py,
Expand Down
131 changes: 61 additions & 70 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
project('valent', 'c',
license: 'GPL-3.0-or-later',
version: '0.1.0',
meson_version: '>= 0.53.0',
meson_version: '>= 0.56.0',
default_options: [
'buildtype=debugoptimized',
'warning_level=2',
Expand Down Expand Up @@ -37,11 +37,9 @@ profile = get_option('profile')
if profile == 'devel'
application_id = 'ca.andyholmes.Valent.Devel'
application_path = '/ca/andyholmes/Valent/Devel'
profile_suffix = ' (Devel)'
else
application_id = 'ca.andyholmes.Valent'
application_path = '/ca/andyholmes/Valent'
profile_suffix = ''
endif


Expand All @@ -67,21 +65,79 @@ pkglibdir = join_paths(libdir, meson.project_name())
pkglibexecdir = join_paths(libexecdir, meson.project_name())
pkgpluginsdir = join_paths(pkglibdir, 'plugins')

po_dir = join_paths(meson.source_root(), 'po')
po_dir = join_paths(meson.current_source_dir(), 'po')


#
# Compiler
#
cc = meson.get_compiler('c')

release_args = []
project_c_args = [
'-Wformat=2',
'-Wincompatible-pointer-types',
'-Wint-conversion',
'-Wint-to-pointer-cast',
'-Wmissing-include-dirs',
'-Woverflow',
'-Wpointer-arith',
'-Wpointer-to-int-cast',
'-Wredundant-decls',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef',

'-Wno-discarded-array-qualifiers',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',

'-Wno-error=cast-function-type',
# TODO: These should be fixed instead of downgraded to warnings
'-Wno-error=shadow',
'-Wno-error=unused-function',
]
project_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
]

# Clang doesn't consider cleanup functions as using a variable
if cc.get_id() == 'clang'
project_c_args += ['-Wno-error=unused-but-set-variable']
endif

if get_option('buildtype') != 'plain'
project_c_args += ['-fstack-protector-strong']
endif

if get_option('debug')
project_c_args += ['-fno-omit-frame-pointer']
endif

if get_option('optimization') in ['2', '3', 's']
project_c_args += ['-DG_DISABLE_CAST_CHECKS']
project_link_args += ['-Wl,-Bsymbolic']

if not get_option('tests')
release_args += ['-DG_DISABLE_ASSERT']
endif
endif

add_project_arguments(cc.get_supported_arguments(project_c_args),
language: 'c',
)

add_project_link_arguments(cc.get_supported_link_arguments(project_link_args),
language: 'c',
)


#
# config.h
#
config_h = configuration_data()
config_h_inc = include_directories('.')

config_h_defines = [
# Desktop
['APPLICATION_ID', application_id],
Expand All @@ -104,7 +160,6 @@ config_h_defines = [
['PACKAGE_PLUGINSDIR', pkgpluginsdir],

['PROFILE_NAME', profile],
['PROFILE_SUFFIX', profile_suffix],

# i18n
['GETTEXT_PACKAGE', meson.project_name()],
Expand All @@ -127,17 +182,11 @@ foreach function : config_h_functions
endif
endforeach


configure_file(
output: 'config.h',
configuration: config_h,
)

add_project_arguments([
'-DHAVE_CONFIG_H',
'-DVALENT_COMPILATION',
], language: 'c')


#
# Dependencies
Expand Down Expand Up @@ -178,64 +227,6 @@ if get_option('profiling')
endif


#
# Build Type
#
release_args = []
project_c_args = [
'-Wformat=2',
'-Wincompatible-pointer-types',
'-Wint-conversion',
'-Wint-to-pointer-cast',
'-Wmissing-include-dirs',
'-Woverflow',
'-Wpointer-arith',
'-Wpointer-to-int-cast',
'-Wredundant-decls',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef',

'-Wno-discarded-array-qualifiers',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',

'-Wno-error=cast-function-type',
# TODO: These should be fixed instead of downgraded to warnings
'-Wno-error=shadow',
'-Wno-error=unused-function',
]
project_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
]

if get_option('buildtype') != 'plain'
project_c_args += ['-fstack-protector-strong']
endif

if get_option('debug')
project_c_args += ['-fno-omit-frame-pointer']
endif

if get_option('optimization') in ['2', '3', 's']
project_c_args += ['-DG_DISABLE_CAST_CHECKS']
project_link_args += ['-Wl,-Bsymbolic']

if not get_option('tests')
release_args += ['-DG_DISABLE_ASSERT']
endif
endif

add_project_arguments(cc.get_supported_arguments(project_c_args),
language: 'c',
)

add_project_link_arguments(cc.get_supported_link_arguments(project_link_args),
language: 'c',
)


#
# Build
#
Expand Down
18 changes: 9 additions & 9 deletions src/libvalent/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ if get_option('introspection')
]

libvalent_gir = gnome.generate_gir(libvalent,
sources: libvalent_gir_sources,
namespace: 'Valent',
nsversion: valent_api_version,
symbol_prefix: meson.project_name(),
identifier_prefix: 'Valent',
includes: libvalent_gir_includes,
install: true,
install_dir_gir: girdir,
sources: libvalent_gir_sources,
namespace: 'Valent',
nsversion: valent_api_version,
symbol_prefix: meson.project_name(),
identifier_prefix: 'Valent',
includes: libvalent_gir_includes,
install: true,
install_dir_gir: girdir,
install_dir_typelib: typelibdir,
extra_args: libvalent_gir_extra_args,
extra_args: libvalent_gir_extra_args,
)
endif

5 changes: 1 addition & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ main (int argc,
{
int ret;
g_autoptr (ValentApplication) service = NULL;
g_autofree char *application_name = NULL;

/* Set up gettext translations */
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);

application_name = g_strconcat ("Valent", PROFILE_SUFFIX, NULL);
g_set_application_name (application_name);

/* Start the service */
valent_debug_init ();

g_set_application_name ("Valent");
service = _valent_application_new ();
ret = g_application_run (G_APPLICATION (service), argc, argv);

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/battery/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugin_battery_sources = files([
plugin_battery_include_directories = [include_directories('.')]

# Resources
plugin_battery_info = i18n.merge_file('battery.plugin',
plugin_battery_info = i18n.merge_file(
input: 'battery.plugin.desktop.in',
output: 'battery.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bluez/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugin_bluez_sources = files([
plugin_bluez_include_directories = [include_directories('.')]

# Resources
plugin_bluez_info = i18n.merge_file('bluez.plugin',
plugin_bluez_info = i18n.merge_file(
input: 'bluez.plugin.desktop.in',
output: 'bluez.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/clipboard/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugin_clipboard_sources = files([
plugin_clipboard_include_directories = [include_directories('.')]

# Resources
plugin_clipboard_info = i18n.merge_file('clipboard.plugin',
plugin_clipboard_info = i18n.merge_file(
input: 'clipboard.plugin.desktop.in',
output: 'clipboard.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/contacts/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugin_contacts_sources = files([
plugin_contacts_include_directories = [include_directories('.')]

# Resources
plugin_contacts_info = i18n.merge_file('contacts.plugin',
plugin_contacts_info = i18n.merge_file(
input: 'contacts.plugin.desktop.in',
output: 'contacts.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/eds/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugin_eds_sources = files([
plugin_eds_include_directories = include_directories('.')

# Resources
plugin_eds_info = i18n.merge_file('eds.plugin',
plugin_eds_info = i18n.merge_file(
input: 'eds.plugin.desktop.in',
output: 'eds.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/fdo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plugin_fdo_sources = files([
plugin_fdo_include_directories = [include_directories('.')]

# Resources
plugin_fdo_info = i18n.merge_file('fdo.plugin',
plugin_fdo_info = i18n.merge_file(
input: 'fdo.plugin.desktop.in',
output: 'fdo.plugin',
po_dir: po_dir,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/findmyphone/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugin_findmyphone_sources = files([
plugin_findmyphone_include_directories = [include_directories('.')]

# Resources
plugin_findmyphone_info = i18n.merge_file('findmyphone.plugin',
plugin_findmyphone_info = i18n.merge_file(
input: 'findmyphone.plugin.desktop.in',
output: 'findmyphone.plugin',
po_dir: po_dir,
Expand Down
Loading

0 comments on commit d6c575a

Please sign in to comment.