From e4cdb9e1a846390bafef8e36085242f793464edd Mon Sep 17 00:00:00 2001 From: zhuyaliang <15132211195@163.com> Date: Fri, 19 May 2023 17:05:11 +0800 Subject: Add meson compilation support --- caja/meson.build | 37 ++++++++++ data/icons/meson.build | 35 +++++++++ data/meson.build | 74 +++++++++++++++++++ help/LINGUAS | 95 ++++++++++++++++++++++++ help/meson.build | 13 ++++ meson.build | 154 +++++++++++++++++++++++++++++++++++++++ meson_options.txt | 29 ++++++++ po/meson.build | 1 + postinstall.py | 27 +++++++ src/meson.build | 111 ++++++++++++++++++++++++++++ src/sh/meson.build | 1 + subprojects/mate-submodules.wrap | 6 ++ 12 files changed, 583 insertions(+) create mode 100644 caja/meson.build create mode 100644 data/icons/meson.build create mode 100644 data/meson.build create mode 100644 help/LINGUAS create mode 100644 help/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 po/meson.build create mode 100755 postinstall.py create mode 100644 src/meson.build create mode 100644 src/sh/meson.build create mode 100644 subprojects/mate-submodules.wrap diff --git a/caja/meson.build b/caja/meson.build new file mode 100644 index 0000000..2324719 --- /dev/null +++ b/caja/meson.build @@ -0,0 +1,37 @@ +shared_module('caja-engrampa', + sources : [ + 'caja-engrampa.c', + 'engrampa-module.c' + ], + dependencies : [ + libm_dep, + thread_dep, + glib_dep, + gthread_dep, + gtk_dep, + libcaja_extension_dep, + use_json_glib ? libjson_glib_dep : [], + ], + include_directories : config_inc, + c_args : c_args, + install : true, + install_dir : libcaja_extension_dep.get_pkgconfig_variable('extensiondir') +) + +desktop_data = configuration_data() +desktop_data.set('VERSION', meson.project_version()) +desktop_data.set('PACKAGE_URL', 'https://mate-desktop.org') +desktop_in_file = configure_file( + input : 'libcaja-engrampa.caja-extension.desktop.in.in', + output : 'libcaja-engrampa.caja-extension.desktop.in', + configuration : desktop_data +) + +i18n.merge_file( + input : desktop_in_file, + output : 'libcaja-engrampa.caja-extension', + type : 'desktop', + po_dir : po_dir, + install : true, + install_dir : join_paths(datadir, 'caja', 'extensions') +) diff --git a/data/icons/meson.build b/data/icons/meson.build new file mode 100644 index 0000000..93c4a29 --- /dev/null +++ b/data/icons/meson.build @@ -0,0 +1,35 @@ +apps_icons = [ + ['16x16', 'engrampa.png'], + ['22x22', 'engrampa.png'], + ['24x24', 'engrampa.png'], + ['32x32', 'engrampa.png'], +] + +actions_icons = [ + ['16x16', 'add-folder-to-archive.png', 'extract-archive.png', 'add-files-to-archive.png'], + ['24x24', 'add-folder-to-archive.png', 'extract-archive.png', 'add-files-to-archive.png'], +] + +foreach icon: actions_icons + install_data( + join_paths(icon[0], 'actions', icon[1]), + install_dir: join_paths(get_option('prefix'), 'share/icons', 'hicolor', icon[0], 'actions') + ) + install_data( + join_paths(icon[0], 'actions', icon[2]), + install_dir: join_paths(get_option('prefix'), 'share/icons', 'hicolor', icon[0], 'actions') + ) + install_data( + join_paths(icon[0], 'actions', icon[3]), + install_dir: join_paths(get_option('prefix'), 'share/icons', 'hicolor', icon[0], 'actions') + ) +endforeach + +foreach icon: apps_icons + install_data( + join_paths(icon[0], 'apps', icon[1]), + install_dir: join_paths(get_option('prefix'), 'share/icons', 'hicolor', icon[0], 'apps') + ) +endforeach + +install_subdir('scalable', install_dir : join_paths(datadir, 'icons', 'hicolor')) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..bde2aed --- /dev/null +++ b/data/meson.build @@ -0,0 +1,74 @@ +po_dir = join_paths(meson.source_root(), 'po') +man1_dir = join_paths(engrampa_mandir, 'man1') + +schema_data = configuration_data() +schema_data.set('GETTEXT_PACKAGE', meson.project_name()) +configure_file( + input : 'org.mate.engrampa.gschema.xml.in', + output : 'org.mate.engrampa.gschema.xml', + configuration : schema_data, + install : true, + install_dir : join_paths(datadir, 'glib-2.0', 'schemas') +) + +install_data('packages.match', + install_dir : join_paths(datadir, meson.project_name()) +) + +install_data('engrampa.1', + install_dir : man1_dir +) + +# .desktop file + +desktop_data = configuration_data() +desktop_data.set('VERSION', meson.project_version()) +desktop_in_file = configure_file( + input : 'engrampa.desktop.in.in', + output : 'engrampa.desktop.in', + configuration : desktop_data +) + +i18n.merge_file( + input : desktop_in_file, + output : 'engrampa.desktop', + type : 'desktop', + po_dir : po_dir, + install : true, + install_dir : join_paths(datadir, 'applications') +) + +# .service files + +service_data = configuration_data() +service_data.set('libexecdir', join_paths(prefix, get_option('libexecdir'))) + +configure_file( + input : 'org.mate.Engrampa.service.in', + output : 'org.mate.Engrampa.service', + configuration : service_data, + install : true, + install_dir : join_paths(datadir, 'dbus-1/services') +) + +# .appdata file + +appdata_data = configuration_data() +appdata_data.set('PACKAGE_URL', 'https://mate-desktop.org') +appdata_in_file = configure_file( + input : 'engrampa.appdata.xml.in.in', + output : 'engrampa.appdata.xml.in', + configuration : appdata_data +) +i18n.merge_file( + input : appdata_in_file, + output : 'engrampa.appdata.xml', + type : 'xml', + po_dir : po_dir, + install : true, + install_dir : join_paths(datadir, 'metainfo') +) + +# Subdirectories + +subdir('icons') diff --git a/help/LINGUAS b/help/LINGUAS new file mode 100644 index 0000000..5b5a012 --- /dev/null +++ b/help/LINGUAS @@ -0,0 +1,95 @@ +af +am +ar +as +ast +az +be +bg +bn +bn_IN +br +bs +ca +ca@valencia +cmn +crh +cs +cy +da +de +dz +el +en_AU +en_CA +en_GB +eo +es +et +eu +fa +fi +fr +ga +gl +gu +he +hi +hr +hu +hy +id +is +it +ja +ka +kk +kn +ko +ku +ky +li +lt +lv +mai +mg +mk +ml +mn +mr +ms +nb +ne +nl +nn +nso +oc +or +pa +pl +pt +pt_BR +ro +ru +si +sk +sl +sq +sr +sr@latin +sv +ta +te +th +tk +tr +ug +uk +ur +vi +wa +xh +zh_CN +zh_HK +zh_TW +zu diff --git a/help/meson.build b/help/meson.build new file mode 100644 index 0000000..0cb598d --- /dev/null +++ b/help/meson.build @@ -0,0 +1,13 @@ +gnome.yelp('engrampa', + sources : [ + 'index.docbook', + 'legal.xml', + ], + media : [ + 'figures/engrampa_home.png', + 'figures/engrampa_main_window.png', + 'figures/engrampa_rightarrow.png', + 'figures/engrampa_leftarrow.png', + 'figures/engrampa_uparrow.png' + ] +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..045a041 --- /dev/null +++ b/meson.build @@ -0,0 +1,154 @@ +project('engrampa', 'c', + license : 'GPL2+', + version : '1.27.0', + meson_version : '>=0.43' +) + +glib_version = '>=2.50' +gtk_version = '>=3.22' +caja_version = '>=1.17.1' +json_glib_version = '>=0.14.0' +sm_version = '>=1.0.0' +ice_version = '>=1.0.0' + +gnome = import('gnome') +i18n = import('i18n') +gettext_package = meson.project_name() +prefix = get_option('prefix') +engrampa_mandir = join_paths(prefix, get_option('mandir')) +datadir = join_paths(prefix, get_option('datadir')) +privexecdir = join_paths(prefix, get_option('libexecdir'), meson.project_name()) +c_comp = meson.get_compiler('c') + +meson.add_install_script('postinstall.py') + +mate_submodules_dep = dependency('mate-submodules', version: '1.24.0', + fallback: ['mate-submodules', 'mate_submodules_dep']) + +# Dependencies + +libm_dep = c_comp.find_library('m') +thread_dep = dependency('threads') +glib_dep = dependency('glib-2.0', version : glib_version) +gthread_dep = dependency('gthread-2.0') +gtk_dep = dependency('gtk+-3.0', version : gtk_version) + +# Optional dependencies + +if get_option('caja-actions') + libcaja_extension_dep = dependency('libcaja-extension', version : caja_version, required : false) + build_caja_actions = libcaja_extension_dep.found() +else + build_caja_actions = false +endif + +libjson_glib_dep = dependency('json-glib-1.0', version : json_glib_version, required : false) +use_json_glib = libjson_glib_dep.found() +sm_dep = dependency('sm', version : sm_version) +ice_dep = dependency('ice', version : ice_version) + +use_magic = false +if get_option('magic') + libmagic_dep = c_comp.find_library('magic') + if c_comp.compiles('''#include + int main () { magic_t m = magic_open(MAGIC_NONE); }''', + dependencies : libmagic_dep) + use_magic = true + endif +endif + +cpio_path = 'cpio' +if get_option('cpio') == 'auto' + cpio = find_program('gcpio', 'cpio', required : false) + if cpio.found() + cpio_path = cpio.path() + endif +endif + +# config.h + +config_data = configuration_data() +config_data.set_quoted('GETTEXT_PACKAGE', gettext_package) +config_data.set_quoted('MATELOCALEDIR', join_paths(prefix, get_option('localedir'))) +config_data.set_quoted('PACKAGE_NAME', meson.project_name()) +config_data.set_quoted('PACKAGE_VERSION', meson.project_version()) +config_data.set_quoted('VERSION', meson.project_version()) +config_data.set_quoted('PKG_DATA_DIR', join_paths(prefix, get_option('datadir'), meson.project_name())) +config_data.set_quoted('ENGRAMPA_RESOURCE_UI_PATH', '/org/mate/Engrampa/ui') +config_data.set_quoted('PACKAGE_URL', 'https://mate-desktop.org') +if get_option('run-in-place') + config_data.set_quoted('PRIVDATADIR', join_paths(meson.source_root(), 'data')) + config_data.set_quoted('PRIVEXECDIR', join_paths(meson.source_root(), 'src', 'commands')) + config_data.set_quoted('UIDIR', join_paths(meson.source_root(), 'data', 'ui')) + config_data.set_quoted('SHDIR', join_paths(meson.source_root(), 'src', 'sh')) +else + config_data.set_quoted('PRIVDATADIR', join_paths(datadir, meson.project_name())) + config_data.set_quoted('PRIVEXECDIR', privexecdir) + config_data.set_quoted('UIDIR', join_paths(datadir, meson.project_name(), 'ui')) + config_data.set_quoted('SHDIR', join_paths(prefix, get_option('libexecdir'), meson.project_name())) +endif +if use_json_glib + config_data.set('HAVE_JSON_GLIB', 1) +endif +if get_option('packagekit') + config_data.set('ENABLE_PACKAGEKIT', 1) +endif +if get_option('buildtype').contains('debug') + config_data.set('MATE_ENABLE_DEBUG', 1) +endif +if use_magic + config_data.set('ENABLE_MAGIC', 1) +endif +config_data.set_quoted('CPIO_PATH', cpio_path) +config_file = configure_file(output : 'config.h', configuration : config_data) +config_inc = include_directories('.') + +# C args + +c_args = [] +if get_option('buildtype').contains('debug') + test_args = [ + '-Wall', + '-Wcast-align', + '-Wtype-limits', + '-Wclobbered', + '-Wempty-body', + '-Wignored-qualifiers', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wpointer-arith', + '-Wno-sign-compare', + '-Wformat-security' + ] +else + c_args += [ '-Wno-deprecated-declarations' ] + test_args = [ '-Wall' ] +endif +c_args += c_comp.get_supported_arguments(test_args) + +# Subdirectories + +subdir('data') +subdir('help') +if build_caja_actions + subdir('caja') +endif +subdir('po') +subdir('src') + +# Summary + +summary = [ + 'configuration summary:', + '', + ' project: @0@ @1@'.format(meson.project_name(), meson.project_version()), + ' prefix: @0@'.format(prefix), + ' Caja supports: @0@'.format(build_caja_actions), + 'PackageKit support: @0@'.format(get_option('packagekit')), + ' Run in place: @0@'.format(get_option('run-in-place')), + ' JSON support: @0@'.format(use_json_glib), + ' Use libmagic: @0@'.format(use_magic), + ' cpio: @0@'.format(cpio_path), + '' +] +message('\n'.join(summary)) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8cfe90c --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,29 @@ +option('run-in-place', + type : 'boolean', + value : false, + description : 'Load ui data from the source tree' +) + +option('caja-actions', + type : 'boolean', + value : true, + description : 'Build the nautilus context menu actions' +) + +option('packagekit', + type : 'boolean', + value : true, + description : 'Build PackageKit installer for missing utilities' +) + +option('magic', + type : 'boolean', + value : true, + description : 'Use libmagic to detect file type' +) + +option('cpio', + type : 'string', + value : 'auto', + description : 'Path to the cpio program' +) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..5159141 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(gettext_package, preset : 'glib') diff --git a/postinstall.py b/postinstall.py new file mode 100755 index 0000000..3a245cd --- /dev/null +++ b/postinstall.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import os +import subprocess + +prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local') +datadir = os.path.join(prefix, 'share') + +# Packaging tools define DESTDIR and this isn't needed for them +if 'DESTDIR' not in os.environ: + print('Updating icon cache…') + icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor') + if not os.path.exists(icon_cache_dir): + os.makedirs(icon_cache_dir) + subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir]) + + print('Updating desktop database…') + desktop_database_dir = os.path.join(datadir, 'applications') + if not os.path.exists(desktop_database_dir): + os.makedirs(desktop_database_dir) + subprocess.call(['update-desktop-database', '-q', desktop_database_dir]) + + print('Compiling GSettings schemas…') + schemas_dir = os.path.join(datadir, 'glib-2.0', 'schemas') + if not os.path.exists(schemas_dir): + os.makedirs(schemas_dir) + subprocess.call(['glib-compile-schemas', schemas_dir]) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..8b0ef91 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,111 @@ +# Sources + +source_files = files( + 'actions.c', + 'dlg-add-files.c', + 'dlg-add-folder.c', + 'dlg-ask-password.c', + 'dlg-batch-add.c', + 'dlg-delete.c', + 'dlg-extract.c', + 'dlg-new.c', + 'dlg-open-with.c', + 'dlg-package-installer.c', + 'dlg-password.c', + 'dlg-prop.c', + 'dlg-update.c', + 'eggfileformatchooser.c', + 'eggtreemultidnd.c', + 'file-data.c', + 'file-utils.c', + 'fr-archive.c', + 'fr-command-7z.c', + 'fr-command-ace.c', + 'fr-command-alz.c', + 'fr-command-ar.c', + 'fr-command-arj.c', + 'fr-command.c', + 'fr-command-cfile.c', + 'fr-command-cpio.c', + 'fr-command-dpkg.c', + 'fr-command-iso.c', + 'fr-command-jar.c', + 'fr-command-lha.c', + 'fr-command-lrzip.c', + 'fr-command-nomarch.c', + 'fr-command-rar.c', + 'fr-command-rpm.c', + 'fr-command-tar.c', + 'fr-command-unstuff.c', + 'fr-command-zip.c', + 'fr-command-zoo.c', + 'fr-error.c', + 'fr-init.c', + 'fr-list-model.c', + 'fr-proc-error.c', + 'fr-process.c', + 'fr-window.c', + 'gio-utils.c', + 'glib-utils.c', + 'gtk-utils.c', + 'java-utils.c', + 'main.c', + 'open-file.c', + 'preferences.c', + 'rar-utils.c' +) +if libjson_glib_dep.found() + source_files += [ 'fr-command-unarchiver.c' ] +endif + +gresource_files = gnome.compile_resources('fr-resources', 'engrampa.gresource.xml', c_name : 'fr') + +marshal_files = gnome.genmarshal('fr-marshal', prefix : 'fr_marshal', sources : 'fr-marshal.list' ) + +enum_files = gnome.mkenums_simple('fr-enum-types', + sources: [ 'typedefs.h' ] +) + +# Build targets + +executable('engrampa', + sources : [ + config_file, + source_files, + gresource_files, + marshal_files, + enum_files + ], + dependencies : [ + libm_dep, + thread_dep, + glib_dep, + gthread_dep, + gtk_dep, + mate_submodules_dep, + use_json_glib ? libjson_glib_dep : [], + use_magic ? libmagic_dep : [] + ], + include_directories : config_inc, + c_args : c_args, + install : true +) + +executable('test-server', 'test-server.c', + dependencies : [ + libm_dep, + thread_dep, + glib_dep, + gthread_dep, + gtk_dep, + use_json_glib ? libjson_glib_dep : [] + ], + include_directories : config_inc, + c_args : c_args, + install : true, + install_dir: privexecdir, +) + +# Subdirectories + +subdir('sh') diff --git a/src/sh/meson.build b/src/sh/meson.build new file mode 100644 index 0000000..5c7c45d --- /dev/null +++ b/src/sh/meson.build @@ -0,0 +1 @@ +install_data('isoinfo.sh', install_dir : privexecdir) diff --git a/subprojects/mate-submodules.wrap b/subprojects/mate-submodules.wrap new file mode 100644 index 0000000..7846605 --- /dev/null +++ b/subprojects/mate-submodules.wrap @@ -0,0 +1,6 @@ +[wrap-git] +directory =mate-submodules +url=https://github.com/mate-desktop/mate-submodules.git +push-url=ssh://git@github.com:mate-desktop/mate-submodules.git +revision=master +depth=1 -- cgit v1.2.1