build for universal architecture on macos

This commit is contained in:
Jeffrey Morgan 2023-07-28 12:18:11 -04:00
parent 67b6f8ba86
commit c75cafdb58
6 changed files with 24 additions and 12 deletions

View file

@ -7,12 +7,14 @@ This app builds upon Ollama to provide a desktop experience for running models.
First, build the `ollama` binary: First, build the `ollama` binary:
``` ```
make -C .. cd ..
go build .
``` ```
Then run the desktop app with `npm start`: Then run the desktop app with `npm start`:
``` ```
cd app
npm install npm install
npm start npm start
``` ```

View file

@ -18,7 +18,7 @@ const config: ForgeConfig = {
asar: true, asar: true,
icon: './assets/icon.icns', icon: './assets/icon.icns',
extraResource: [ extraResource: [
'../ollama', '../dist/ollama',
path.join(__dirname, './assets/iconTemplate.png'), path.join(__dirname, './assets/iconTemplate.png'),
path.join(__dirname, './assets/iconTemplate@2x.png'), path.join(__dirname, './assets/iconTemplate@2x.png'),
path.join(__dirname, './assets/iconUpdateTemplate.png'), path.join(__dirname, './assets/iconUpdateTemplate.png'),
@ -42,6 +42,9 @@ const config: ForgeConfig = {
}, },
} }
: {}), : {}),
osxUniversal: {
x64ArchFiles: '**/ollama',
},
}, },
rebuildConfig: {}, rebuildConfig: {},
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin'])], makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin'])],

7
app/package-lock.json generated
View file

@ -32,6 +32,7 @@
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1", "@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"@electron-forge/plugin-webpack": "^6.2.1", "@electron-forge/plugin-webpack": "^6.2.1",
"@electron-forge/publisher-github": "^6.2.1", "@electron-forge/publisher-github": "^6.2.1",
"@electron/universal": "^1.4.1",
"@svgr/webpack": "^8.0.1", "@svgr/webpack": "^8.0.1",
"@types/chmodr": "^1.0.0", "@types/chmodr": "^1.0.0",
"@types/node": "^20.4.0", "@types/node": "^20.4.0",
@ -3328,9 +3329,9 @@
} }
}, },
"node_modules/@electron/universal": { "node_modules/@electron/universal": {
"version": "1.3.4", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/@electron/universal/-/universal-1.3.4.tgz", "resolved": "https://registry.npmjs.org/@electron/universal/-/universal-1.4.1.tgz",
"integrity": "sha512-BdhBgm2ZBnYyYRLRgOjM5VHkyFItsbggJ0MHycOjKWdFGYwK97ZFXH54dTvUWEfha81vfvwr5On6XBjt99uDcg==", "integrity": "sha512-lE/U3UNw1YHuowNbTmKNs9UlS3En3cPgwM5MI+agIgr/B1hSze9NdOP0qn7boZaI9Lph8IDv3/24g9IxnJP7aQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron/asar": "^3.2.1", "@electron/asar": "^3.2.1",

View file

@ -6,10 +6,10 @@
"main": ".webpack/main", "main": ".webpack/main",
"scripts": { "scripts": {
"start": "electron-forge start", "start": "electron-forge start",
"package": "electron-forge package", "package": "electron-forge package --arch universal",
"package:sign": "SIGN=1 electron-forge package", "package:sign": "SIGN=1 electron-forge package --arch universal",
"make": "electron-forge make", "make": "electron-forge make --arch universal",
"make:sign": "SIGN=1 electron-forge make", "make:sign": "SIGN=1 electron-forge make --arch universal",
"publish": "SIGN=1 electron-forge publish", "publish": "SIGN=1 electron-forge publish",
"lint": "eslint --ext .ts,.tsx .", "lint": "eslint --ext .ts,.tsx .",
"format": "prettier --check . --ignore-path .gitignore", "format": "prettier --check . --ignore-path .gitignore",
@ -32,6 +32,7 @@
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1", "@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"@electron-forge/plugin-webpack": "^6.2.1", "@electron-forge/plugin-webpack": "^6.2.1",
"@electron-forge/publisher-github": "^6.2.1", "@electron-forge/publisher-github": "^6.2.1",
"@electron/universal": "^1.4.1",
"@svgr/webpack": "^8.0.1", "@svgr/webpack": "^8.0.1",
"@types/chmodr": "^1.0.0", "@types/chmodr": "^1.0.0",
"@types/node": "^20.4.0", "@types/node": "^20.4.0",

7
scripts/build.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
mkdir -p dist
CGO_ENABLED=1 GOARCH=arm64 go build -o dist/ollama_arm64
CGO_ENABLED=1 GOARCH=amd64 go build -o dist/ollama_amd64
lipo -create -output dist/ollama dist/ollama_arm64 dist/ollama_amd64
npm run --prefix app make:sign

View file

@ -10,9 +10,7 @@ fi
OS=$(go env GOOS) OS=$(go env GOOS)
ARCH=$(go env GOARCH) ARCH=$(go env GOARCH)
go build . ./script/build.sh
npm --prefix app run make:sign
# Create a new tag if it doesn't exist. # Create a new tag if it doesn't exist.
if ! git rev-parse v$VERSION >/dev/null 2>&1; then if ! git rev-parse v$VERSION >/dev/null 2>&1; then