From 6a35db6ec2d530f3ef0cc68b03f45be59cc34c51 Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Sat, 21 Mar 2026 17:56:06 -0300 Subject: [PATCH] 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. --- build/macos/1_build-deps-macports.sh | 1 - ...ts-meson-plug-ins-Patch-macOS-bundle.patch | 49 ------------------- libgimpbase/gimpenv.c | 31 ++++++++++-- 3 files changed, 28 insertions(+), 53 deletions(-) delete mode 100644 build/macos/patches/0001-app-libgimpwidgets-meson-plug-ins-Patch-macOS-bundle.patch diff --git a/build/macos/1_build-deps-macports.sh b/build/macos/1_build-deps-macports.sh index 849bf2cf31..a81cdf55a2 100644 --- a/build/macos/1_build-deps-macports.sh +++ b/build/macos/1_build-deps-macports.sh @@ -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" diff --git a/build/macos/patches/0001-app-libgimpwidgets-meson-plug-ins-Patch-macOS-bundle.patch b/build/macos/patches/0001-app-libgimpwidgets-meson-plug-ins-Patch-macOS-bundle.patch deleted file mode 100644 index 72e13cc4c8..0000000000 --- a/build/macos/patches/0001-app-libgimpwidgets-meson-plug-ins-Patch-macOS-bundle.patch +++ /dev/null @@ -1,49 +0,0 @@ -From f4a107250cc0d7d29fb1f55c8652dff219e663dc Mon Sep 17 00:00:00 2001 -From: Bruno Lopes -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) - diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c index 8961ad68ba..0ccfa3d721 100644 --- a/libgimpbase/gimpenv.c +++ b/libgimpbase/gimpenv.c @@ -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]; }