From 6c7626d55e3f62a339b2b51ca440019022f3c76c Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 30 Jul 2023 02:05:49 +0900 Subject: [PATCH] Meson: modernize (#1360) --- data/meson.build | 16 ++++++++-------- meson.build | 11 ++++++----- meson/post_install.py | 10 ---------- plugins/brackets-completion/meson.build | 6 +++--- plugins/detect-indent/meson.build | 6 +++--- plugins/editorconfig/meson.build | 6 +++--- plugins/highlight-word-selection/meson.build | 6 +++--- plugins/markdown-actions/meson.build | 6 +++--- plugins/pastebin/meson.build | 6 +++--- plugins/preserve-indent/meson.build | 6 +++--- plugins/spell/meson.build | 6 +++--- plugins/vim-emulation/meson.build | 6 +++--- plugins/word-completion/meson.build | 6 +++--- po/extra/meson.build | 2 +- po/meson.build | 2 +- po/plugins/meson.build | 2 +- src/meson.build | 6 +++--- 17 files changed, 50 insertions(+), 59 deletions(-) delete mode 100755 meson/post_install.py diff --git a/data/meson.build b/data/meson.build index 01a0437d81..b28891a23d 100644 --- a/data/meson.build +++ b/data/meson.build @@ -16,16 +16,16 @@ endforeach install_data([ 'styles/elementary-dark.xml', 'styles/elementary-light.xml', -], install_dir: join_paths(get_option('datadir'), 'gtksourceview-4', 'styles')) +], install_dir: get_option('datadir') / 'gtksourceview-4' / 'styles') install_data([ 'fonts/BuilderBlocks.ttf', -], install_dir: join_paths(get_option('datadir'), meson.project_name(), 'fonts')) +], install_dir: get_option('datadir') / meson.project_name() / 'fonts') install_data( 'io.elementary.code.gschema.xml', 'io.elementary.code.plugins.spell.gschema.xml', - install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas') + install_dir: get_option('prefix') / get_option('datadir') / 'glib-2.0' / 'schemas' ) config_data = configuration_data() @@ -47,16 +47,16 @@ desktop_in_file = configure_file( desktop_file = i18n.merge_file( input: desktop_in_file, output: 'io.elementary.code.desktop', - po_dir: join_paths(meson.source_root (), 'po', 'extra'), + po_dir: meson.project_source_root () / 'po' / 'extra', type: 'desktop', - install_dir: join_paths(get_option('datadir'), 'applications'), + install_dir: get_option('datadir') / 'applications', install: true ) i18n.merge_file( input: 'code.metainfo.xml.in', output: meson.project_name() + '.metainfo.xml', - po_dir: meson.source_root() / 'po' / 'extra', + po_dir: meson.project_source_root() / 'po' / 'extra', type: 'xml', install: true, install_dir: get_option('datadir') / 'metainfo', @@ -78,9 +78,9 @@ if get_option ('have_pkexec') i18n.merge_file( input: policy_in, output: meson.project_name() + '.policy', - po_dir: join_paths(meson.source_root (), 'po', 'extra'), + po_dir: meson.project_source_root () / 'po' / 'extra', install: true, - install_dir: join_paths(get_option('datadir'), 'polkit-1', 'actions'), + install_dir: get_option('datadir') / 'polkit-1' / 'actions', ) endif diff --git a/meson.build b/meson.build index 1d72ef89f1..c8bce58a37 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,7 @@ project( 'io.elementary.code', 'vala', 'c', + meson_version: '>= 0.58.0', version: '7.0.0' ) @@ -11,7 +12,7 @@ add_project_arguments([ ) add_project_arguments( - ['--vapidir', join_paths(meson.current_source_dir(), 'vapi')], + ['--vapidir', meson.project_source_root() / 'vapi'], language: 'vala' ) @@ -19,8 +20,8 @@ if get_option('have_pkexec') add_project_arguments('--define=HAVE_PKEXEC', language: 'vala') endif -libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'), meson.project_name()) -pluginsdir = join_paths(get_option('prefix'), get_option('libdir'), meson.project_name(), 'plugins') +libexecdir = get_option('prefix') / get_option('libexecdir') / meson.project_name() +pluginsdir = get_option('prefix') / get_option('libdir') / meson.project_name() / 'plugins' gnome = import('gnome') i18n = import('i18n') @@ -46,7 +47,7 @@ code_resources = gnome.compile_resources( ) # We need libvala-X.XX library, but it changes depending on the version that is installed -vala_version = run_command (meson.get_compiler('vala'), '--api-version').stdout().strip() +vala_version = run_command (meson.get_compiler('vala'), '--api-version', check: true).stdout().strip() vala_dep = dependency('libvala-@0@'.format(vala_version)) dependencies = [ @@ -81,4 +82,4 @@ if get_option('plugins') endif subdir('po') -meson.add_install_script('meson/post_install.py') +gnome.post_install(glib_compile_schemas: true) diff --git a/meson/post_install.py b/meson/post_install.py deleted file mode 100755 index d50b982d5d..0000000000 --- a/meson/post_install.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 - -import os -import subprocess - -schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas') - -if not os.environ.get('DESTDIR'): - print('Compiling gsettings schemas…') - subprocess.call(['glib-compile-schemas', schemadir]) diff --git a/plugins/brackets-completion/meson.build b/plugins/brackets-completion/meson.build index e46ea62ecb..880e976202 100644 --- a/plugins/brackets-completion/meson.build +++ b/plugins/brackets-completion/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/detect-indent/meson.build b/plugins/detect-indent/meson.build index 1d345960bb..d70c52eaa3 100644 --- a/plugins/detect-indent/meson.build +++ b/plugins/detect-indent/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/editorconfig/meson.build b/plugins/editorconfig/meson.build index a4a8b9eb40..eabe838183 100644 --- a/plugins/editorconfig/meson.build +++ b/plugins/editorconfig/meson.build @@ -15,7 +15,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -25,10 +25,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/highlight-word-selection/meson.build b/plugins/highlight-word-selection/meson.build index aaa960adaa..393f197b2f 100644 --- a/plugins/highlight-word-selection/meson.build +++ b/plugins/highlight-word-selection/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/markdown-actions/meson.build b/plugins/markdown-actions/meson.build index d8d15aad3d..529dd12128 100644 --- a/plugins/markdown-actions/meson.build +++ b/plugins/markdown-actions/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/pastebin/meson.build b/plugins/pastebin/meson.build index faacc10b60..f18e644d41 100644 --- a/plugins/pastebin/meson.build +++ b/plugins/pastebin/meson.build @@ -17,7 +17,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -27,10 +27,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/preserve-indent/meson.build b/plugins/preserve-indent/meson.build index db9b35eb85..bd9c5596bd 100644 --- a/plugins/preserve-indent/meson.build +++ b/plugins/preserve-indent/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/spell/meson.build b/plugins/spell/meson.build index 15bd141f10..6d64af66be 100644 --- a/plugins/spell/meson.build +++ b/plugins/spell/meson.build @@ -16,7 +16,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -26,10 +26,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/vim-emulation/meson.build b/plugins/vim-emulation/meson.build index c32e5a8d1c..6017f329d5 100644 --- a/plugins/vim-emulation/meson.build +++ b/plugins/vim-emulation/meson.build @@ -13,7 +13,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -23,10 +23,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/plugins/word-completion/meson.build b/plugins/word-completion/meson.build index 2887aef312..247b0e60ad 100644 --- a/plugins/word-completion/meson.build +++ b/plugins/word-completion/meson.build @@ -16,7 +16,7 @@ shared_module( module_files, dependencies: module_deps, install: true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) custom_target(module_name + '.plugin_merge', @@ -26,10 +26,10 @@ custom_target(module_name + '.plugin_merge', '--desktop', '--keyword=Description', '--keyword=Name', - '-d' + join_paths(meson.source_root (), 'po', 'plugins'), + '-d' + meson.project_source_root () / 'po' / 'plugins', '--template=@INPUT@', '-o@OUTPUT@', ], install : true, - install_dir: join_paths(pluginsdir, module_name), + install_dir: pluginsdir / module_name, ) diff --git a/po/extra/meson.build b/po/extra/meson.build index adf2c250de..5066b627e3 100644 --- a/po/extra/meson.build +++ b/po/extra/meson.build @@ -1,5 +1,5 @@ i18n.gettext('extra', - args: ['--directory='+meson.source_root()], + args: ['--directory='+meson.project_source_root()], install: false, preset: 'glib' ) diff --git a/po/meson.build b/po/meson.build index a6fbf736b5..d11641c016 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1,5 +1,5 @@ i18n.gettext(meson.project_name(), - args: ['--directory='+meson.source_root()], + args: ['--directory='+meson.project_source_root()], preset: 'glib' ) subdir('extra') diff --git a/po/plugins/meson.build b/po/plugins/meson.build index 8a0c5e4630..fa01a5821f 100644 --- a/po/plugins/meson.build +++ b/po/plugins/meson.build @@ -1,5 +1,5 @@ i18n.gettext('plugins', - args: ['--directory='+meson.source_root(), + args: ['--directory='+meson.project_source_root(), '--from-code=UTF-8', '--language=Desktop', '--keyword=', diff --git a/src/meson.build b/src/meson.build index 55f6b3510a..ff454644d7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,8 +4,8 @@ conf_data.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf_data.set_quoted('VERSION', meson.project_version()) conf_data.set_quoted('PREFIX', get_option('prefix')) conf_data.set_quoted('PLUGINDIR', pluginsdir) -conf_data.set_quoted('DATADIR', join_paths (get_option('prefix'), get_option('datadir'))) -conf_data.set_quoted('LOCALEDIR', join_paths (get_option('prefix'), get_option('localedir'))) +conf_data.set_quoted('DATADIR', get_option('prefix') / get_option('datadir')) +conf_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) conf_data.set_quoted('BRANCH', branch) config_header = configure_file( @@ -89,7 +89,7 @@ pkg.generate( filebase: 'codecore' ) -install_data ('codecore.deps', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'vala', 'vapi')) +install_data ('codecore.deps', install_dir: get_option('prefix') / get_option('datadir') / 'vala' / 'vapi') codecore_dep = declare_dependency( link_with: codecore,