Skip to content

Commit

Permalink
Add script to build an universal binary on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky authored and LukeUsher committed Sep 25, 2022
1 parent 4644bb4 commit 12a1585
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
obj/
out/
obj-amd64/
obj-arm64/
out-amd64/
out-arm64/
29 changes: 29 additions & 0 deletions scripts/macos-make-universal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -euo pipefail

if ! command -v lipo >/dev/null; then
echo "Command lipo not found; please install XCode"
exit 1
fi

if ! command -v gmake >/dev/null; then
echo "Please install make via Homebrew (brew install make)"
exit 1
fi

# Change to parent directory (top-level)
cd "$(dirname "$0")"/.. || exit 1

echo "Building for amd64..."
gmake arch=amd64 object.path=obj-amd64 output.path=out-amd64 "$@"

echo "Building for arm64..."
gmake arch=arm64 object.path=obj-arm64 output.path=out-arm64 "$@"

echo "Assembling universal binary"
rm -rf desktop-ui/out
cp -a desktop-ui/out-amd64 desktop-ui/out
lipo -create -output desktop-ui/out/ares.app/Contents/MacOS/ares \
desktop-ui/out-amd64/ares.app/Contents/MacOS/ares \
desktop-ui/out-arm64/ares.app/Contents/MacOS/ares
codesign --force --deep --sign - desktop-ui/out/ares.app

0 comments on commit 12a1585

Please sign in to comment.