Skip to content

Commit

Permalink
Get arm64 + universal builds to work
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Apr 15, 2021
1 parent dcf4bfa commit e2dee5b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 29 deletions.
62 changes: 43 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

all: build/icon.icns build/icon.ico win mac linux

win: resources/win/mmseqs.bat resources/win/mmseqs-web-backend.exe
mac: resources/mac/mmseqs resources/mac/arm64/mmseqs-web-backend resources/mac/x64/mmseqs-web-backend
linux: resources/linux/mmseqs-sse41 resources/linux/mmseqs-avx2 resources/linux/mmseqs-web-backend
win: resources/win/x64/mmseqs.bat resources/win/x64/mmseqs-web-backend.exe
mac: resources/mac/x64/mmseqs resources/mac/arm64/mmseqs resources/mac/arm64/mmseqs-web-backend resources/mac/x64/mmseqs-web-backend
linux: resources/linux/arm64/mmseqs resources/linux/arm64/mmseqs-web-backend resources/linux/x64/mmseqs resources/linux/x64/mmseqs-web-backend

mmseqshash := 19064f27c8d86fcdcd3daad60f6db70f6360f30b

Expand All @@ -22,31 +22,55 @@ resources/mac/arm64/mmseqs-web-backend: backend/*.go backend/go.*
mkdir -p resources/mac/arm64
cd backend/ && GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o ../resources/mac/arm64/mmseqs-web-backend

resources/linux/mmseqs-web-backend: backend/*.go backend/go.*
mkdir -p resources/linux
cd backend/ && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/linux/mmseqs-web-backend
resources/linux/x64/mmseqs-web-backend: backend/*.go backend/go.*
mkdir -p resources/linux/x64
cd backend/ && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/linux/x64/mmseqs-web-backend

resources/win/mmseqs-web-backend.exe: backend/*.go backend/go.*
mkdir -p resources/win
cd backend/ && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/win/mmseqs-web-backend.exe
resources/linux/arm64/mmseqs-web-backend: backend/*.go backend/go.*
mkdir -p resources/linux/arm64
cd backend/ && GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ../resources/linux/arm64/mmseqs-web-backend

resources/win/x64/mmseqs-web-backend.exe: backend/*.go backend/go.*
mkdir -p resources/win/x64
cd backend/ && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/win/x64/mmseqs-web-backend.exe

resources/mac/mmseqs:
mkdir -p resources/mac
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-osx-universal.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/mac/mmseqs
chmod +x resources/mac/mmseqs

resources/mac/x64/mmseqs: resources/mac/mmseqs
mkdir -p resources/mac/x64
lipo resources/mac/mmseqs -remove arm64 -output resources/mac/x64/mmseqs || cp -f -- resources/mac/mmseqs resources/mac/x64/mmseqs

resources/mac/arm64/mmseqs: resources/mac/mmseqs
mkdir -p resources/mac/arm64
lipo resources/mac/mmseqs -thin arm64 -output resources/mac/arm64/mmseqs || cp -f -- resources/mac/mmseqs resources/mac/arm64/mmseqs

resources/linux/x64/mmseqs-sse41:
mkdir -p resources/linux/x64
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-linux-sse41.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/linux/x64/mmseqs-sse41
chmod +x resources/linux/x64/mmseqs-sse41

resources/linux/x64/mmseqs-avx2:
mkdir -p resources/linux/x64
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-linux-avx2.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/linux/x64/mmseqs-avx2
chmod +x resources/linux/x64/mmseqs-avx2

resources/linux/mmseqs-sse41:
mkdir -p resources/linux
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-linux-sse41.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/linux/mmseqs-sse41
resources/linux/x64/mmseqs: electron/mmseqs-wrapper.sh resources/linux/x64/mmseqs-avx2 resources/linux/x64/mmseqs-sse41
cp electron/mmseqs-wrapper.sh resources/linux/x64/mmseqs
chmod +x resources/linux/x64/mmseqs

resources/linux/mmseqs-avx2:
mkdir -p resources/linux
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-linux-avx2.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/linux/mmseqs-avx2
resources/linux/arm64/mmseqs:
mkdir -p resources/linux/arm64
wget -nv -q -O - https://mmseqs.com/archive/$(mmseqshash)/mmseqs-linux-arm64.tar.gz | tar -xOf - mmseqs/bin/mmseqs > resources/linux/arm64/mmseqs
chmod +x resources/linux/arm64/mmseqs

resources/win/mmseqs.bat:
mkdir -p resources/win
cd resources/win && wget -nv -O mmseqs-win64.zip https://mmseqs.com/archive/$(mmseqshash)/mmseqs-win64.zip \
resources/win/x64/mmseqs.bat:
mkdir -p resources/win/x64
cd resources/win/x64 && wget -nv -O mmseqs-win64.zip https://mmseqs.com/archive/$(mmseqshash)/mmseqs-win64.zip \
&& unzip mmseqs-win64.zip && mv mmseqs/* . && rmdir mmseqs && rm mmseqs-win64.zip
chmod -R +x resources/win/mmseqs.bat resources/win/bin/*
chmod -R +x resources/win/x64/mmseqs.bat resources/win/x64/bin/*

clean:
@rm -f build/icon.icns build/icon.ico
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
secureFile: certificate.p12
- task: CmdLine@2
inputs:
script: ./node_modules/.bin/electron-builder --x64 -mwl
script: ./node_modules/.bin/electron-builder -mwl
env:
CSC_LINK: $(certificate.secureFilePath)
CSC_KEY_PASSWORD: $(CSC_KEY_PASSWORD)
Expand Down
12 changes: 10 additions & 2 deletions electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { default as fp } from 'find-free-port';
import { default as os } from 'os';
import { createReadStream, createWriteStream } from 'fs';
import { randomBytes } from 'crypto';
import { parse, join, dirname } from 'path';
import { parse, join } from 'path';
import appRootDir from 'app-root-dir';
import defaultMenu from './menu';
import contextMenu from './context'
Expand Down Expand Up @@ -34,7 +34,7 @@ const mapPlatform = (platform) => {
}
const binPath = (process.env.NODE_ENV === 'production') ?
join(process.resourcesPath, 'bin') :
join(appRootDir.get(), 'resources', mapPlatform(platform));
join(appRootDir.get(), 'resources', mapPlatform(platform), os.arch());

app.os = {
arch: os.arch(),
Expand Down Expand Up @@ -132,16 +132,24 @@ console.log(err);

function createWindow() {
mainWindow = new BrowserWindow({
backgroundColor: "#FAFAFA",
height: 615,
useContentSize: true,
width: 1000,
show: false,
// titleBarStyle: "hidden",
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false
}
});

mainWindow.loadURL(winURL);

mainWindow.once('ready-to-show', () => {
mainWindow.show()
});

mainWindow.webContents.on('new-window', (e, url) => {
if (url != mainWindow.webContents.getURL()) {
Expand Down
11 changes: 11 additions & 0 deletions electron/mmseqs-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#/bin/sh
DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
FLAGS="$(grep -m 1 '^flags' /proc/cpuinfo)"
case "${FLAGS}" in
*avx2*)
exec "${DIR}/mmseqs-avx2" "$@"
;;
*)
exec "${DIR}/mmseqs-sse41" "$@"
;;
esac
32 changes: 25 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "dist/main.js",
"scripts": {
"electron:deps": "make all",
"electron:build": "npm run electron:deps && cross-env ELECTRON=1 node ./electron/build.js && electron-builder --x64 -mwl",
"electron:dir": "npm run electron:deps && cross-env ELECTRON=1 node ./electron/build.js && electron-builder --x64 --dir",
"electron:build": "npm run electron:deps && cross-env ELECTRON=1 node ./electron/build.js && electron-builder -mwl",
"electron:dir": "npm run electron:deps && cross-env ELECTRON=1 node ./electron/build.js && electron-builder --dir",
"electron:dev": "cross-env ELECTRON=1 node ./electron/dev-runner.js",
"electron:pack": "npm run electron:main && cross-env ELECTRON=1 npm run frontend",
"electron:main": "webpack -p --progress --hide-modules --colors --config ./webpack.electron.config.js",
Expand All @@ -36,10 +36,6 @@
"dist/**/*"
],
"extraFiles": [
{
"from": "resources/${os}",
"to": "resources/bin"
},
{
"from": "resources/${os}/${arch}",
"to": "resources/bin"
Expand All @@ -60,8 +56,30 @@
}
]
},
"win": {
"target": [
{
"target": "nsis",
"arch": [ "x64" ]
}
]
},
"linux": {
"category": "Science"
"category": "Science",
"target": [
{
"target": "AppImage",
"arch": [ "x64", "arm64" ]
}
]
},
"mac": {
"target": [
{
"target": "dmg",
"arch": [ "universal" ]
}
]
}
},
"devDependencies": {
Expand Down

0 comments on commit e2dee5b

Please sign in to comment.