[gnome-maps/wip/binary] Make gnome-maps a binary



commit 5e5181372dd1e5938c6139443871ddd5cd668ef5
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Tue Jan 21 06:50:12 2014 +0100

    Make gnome-maps a binary

 configure.ac                      |    8 +++++-
 src/Makefile-js.am                |   33 +++++++----------------
 src/Makefile.am                   |   53 +++++++++++++++++++++++-------------
 src/application.js                |    2 +-
 src/gnome-maps.c                  |   49 ++++++++++++++++++++++++++++++++++
 src/gnome-maps.data.gresource.xml |   15 ++++++++++
 src/gnome-maps.gresource.xml      |   15 ----------
 src/gnome-maps.in                 |   18 ------------
 src/gnome-maps.js.gresource.xml   |   19 +++++++++++++
 9 files changed, 135 insertions(+), 77 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6d475b6..5e21f67 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AC_INIT([gnome-maps],
         [gnome-maps])
 
 AC_CONFIG_HEADERS([config/config.h])
-AC_CONFIG_SRCDIR([src/main.js])
+AC_CONFIG_SRCDIR([src/gnome-maps.c])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([config])
 
@@ -22,6 +22,12 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext d
 IT_PROG_INTLTOOL(0.40.0)
 PKG_PROG_PKG_CONFIG([0.22])
 
+SHARED_PCS="gtk+-3.0                  >= 3.11.4
+            gjs-internals-1.0         >= 1.39.0 
+            gobject-introspection-1.0 >= 0.10.1"
+
+PKG_CHECK_MODULES(GNOME_MAPS, $SHARED_PCS)
+
 # no stupid static libraries
 AM_DISABLE_STATIC
 # enable libtool
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index a7055f5..c5812a8 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -1,21 +1,3 @@
-jsdir = $(pkgdatadir)/js/
-dist_js_DATA = \
-    application.js \
-    main.js \
-    mainWindow.js \
-    mapLocation.js \
-    mapView.js \
-    path.js \
-    sidebar.js \
-    settings.js \
-    utils.js \
-    userLocation.js \
-    geoclue.js \
-    zoomControl.js \
-    searchPopup.js \
-    contextMenu.js \
-    placeStore.js
-
 BUILT_SOURCES += \
     path.js \
     config.js
@@ -25,12 +7,17 @@ path.js: Makefile path.js.in
 config.js: Makefile config.js.in
        $(AM_V_GEN) $(do_subst) $(srcdir)/config.js.in > $@
 
-nodist_js_DATA = \
-    path.js \
-    config.js
+js_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/js.gresource.xml)
+gnome-maps-js.h: gnome-maps.js.gresource.xml $(js_files) path.js config.js
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name gnome_maps_js $<
+gnome-maps-js.c: gnome-maps.js.gresource.xml $(js_files) path.js config.js
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name gnome_maps_js $<
+
+js_built_sources = gnome-maps-js.c gnome-maps-js.h
+
+BUILT_SOURCES += $(js_built_sources)
 
-CLEANFILES += \
-    $(BUILT_SOURCES)
+CLEANFILES += $(js_built_sources)
 
 EXTRA_DIST += \
     path.js.in \
diff --git a/src/Makefile.am b/src/Makefile.am
index b5dbbc0..411e464 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,23 +20,38 @@ do_subst = sed -e 's|@abs_top_srcdir[ ]|$(abs_top_srcdir)|g' \
 include $(INTROSPECTION_MAKEFILE)
 include Makefile-js.am
 
-resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/gnome-maps.gresource.xml)
-gnome-maps.gresource: gnome-maps.gresource.xml $(resource_files)
+data_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/gnome-maps.data.gresource.xml)
+gnome-maps.data.gresource: gnome-maps.data.gresource.xml $(resource_files)
        $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
