r18207 - gnucash/trunk/src/engine - Patch by John Ralls. Permits binreloc to work from inside a MacOSX application bundle.
Charles Day
cedayiv at code.gnucash.org
Mon Jul 13 16:39:44 EDT 2009
Author: cedayiv
Date: 2009-07-13 16:39:44 -0400 (Mon, 13 Jul 2009)
New Revision: 18207
Trac: http://svn.gnucash.org/trac/changeset/18207
Modified:
gnucash/trunk/src/engine/Makefile.am
gnucash/trunk/src/engine/binreloc.c
gnucash/trunk/src/engine/binreloc.h
Log:
Patch by John Ralls. Permits binreloc to work from inside a MacOSX application bundle.
Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am 2009-07-13 20:38:44 UTC (rev 18206)
+++ gnucash/trunk/src/engine/Makefile.am 2009-07-13 20:39:44 UTC (rev 18207)
@@ -10,6 +10,7 @@
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/libqof/qof \
${GLIB_CFLAGS} \
+ ${IGE_MAC_CFLAGS} \
${GUILE_INCS}
libgncmod_engine_la_SOURCES = \
@@ -116,6 +117,7 @@
${REGEX_LIBS} \
${GLIB_LIBS} \
${BINRELOC_LIBS} \
+ ${IGE_MAC_LIBS} \
${top_builddir}/lib/libc/libc-missing.la
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
Modified: gnucash/trunk/src/engine/binreloc.c
===================================================================
--- gnucash/trunk/src/engine/binreloc.c 2009-07-13 20:38:44 UTC (rev 18206)
+++ gnucash/trunk/src/engine/binreloc.c 2009-07-13 20:39:44 UTC (rev 18207)
@@ -18,6 +18,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#ifdef MAC_INTEGRATION
+#include <igemacintegration/ige-mac-bundle.h>
+#endif
#endif /* ENABLE_BINRELOC */
#include <stdio.h>
#include <stdlib.h>
@@ -27,8 +30,10 @@
#include <glib.h>
G_BEGIN_DECLS
+#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
+static IgeMacBundle *bundle = NULL;
+#endif
-
/** @internal
* Find the canonical filename of the executable. Returns the filename
* (which must be freed) or NULL on error. If the parameter 'error' is
@@ -60,6 +65,26 @@
(char*)NULL);
g_free (prefix);
return result;
+#elif MAC_INTEGRATION
+ gchar *prefix = NULL, *result = NULL;
+ g_type_init();
+ bundle = ige_mac_bundle_new();
+ if (!bundle) {
+ *error = GBR_INIT_ERROR_MAC_NOT_BUNDLE;
+ return NULL;
+ }
+ if (!ige_mac_bundle_get_is_app_bundle (bundle)) {
+ g_object_unref(bundle);
+ bundle = NULL;
+ *error = GBR_INIT_ERROR_MAC_NOT_APP_BUNDLE;
+ return NULL;
+ }
+ ige_mac_bundle_setup_environment(bundle);
+ prefix = g_strdup(ige_mac_bundle_get_path(bundle));
+ result = g_build_filename(prefix, "Contents/MacOS",
+ "gnucash-bin", NULL);
+ g_free(prefix);
+ return result;
#else
char *path, *path2, *line, *result;
size_t buf_size;
@@ -201,7 +226,7 @@
*error = GBR_INIT_ERROR_DISABLED;
return (char *) NULL;
#else
-#ifdef G_OS_WIN32
+#if defined G_OS_WIN32
g_warning ("_br_find_exe_for_symbol not implemented on win32.");
if (error)
*error = GBR_INIT_ERROR_DISABLED;
@@ -390,6 +415,12 @@
case GBR_INIT_ERROR_INVALID_MAPS:
error_message = "The file format of /proc/self/maps is invalid.";
break;
+ case GBR_INIT_ERROR_MAC_NOT_BUNDLE:
+ error_message = "Binreloc did not find a bundle";
+ break;
+ case GBR_INIT_ERROR_MAC_NOT_APP_BUNDLE:
+ error_message = "Binreloc found that the bundle is not an app bundle";
+ break;
case GBR_INIT_ERROR_DISABLED:
error_message = "Binary relocation support is disabled.";
break;
@@ -473,6 +504,21 @@
{
gchar *dir1, *dir2;
+#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
+ gchar *prefix = NULL, *result = NULL;
+ if (bundle == NULL) {
+ /* BinReloc not initialized. */
+ if (default_prefix != NULL)
+ return g_strdup (default_prefix);
+ else
+ return NULL;
+ }
+ prefix = g_strdup(ige_mac_bundle_get_path(bundle));
+ result = g_build_filename(prefix, "Contents/Resources", NULL);
+ g_free(prefix);
+ return result;
+#else
+
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_prefix != NULL)
@@ -480,11 +526,11 @@
else
return NULL;
}
-
dir1 = g_path_get_dirname (exe);
dir2 = g_path_get_dirname (dir1);
g_free (dir1);
return dir2;
+#endif //ENABLE_BINRELOC && MAC_INTEGRATION
}
@@ -505,6 +551,19 @@
gbr_find_bin_dir (const gchar *default_bin_dir)
{
gchar *prefix, *dir;
+#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
+ if (bundle == NULL) {
+ /* BinReloc not initialized. */
+ if (default_bin_dir != NULL)
+ return g_strdup (default_bin_dir);
+ else
+ return NULL;
+ }
+ prefix = g_strdup(ige_mac_bundle_get_path(bundle));
+ dir = g_build_filename(prefix, "Contents/MacOS", NULL);
+ g_free(prefix);
+ return dir;
+#else
prefix = gbr_find_prefix (NULL);
if (prefix == NULL) {
@@ -518,6 +577,7 @@
dir = g_build_filename (prefix, "bin", NULL);
g_free (prefix);
return dir;
+#endif //ENABLE_BINRELOC && MAC_INTEGRATION
}
Modified: gnucash/trunk/src/engine/binreloc.h
===================================================================
--- gnucash/trunk/src/engine/binreloc.h 2009-07-13 20:38:44 UTC (rev 18206)
+++ gnucash/trunk/src/engine/binreloc.h 2009-07-13 20:39:44 UTC (rev 18207)
@@ -28,6 +28,10 @@
GBR_INIT_ERROR_READ_MAPS,
/** The file format of /proc/self/maps is invalid; kernel bug? */
GBR_INIT_ERROR_INVALID_MAPS,
+ /** BinReloc determined that gnucash is not running from a bundle */
+ GBR_INIT_ERROR_MAC_NOT_BUNDLE,
+ /** Binreloc determined that the bundle is not an app bundle */
+ GBR_INIT_ERROR_MAC_NOT_APP_BUNDLE,
/** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */
GBR_INIT_ERROR_DISABLED
} GbrInitError;
More information about the gnucash-changes
mailing list