[ghex] Migrate build system to meson
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] Migrate build system to meson
- Date: Wed, 7 Mar 2018 11:12:43 +0000 (UTC)
commit 949d08b25dc49e93fc80a990e426d72076c1b881
Author: Martin Blanchard <tchaik gmx com>
Date: Tue Oct 17 23:10:54 2017 +0200
Migrate build system to meson
Port the entire build system from autotools to Meson. Should be
complete. Autotools files are not removed.
https://bugzilla.gnome.org/show_bug.cgi?id=789118
data/{ghex.appdata.xml => ghex.appdata.xml.in} | 0
data/ghex.desktop.in | 8 +-
data/meson.build | 63 ++++++++++++
help/meson.build | 37 +++++++
.../16x16/apps/ghex.png} | Bin 857 -> 857 bytes
.../22x22/apps/ghex.png} | Bin 1314 -> 1314 bytes
.../24x24/apps/ghex.png} | Bin 1323 -> 1323 bytes
.../256x256/apps/ghex.png} | Bin 34121 -> 34121 bytes
.../32x32/apps/ghex.png} | Bin 1850 -> 1850 bytes
.../48x48/apps/ghex.png} | Bin 3439 -> 3439 bytes
.../512x512/apps/ghex.png} | Bin 87715 -> 87715 bytes
.../scalable/apps/ghex-symbolic.svg} | 0
icons/meson.build | 17 ++++
meson.build | 100 +++++++++++++++++++
meson_post_install.py | 27 +++++
po/POTFILES.in | 1 +
po/meson.build | 4 +
src/ghex-window.c | 4 +-
src/gtkhex.c | 4 +-
src/meson.build | 101 ++++++++++++++++++++
src/ui.c | 2 +-
21 files changed, 357 insertions(+), 11 deletions(-)
---
diff --git a/data/ghex.appdata.xml b/data/ghex.appdata.xml.in
similarity index 100%
rename from data/ghex.appdata.xml
rename to data/ghex.appdata.xml.in
diff --git a/data/ghex.desktop.in b/data/ghex.desktop.in
index e44ce17..190b5c1 100644
--- a/data/ghex.desktop.in
+++ b/data/ghex.desktop.in
@@ -1,9 +1,9 @@
[Desktop Entry]
-_Name=GHex
-_GenericName=Hex Editor
-_Comment=Inspect and edit binary files
+Name=GHex
+GenericName=Hex Editor
+Comment=Inspect and edit binary files
#TRANSLATORS: here, 'binary' means a binary file (not the base-2 numeric system)
-_Keywords=binary;debug;
+Keywords=binary;debug;
Exec=ghex %F
Terminal=false
Type=Application
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..796d78c
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,63 @@
+install_data(
+ 'org.gnome.GHex.gschema.xml',
+ install_dir: ghex_schemasdir
+)
+
+ghex_desktop = i18n.merge_file(
+ input: 'ghex.desktop.in',
+ output: 'ghex.desktop',
+ po_dir: ghex_po_dir,
+ type: 'desktop',
+ install_dir: ghex_applicationsdir,
+ install: true
+)
+
+desktop_file_validate_prg = find_program(
+ 'desktop-file-validate',
+ required: false
+)
+
+if desktop_file_validate_prg.found()
+ test(
+ 'Validate desktop file',
+ desktop_file_validate_prg,
+ args: [ghex_desktop]
+ )
+endif
+
+pkg_conf = configuration_data()
+pkg_conf.set('prefix', ghex_prefix)
+pkg_conf.set('exec_prefix', ghex_prefix)
+pkg_conf.set('libdir', ghex_libdir)
+pkg_conf.set('includedir', ghex_includedir)
+
+pkg_conf.set('VERSION', meson.project_version())
+
+configure_file(
+ input: 'gtkhex-3.pc.in',
+ output: 'gtkhex-3.pc',
+ configuration: pkg_conf,
+ install_dir: ghex_pkgconfigdir,
+ install: true
+)
+
+ghex_appdata = i18n.merge_file(
+ input: 'ghex.appdata.xml.in',
+ output: 'ghex.appdata.xml',
+ po_dir: ghex_po_dir,
+ install_dir: ghex_appdatadir,
+ install: true,
+)
+
+appstream_util_prg = find_program(
+ 'appstream-util',
+ required: false
+)
+
+if appstream_util_prg.found()
+ test(
+ 'Validate appstream file',
+ appstream_util_prg,
+ args: ['validate', ghex_appdata]
+ )
+endif
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..e2c15e7
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,37 @@
+help_pages = [
+ 'index.docbook',
+ 'legal.xml'
+]
+
+help_media = [
+ 'figures/ghex_window_empty.png',
+ 'figures/ghex_window_open.png'
+]
+
+help_languages = [
+ 'cs',
+ 'de',
+ 'el',
+ 'es',
+ 'fr',
+ 'id',
+ 'it',
+ 'ja',
+ 'ko',
+ 'oc',
+ 'pt_BR',
+ 'ru',
+ 'sl',
+ 'sv',
+ 'th',
+ 'zh_CN',
+ 'zh_TW'
+]
+
+gnome.yelp(
+ meson.project_name(),
+ sources: help_pages,
+ media: help_media,
+ symlink_media: false,
+ languages: help_languages
+)
diff --git a/icons/hicolor_apps_scalable_ghex-symbolic.svg b/icons/hicolor/scalable/apps/ghex-symbolic.svg
similarity index 100%
rename from icons/hicolor_apps_scalable_ghex-symbolic.svg
rename to icons/hicolor/scalable/apps/ghex-symbolic.svg
diff --git a/icons/meson.build b/icons/meson.build
new file mode 100644
index 0000000..2474dd3
--- /dev/null
+++ b/icons/meson.build
@@ -0,0 +1,17 @@
+ghex_icon_sizes = [
+ '16x16',
+ '22x22',
+ '24x24',
+ '32x32',
+ '48x48',
+ '256x256',
+ '512x512',
+ 'scalable'
+]
+
+foreach s : ghex_icon_sizes
+ install_subdir(
+ join_paths('hicolor', s),
+ install_dir: join_paths(ghex_iconsdir, 'hicolor')
+ )
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f7379da
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,100 @@
+project(
+ 'ghex', 'c',
+ version: '3.18.3',
+ meson_version: '>=0.37.0',
+ license: 'GPL2'
+)
+
+version_arr = meson.project_version().split('.')
+ghex_version_major = version_arr[0].to_int()
+ghex_version_minor = version_arr[1].to_int()
+ghex_version_micro = version_arr[2].to_int()
+
+libghex_version_major = version_arr[0].to_int()
+
+ghex_prefix = get_option('prefix')
+ghex_libdir = join_paths(ghex_prefix, get_option('libdir'))
+ghex_includedir = join_paths(ghex_prefix, get_option('includedir'))
+ghex_datadir = join_paths(ghex_prefix, get_option('datadir'))
+ghex_localedir = join_paths(ghex_prefix, get_option('localedir'))
+ghex_pkgconfigdir = join_paths(ghex_libdir, 'pkgconfig')
+ghex_applicationsdir = join_paths(ghex_datadir, 'applications')
+ghex_schemasdir = join_paths(ghex_datadir, 'glib-2.0/schemas')
+ghex_appdatadir = join_paths(ghex_datadir, 'appdata')
+ghex_iconsdir = join_paths(ghex_datadir, 'icons')
+
+ghex_root_dir = include_directories('.')
+ghex_po_dir = join_paths(meson.source_root(), 'po')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+cc = meson.get_compiler('c')
+
+ghex_conf = configuration_data()
+ghex_conf.set_quoted('PACKAGE_NAME', meson.project_name())
+ghex_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+ghex_conf.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.project_version()))
+ghex_conf.set_quoted('PACKAGE_DATADIR', ghex_datadir)
+ghex_conf.set_quoted('PACKAGE_LIBDIR', ghex_libdir)
+ghex_conf.set_quoted('PACKAGE_LOCALE_DIR', ghex_localedir)
+
+ghex_conf.set('VERSION', 'PACKAGE_VERSION')
+ghex_conf.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
+ghex_conf.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
+
+ghex_conf.set_quoted('LIBGTKHEX_RELEASE_STRING', 'gtkhex-@0@.0'.format(libghex_version_major))
+
+ghex_conf.set10('ENABLE_NLS', true) # Always enabled
+
+check_headers = [
+ 'dlfcn.h',
+ 'inttypes.h',
+ 'memory.h',
+ 'stdint.h',
+ 'stdlib.h',
+ 'string.h',
+ 'sys/stat.h',
+ 'sys/types.h',
+ 'unistd.h'
+]
+
+foreach h : check_headers
+ if cc.has_header(h)
+ ghex_conf.set('HAVE_' + h.underscorify().to_upper(), 1)
+ endif
+endforeach
+
+check_functions = [
+ 'pow',
+ 'strstr',
+ 'strtoul'
+]
+
+foreach f : check_functions
+ if cc.has_function(f)
+ ghex_conf.set('HAVE_' + f.underscorify().to_upper(), 1)
+ endif
+endforeach
+
+atk_dep = dependency('atk', version: '>= 1.0.0')
+gio_dep = dependency('gio-2.0', version: '>= 2.31.10')
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.3.8')
+gail_dep = dependency('gail-3.0', version: '>= 1.0.0')
+
+configure_file(
+ output: 'config.h',
+ configuration: ghex_conf
+)
+
+update_icon_cache_prg = find_program('gtk-update-icon-cache', required : false)
+update_desktop_database_prg = find_program('update-desktop-database', required : false)
+compile_schemas_prg = find_program('glib-compile-schemas', required : false)
+
+subdir('src')
+subdir('data')
+subdir('icons')
+subdir('po')
+subdir('help')
+
+meson.add_install_script('meson_post_install.py')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..81afb18
--- /dev/null
+++ b/meson_post_install.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/po/POTFILES.in b/po/POTFILES.in
index 893c3c8..74d350a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,5 +1,6 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
+data/ghex.appdata.xml.in
data/ghex.desktop.in
src/chartable.c
src/config.c
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..66362aa
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,4 @@
+i18n.gettext(
+ meson.project_name(),
+ preset: 'glib'
+)
diff --git a/src/ghex-window.c b/src/ghex-window.c
index d1d0650..24f3c55 100644
--- a/src/ghex-window.c
+++ b/src/ghex-window.c
@@ -22,9 +22,7 @@
* Author: Jaka Mocnik <jaka gnu org>
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 9c730b0..5f745d0 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -21,9 +21,7 @@
Author: Jaka Mocnik <jaka gnu org>
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
#include <string.h>
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..f6f84c6
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,101 @@
+libghex_sources = [
+ 'accessiblegtkhex.c',
+ 'accessiblegtkhex.h',
+ 'accessiblegtkhexfactory.c',
+ 'accessiblegtkhexfactory.h',
+ 'gtkhex.c',
+ 'gtkhex-private.h',
+ 'hex-document.c'
+]
+
+libghex_headers = [
+ 'hex-document.h',
+ 'gtkhex.h'
+]
+
+libghex_deps = [
+ atk_dep,
+ gtk_dep,
+ gail_dep
+]
+
+libghex_c_args = [
+ '-DG_LOG_DOMAIN="libgtkhex-3"'
+]
+
+libghex_link_args = [
+ '-Wl,--no-undefined'
+]
+
+install_headers(
+ libghex_headers,
+ subdir: 'gtkhex-@0@.0'.format(libghex_version_major)
+)
+
+libghex = library(
+ 'gtkhex-@0@.0'.format(libghex_version_major),
+ libghex_sources + libghex_headers,
+ version: '@0@.0.0'.format(libghex_version_major),
+ include_directories: ghex_root_dir,
+ dependencies: libghex_deps,
+ c_args: libghex_c_args,
+ link_args: libghex_link_args,
+ install: true
+)
+
+libghex_dep = declare_dependency(
+ link_with: libghex,
+ include_directories: ghex_root_dir,
+ dependencies: libghex_deps,
+ sources: libghex_headers
+)
+
+ghex_sources = [
+ 'chartable.c',
+ 'chartable.h',
+ 'config.c',
+ 'configuration.h',
+ 'converter.c',
+ 'converter.h',
+ 'factory.c',
+ 'factory.h',
+ 'findreplace.c',
+ 'findreplace.h',
+ 'ghex-window.c',
+ 'ghex-window.h',
+ 'hex-dialog.c',
+ 'hex-dialog.h',
+ 'hex-document-ui.c',
+ 'main.c',
+ 'preferences.c',
+ 'preferences.h',
+ 'print.c',
+ 'print.h',
+ 'ui.c',
+ 'ui.h'
+]
+
+ghex_deps = [
+ atk_dep,
+ gio_dep,
+ gtk_dep
+]
+
+ghex_res = gnome.compile_resources(
+ 'ghex-resources',
+ 'ghex.gresource.xml',
+ c_name: 'ghex'
+)
+
+ghex_c_args = [
+ '-DG_LOG_DOMAIN="GHex"'
+]
+
+ghex = executable(
+ meson.project_name(),
+ ghex_sources + ghex_res,
+ include_directories: ghex_root_dir,
+ dependencies: ghex_deps + [libghex_dep, ],
+ c_args: ghex_c_args,
+ install: true
+)
diff --git a/src/ui.c b/src/ui.c
index c681777..0be8dda 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -185,7 +185,7 @@ about_cb (GtkAction *action,
"copyright", copyright,
"documenters", documentation_credits,
"license", license_translated,
- "logo-icon-name", PACKAGE,
+ "logo-icon-name", PACKAGE_NAME,
"program-name", "GHex",
"title", _("About GHex"),
"translator-credits", _("translator-credits"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]