build/macos, libgimpbase: Support both in-house and CircleCI relocatable bundles

This was the last patch. Now, GIMP can finally be built without patches on Mac.
This commit is contained in:
Bruno Lopes 2026-03-21 17:56:06 -03:00
parent 16fc8d6306
commit 6a35db6ec2
3 changed files with 28 additions and 53 deletions

View file

@ -53,7 +53,6 @@ else
brew install --quiet $(tr '\\' '\n' < build/macos/all-deps-uni.txt | grep -v '#' | sed -n 's/.*|homebrew://p' | awk '{print $1}' | xargs)
git apply -v build/macos/patches/0001-build-macos-Do-not-require-gexiv2-0.14-on-homebrew.patch || true
fi
git apply -v build/macos/patches/0001-app-libgimpwidgets-meson-plug-ins-Patch-macOS-bundle.patch || true
printf "\e[0Ksection_end:`date +%s`:deps_install\r\e[0K\n"

View file

@ -1,49 +0,0 @@
From f4a107250cc0d7d29fb1f55c8652dff219e663dc Mon Sep 17 00:00:00 2001
From: Bruno Lopes <brunvonlope@outlook.com>
Date: Sat, 21 Mar 2026 14:51:17 -0300
Subject: [PATCH] app, libgimpwidgets, meson, plug-ins: Patch macOS bundle
---
libgimpbase/gimpenv.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 8961ad68ba..ba10796164 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -434,17 +434,18 @@ gimp_installation_directory (void)
{
NSAutoreleasePool *pool;
- NSString *resource_path;
+ NSString *app_path;
+ gchar *app_gpath;
gchar *basename;
gchar *basepath;
gchar *dirname;
pool = [[NSAutoreleasePool alloc] init];
- resource_path = [[NSBundle mainBundle] resourcePath];
+ app_path = [[NSBundle mainBundle] bundlePath];
- basename = g_path_get_basename ([resource_path UTF8String]);
- basepath = g_path_get_dirname ([resource_path UTF8String]);
+ basename = g_path_get_basename ([app_path UTF8String]);
+ basepath = g_path_get_dirname ([app_path UTF8String]);
dirname = g_path_get_basename (basepath);
if (! strcmp (basename, ".libs"))
@@ -507,7 +508,8 @@ gimp_installation_directory (void)
{
/* if none of the above match, we assume that we are really in a bundle */
- toplevel = g_strdup ([resource_path UTF8String]);
+ app_gpath = g_strdup ([app_path UTF8String]);
+ toplevel = g_strconcat (app_gpath, "/Contents", NULL);
}
g_free (basename);
--
2.50.1 (Apple Git-155)

View file

@ -435,6 +435,8 @@ gimp_installation_directory (void)
{
NSAutoreleasePool *pool;
NSString *resource_path;
gchar *resource_path_test;
NSString *app_path;
gchar *basename;
gchar *basepath;
gchar *dirname;
@ -442,9 +444,22 @@ gimp_installation_directory (void)
pool = [[NSAutoreleasePool alloc] init];
resource_path = [[NSBundle mainBundle] resourcePath];
app_path = [[NSBundle mainBundle] bundlePath];
basename = g_path_get_basename ([resource_path UTF8String]);
basepath = g_path_get_dirname ([resource_path UTF8String]);
resource_path_test = g_build_filename([resource_path UTF8String], "share",
GIMP_PACKAGE, GIMP_DATA_VERSION, NULL);
if (g_file_test (resource_path_test, G_FILE_TEST_IS_DIR))
{
/* Legacy CircleCI era relocatable code */
basename = g_path_get_basename ([resource_path UTF8String]);
basepath = g_path_get_dirname ([resource_path UTF8String]);
}
else
{
/* Modern GitLab CI era relocatable code */
basename = g_path_get_basename ([app_path UTF8String]);
basepath = g_path_get_dirname ([app_path UTF8String]);
}
dirname = g_path_get_basename (basepath);
if (! strcmp (basename, ".libs"))
@ -507,12 +522,22 @@ gimp_installation_directory (void)
{
/* if none of the above match, we assume that we are really in a bundle */
toplevel = g_strdup ([resource_path UTF8String]);
if (g_file_test (resource_path_test, G_FILE_TEST_IS_DIR))
{
/* Legacy CircleCI era relocatable prefix */
toplevel = g_strdup ([resource_path UTF8String]);
}
else
{
/* Modern GitLab CI era relocatable prefix */
toplevel = g_strconcat ([app_path UTF8String], "/Contents", NULL);
}
}
g_free (basename);
g_free (basepath);
g_free (dirname);
g_free (resource_path_test);
[pool drain];
}