[ghex/gtk4-port] meson/ci: cleanup, add devel rules for ghex4 pre-alpha



commit 7144f4dedaa549ec712d476ee84759d204f1d327
Author: Logan Rathbone <poprocks gmail com>
Date:   Sun Dec 5 21:53:51 2021 -0500

    meson/ci: cleanup, add devel rules for ghex4 pre-alpha
    
    It might work.  Maybe.

 data/meson.build                                   | 29 ++++++++---
 ...Hex.desktop.in => org.gnome.GHex.desktop.in.in} |  4 +-
 data/org.gnome.GHex.gschema.xml.in                 |  2 +-
 meson.build                                        | 59 ++++++++++++++--------
 meson_options.txt                                  |  1 +
 org.gnome.GHex.json => org.gnome.GHex.Devel.json   |  3 +-
 src/chartable.c                                    |  4 +-
 src/common-ui.c                                    |  4 +-
 src/configuration.c                                |  4 +-
 src/converter.c                                    |  8 ++-
 src/findreplace.c                                  |  1 -
 src/gtkhex.c                                       |  1 -
 src/hex-dialog.c                                   |  8 +--
 src/hex-document.c                                 |  4 +-
 src/main.c                                         |  8 +--
 src/preferences.c                                  | 13 ++---
 src/print.c                                        |  6 +--
 17 files changed, 87 insertions(+), 72 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index e9b900e..106fa80 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,6 +1,21 @@
-ghex_desktop = i18n.merge_file(
-  input: 'org.gnome.GHex.desktop.in',
-  output: 'org.gnome.GHex.desktop',
+if get_option('development')
+  app_name = 'GHex (Development)'
+else    
+  app_name = 'GHex'
+endif
+
+desktop_file_in_config = configuration_data()
+desktop_file_in_config.set('app_id', app_id)
+desktop_file_in_config.set('app_name', app_name)
+desktop_file_in = configure_file(
+          input: 'org.gnome.GHex.desktop.in.in',
+         output: '@0  desktop in'.format(app_id),
+  configuration: desktop_file_in_config,
+)
+
+desktop_file = i18n.merge_file(
+  input: desktop_file_in,
+  output: '@0@.desktop'.format(app_id),
   po_dir: ghex_po_dir,
   type: 'desktop',
   install_dir: ghex_applicationsdir,
@@ -16,7 +31,7 @@ if desktop_file_validate_prg.found()
   test(
     'Validate desktop file',
     desktop_file_validate_prg,
-    args: [ghex_desktop]
+    args: [desktop_file]
   )
 endif
 
@@ -28,7 +43,6 @@ pkg_conf.set('includedir', ghex_includedir)
 
 pkg_conf.set('VERSION', meson.project_version())
 
-pkg_conf.set_quoted('XML_SHADED_BOX_MAX', shaded_box_max.to_string())
 
 configure_file(
   input: 'gtkhex-4.pc.in',
@@ -38,10 +52,13 @@ configure_file(
   install: true
 )
 
+schema_conf = configuration_data()
+schema_conf.set_quoted('XML_SHADED_BOX_MAX', shaded_box_max.to_string())
+
 configure_file(
   input: 'org.gnome.GHex.gschema.xml.in',
   output: 'org.gnome.GHex.gschema.xml',
-  configuration: pkg_conf,
+  configuration: schema_conf,
   install_dir: ghex_schemasdir,
   install: true
 )
diff --git a/data/org.gnome.GHex.desktop.in b/data/org.gnome.GHex.desktop.in.in
similarity index 94%
rename from data/org.gnome.GHex.desktop.in
rename to data/org.gnome.GHex.desktop.in.in
index 0c9c404..9570fb6 100644
--- a/data/org.gnome.GHex.desktop.in
+++ b/data/org.gnome.GHex.desktop.in.in
@@ -1,5 +1,5 @@
 [Desktop Entry]
-Name=GHex
+Name=@app_name@
 GenericName=Hex Editor
 Comment=Inspect and edit binary files
 # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list 
MUST also end with a semicolon! Here, 'binary' means a binary file (not the base-2 numeric system).
@@ -8,6 +8,6 @@ Exec=ghex %F
 Terminal=false
 Type=Application
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
-Icon=org.gnome.GHex
+Icon=@app_id@
 Categories=GNOME;GTK;Development;
 StartupNotify=true
diff --git a/data/org.gnome.GHex.gschema.xml.in b/data/org.gnome.GHex.gschema.xml.in
index d6250c9..32c02e2 100644
--- a/data/org.gnome.GHex.gschema.xml.in
+++ b/data/org.gnome.GHex.gschema.xml.in
@@ -2,7 +2,7 @@
 -->
 <schemalist>
 
-       <!-- it does not appear possible to automate this with meson presently.
+       <!-- it does not appear possible to automate this (enums) with meson presently.
                See: https://github.com/mesonbuild/meson/issues/1687
        -->
        <enum id="org.gnome.GHex.GroupType">
diff --git a/meson.build b/meson.build
index cb70271..e16796b 100644
--- a/meson.build
+++ b/meson.build
@@ -1,14 +1,18 @@
 project(
   'ghex', 'c',
   version: '4.alpha.1',
-  meson_version: '>=0.50.0',
+  meson_version: '>=0.53.0',
   license: 'GPL2'
 )
 
+if get_option('development')
+  app_id = 'org.gnome.GHex.Devel'
+else
+  app_id = 'org.gnome.GHex'
+endif
+
 version_arr = meson.project_version().split('.')
 ghex_version_major = version_arr[0].to_int()
-ghex_version_minor = version_arr[1]
-ghex_version_micro = version_arr[2].to_int()
 
 libghex_version_major = version_arr[0].to_int()
 
@@ -40,30 +44,32 @@ i18n = import('i18n')
 
 cc = meson.get_compiler('c')
 
+# just to avoid manually punching it into the XML files as well as the source.
 shaded_box_max = 1000
 
-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)
+config_h = configuration_data()
+config_h.set_quoted('APP_ID', app_id)
+config_h.set_quoted('PACKAGE_NAME', meson.project_name())
+config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
+config_h.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.project_version()))
+config_h.set_quoted('PACKAGE_DATADIR', ghex_datadir)
+config_h.set_quoted('PACKAGE_LIBDIR', ghex_libdir)
+config_h.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')
+config_h.set('VERSION', 'PACKAGE_VERSION')
+config_h.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
+config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
 
-ghex_conf.set('CONFIG_H_SHADED_BOX_MAX', shaded_box_max)
+config_h.set('CONFIG_H_SHADED_BOX_MAX', shaded_box_max)
 
-ghex_conf.set_quoted('LIBGTKHEX_RELEASE_STRING', 'gtkhex-@0@.0'.format(libghex_version_major))
+config_h.set_quoted('LIBGTKHEX_RELEASE_STRING', 'gtkhex-@0@.0'.format(libghex_version_major))
 
-ghex_conf.set('DEBUG', get_option('debug'))
+config_h.set('DEBUG', get_option('debug'))
 
 # Always enable; it's generated by Meson anyway.
-ghex_conf.set('HAVE_CONFIG_H', true)
+config_h.set('HAVE_CONFIG_H', true)
 
