Make gnome-shell-extension-prefs a binary executable

Since commit 1ebb162a00 moved JS sources into resources,
the extension-prefs tool was broken. To fix it, we would either
need to generate an external GResource in addition to the generated
C code and teach gjs-console about loading it before evaluating
the script, or turn gnome-shell-extension-prefs into a binary with
the JS resources compiled in.

https://bugzilla.gnome.org/show_bug.cgi?id=722334
This commit is contained in:
Florian Müllner 2013-12-06 21:20:03 +01:00
parent 1d7354696e
commit 2dd7db4808
3 changed files with 59 additions and 23 deletions

View File

@ -29,11 +29,9 @@ CLEANFILES += $(service_DATA)
CLEANFILES += $(gir_DATA) $(typelib_DATA) CLEANFILES += $(gir_DATA) $(typelib_DATA)
bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-extension-prefs \ bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-perf-tool
gnome-shell-perf-tool EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-perf-tool.in
EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-extension-prefs.in \ bin_PROGRAMS = gnome-shell gnome-shell-extension-prefs
gnome-shell-perf-tool.in
bin_PROGRAMS = gnome-shell
if HAVE_MUTTER_WAYLAND if HAVE_MUTTER_WAYLAND
bin_PROGRAMS += gnome-shell-wayland bin_PROGRAMS += gnome-shell-wayland
@ -54,9 +52,6 @@ generated_script_substitutions = \
gnome-shell-extension-tool: gnome-shell-extension-tool.in Makefile gnome-shell-extension-tool: gnome-shell-extension-tool.in Makefile
$(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@ $(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
gnome-shell-extension-prefs: gnome-shell-extension-prefs.in Makefile
$(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
gnome-shell-perf-tool: gnome-shell-perf-tool.in Makefile gnome-shell-perf-tool: gnome-shell-perf-tool.in Makefile
$(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@ $(AM_V_GEN) sed $(generated_script_substitutions) $< > $@.tmp && mv $@.tmp $@ && chmod a+x $@
@ -209,6 +204,13 @@ gnome_shell_wayland_LDADD = libgnome-shell-wayland.la libgnome-shell-js.la $(GNO
gnome_shell_wayland_DEPENDENCIES = libgnome-shell-wayland.la gnome_shell_wayland_DEPENDENCIES = libgnome-shell-wayland.la
endif HAVE_MUTTER_WAYLAND endif HAVE_MUTTER_WAYLAND
gnome_shell_extension_prefs_SOURCES = gnome-shell-extension-prefs.c \
$(top_builddir)/js/js-resources.c \
$(top_builddir)/js/js-resources.h \
$(NULL)
gnome_shell_extension_prefs_CPPFLAGS = $(gnome_shell_cflags)
gnome_shell_extension_prefs_LDADD = libgnome-shell-js.la
######################################## ########################################
libgnome_shell_js_la_SOURCES = \ libgnome_shell_js_la_SOURCES = \

View File

@ -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/shell", 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_SHELL_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.extensionPrefs.main; Main.main(ARGV);",
-1,
"<main>",
&status,
&error))
{
g_message ("Execution of main.js threw exception: %s", error->message);
g_error_free (error);
return status;
}
return 0;
}

View File

@ -1,15 +0,0 @@
#!/bin/sh
if [ -z "$GI_TYPELIB_PATH" ]; then
export GI_TYPELIB_PATH=@pkglibdir@
else
export GI_TYPELIB_PATH=@pkglibdir@:$GI_TYPELIB_PATH
fi
if [ -z "$LD_LIBRARY_PATH" ] ; then
export LD_LIBRARY_PATH=@pkglibdir@
else
export LD_LIBRARY_PATH=@pkglibdir@:$LD_LIBRARY_PATH
fi
@GJS_CONSOLE@ -I @pkgdatadir@/js -c "const Main = imports.extensionPrefs.main; Main.main(ARGV);" "$@"