[gjs] console: Only use basic GJS API <gjs/gjs.h> and link against GLib



commit c9f30e1b5f7eefe71d65326341661fc0500200d9
Author: Colin Walters <walters verbum org>
Date:   Fri Oct 22 11:05:46 2010 -0400

    console: Only use basic GJS API <gjs/gjs.h> and link against GLib
    
    We need to link explicitly against GObject, since we use The
    commit 25681375970de9 intentionally removed the dependency on all
    the "internal" GJS libraries like libmozjs.so from gjs-console,
    but first, we need to explicitly link against libgobject, because
    we do use it.
    
    Secondly, to make things more clear here, drop the random unnecessary
    use of "internal" GJS API like gjs_debug and gjs_memory_report (
    the memory report could be an environment variable).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632844

 Makefile.am   |    3 ++-
 configure.ac  |    1 +
 gjs/console.c |   15 ++++-----------
 3 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 5f512fa..c9978cb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -119,8 +119,9 @@ bin_PROGRAMS += gjs-console
 
 gjs_console_CFLAGS = 		\
 	$(AM_CFLAGS)		\
-	$(GJS_CFLAGS)
+        $(GOBJECT_CFLAGS)
 gjs_console_LDADD =		\
+         $(GOBJECT_LIBS)           \
          libgjs.la
 gjs_console_LDFLAGS = -R $(FIREFOX_JS_LIBDIR) -rdynamic
 gjs_console_SOURCES = gjs/console.c
diff --git a/configure.ac b/configure.ac
index 22bfad0..0c6aad8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,6 +195,7 @@ gjs_dbus_packages="dbus-glib-1 $common_packages"
 # gjs-tests links against everything
 gjstests_packages="$gjstests_packages $gjs_packages"
 
+PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= gobject_required_version])
 PKG_CHECK_MODULES([GJS], [$gjs_packages])
 PKG_CHECK_MODULES([GJS_GI], [$gjs_gi_packages])
 PKG_CHECK_MODULES([GJS_CAIRO], [$gjs_cairo_packages])
diff --git a/gjs/console.c b/gjs/console.c
index 2ce5c12..652df63 100644
--- a/gjs/console.c
+++ b/gjs/console.c
@@ -26,9 +26,7 @@
 #include <stdlib.h>
 #include <locale.h>
 
-#include <util/log.h>
-#include <gjs/gjs-module.h>
-#include <gjs/compat.h>
+#include <gjs/gjs.h>
 
 static char **include_path = NULL;
 static char *command = NULL;
@@ -58,7 +56,7 @@ main(int argc, char **argv)
     /* pass unknown through to the JS script */
     g_option_context_set_ignore_unknown_options(context, TRUE);
 
-    g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+    g_option_context_add_main_entries(context, entries, NULL);
     if (!g_option_context_parse(context, &argc, &argv, &error))
         g_error("option parsing failed: %s", error->message);
 
@@ -66,11 +64,10 @@ main(int argc, char **argv)
     g_type_init();
 
     command_line = g_strjoinv(" ", argv);
-    gjs_debug(GJS_DEBUG_LOG, "Command line: %s", command_line);
+    g_debug("Command line: %s", command_line);
     g_free(command_line);
 
-    gjs_debug(GJS_DEBUG_CONTEXT,
-              "Creating new context to eval console script");
+    g_debug("Creating new context to eval console script");
     js_context = gjs_context_new_with_search_path(include_path);
 
     /* prepare command line arguments */
@@ -107,10 +104,6 @@ main(int argc, char **argv)
         exit(1);
     }
 
-    gjs_memory_report("before destroying context", FALSE);
-    g_object_unref(js_context);
-    gjs_memory_report("after destroying context", TRUE);
-
     g_free(script);
     exit(code);
 }



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