mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Patch by John Ralls. Permits binreloc to work from inside a MacOSX application bundle.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18207 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cd3df9ae82
commit
afe64deb46
@ -10,6 +10,7 @@ AM_CPPFLAGS = \
|
|||||||
-I${top_srcdir}/src/gnc-module \
|
-I${top_srcdir}/src/gnc-module \
|
||||||
-I${top_srcdir}/src/libqof/qof \
|
-I${top_srcdir}/src/libqof/qof \
|
||||||
${GLIB_CFLAGS} \
|
${GLIB_CFLAGS} \
|
||||||
|
${IGE_MAC_CFLAGS} \
|
||||||
${GUILE_INCS}
|
${GUILE_INCS}
|
||||||
|
|
||||||
libgncmod_engine_la_SOURCES = \
|
libgncmod_engine_la_SOURCES = \
|
||||||
@ -116,6 +117,7 @@ libgncmod_engine_la_LIBADD = \
|
|||||||
${REGEX_LIBS} \
|
${REGEX_LIBS} \
|
||||||
${GLIB_LIBS} \
|
${GLIB_LIBS} \
|
||||||
${BINRELOC_LIBS} \
|
${BINRELOC_LIBS} \
|
||||||
|
${IGE_MAC_LIBS} \
|
||||||
${top_builddir}/lib/libc/libc-missing.la
|
${top_builddir}/lib/libc/libc-missing.la
|
||||||
|
|
||||||
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
|
gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef MAC_INTEGRATION
|
||||||
|
#include <igemacintegration/ige-mac-bundle.h>
|
||||||
|
#endif
|
||||||
#endif /* ENABLE_BINRELOC */
|
#endif /* ENABLE_BINRELOC */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -27,7 +30,9 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
|
||||||
|
static IgeMacBundle *bundle = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @internal
|
/** @internal
|
||||||
* Find the canonical filename of the executable. Returns the filename
|
* Find the canonical filename of the executable. Returns the filename
|
||||||
@ -60,6 +65,26 @@ _br_find_exe (GbrInitError *error)
|
|||||||
(char*)NULL);
|
(char*)NULL);
|
||||||
g_free (prefix);
|
g_free (prefix);
|
||||||
return result;
|
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
|
#else
|
||||||
char *path, *path2, *line, *result;
|
char *path, *path2, *line, *result;
|
||||||
size_t buf_size;
|
size_t buf_size;
|
||||||
@ -201,7 +226,7 @@ _br_find_exe_for_symbol (const void *symbol, GbrInitError *error)
|
|||||||
*error = GBR_INIT_ERROR_DISABLED;
|
*error = GBR_INIT_ERROR_DISABLED;
|
||||||
return (char *) NULL;
|
return (char *) NULL;
|
||||||
#else
|
#else
|
||||||
#ifdef G_OS_WIN32
|
#if defined G_OS_WIN32
|
||||||
g_warning ("_br_find_exe_for_symbol not implemented on win32.");
|
g_warning ("_br_find_exe_for_symbol not implemented on win32.");
|
||||||
if (error)
|
if (error)
|
||||||
*error = GBR_INIT_ERROR_DISABLED;
|
*error = GBR_INIT_ERROR_DISABLED;
|
||||||
@ -390,6 +415,12 @@ set_gerror (GError **error, GbrInitError errcode)
|
|||||||
case GBR_INIT_ERROR_INVALID_MAPS:
|
case GBR_INIT_ERROR_INVALID_MAPS:
|
||||||
error_message = "The file format of /proc/self/maps is invalid.";
|
error_message = "The file format of /proc/self/maps is invalid.";
|
||||||
break;
|
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:
|
case GBR_INIT_ERROR_DISABLED:
|
||||||
error_message = "Binary relocation support is disabled.";
|
error_message = "Binary relocation support is disabled.";
|
||||||
break;
|
break;
|
||||||
@ -473,6 +504,21 @@ gbr_find_prefix (const gchar *default_prefix)
|
|||||||
{
|
{
|
||||||
gchar *dir1, *dir2;
|
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) {
|
if (exe == NULL) {
|
||||||
/* BinReloc not initialized. */
|
/* BinReloc not initialized. */
|
||||||
if (default_prefix != NULL)
|
if (default_prefix != NULL)
|
||||||
@ -480,11 +526,11 @@ gbr_find_prefix (const gchar *default_prefix)
|
|||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir1 = g_path_get_dirname (exe);
|
dir1 = g_path_get_dirname (exe);
|
||||||
dir2 = g_path_get_dirname (dir1);
|
dir2 = g_path_get_dirname (dir1);
|
||||||
g_free (dir1);
|
g_free (dir1);
|
||||||
return dir2;
|
return dir2;
|
||||||
|
#endif //ENABLE_BINRELOC && MAC_INTEGRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -505,6 +551,19 @@ gchar *
|
|||||||
gbr_find_bin_dir (const gchar *default_bin_dir)
|
gbr_find_bin_dir (const gchar *default_bin_dir)
|
||||||
{
|
{
|
||||||
gchar *prefix, *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);
|
prefix = gbr_find_prefix (NULL);
|
||||||
if (prefix == NULL) {
|
if (prefix == NULL) {
|
||||||
@ -518,6 +577,7 @@ gbr_find_bin_dir (const gchar *default_bin_dir)
|
|||||||
dir = g_build_filename (prefix, "bin", NULL);
|
dir = g_build_filename (prefix, "bin", NULL);
|
||||||
g_free (prefix);
|
g_free (prefix);
|
||||||
return dir;
|
return dir;
|
||||||
|
#endif //ENABLE_BINRELOC && MAC_INTEGRATION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,10 @@ typedef enum {
|
|||||||
GBR_INIT_ERROR_READ_MAPS,
|
GBR_INIT_ERROR_READ_MAPS,
|
||||||
/** The file format of /proc/self/maps is invalid; kernel bug? */
|
/** The file format of /proc/self/maps is invalid; kernel bug? */
|
||||||
GBR_INIT_ERROR_INVALID_MAPS,
|
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). */
|
/** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */
|
||||||
GBR_INIT_ERROR_DISABLED
|
GBR_INIT_ERROR_DISABLED
|
||||||
} GbrInitError;
|
} GbrInitError;
|
||||||
|
Loading…
Reference in New Issue
Block a user