From b570c19fc01040c32840406be7f47ac6c6858c0f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Feb 2017 23:29:13 +0100 Subject: Update Mac bundling --- osx/bundleify.sh | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'osx/bundleify.sh') diff --git a/osx/bundleify.sh b/osx/bundleify.sh index a9a6cf1..3806bd2 100755 --- a/osx/bundleify.sh +++ b/osx/bundleify.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ "$#" != 3 ]; then echo "USAGE: $0 LIB_PREFIX BUNDLE EXE"; @@ -17,38 +17,54 @@ sed -i '' 's/GDK_CONTROL_MASK/GDK_META_MASK/' $bundle/Contents/patchage.ui # Copy font configuration files cp $prefix/etc/fonts/fonts.conf $bundle/Contents/Resources -# Copy GTK and pango modules to bundle +# Copy GTK and pango modules mkdir -p "$bundle/Contents/lib/modules" mkdir -p "$bundle/Contents/lib/gtk-2.0/engines" cp $prefix/lib/gtk-2.0/2.10.0/engines/libquartz.so $bundle/Contents/lib/gtk-2.0/engines -cp $prefix/lib/pango/1.8.0/modules/*basic*.so $bundle/Contents/lib/modules +cp $(find /usr/local/Cellar/pango -name '*basic-coretext*') $bundle/Contents/lib/modules # Copy GdkPixbuf loaders mkdir -p $bundle/Contents/lib/gdk-pixbuf-2.0/2.10.0/loaders/ for fmt in icns png; do - cp $prefix/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-$fmt.so \ - $bundle/Contents/lib/gdk-pixbuf-2.0/2.10.0/loaders/; + cp $prefix/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-$fmt.so \ + $bundle/Contents/lib/gdk-pixbuf-2.0/2.10.0/loaders/; done +chmod -R 755 $bundle/Contents/lib/* + # Copy libraries depended on by the executable to bundle -libs="`otool -L $exe | grep '\.dylib\|\.so' | grep '/User\|/opt/local\|/usr/local' | sed 's/(.*//'`" +libs="`otool -L $exe | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//'`" for l in $libs; do - cp $l $bundle/Contents/lib + cp $l $bundle/Contents/lib/; done +chmod 755 $bundle/Contents/lib/* -# Add libraries depended on by those libraries -reclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/gtk-2.0/engines/* $bundle/Contents/lib/modules/* $bundle/Contents/lib/gdk-pixbuf-2.0/2.10.0/loaders/* | grep '\.dylib\|\.so' | grep \"$prefix\|/User\|/opt/local\|/usr/local\" | sed 's/(.*//'`" -for l in $reclibs; do - cp $l $bundle/Contents/lib -done +# ... recursively +while true; do + newlibs=$libs + + # Copy all libraries this library depends on to bundle + for l in $(find $bundle -name '*.dylib' -or -name '*.so'); do + reclibs="`otool -L $l | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//'`" + for rl in $reclibs; do + cp $rl $bundle/Contents/lib/; + done + chmod 755 $bundle/Contents/lib/* + newlibs=$(echo "$newlibs"; echo "$reclibs") + done -# ... and libraries depended on by those libraries (yes, this should be done more sanely) -recreclibs="`otool -L $bundle/Contents/lib/* $bundle/Contents/lib/gtk-2.0/engines/* $bundle/Contents/lib/modules/* $bundle/Contents/lib/gdk-pixbuf-2.0/2.10.0/loaders/* | grep '\.dylib\|\.so' | grep \"$prefix\|/User\|/opt/local\|/usr/local\" | sed 's/(.*//'`" -for l in $recreclibs; do - cp $l $bundle/Contents/lib + # Exit once we haven't added any new libraries + newlibs=$(echo "$newlibs" | sort | uniq) + if [ "$newlibs" = "$libs" ]; then + break; + fi + libs=$newlibs done -for l in $libs $reclibs $recreclibs; do +echo "Bundled libraries:" +echo "$libs" + +for l in $libs; do lname=`echo $l | sed 's/.*\///'` lid="@executable_path/lib/$lname" lpath="$bundle/Contents/lib/$lname" -- cgit v1.2.1