-ghex_conf.set10('ENABLE_NLS', true) # Always enabled
+config_h.set10('ENABLE_NLS', true) # Always enabled
 
 check_headers = [
   'dlfcn.h',
@@ -79,7 +85,7 @@ check_headers = [
 
 foreach h : check_headers
   if cc.has_header(h)
-    ghex_conf.set('HAVE_' + h.underscorify().to_upper(), 1)
+    config_h.set('HAVE_' + h.underscorify().to_upper(), 1)
   endif
 endforeach
 
@@ -91,7 +97,7 @@ check_functions = [
 
 foreach f : check_functions
   if cc.has_function(f)
-    ghex_conf.set('HAVE_' + f.underscorify().to_upper(), 1)
+    config_h.set('HAVE_' + f.underscorify().to_upper(), 1)
   endif
 endforeach
 
@@ -100,7 +106,7 @@ gtk_dep = dependency('gtk4', version: '>= 4.0.0')
 
 configure_file(
   output: 'config.h',
-  configuration: ghex_conf
+  configuration: config_h
 )
 
 update_icon_cache_prg = find_program('gtk-update-icon-cache', required : false)
@@ -114,3 +120,14 @@ subdir('po')
 subdir('help')
 
 meson.add_install_script('meson_post_install.py')
+
+### SUMMARY PRINTOUT ###
+
+summary({'prefix': ghex_prefix,
+        'libdir': ghex_libdir,
+        'datadir': ghex_datadir,
+        'includedir': ghex_includedir,
+        }, section: 'Directories')
+
+summary({'Development build': get_option('development'),
+        }, section: 'Configuration')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..5991092
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('development', type: 'boolean', value: false, description: 'If this is a development build')
diff --git a/org.gnome.GHex.json b/org.gnome.GHex.Devel.json
similarity index 91%
rename from org.gnome.GHex.json
rename to org.gnome.GHex.Devel.json
index b31dd24..a5c52f7 100644
--- a/org.gnome.GHex.json
+++ b/org.gnome.GHex.Devel.json
@@ -1,9 +1,10 @@
 {
-    "app-id": "org.gnome.GHex",
+    "app-id": "org.gnome.GHex.Devel",
     "runtime": "org.gnome.Platform",
     "runtime-version": "master",
     "sdk": "org.gnome.Sdk",
     "command": "ghex",
+    "branch": "gtk4-port",
     "finish-args": [
         /* X11 + XShm */
         "--share=ipc", "--socket=x11",
diff --git a/src/chartable.c b/src/chartable.c
index bba0661..0486798 100644
--- a/src/chartable.c
+++ b/src/chartable.c
@@ -32,9 +32,7 @@
 
 #include "chartable.h"
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 /* STATIC GLOBALS */
 
diff --git a/src/common-ui.c b/src/common-ui.c
index a86886b..d3b5f41 100644
--- a/src/common-ui.c
+++ b/src/common-ui.c
@@ -32,10 +32,8 @@
 
 #include "common-ui.h"
 
-/* Not optional. */
 #include <config.h>
 
-
 /* helper for common_set_gtkhex_font_from_settings.
  * 
  * This function was written by Matthias Clasen and is included somewhere in
@@ -262,7 +260,7 @@ common_about_cb (GtkWindow *parent)
                               "copyright", copyright,
                               "documenters", documentation_credits,
                               "license", license_translated,
-                              "logo-icon-name", "org.gnome.GHex",
+                              "logo-icon-name", APP_ID,
                               "program-name", "GHex",
                               "title", _("About GHex"),
                               "translator-credits", _("translator-credits"),
diff --git a/src/configuration.c b/src/configuration.c
index 31ac266..3b225ef 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -30,9 +30,7 @@
    Author: Jaka Mocnik <jaka gnu org>
 */
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include "configuration.h"
 
diff --git a/src/converter.c b/src/converter.c
index f3eb821..db12797 100644
--- a/src/converter.c
+++ b/src/converter.c
@@ -32,9 +32,8 @@
    Chema Celorio <chema gnome org>
 */
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include "gtkhex.h"
+#include "converter.h"
 
 #include <ctype.h>      /* for isdigit */
 #include <stdlib.h>     /* for strtoul */
@@ -43,8 +42,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
 
-#include "gtkhex.h"
-#include "converter.h"
+#include <config.h>
 
 /* OPAQUE DATATYPES */
 
diff --git a/src/findreplace.c b/src/findreplace.c
index 5a92c20..3f7cc3f 100644
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@ -32,7 +32,6 @@
 
 #include "findreplace.h"
 
-/* Not optional. */
 #include <config.h>
 
 /* DEFINES */
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 1d4e085..bd833c5 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -35,7 +35,6 @@
 
 #include <string.h>
 
-/* Not optional. */
 #include <config.h>
 
 /* Don't move these from the source file as they are not part of the public
diff --git a/src/hex-dialog.c b/src/hex-dialog.c
index b765456..099d694 100644
--- a/src/hex-dialog.c
+++ b/src/hex-dialog.c
@@ -28,9 +28,10 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <config.h>
-#include <glib-object.h>
+#include "hex-dialog.h"
+#include "gtkhex.h"
 
+#include <glib-object.h>
 #include <glib/gi18n.h>
 
 #include <stdio.h>
@@ -39,8 +40,7 @@
 #include <string.h>
 #include <math.h>
 
-#include "gtkhex.h"
-#include "hex-dialog.h"
+#include <config.h>
 
 struct _HexDialog
 {
diff --git a/src/hex-document.c b/src/hex-document.c
index ea6a788..77ef050 100644
--- a/src/hex-document.c
+++ b/src/hex-document.c
@@ -30,7 +30,6 @@
    Author: Jaka Mocnik <jaka gnu org>
  */
 
-#include <config.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
 
@@ -41,8 +40,7 @@
 #include <sys/stat.h>
 #include <string.h>
 
-//static void hex_document_class_init     (HexDocumentClass *);
-//static void hex_document_init           (HexDocument *doc);
+#include <config.h>
 
 static void hex_document_real_changed   (HexDocument *doc,
                                                                                 gpointer change_data,
diff --git a/src/main.c b/src/main.c
index 3e933c1..ff41af0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,10 +30,11 @@
    Original Author: Jaka Mocnik <jaka gnu org>
 */
 
+#include "ghex-application-window.h"
+
 #include <locale.h>
-#include <config.h>
 
-#include "ghex-application-window.h"
+#include <config.h>
 
 static GtkWindow *window = NULL;
 
@@ -132,8 +133,7 @@ main (int argc, char *argv[])
 
        ghex_init_configuration ();
 
-       app = gtk_application_new ("org.gnome.GHex",
-                       G_APPLICATION_HANDLES_OPEN);
+       app = gtk_application_new (APP_ID, G_APPLICATION_HANDLES_OPEN);
 
        g_signal_connect (app, "activate", G_CALLBACK(activate), NULL);
        g_signal_connect (app, "open", G_CALLBACK(open), NULL);
diff --git a/src/preferences.c b/src/preferences.c
index c90b141..e4f1755 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -32,19 +32,12 @@
 
 #include "preferences.h"
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 /* CONSTANTS */
 
-#ifdef HAVE_CONFIG_H
-#  define SHADED_BOX_MAX                               CONFIG_H_SHADED_BOX_MAX
-#else
-#  define SHADED_BOX_MAX                               1000
-#endif
-
-#define PREFS_RESOURCE "/org/gnome/GHex/preferences.ui"
+#define SHADED_BOX_MAX CONFIG_H_SHADED_BOX_MAX
+#define PREFS_RESOURCE "/org/gnome/GHex/preferences.ui"
 
 /* MACROS */
 
diff --git a/src/print.c b/src/print.c
index 557dd0f..f10486a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -24,12 +24,10 @@
    Printing module by: Chema Celorio <chema celorio com>
 */
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
-
 #include "print.h"
 
+#include <config.h>
+
 #define is_printable(c) (((((guchar)c)>=0x20) && (((guchar)c)<0x7F))?1:0)
 
 static void print_header(GHexPrintJobInfo *pji, unsigned int page);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]