Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Re-enable heif build on Apple Silicon #611

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
85 changes: 45 additions & 40 deletions build_mac.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@

rustup target list | grep installed
TOOLCHAIN=$(rustc --version --verbose | grep host | cut -f2 -d":" | tr -d "[:space:]")
echo we are using $TOOLCHAIN
export MACOSX_DEPLOYMENT_TARGET=10.15
cargo install cargo-bundle
brew install libheif
brew install nasm
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
cargo bundle --release
cargo install cargo-bundle --quiet
brew install libheif ffmpeg nasm --quiet

rustup target add aarch64-apple-darwin
# rustup target add x86_64-apple-darwin

cargo build --release --target aarch64-apple-darwin --features "notan/shaderc heif"
cargo build --release --target x86_64-apple-darwin --features notan/shaderc
cargo bundle --release --features "notan/shaderc heif"
# cargo build --release --target aarch64-apple-darwin --features "notan/shaderc heif"
# cargo build --release --target x86_64-apple-darwin --features notan/shaderc
echo otool for aarch64:
otool -L target/aarch64-apple-darwin/release/oculante
lipo -create -output target/release/bundle/osx/oculante.app/Contents/MacOS/oculante target/x86_64-apple-darwin/release/oculante target/aarch64-apple-darwin/release/oculante
# lipo -create -output target/release/bundle/osx/oculante.app/Contents/MacOS/oculante target/x86_64-apple-darwin/release/oculante target/aarch64-apple-darwin/release/oculante
file target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
echo otool for universal binary:
otool -L target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
# echo otool for universal binary:
# otool -L target/release/bundle/osx/oculante.app/Contents/MacOS/oculante

otool -L target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
mkdir target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/libheif/lib/libheif.1.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/x265/lib/libx265.209.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/libde265/lib/libde265.0.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/aom/lib/libaom.3.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/webp/lib/libsharpyuv.0.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
cp /opt/homebrew/opt/libvmaf/lib/libvmaf.3.dylib target/release/bundle/osx/oculante.app/Contents/Frameworks/
install_name_tool -change /opt/homebrew/opt/libheif/lib/libheif.1.dylib "@executable_path/../Frameworks/libheif.1.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -add_rpath "@executable_path/../Frameworks/libx265.209.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -add_rpath "@executable_path/../Frameworks/libde265.0.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -add_rpath "@executable_path/../Frameworks/libaom.3.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -add_rpath "@executable_path/../Frameworks/libsharpyuv.0.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -add_rpath "@executable_path/../Frameworks/libvmaf.3.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -change /opt/homebrew/opt/x265/lib/libx265.209.dylib "@executable_path/../Frameworks/libx265.209.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/libde265/lib/libde265.0.dylib "@executable_path/../Frameworks/libde265.0.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/aom/lib/libaom.3.dylib "@executable_path/../Frameworks/libaom.3.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/webp/lib/libsharpyuv.0.dylib "@executable_path/../Frameworks/libsharpyuv.0.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/libvmaf/lib/libvmaf.3.dylib "@executable_path/../Frameworks/libvmaf.3.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libaom.3.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libvmaf.3.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libsharpyuv.0.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libaom.3.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libde265.0.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libx265.209.dylib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
otool -L target/release/bundle/osx/oculante.app/Contents/MacOS/oculante


chmod +rw target/release/bundle/osx/oculante.app/Contents/Frameworks/*

libs=( /opt/homebrew/opt/x265/lib/libx265.215.dylib /opt/homebrew/opt/libheif/lib/libheif.1.dylib /opt/homebrew/opt/x265/lib/libx265.209.dylib /opt/homebrew/opt/libde265/lib/libde265.0.dylib /opt/homebrew/opt/aom/lib/libaom.3.dylib /opt/homebrew/opt/webp/lib/libsharpyuv.0.dylib /opt/homebrew/opt/libvmaf/lib/libvmaf.3.dylib )

for lib in ${libs[@]}
do
echo COPY $lib
# deploy lib
cp $lib target/release/bundle/osx/oculante.app/Contents/Frameworks/
install_name_tool -add_rpath "@executable_path/../Frameworks/$(basename $lib)" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
# install_name_tool -change $lib "@executable_path/../Frameworks/$(basename $lib)" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante

done

install_name_tool -change /opt/homebrew/opt/x265/lib/libx265.209.dylib "@executable_path/../Frameworks/libx265.209.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/libde265/lib/libde265.0.dylib "@executable_path/../Frameworks/libde265.0.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/libheif/lib/libheif.1.dylib "@executable_path/../Frameworks/libheif.1.dylib" target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
install_name_tool -change /opt/homebrew/opt/aom/lib/libaom.3.dylib "@executable_path/../Frameworks/libaom.3.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/webp/lib/libsharpyuv.0.dylib "@executable_path/../Frameworks/libsharpyuv.0.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/libvmaf/lib/libvmaf.3.dylib "@executable_path/../Frameworks/libvmaf.3.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libaom.3.dylib
install_name_tool -change /opt/homebrew/lib/libx265.215.dylib "@executable_path/../Frameworks/libx265.215.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
install_name_tool -change /opt/homebrew/opt/x265/lib/libx265.215.dylib "@executable_path/../Frameworks/libx265.215.dylib" target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib

for lib in ${libs[@]}
do
# sign lib
echo SIGN $lib
codesign -s "-" -fv target/release/bundle/osx/oculante.app/Contents/Frameworks/$(basename $lib)
done

cp Info.plist target/release/bundle/osx/oculante.app/Contents/Info.plist

echo try this to test the build:
echo brew uninstall libheif ffmpeg
brew uninstall libheif ffmpeg
echo you can test target/release/bundle/osx/oculante.app now


otool -L target/release/bundle/osx/oculante.app/Contents/MacOS/oculante
otool -L target/release/bundle/osx/oculante.app/Contents/Frameworks/libheif.1.dylib
Loading