libgimp, meson: Port make-in-build-typelib to Python and fix build order
Seems this was the last .sh script pending to ported. Since I was experiencing problems with the .sh one (not working locally nor on HomeBrew), I just ported. Now, it is easier to read and fix if needed. I also fixed the build order on libgimp meson.build to ensure the patched .typelib being always present at the time GIMP generate splash screen etc.
This commit is contained in:
parent
391008e42f
commit
a99910217a
4 changed files with 59 additions and 42 deletions
35
libgimp/make-in-build-typelib.py
Normal file
35
libgimp/make-in-build-typelib.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
# macOS-only script to generate temporary .gir then .typelib files only to be
|
||||
# used during build, pointing to the non-installed libgimp* .dylib libraries.
|
||||
# This is needed because .typelib have path references to .dylib so we patch in
|
||||
# a similar way we path GIMP_TEMP_UPDATE_RPATH binaries from tools/in-build-gimp.py
|
||||
from datetime import datetime
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Arguments to this script:
|
||||
gir_name = os.path.basename(sys.argv[1])
|
||||
typelib_name = os.path.basename(sys.argv[2])
|
||||
builddir = sys.argv[3]
|
||||
prefix = sys.argv[4]
|
||||
|
||||
print("PWD:", os.getcwd())
|
||||
print("ARGS:", " ".join(sys.argv[1:]))
|
||||
|
||||
# This is only for macOS (see the rationale in the comment above).
|
||||
tmp_gir_dir = Path(builddir) / "tmp"
|
||||
tmp_gir_dir.mkdir(parents=True, exist_ok=True)
|
||||
tmp_gir_path = Path(f"{tmp_gir_dir}/{gir_name}")
|
||||
shutil.copy2(Path(f"{builddir}/{gir_name}"), tmp_gir_path)
|
||||
|
||||
text = Path(tmp_gir_path).read_text()
|
||||
text = re.sub(r'shared-library="([^"]+)"', lambda m: 'shared-library="' + ",".join("libgimp/" + os.path.basename(p) for p in m.group(1).split(",")) + '"', text)
|
||||
Path(tmp_gir_path).write_text(text)
|
||||
subprocess.run(["g-ir-compiler", f"--includedir={tmp_gir_dir}", f"--includedir={prefix}/share/gir-1.0/", str(tmp_gir_path), "-o", tmp_gir_dir / typelib_name], check=True)
|
||||
|
||||
stamp_path = Path(f"{builddir}/{gir_name}-macos-typelib.stamp")
|
||||
stamp_path.write_text(f"/* Generated on {datetime.now().strftime('%c')}. */\n")
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#!/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
|
||||
|
|
@ -564,6 +564,17 @@ else
|
|||
install: true,
|
||||
)
|
||||
|
||||
if platform_osx
|
||||
patched_libgimp_gir = custom_target('libgimp-macos-typelib.stamp',
|
||||
output: [ 'libgimp-macos-typelib.stamp' ],
|
||||
depends: [ libgimp_gir ],
|
||||
command: [
|
||||
'make-in-build-typelib.py', libgimp_gir,
|
||||
meson.current_build_dir(), prefix, g_ir_compiler
|
||||
],
|
||||
build_by_default: true)
|
||||
endif
|
||||
|
||||
libgimpui_gir = gnome.generate_gir(
|
||||
libgimpui,
|
||||
libgimpwidgets,
|
||||
|
|
@ -582,14 +593,14 @@ else
|
|||
)
|
||||
|
||||
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)
|
||||
patched_libgimpui_gir = custom_target('libgimpui-macos-typelib.stamp',
|
||||
output: [ 'libgimpui-macos-typelib.stamp' ],
|
||||
depends: [ libgimp_gir, libgimpui_gir ],
|
||||
command: [
|
||||
'make-in-build-typelib.py', libgimpui_gir,
|
||||
meson.current_build_dir(), prefix, g_ir_compiler
|
||||
],
|
||||
build_by_default: true)
|
||||
endif
|
||||
|
||||
if have_vala
|
||||
|
|
|
|||
|
|
@ -1238,6 +1238,10 @@ desktop_validate = find_program('desktop-file-validate', required: false)
|
|||
|
||||
appstreamcli = find_program('appstreamcli', version: '>=0.15.3', required: get_option('appdata-test'))
|
||||
|
||||
# Check for .typelib generation tools
|
||||
|
||||
g_ir_compiler = find_program('g-ir-compiler')
|
||||
|
||||
# Check for doc generation tools
|
||||
|
||||
gi_docgen = find_program('gi-docgen', required: get_option('gi-docgen'))
|
||||
|
|
@ -1969,7 +1973,7 @@ if meson.can_run_host_binaries() and have_gobject_introspection
|
|||
gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpthumb')
|
||||
gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpwidgets')
|
||||
elif platform_osx
|
||||
gimp_exe_depends += [gimp_exe_typelib]
|
||||
gimp_exe_depends += [patched_libgimp_gir, patched_libgimpui_gir]
|
||||
|
||||
gimp_run_env.set('GIMP_GI_DIR', gi.get_variable('libdir'))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue