From 3e980d5ad4b82976a7a65603d96b283ad9e8af07 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 14 Apr 2024 16:20:39 +0200 Subject: [PATCH] libgimp: generate build-only GIR/Typelib variants for macOS. The previous commit worked for all the compiled executables, but for Python plug-ins (and likely all other GObject-Introspected bindings), we need to generate a temporary typelib linking to the in-build-directory libgimp* libraries. This is similar to what the script `package/macports_build_app.sh` does for packaging in gimp-macos-build repository. --- libgimp/make-in-build-typelib.sh | 33 ++++++++++++++++++++++++++++++++ libgimp/meson.build | 11 +++++++++++ meson.build | 15 ++++++++++----- 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 libgimp/make-in-build-typelib.sh diff --git a/libgimp/make-in-build-typelib.sh b/libgimp/make-in-build-typelib.sh new file mode 100644 index 0000000000..5a88fab32c --- /dev/null +++ b/libgimp/make-in-build-typelib.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# macOS-only script to generate temporary .gir and .typelib files only to be +# used during build, pointing to the non-installed libgimp* libraries. +# This allows to run non-installed GIMP binaries in a macOS development +# environment. + +gimp_gir="$1" +gimp_typelib="$2" +gimpui_gir="$3" +gimpui_typelib="$4" +builddir="$5" +prefix="$6" +g_ir_compiler="$7" + +echo PWD: $PWD +echo ARGS: "$*" + +# This is only for macOS. +mkdir -p $builddir/tmp/ +cp -f "$gimp_gir" "$gimpui_gir" "$builddir/tmp/" +cd "$builddir/tmp/" +gimp_gir=`basename "$gimp_gir"` +gimpui_gir=`basename "$gimpui_gir"` +gimp_typelib=`basename "$gimp_typelib"` +gimpui_typelib=`basename "$gimpui_typelib"` + +sed -i '' "s|${prefix}/*||g" "$gimp_gir" "$gimpui_gir" +sed -i '' "s|@rpath/||g" "$gimp_gir" "$gimpui_gir" +sed -i '' 's|lib/\(libgimp\(ui\)\?-\([0-9.]*\).dylib\)|libgimp/\1|g; s|lib/\(libgimp\([a-z]*\)-\([0-9.]*\).dylib\)|libgimp\2/\1|g;' "$gimp_gir" "$gimpui_gir" +$g_ir_compiler --includedir=${prefix}/share/gir-1.0/ --includedir=. "$gimp_gir" -o "${gimp_typelib}" +$g_ir_compiler --includedir=${prefix}/share/gir-1.0/ --includedir=. "$gimpui_gir" -o "${gimpui_typelib}" + +echo "/* Generated on `date`. */" > $builddir/macos-typelib.stamp diff --git a/libgimp/meson.build b/libgimp/meson.build index bc9727e2b5..91d91d9b48 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -521,6 +521,17 @@ else install: true, ) + if platform_osx + g_ir_compiler = find_program('g-ir-compiler') + gimp_exe_typelib = custom_target('macos-typelib.stamp', + output: [ 'macos-typelib.stamp' ], + command: [ + 'make-in-build-typelib.sh', libgimp_gir, libgimpui_gir, + meson.current_build_dir(), prefix, g_ir_compiler + ], + build_by_default: true) + endif + if have_vala vapi_deps = [ 'babl-0.1', diff --git a/meson.build b/meson.build index c1f74b06ff..4afe9f24ff 100644 --- a/meson.build +++ b/meson.build @@ -1846,11 +1846,12 @@ gimp_run_env=environment() if meson.can_run_host_binaries() if enable_console_bin - gimp_exe_depends = gimpconsole_exe + gimp_real_exe = gimpconsole_exe else - gimp_exe_depends = gimpmain_exe + gimp_real_exe = gimpmain_exe endif - gimp_run_env.set('GIMP_SELF_IN_BUILD', gimp_exe_depends.full_path()) + gimp_exe_depends = [gimp_real_exe] + gimp_run_env.set('GIMP_SELF_IN_BUILD', gimp_real_exe.full_path()) menu_paths=meson.global_build_root() / 'menus:' + meson.global_source_root() / 'menus' gimp_run_env.set('GIMP_TESTING_MENUS_PATH', menu_paths) @@ -1863,7 +1864,11 @@ if meson.can_run_host_binaries() gimp_run_env.set('GIMP_TESTING_ENVIRON_DIRS', meson.global_source_root() / 'data/environ/') gimp_run_env.prepend('GI_TYPELIB_PATH', prefix / 'lib/girepository-1.0/') - gimp_run_env.prepend('GI_TYPELIB_PATH', meson.global_build_root() / 'libgimp') + if platform_osx + gimp_run_env.prepend('GI_TYPELIB_PATH', meson.global_build_root() / 'libgimp/tmp') + else + gimp_run_env.prepend('GI_TYPELIB_PATH', meson.global_build_root() / 'libgimp') + endif gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimp') gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpbase') @@ -1891,7 +1896,7 @@ if meson.can_run_host_binaries() gimp_run_env.set('GIMP_GI_DIR', gi.get_variable('libdir')) - gimp_run_env.set('GIMP_TEMP_UPDATE_RPATH', gimp_exe_depends.full_path()) + gimp_run_env.set('GIMP_TEMP_UPDATE_RPATH', gimp_real_exe.full_path()) gimp_run_env.prepend('GIMP_TEMP_UPDATE_RPATH', libgimp.full_path()) gimp_run_env.prepend('GIMP_TEMP_UPDATE_RPATH', libgimpbase.full_path()) gimp_run_env.prepend('GIMP_TEMP_UPDATE_RPATH', libgimpcolor.full_path())