-EXTRA_DIST += gnome-maps.gresource.xml $(resource_files)
-
-resourcedir = $(pkgdatadir)
-resource_DATA = gnome-maps.gresource
-
-CLEANFILES += gnome-maps.gresource
-
-bin_SCRIPTS = gnome-maps
-
-gnome-maps: gnome-maps.in
-       $(AM_V_GEN) $(do_subst) $< > $@
-       chmod +x $@
-
-CLEANFILES += \
-    gnome-maps
-EXTRA_DIST += \
-    gnome-maps.in
+gnome-maps-data.h: gnome-maps.data.gresource.xml $(data_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name gnome_maps_data $<
+gnome-maps-data.c: gnome-maps.data.gresource.xml $(js_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(builddir) 
--generate --c-name gnome_maps_data $<
+
+EXTRA_DIST += gnome-maps.data.gresource.xml $(resource_files)
+
+data_built_sources = gnome-maps-data.c gnome-maps-data.h
+
+BUILT_SOURCES += $(data_built_sources)
+
+bin_PROGRAMS = gnome-maps
+
+CLEANFILES +=                  \
+    gnome-maps                 \
+       $(data_built_sources)
+
+gnome_maps_SOURCES = gnome-maps.c      \
+       $(NULL)
+nodist_gnome_maps_SOURCES =                                    \
+       $(top_builddir)/src/gnome-maps-data.c           \
+       $(top_builddir)/src/gnome-maps-data.h           \
+       $(top_builddir)/src/gnome-maps-js.c                     \
+       $(top_builddir)/src/gnome-maps-js.h                     \
+       $(NULL)
+
+gnome_maps_CPPFLAGS =                                          \
+       $(GNOME_MAPS_CFLAGS)                                    \
+       -DLOCALEDIR=\"$(localedir)\"                    \
+       -DGNOME_MAPS_PKGLIBDIR=\"$(pkglibdir)\"
+gnome_maps_LDADD =                                                     \
+       $(GNOME_MAPS_LIBS)
diff --git a/src/application.js b/src/application.js
index 3a67dc6..3e7b1e4 100644
--- a/src/application.js
+++ b/src/application.js
@@ -75,7 +75,7 @@ const Application = new Lang.Class({
 
         GtkClutter.init(null);
 
-        let resource = Gio.Resource.load(Path.RESOURCE_DIR + '/gnome-maps.gresource');
+        let resource = Gio.Resource.load(Path.RESOURCE_DIR + '/gnome-maps-data.gresource');
         resource._register();
 
         Utils.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/maps/application.css'));
diff --git a/src/gnome-maps.c b/src/gnome-maps.c
new file mode 100644
index 0000000..d2dfbee
--- /dev/null
+++ b/src/gnome-maps.c
@@ -0,0 +1,49 @@
+#include "config.h"
+
+#include <girepository.h>
+#include <gjs/gjs.h>
+
+int
+main (int argc, char *argv)
+{
+  const char *search_path[] = { "resource:///org/gnome/maps", NULL };
+  GError *error = NULL;
+  GjsContext *context;
+  int status;
+
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
+  g_irepository_prepend_search_path (GNOME_MAPS_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 defined ARGV: %s", error->message);
+      g_error_free (error);
+
+      return 1;
+    }
+
+
+  if (!gjs_context_eval (context,
+                         "const Main = imports.main; Main.start();",
+                         -1,
+                         "<main>",
+                         &status,
+                         &error))
+    {
+      g_message ("Execution of main.js threw exception: %s", error->message);
+      g_error_free (error);
+
+      return status;
+    }
+
+  return 0;
+}
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
new file mode 100644
index 0000000..b56e35f
--- /dev/null
+++ b/src/gnome-maps.data.gresource.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/maps">
+       <file preprocess="xml-stripblanks">app-menu.ui</file>
+       <file preprocess="xml-stripblanks">main-window.ui</file>
+       <file preprocess="xml-stripblanks">zoom-control.ui</file>
+       <file preprocess="xml-stripblanks">search-popup.ui</file>
+       <file preprocess="xml-stripblanks">context-menu.ui</file>
+       <file alias="application.css">../data/gnome-maps.css</file>
+       <file alias="zoom-in.png">../data/media/zoom-in.png</file>
+       <file alias="zoom-out.png">../data/media/zoom-out.png</file>
+       <file alias="zoom-in-insensitive.png">../data/media/zoom-in-insensitive.png</file>
+       <file alias="zoom-out-insensitive.png">../data/media/zoom-out-insensitive.png</file>
+  </gresource>
+</gresources>
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
new file mode 100644
index 0000000..66900b4
--- /dev/null
+++ b/src/gnome-maps.js.gresource.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/maps">
+    <file>application.js</file>
+    <file>contextMenu.js</file>
+    <file>geoclue.js</file>
+    <file>main.js</file>
+    <file>mainWindow.js</file>
+    <file>mapLocation.js</file>
+    <file>mapView.js</file>
+    <file>placeStore.js</file>
+    <file>searchPopup.js</file>
+    <file>settings.js</file>
+    <file>sidebar.js</file>
+    <file>userLocation.js</file>
+    <file>utils.js</file>
+    <file>zoomControl.js</file>
+  </gresource>
+</gresources>


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