mirror of https://github.com/GNOME/gimp.git
macos: support for homebrew build
Supports running gimp in homebrew builds which have more complex structures of where things are placed.
This commit is contained in:
parent
177bb822b6
commit
271435534f
31
app/main.c
31
app/main.c
|
@ -334,12 +334,13 @@ gimp_macos_setenv (const char * progname)
|
|||
*/
|
||||
static gboolean show_playground = TRUE;
|
||||
|
||||
gchar *path;
|
||||
gchar *tmp;
|
||||
gchar *app_dir;
|
||||
gchar *res_dir;
|
||||
size_t path_len;
|
||||
struct stat sb;
|
||||
gchar *path;
|
||||
gchar *tmp;
|
||||
gchar *app_dir;
|
||||
gchar *res_dir;
|
||||
size_t path_len;
|
||||
struct stat sb;
|
||||
gboolean need_pythonhome = TRUE;
|
||||
|
||||
app_dir = g_path_get_dirname (resolved_path);
|
||||
tmp = g_strdup_printf ("%s/../Resources", app_dir);
|
||||
|
@ -371,6 +372,15 @@ gimp_macos_setenv (const char * progname)
|
|||
}
|
||||
}
|
||||
|
||||
/* Detect we were built in homebrew for MacOS */
|
||||
tmp = g_strdup_printf ("%s/Frameworks/Python.framework", res_dir);
|
||||
if (tmp && !stat (tmp, &sb) && S_ISDIR (sb.st_mode))
|
||||
{
|
||||
g_print ("GIMP was built with homebrew\n");
|
||||
need_pythonhome = FALSE;
|
||||
}
|
||||
g_free (tmp);
|
||||
|
||||
path_len = strlen (g_getenv ("PATH") ? g_getenv ("PATH") : "") + strlen (app_dir) + 2;
|
||||
path = g_try_malloc (path_len);
|
||||
if (path == NULL)
|
||||
|
@ -400,9 +410,12 @@ gimp_macos_setenv (const char * progname)
|
|||
tmp = g_strdup_printf ("%s/etc/fonts", res_dir);
|
||||
g_setenv ("FONTCONFIG_PATH", tmp, TRUE);
|
||||
g_free (tmp);
|
||||
tmp = g_strdup_printf ("%s", res_dir);
|
||||
g_setenv ("PYTHONHOME", tmp, TRUE);
|
||||
g_free (tmp);
|
||||
if (need_pythonhome)
|
||||
{
|
||||
tmp = g_strdup_printf ("%s", res_dir);
|
||||
g_setenv ("PYTHONHOME", tmp, TRUE);
|
||||
g_free (tmp);
|
||||
}
|
||||
tmp = g_strdup_printf ("%s/lib/python3.9", res_dir);
|
||||
g_setenv ("PYTHONPATH", tmp, TRUE);
|
||||
g_free (tmp);
|
||||
|
|
|
@ -441,6 +441,31 @@ gimp_installation_directory (void)
|
|||
g_free (tmp2);
|
||||
g_free (tmp3);
|
||||
}
|
||||
else if (strstr (basepath, "/Cellar/"))
|
||||
{
|
||||
/* we are running from a Python.framework bundle built in homebrew
|
||||
* during the build phase
|
||||
*/
|
||||
|
||||
gchar *fulldir = g_strdup (basepath);
|
||||
gchar *lastdir = g_path_get_basename (fulldir);
|
||||
gchar *tmp_fulldir;
|
||||
|
||||
while (strcmp (lastdir, "Cellar"))
|
||||
{
|
||||
tmp_fulldir = g_path_get_dirname (fulldir);
|
||||
|
||||
g_free (lastdir);
|
||||
g_free (fulldir);
|
||||
|
||||
fulldir = tmp_fulldir;
|
||||
lastdir = g_path_get_basename (fulldir);
|
||||
}
|
||||
toplevel = g_path_get_dirname (fulldir);
|
||||
|
||||
g_free (fulldir);
|
||||
g_free (lastdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if none of the above match, we assume that we are really in a bundle */
|
||||
|
|
Loading…
Reference in New Issue