build_darwin.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. set -e
  3. . $(dirname $0)/env.sh
  4. mkdir -p dist
  5. # These require Xcode v13 or older to target MacOS v11
  6. # If installed to an alternate location use the following to enable
  7. # export SDKROOT=/Applications/Xcode_12.5.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
  8. # export DEVELOPER_DIR=/Applications/Xcode_12.5.1.app/Contents/Developer
  9. export CGO_CPPFLAGS=-mmacosx-version-min=11.3
  10. rm -rf llama/build dist/darwin-*
  11. echo "Building darwin arm64"
  12. GOOS=darwin ARCH=arm64 GOARCH=arm64 make -j 8 dist
  13. echo "Building darwin amd64 with AVX enabled"
  14. GOOS=darwin ARCH=amd64 GOARCH=amd64 CUSTOM_CPU_FLAGS="avx" make -j 8 dist
  15. lipo -create -output dist/ollama dist/darwin-arm64/bin/ollama dist/darwin-amd64/bin/ollama
  16. if [ -n "$APPLE_IDENTITY" ]; then
  17. codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
  18. else
  19. echo "Skipping code signing - set APPLE_IDENTITY"
  20. fi
  21. chmod +x dist/ollama
  22. # build and optionally sign the mac app
  23. npm install --prefix macapp
  24. if [ -n "$APPLE_IDENTITY" ]; then
  25. npm run --prefix macapp make:sign
  26. else
  27. npm run --prefix macapp make
  28. fi
  29. cp macapp/out/make/zip/darwin/universal/Ollama-darwin-universal-$VERSION.zip dist/Ollama-darwin.zip
  30. # sign the binary and rename it
  31. if [ -n "$APPLE_IDENTITY" ]; then
  32. codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
  33. else
  34. echo "WARNING: Skipping code signing - set APPLE_IDENTITY"
  35. fi
  36. ditto -c -k --keepParent dist/ollama dist/temp.zip
  37. if [ -n "$APPLE_IDENTITY" ]; then
  38. xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
  39. fi
  40. mv dist/ollama dist/ollama-darwin
  41. rm -f dist/temp.zip