fortrangoingonforty/sniffly / 80039e3

Browse files

fix this a bit

Authored by espadonne
SHA
80039e35c28170732b85b0eddbc3476ef9ca331d
Parents
ef8222c
Tree
034171e

1 changed file

StatusFile+-
M scripts/bundle-libs.sh 25 19
scripts/bundle-libs.shmodified
@@ -56,23 +56,15 @@ cp -v /opt/homebrew/opt/fribidi/lib/libfribidi.0.dylib "$FRAMEWORKS/" 2>/dev/nul
5656
 cp -v /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib "$FRAMEWORKS/" 2>/dev/null || true
5757
 cp -v /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib "$FRAMEWORKS/" 2>/dev/null || true
5858
 
59
-# GFortran runtime (dylibbundler can't handle this due to header padding)
60
-echo "Manually copying GFortran runtime..."
61
-cp -v /opt/homebrew/opt/gcc/lib/gcc/current/libgfortran.5.dylib "$FRAMEWORKS/" 2>/dev/null || \
62
-  cp -v /usr/local/lib/gcc/current/libgfortran.5.dylib "$FRAMEWORKS/" 2>/dev/null || true
63
-cp -v /opt/homebrew/opt/gcc/lib/gcc/current/libgcc_s.1.1.dylib "$FRAMEWORKS/" 2>/dev/null || \
64
-  cp -v /usr/local/lib/gcc/current/libgcc_s.1.1.dylib "$FRAMEWORKS/" 2>/dev/null || true
65
-cp -v /opt/homebrew/opt/gcc/lib/gcc/current/libquadmath.0.dylib "$FRAMEWORKS/" 2>/dev/null || \
66
-  cp -v /usr/local/lib/gcc/current/libquadmath.0.dylib "$FRAMEWORKS/" 2>/dev/null || true
67
-
68
-# Fix paths in sniffly-bin to point to bundled gfortran
69
-echo "Fixing GFortran library paths in binary..."
70
-install_name_tool -change /opt/homebrew/opt/gcc/lib/gcc/current/libgfortran.5.dylib @executable_path/../Frameworks/libgfortran.5.dylib "$MACOS_BIN" 2>/dev/null || true
71
-install_name_tool -change /usr/local/lib/gcc/current/libgfortran.5.dylib @executable_path/../Frameworks/libgfortran.5.dylib "$MACOS_BIN" 2>/dev/null || true
72
-
7359
 echo ""
7460
 echo "Step 2: Running dylibbundler for ALL dependencies..."
61
+echo "Note: dylibbundler may fail on GFortran libraries due to Mach-O header limits."
62
+echo "      This is expected and non-fatal - the app will still work correctly."
63
+echo ""
64
+
7565
 # Use -of to overwrite and fix ALL dylibs recursively
66
+# The dylibbundler will fail on libgfortran.5.dylib due to insufficient Mach-O header padding,
67
+# but this is non-fatal. The library will still be bundled and functional.
7668
 dylibbundler -of -b \
7769
     -x "$MACOS_BIN" \
7870
     -d "$FRAMEWORKS/" \
@@ -96,10 +88,24 @@ dylibbundler -of -b \
9688
     -s /opt/homebrew/opt/pcre2/lib \
9789
     -s /opt/homebrew/opt/brotli/lib \
9890
     -s /opt/homebrew/opt/bzip2/lib \
99
-    -s /opt/homebrew/opt/zstd/lib 2>&1
91
+    -s /opt/homebrew/opt/zstd/lib 2>&1 || echo "  (dylibbundler completed with warnings - this is expected)"
92
+
93
+echo ""
94
+echo "Step 2.5: Manually fixing GFortran library references..."
95
+# dylibbundler fails to fully fix libgfortran due to header limits, so we fix remaining references manually
96
+# Fix binary's reference to libgfortran
97
+install_name_tool -change /opt/homebrew/opt/gcc/lib/gcc/current/libgfortran.5.dylib @executable_path/../Frameworks/libgfortran.5.dylib "$MACOS_BIN" 2>/dev/null || true
98
+install_name_tool -change /usr/local/lib/gcc/current/libgfortran.5.dylib @executable_path/../Frameworks/libgfortran.5.dylib "$MACOS_BIN" 2>/dev/null || true
99
+
100
+# Fix libgfortran's internal references (only if it exists and isn't fully fixed)
101
+if [ -f "$FRAMEWORKS/libgfortran.5.dylib" ]; then
102
+    # Try to fix remaining references - these might fail if header is full, but that's OK
103
+    install_name_tool -change "@rpath/libgcc_s.1.1.dylib" "@executable_path/../Frameworks/libgcc_s.1.1.dylib" "$FRAMEWORKS/libgfortran.5.dylib" 2>/dev/null || true
104
+    install_name_tool -id "@executable_path/../Frameworks/libgfortran.5.dylib" "$FRAMEWORKS/libgfortran.5.dylib" 2>/dev/null || true
105
+fi
100106
 
101107
 echo ""
102
-echo "Step 2.5: Fixing library interdependencies..."
108
+echo "Step 3: Fixing library interdependencies..."
103109
 # dylibbundler should have done this, but let's make sure all bundled libs reference each other correctly
104110
 for lib in "$FRAMEWORKS"/*.dylib; do
105111
     if [ -f "$lib" ]; then
@@ -134,14 +140,14 @@ for lib in "$FRAMEWORKS"/*.dylib; do
134140
 done
135141
 
136142
 echo ""
137
-echo "Step 3: Verifying bundle..."
143
+echo "Step 4: Verifying bundle..."
138144
 TOTAL_LIBS=$(ls -1 "$FRAMEWORKS" | wc -l | tr -d ' ')
139145
 echo "Total libraries bundled: $TOTAL_LIBS"
140146
 
141147
 # Check for critical libraries
142148
 echo ""
143149
 echo "Critical libraries check:"
144
-for lib in libgtk-4 libglib-2.0 libgtk-4-fortran libcairo libpango; do
150
+for lib in libgtk-4 libglib-2.0 libgtk-4-fortran libcairo libpango libgfortran; do
145151
     if ls "$FRAMEWORKS"/${lib}* 1> /dev/null 2>&1; then
146152
         echo "  ✓ ${lib}"
147153
     else
@@ -150,7 +156,7 @@ for lib in libgtk-4 libglib-2.0 libgtk-4-fortran libcairo libpango; do
150156
 done
151157
 
152158
 echo ""
153
-echo "Step 4: Checking binary dependencies..."
159
+echo "Step 5: Checking binary dependencies..."
154160
 otool -L "$MACOS_BIN" | grep -E "(gtk|glib|cairo)" | head -5
155161
 
156162
 echo ""