Skip to content

Commit

Permalink
Merge pull request #4772 from gigamonster256/macos-arm64
Browse files Browse the repository at this point in the history
Support compiling native MacOS arm64 (Apple Silicon) builds
  • Loading branch information
zadam authored May 30, 2024
2 parents 25b49e1 + f0d30db commit 8ebebec
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
Binary file added bin/better-sqlite3/mac-arm64-better_sqlite3.node
Binary file not shown.
File renamed without changes.
38 changes: 38 additions & 0 deletions bin/build-mac-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

SRC_DIR=./dist/trilium-mac-arm64-src

if [ "$1" != "DONTCOPY" ]
then
./bin/copy-trilium.sh $SRC_DIR
fi

echo "Copying required mac arm64 binaries"

cp -r bin/better-sqlite3/mac-arm64-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node

rm -r $SRC_DIR/src/public/app-dist/*.mobile.*

echo "Packaging mac arm64 electron build"

./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=darwin --arch=arm64 --overwrite --icon=images/app-icons/mac/icon.icns

BUILD_DIR=./dist/trilium-mac-arm64
rm -rf $BUILD_DIR

# Mac build has by default useless directory level
mv "./dist/Trilium Notes-darwin-arm64" $BUILD_DIR

cp bin/tpl/anonymize-database.sql $BUILD_DIR/

cp -r dump-db $BUILD_DIR/
rm -rf $BUILD_DIR/dump-db/node_modules

echo "Zipping mac arm64 electron distribution..."

VERSION=`jq -r ".version" package.json`

cd dist

rm trilium-mac-arm64-${VERSION}.zip
zip -r9 --symlinks trilium-mac-arm64-${VERSION}.zip trilium-mac-arm64
4 changes: 2 additions & 2 deletions bin/build-mac-x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ then
./bin/copy-trilium.sh $SRC_DIR
fi

echo "Copying required mac binaries"
echo "Copying required mac x64 binaries"

cp -r bin/better-sqlite3/mac-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node
cp -r bin/better-sqlite3/mac-x64-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node

rm -r $SRC_DIR/src/public/app-dist/*.mobile.*

Expand Down
3 changes: 3 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ cp -r $SRC_DIR ./dist/trilium-linux-x64-src
cp -r $SRC_DIR ./dist/trilium-linux-x64-server
cp -r $SRC_DIR ./dist/trilium-windows-x64-src
cp -r $SRC_DIR ./dist/trilium-mac-x64-src
cp -r $SRC_DIR ./dist/trilium-mac-arm64-src

bin/build-win-x64.sh DONTCOPY

bin/build-mac-x64.sh DONTCOPY

bin/build-mac-arm64.sh DONTCOPY

bin/build-linux-x64.sh DONTCOPY

bin/build-server.sh DONTCOPY
2 changes: 2 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ LINUX_X64_BUILD=trilium-linux-x64-$VERSION.tar.xz
DEBIAN_X64_BUILD=trilium_${VERSION}_amd64.deb
WINDOWS_X64_BUILD=trilium-windows-x64-$VERSION.zip
MAC_X64_BUILD=trilium-mac-x64-$VERSION.zip
MAC_ARM64_BUILD=trilium-mac-arm64-$VERSION.zip
SERVER_BUILD=trilium-linux-x64-server-$VERSION.tar.xz

echo "Creating release in GitHub"
Expand All @@ -68,4 +69,5 @@ gh release create "$TAG" \
"dist/$LINUX_X64_BUILD" \
"dist/$WINDOWS_X64_BUILD" \
"dist/$MAC_X64_BUILD" \
"dist/$MAC_ARM64_BUILD" \
"dist/$SERVER_BUILD"

0 comments on commit 8ebebec

Please sign in to comment.