Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/linux-docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- master
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand All @@ -14,6 +15,7 @@ on:
branches:
- main
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linux-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
push:
branches: [main, master]
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
- '.github/workflows/release.yml'
pull_request:
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- master
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand All @@ -14,6 +15,7 @@ on:
branches:
- main
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nix-flake-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches: [main, master]
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand Down
102 changes: 66 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags:
- 'v*'
branches:
- 'release-binaries-04'
- 'mac-binary-02'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -240,76 +240,106 @@ jobs:
# Copy the binary
cp build/vsdf release/macos/

# Find and copy all non-system dylibs
echo "Bundling dynamic libraries..."
echo "📋 Libraries linked BEFORE bundling:"
otool -L build/vsdf
echo ""

# Get list of dynamic libraries (excluding system ones)
DYLIBS=$(otool -L build/vsdf | grep -E "(glslang|spirv-tools|ffmpeg|libav)" | awk '{print $1}')
# Recursively find and copy all non-system dylibs
echo "🔍 Finding and bundling dynamic libraries..."

for lib in $DYLIBS; do
# Function to copy a library and its dependencies
copy_lib_recursive() {
local lib="$1"
local libname=$(basename "$lib")

# Skip if already copied
if [ -f "release/macos/libs/$libname" ]; then
return
fi

# Skip system libraries
if [[ "$lib" == /System/* ]] || [[ "$lib" == /usr/lib/* ]] || [[ "$lib" == /Library/Apple/* ]]; then
return
fi

# Copy the library
if [ -f "$lib" ]; then
libname=$(basename "$lib")
if [ -f "release/macos/libs/$libname" ]; then
echo "Already copied $libname"
else
echo "Copying $libname"
cp "$lib" release/macos/libs/
fi

# Also copy any dependencies of this library
SUB_DYLIBS=$(otool -L "$lib" | grep -E "(glslang|spirv-tools|ffmpeg|libav)" | awk '{print $1}')
for sublib in $SUB_DYLIBS; do
if [ -f "$sublib" ]; then
sublibname=$(basename "$sublib")
if [ ! -f "release/macos/libs/$sublibname" ]; then
echo "Copying dependency $sublibname"
cp "$sublib" release/macos/libs/
fi
echo " → Copying $libname"
cp "$lib" release/macos/libs/

# Recursively copy dependencies of this library
otool -L "$lib" | tail -n +2 | awk '{print $1}' | while read -r dep; do
if [ -f "$dep" ]; then
copy_lib_recursive "$dep"
fi
done
fi
}

# Get initial list of libraries from the binary
otool -L build/vsdf | tail -n +2 | awk '{print $1}' | while read -r lib; do
if [ -f "$lib" ]; then
copy_lib_recursive "$lib"
fi
done

BUNDLED_COUNT=$(ls release/macos/libs/*.dylib 2>/dev/null | wc -l | xargs)
echo ""
echo "Total libraries bundled: $BUNDLED_COUNT"
echo ""

# Fix all library paths to use @rpath
echo "Fixing library paths..."
echo "🔧 Fixing library paths..."

# Set rpath on the binary to look next to the executable
install_name_tool -add_rpath "@executable_path" release/macos/vsdf
# Set rpath on the binary to look in libs/ folder next to the executable
# Only add if it doesn't already exist
if ! otool -l release/macos/vsdf | grep -q "@executable_path/libs"; then
echo " Adding @executable_path/libs to rpath"
install_name_tool -add_rpath "@executable_path/libs" release/macos/vsdf
else
echo " @executable_path/libs already in rpath"
fi

# Fix paths in the main binary
for lib in release/macos/libs/*.dylib; do
libname=$(basename "$lib")
# Find the original path in the binary
ORIG_PATH=$(otool -L release/macos/vsdf | grep "$libname" | awk '{print $1}')
if [ ! -z "$ORIG_PATH" ]; then
echo "Fixing $libname in vsdf"
install_name_tool -change "$ORIG_PATH" "@rpath/libs/$libname" release/macos/vsdf
echo " Fixing $libname in vsdf: $ORIG_PATH -> @rpath/$libname"
install_name_tool -change "$ORIG_PATH" "@rpath/$libname" release/macos/vsdf
fi
done

# Fix inter-library dependencies
for lib in release/macos/libs/*.dylib; do
libname=$(basename "$lib")
echo "Fixing paths in $libname"

# Fix the library's own id
install_name_tool -id "@rpath/libs/$libname" "$lib"
install_name_tool -id "@rpath/$libname" "$lib"

# Fix references to other bundled libraries
for otherlib in release/macos/libs/*.dylib; do
othername=$(basename "$otherlib")
ORIG_PATH=$(otool -L "$lib" | grep "$othername" | awk '{print $1}')
if [ ! -z "$ORIG_PATH" ] && [ "$ORIG_PATH" != "@rpath/libs/$othername" ]; then
install_name_tool -change "$ORIG_PATH" "@rpath/libs/$othername" "$lib"
if [ ! -z "$ORIG_PATH" ] && [ "$ORIG_PATH" != "@rpath/$othername" ]; then
echo " Fixing $othername in $libname: $ORIG_PATH -> @rpath/$othername"
install_name_tool -change "$ORIG_PATH" "@rpath/$othername" "$lib"
fi
done
done

echo "Bundle complete!"
echo "Bundled libraries:"
echo ""
echo "✓ Bundling complete"
echo ""
echo "📦 Binary info:"
file release/macos/vsdf
ls -lh release/macos/vsdf
echo ""
echo "📚 Bundled libraries:"
ls -lh release/macos/libs/

echo "Binary dependencies after fixing:"
echo ""
echo "🔗 Binary dependencies after fixing:"
otool -L release/macos/vsdf

- name: Code sign binaries
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- master
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand All @@ -14,6 +15,7 @@ on:
branches:
- main
paths-ignore:
- 'scripts/**'
- '**.md'
- 'LICENSE'
- '.gitignore'
Expand Down
152 changes: 152 additions & 0 deletions scripts/bundle_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/bin/bash
set -e

# macOS bundling script - replicates the GitHub Actions workflow logic
# Usage: ./scripts/bundle_macos.sh [build_dir] [release_dir]

BUILD_DIR="${1:-build}"
RELEASE_DIR="${2:-release/macos}"

echo "📦 macOS Binary Bundling Script"
echo "================================"
echo "Build directory: $BUILD_DIR"
echo "Release directory: $RELEASE_DIR"
echo ""

# Check if binary exists
if [ ! -f "$BUILD_DIR/vsdf" ]; then
echo "❌ Error: $BUILD_DIR/vsdf not found"
echo "Please build the project first with: cmake -B build -DCMAKE_BUILD_TYPE=Release . && cmake --build build"
exit 1
fi

# Create libs directory
mkdir -p "$RELEASE_DIR/libs"

# Copy the binary
cp "$BUILD_DIR/vsdf" "$RELEASE_DIR/"

echo "📋 Libraries linked BEFORE bundling:"
otool -L "$BUILD_DIR/vsdf"
echo ""

# Recursively find and copy all non-system dylibs
echo "🔍 Finding and bundling dynamic libraries..."

# Function to copy a library and its dependencies
copy_lib_recursive() {
local lib="$1"
local libname=$(basename "$lib")

# Skip if already copied
if [ -f "$RELEASE_DIR/libs/$libname" ]; then
return
fi

# Skip system libraries
if [[ "$lib" == /System/* ]] || [[ "$lib" == /usr/lib/* ]] || [[ "$lib" == /Library/Apple/* ]]; then
return
fi

# Copy the library
if [ -f "$lib" ]; then
echo " → Copying $libname"
cp "$lib" "$RELEASE_DIR/libs/"

# Recursively copy dependencies of this library
otool -L "$lib" | tail -n +2 | awk '{print $1}' | while read -r dep; do
if [ -f "$dep" ]; then
copy_lib_recursive "$dep"
fi
done
fi
}

# Get initial list of libraries from the binary
otool -L "$BUILD_DIR/vsdf" | tail -n +2 | awk '{print $1}' | while read -r lib; do
if [ -f "$lib" ]; then
copy_lib_recursive "$lib"
fi
done

BUNDLED_COUNT=$(ls "$RELEASE_DIR/libs"/*.dylib 2>/dev/null | wc -l | xargs)
echo ""
echo "Total libraries bundled: $BUNDLED_COUNT"
echo ""

# Fix all library paths to use @rpath
echo "🔧 Fixing library paths..."

# Set rpath on the binary to look in libs/ folder next to the executable
# Only add if it doesn't already exist
if ! otool -l "$RELEASE_DIR/vsdf" | grep -q "@executable_path/libs"; then
echo " Adding @executable_path/libs to rpath"
install_name_tool -add_rpath "@executable_path/libs" "$RELEASE_DIR/vsdf"
else
echo " @executable_path/libs already in rpath"
fi

# Fix paths in the main binary
for lib in "$RELEASE_DIR/libs"/*.dylib; do
libname=$(basename "$lib")
# Find the original path in the binary
ORIG_PATH=$(otool -L "$RELEASE_DIR/vsdf" | grep "$libname" | awk '{print $1}')
if [ ! -z "$ORIG_PATH" ]; then
echo " Fixing $libname in vsdf: $ORIG_PATH -> @rpath/$libname"
install_name_tool -change "$ORIG_PATH" "@rpath/$libname" "$RELEASE_DIR/vsdf"
fi
done

# Fix inter-library dependencies
for lib in "$RELEASE_DIR/libs"/*.dylib; do
libname=$(basename "$lib")

# Fix the library's own id
install_name_tool -id "@rpath/$libname" "$lib"

# Fix references to other bundled libraries
for otherlib in "$RELEASE_DIR/libs"/*.dylib; do
othername=$(basename "$otherlib")
ORIG_PATH=$(otool -L "$lib" | grep "$othername" | awk '{print $1}')
if [ ! -z "$ORIG_PATH" ] && [ "$ORIG_PATH" != "@rpath/$othername" ]; then
echo " Fixing $othername in $libname: $ORIG_PATH -> @rpath/$othername"
install_name_tool -change "$ORIG_PATH" "@rpath/$othername" "$lib"
fi
done
done

echo "Ad-hoc signing binary and libraries..."
# Ad-hoc sign all libraries
for lib in release/macos/libs/*.dylib; do
echo "Signing $(basename "$lib")"
codesign --force --sign - "$lib"
done

# Ad-hoc sign the main binary
echo "Signing vsdf"
codesign --force --sign - release/macos/vsdf

echo "Verifying signatures..."
codesign -v release/macos/vsdf
for lib in release/macos/libs/*.dylib; do
codesign -v "$lib"
done

echo ""
echo "✓ Bundling complete"
echo ""
echo "📦 Binary info:"
file "$RELEASE_DIR/vsdf"
ls -lh "$RELEASE_DIR/vsdf"
echo ""
echo "📚 Bundled libraries:"
ls -lh "$RELEASE_DIR/libs/"
echo ""
echo "🔗 Binary dependencies after fixing:"
otool -L "$RELEASE_DIR/vsdf"

echo ""
echo "🎉 Done! To package the release:"
echo " cp -r shaders $RELEASE_DIR/"
echo " cp README.md LICENSE $RELEASE_DIR/"
echo " cd release && tar -czf vsdf-macos-$(uname -m).tar.gz macos/"
Loading