[polari] build: Use a small C wrapper
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] build: Use a small C wrapper
- Date: Sun, 30 Oct 2016 19:51:17 +0000 (UTC)
commit f5dce05bb32b4409b32ff18ab5b7a71d27a02bfd
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Oct 15 00:59:27 2016 +0200
build: Use a small C wrapper
Gjs' package module provides some convenience like automatically loading
resources and setting the correct WM_CLASS, however this requires apps
to follow the somehow problematic pattern of either using the App ID as
name of the main binary (which nobody does for the time being), or making
it a symlink to a script of that name. Unfortunately this pattern requires
special treatment in the build system (hello, meson), which then makes it
harder to support from IDEs (hello, builder). Instead, replace the current
launcher script with a small binary that runs the same code, but also
includes the required resources.
https://bugzilla.gnome.org/show_bug.cgi?id=773293
configure.ac | 4 +++
data/Makefile.am | 9 -------
src/Makefile.am | 55 +++++++++++++++++++++++++++++------------------
src/application.js | 1 +
src/org.gnome.Polari.in | 5 ----
src/polari.c | 43 ++++++++++++++++++++++++++++++++++++
6 files changed, 82 insertions(+), 35 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9446af1..727daef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,10 @@ PKG_CHECK_MODULES(LIBPOLARI,
gio-2.0 >= 2.43.4
gtk+-3.0 >= 3.21.6
telepathy-glib);
+PKG_CHECK_MODULES(POLARI,
+ gio-2.0
+ gobject-introspection-1.0
+ gjs-1.0)
AC_CHECK_FUNCS([strcasestr])
diff --git a/data/Makefile.am b/data/Makefile.am
index c3c21fd..3f9866c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -18,13 +18,6 @@ service_in_files = $(APP_ID).service.in \
check-local:
$(DESKTOP_FILE_VALIDATE) $(desktop_DATA)
-resource_files=$(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/$(APP_ID).data.gresource.xml)
-$(APP_ID).data.gresource: $(APP_ID).data.gresource.xml $(resource_files)
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
-
-resourcedir=$(pkgdatadir)
-resource_DATA=$(APP_ID).data.gresource
-
gsettings_SCHEMAS = $(APP_ID).gschema.xml
@GSETTINGS_RULES@
@@ -35,12 +28,10 @@ EXTRA_DIST = \
$(desktop_in_files) \
$(service_in_files) \
$(APP_ID).data.gresource.xml \
- $(resource_files) \
$(gsettings_SCHEMAS) \
$(NULL)
CLEANFILES = \
$(desktop_DATA) \
$(service_DATA) \
- $(resource_DATA) \
$(NULL)
diff --git a/src/Makefile.am b/src/Makefile.am
index 1a71513..caf1f17 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@ EXTRA_SCRIPTS =
EXTRA_DIST =
CLEANFILES =
INTROSPECTION_GIRS =
+BUILT_SOURCES =
girdir = $(pkgdatadir)/gir-1.0
typelibdir = $(pkglibdir)/girepository-1.0
@@ -21,40 +22,52 @@ do_subst = sed -e 's|@prefix[@]|$(prefix)|g' \
-e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \
$(NULL)
-appdir = $(pkgdatadir)
-nodist_app_SCRIPTS = $(APP_ID)
-
-$(APP_ID): $(APP_ID).in $(top_srcdir)/configure.ac
- $(AM_V_GEN) $(do_subst) $< > $@
+bin_PROGRAMS = polari
+polari_SOURCES = \
+ polari.c \
+ $(src_resources) \
+ $(data_resources) \
+ $(NULL)
+polari_CFLAGS = \
+ $(POLARI_CFLAGS) \
+ -DPREFIX=\"$(prefix)\" \
+ -DLIBDIR=\"$(libdir)\" \
+ -DPKGLIBDIR=\"$(pkglibdir)\" \
+ $(NULL)
+polari_LDADD = $(POLARI_LIBS)
nodist_noinst_SCRIPTS = polari-accounts
polari-accounts: polari-accounts.in
$(AM_V_GEN) $(do_subst) $< > $@ && chmod +x $@
-resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/$(APP_ID).src.gresource.xml)
-$(APP_ID).src.gresource: $(APP_ID).src.gresource.xml $(resource_files)
- $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
+src_resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies
$(srcdir)/$(APP_ID).src.gresource.xml)
+src-resources.h: $(APP_ID).src.gresource.xml $(src_resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name
src_resources $<
+src-resources.c: $(APP_ID).src.gresource.xml $(src_resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name
src_resources $<
+src_resources = src-resources.c src-resources.h
-resourcedir = $(pkgdatadir)
-resource_DATA = $(APP_ID).src.gresource
+BUILT_SOURCES += $(src_resources)
+
+data_resource_files=$(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies
$(top_srcdir)/data/$(APP_ID).data.gresource.xml)
+data-resources.h: $(top_srcdir)/data/$(APP_ID).data.gresource.xml $(data_resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate --c-name
data_resources $<
+data-resources.c: $(top_srcdir)/data/$(APP_ID).data.gresource.xml $(data_resource_files)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate --c-name
data_resources $<
+data_resources = data-resources.h data-resources.c
+
+BUILT_SOURCES += $(data_resources)
EXTRA_DIST += \
- $(APP_ID).in \
$(APP_ID).src.gresource.xml \
polari-accounts.in \
- $(resource_files) \
+ $(data_resource_files) \
+ $(src_resource_files) \
$(NULL)
CLEANFILES += \
- $(APP_ID) \
- $(APP_ID).src.gresource \
+ $(data_resources) \
+ $(src_resources) \
polari-accounts \
$(NULL)
-
-install-exec-hook:
- $(MKDIR_P) $(DESTDIR)$(bindir)
- -rm -f $(DESTDIR)$(bindir)/$(PACKAGE_NAME)
- $(LN_S) $(appdir)/$(APP_ID) $(DESTDIR)$(bindir)/$(PACKAGE_NAME)
-uninstall-hook:
- -rm -f $(DESTDIR)$(bindir)/$(PACKAGE_NAME)
diff --git a/src/application.js b/src/application.js
index 161e44d..63433f1 100644
--- a/src/application.js
+++ b/src/application.js
@@ -31,6 +31,7 @@ const Application = new Lang.Class({
flags: Gio.ApplicationFlags.HANDLES_OPEN });
GLib.set_application_name('Polari');
+ GLib.set_prgname('org.gnome.Polari');
this._retryData = new Map();
this.add_main_option('start-client', 0,
diff --git a/src/polari.c b/src/polari.c
new file mode 100644
index 0000000..5ed30e8
--- /dev/null
+++ b/src/polari.c
@@ -0,0 +1,43 @@
+#include <girepository.h>
+#include <gjs/gjs.h>
+
+const char *src =
+ "imports.package.start({ name: '" PACKAGE_NAME "',"
+ " version: '" PACKAGE_VERSION "',"
+ " prefix: '" PREFIX "',"
+ " libdir: '" LIBDIR "' });";
+
+int
+main (int argc, char *argv[])
+{
+ const char *search_path[] = { "resource:///org/gnome/Polari/js", NULL };
+ GError *error = NULL;
+ GjsContext *context;
+ int status;
+
+ g_irepository_prepend_search_path (PKGLIBDIR);
+
+ context = g_object_new (GJS_TYPE_CONTEXT,
+ "search-path", search_path,
+ NULL);
+
+ if (!gjs_context_define_string_array (context, "ARGV",
+ argc - 1, (const char **)argv + 1,
+ &error))
+ {
+ g_message ("Failed to define ARGV: %s", error->message);
+ g_error_free (error);
+
+ return 1;
+ }
+
+ if (!gjs_context_eval (context, src, -1, "<main>", &status, &error))
+ {
+ g_message ("Execution of start() threw exception: %s", error->message);
+ g_error_free (error);
+
+ return status;
+ }
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]