[file-roller/wip/jtojnar/gtk4: 14/16] Add support for introspection
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/gtk4: 14/16] Add support for introspection
- Date: Wed, 30 Mar 2022 21:02:18 +0000 (UTC)
commit 965c3ce2a8ba6f0dfe31f4ae51198609d96f32ba
Author: Jan Tojnar <jtojnar gmail com>
Date: Tue Dec 21 02:46:29 2021 +0100
Add support for introspection
It is required for Tartan to properly analyze our types.
meson.build | 7 ++++++
meson_options.txt | 6 +++++
src/fr-application.c | 24 ++++++++++++++++++++
src/meson.build | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 100 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 8b6838cb..f38cb604 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,10 @@ gtk_dep = dependency('gtk+-3.0', version : gtk_version)
hdy_dep = dependency('libhandy-1', version: hdy_version)
# Optional dependencies
+use_gobject_introspection = get_option('introspection')
+if use_gobject_introspection
+ gobject_introspection_dep = dependency('gobject-introspection-1.0')
+endif
libnautilus_extension_dep = dependency('libnautilus-extension', version : nautilus_version, required :
get_option('nautilus-actions'))
build_nautilus_actions = libnautilus_extension_dep.found()
@@ -73,6 +77,9 @@ else
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_gobject_introspection
+ config_data.set('ENABLE_INTROSPECTION', 1)
+endif
if use_json_glib
config_data.set('HAVE_JSON_GLIB', 1)
endif
diff --git a/meson_options.txt b/meson_options.txt
index 662cc8ef..6040c516 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -33,3 +33,9 @@ option('cpio',
value : 'auto',
description : 'Path to the cpio program'
)
+
+option('introspection',
+ type : 'boolean',
+ value : false,
+ description : 'Generate introspection data for the executable (e.g. for static analysis)'
+)
diff --git a/src/fr-application.c b/src/fr-application.c
index e29d29c0..abcec378 100644
--- a/src/fr-application.c
+++ b/src/fr-application.c
@@ -32,6 +32,9 @@
#ifdef ENABLE_NOTIFICATION
# include <libnotify/notify.h>
#endif
+#ifdef ENABLE_INTROSPECTION
+# include <girepository.h>
+#endif
#include "file-utils.h"
#include "fr-application.h"
#include "fr-application-menu.h"
@@ -55,6 +58,9 @@ static gboolean arg_version = FALSE;
static gboolean arg_service = FALSE;
static gboolean arg_notify = FALSE;
static const char *program_argv0 = NULL; /* argv[0] from main(); used as the command to restart the program
*/
+#ifdef ENABLE_INTROSPECTION
+static char *introspection_dump = NULL;
+#endif
static const GOptionEntry options[] = {
@@ -95,6 +101,12 @@ static const GOptionEntry options[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &arg_version,
N_("Show version"), NULL },
+#ifdef ENABLE_INTROSPECTION
+ { "introspect-dump", '\0', 0, G_OPTION_ARG_STRING, &introspection_dump,
+ N_("Dump gobject introspection file"),
+ N_("input.txt,output.xml") },
+#endif
+
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
NULL,
NULL },
@@ -553,6 +565,18 @@ fr_application_command_line (GApplication *application,
g_strfreev (argv);
g_option_context_free (context);
+#ifdef ENABLE_INTROSPECTION
+ if (introspection_dump) {
+ if (!g_irepository_dump (introspection_dump, &error)) {
+ g_critical ("Failed to dump introspection data: %s", error->message);
+ g_error_free (error);
+ return fr_application_command_line_finished (application, EXIT_FAILURE);
+ }
+
+ return fr_application_command_line_finished (application, EXIT_SUCCESS);
+ }
+#endif
+
if (remaining_args == NULL) { /* No archive specified. */
if (! arg_service)
gtk_widget_show (fr_window_new ());
diff --git a/src/meson.build b/src/meson.build
index c0d2fb9e..850f322f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -56,11 +56,50 @@ source_files = files(
'preferences.c',
'rar-utils.c'
)
+
+fr_headers = files(
+ 'fr-application-menu.h',
+ 'fr-application.h',
+ 'fr-archive.h',
+ 'fr-command-7z.h',
+ 'fr-command-ace.h',
+ 'fr-command-alz.h',
+ 'fr-command-ar.h',
+ 'fr-command-arj.h',
+ 'fr-command-cfile.h',
+ 'fr-command-cpio.h',
+ 'fr-command-dpkg.h',
+ 'fr-command-iso.h',
+ 'fr-command-jar.h',
+ 'fr-command-lha.h',
+ 'fr-command-lrzip.h',
+ 'fr-command-rar.h',
+ 'fr-command-rpm.h',
+ 'fr-command-tar.h',
+ 'fr-command-unsquashfs.h',
+ 'fr-command-unstuff.h',
+ 'fr-command-zip.h',
+ 'fr-command-zoo.h',
+ 'fr-command.h',
+ 'fr-error.h',
+ 'fr-file-selector-dialog.h',
+ 'fr-init.h',
+ 'fr-list-model.h',
+ 'fr-location-bar.h',
+ 'fr-new-archive-dialog.h',
+ 'fr-process.h',
+ 'fr-window-actions-callbacks.h',
+ 'fr-window-actions-entries.h',
+ 'fr-window.h',
+)
+
if libjson_glib_dep.found()
source_files += [ 'fr-command-unarchiver.c' ]
+ fr_headers += [ 'fr-command-unarchiver.h' ]
endif
if use_libarchive
source_files += [ 'fr-archive-libarchive.c' ]
+ fr_headers += [ 'fr-archive-libarchive.h' ]
endif
if not have_mkdtemp
source_files += [ 'mkdtemp.c' ]
@@ -76,7 +115,7 @@ enum_files = gnome.mkenums_simple('fr-enum-types',
# Build targets
-executable('file-roller',
+fr_exe = executable('file-roller',
sources : [
config_file,
source_files,
@@ -91,15 +130,38 @@ executable('file-roller',
gthread_dep,
gtk_dep,
hdy_dep,
+ use_gobject_introspection ? gobject_introspection_dep : [],
use_json_glib ? libjson_glib_dep : [],
use_libnotify ? libnotify_dep : [],
use_libarchive ? libarchive_dep : []
],
+ link_args: [
+ # Required for GIRepository to be able to dump symbols.
+ use_gobject_introspection ? '-Wl,--export-dynamic' : [],
+ ],
include_directories : config_inc,
c_args : c_args,
install : true
)
+if use_gobject_introspection
+ fr_gir = gnome.generate_gir(
+ fr_exe,
+ sources: [
+ source_files,
+ fr_headers,
+ ],
+ namespace: 'FileRoller',
+ nsversion: '1.0',
+ identifier_prefix: 'Fr',
+ includes : [
+ 'Gio-2.0',
+ 'GObject-2.0',
+ 'Gtk-3.0',
+ ],
+ )
+endif
+
executable('test-server', 'test-server.c',
dependencies : [
libm_dep,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]