From 5761ba5a3b7cd85fb7e7412b22e15d7cecc7555b Mon Sep 17 00:00:00 2001 From: Milot Mirdita Date: Thu, 15 Apr 2021 20:07:39 +0200 Subject: [PATCH] Prepare AppleSilicon build Doesn't work yet because of https://github.com/electron-userland/electron-builder/issues/5552 --- Makefile | 29 ++++++++++++----------------- azure-pipelines.yml | 4 ++-- electron/index.js | 9 +++++++-- package-lock.json | 30 +++++++++++++++--------------- package.json | 6 +++++- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 3491abf..4686396 100644 --- a/Makefile +++ b/Makefile @@ -3,18 +3,22 @@ all: resources/icons/icon.icns resources/icons/icon.ico win mac linux win: resources/win/mmseqs.bat resources/win/mmseqs-web-backend.exe resources/win/cpu-check.exe -mac: resources/mac/mmseqs-sse41 resources/mac/mmseqs-avx2 resources/mac/mmseqs-web-backend resources/mac/cpu-check +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 resources/linux/cpu-check -mmseqshash := d1607bc8acee560772c1b0863e14c475398aa32c +mmseqshash := 19064f27c8d86fcdcd3daad60f6db70f6360f30b resources/icons/icon.icns resources/icons/icon.ico: frontend/assets/marv1-square.svg mkdir -p resources/icons ./node_modules/.bin/icon-gen -i frontend/assets/marv1-square.svg -o resources/icons/ --icns name=icon --ico name=icon -resources/mac/mmseqs-web-backend: backend/*.go backend/go.* - mkdir -p resources/mac - cd backend/ && GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/mac/mmseqs-web-backend +resources/mac/x64/mmseqs-web-backend: backend/*.go backend/go.* + mkdir -p resources/mac/x64 + cd backend/ && GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ../resources/mac/x64/mmseqs-web-backend + +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 @@ -24,10 +28,6 @@ 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/mac/cpu-check: cpu-check/*.go cpu-check/go.* - mkdir -p resources/mac - cd cpu-check/ && GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o ../resources/mac/cpu-check - resources/linux/cpu-check: cpu-check/*.go cpu-check/go.* mkdir -p resources/linux cd cpu-check/ && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o ../resources/linux/cpu-check @@ -36,15 +36,10 @@ resources/win/cpu-check.exe: cpu-check/*.go cpu-check/go.* mkdir -p resources/win cd cpu-check/ && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o ../resources/win/cpu-check.exe -resources/mac/mmseqs-sse41: +resources/mac/mmseqs: mkdir -p resources/mac - cd resources/mac && wget -nv -O mmseqs.tar.gz https://mmseqs.com/archive/$(mmseqshash)/mmseqs-osx-sse41.tar.gz \ - && tar --strip-components=2 -xf mmseqs.tar.gz mmseqs/bin/mmseqs && mv mmseqs mmseqs-sse41 && rm mmseqs.tar.gz - -resources/mac/mmseqs-avx2: - mkdir -p resources/mac - cd resources/mac && wget -nv -O mmseqs.tar.gz https://mmseqs.com/archive/$(mmseqshash)/mmseqs-osx-avx2.tar.gz \ - && tar --strip-components=2 -xf mmseqs.tar.gz mmseqs/bin/mmseqs && mv mmseqs mmseqs-avx2 && rm mmseqs.tar.gz + cd resources/mac && wget -nv -O mmseqs.tar.gz https://mmseqs.com/archive/$(mmseqshash)/mmseqs-osx-universal.tar.gz \ + && tar --strip-components=2 -xf mmseqs.tar.gz mmseqs/bin/mmseqs && rm mmseqs.tar.gz resources/linux/mmseqs-sse41: mkdir -p resources/linux diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7a9b220..2eed66e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,11 +9,11 @@ trigger: - master pool: - vmImage: 'macOS-10.14' + vmImage: 'macOS-10.15' steps: - task: NodeTool@0 inputs: - versionSpec: '12.x' + versionSpec: '15.x' - script: | npm install make all -j $(nproc --all) diff --git a/electron/index.js b/electron/index.js index 6fc34c3..2fc2ebc 100644 --- a/electron/index.js +++ b/electron/index.js @@ -36,13 +36,18 @@ const binPath = (process.env.NODE_ENV === 'production') ? join(process.resourcesPath, 'bin') : join(appRootDir.get(), 'resources', mapPlatform(platform)); + +var simd = "universal"; +if (platform !== 'darwin') { + simd = String(execFileSync(join(binPath, "cpu-check" + (platform == "win32" ? ".exe" : "")))).trim() +} app.os = { arch: os.arch(), platform: platform, - simd: String(execFileSync(join(binPath, "cpu-check" + (platform == "win32" ? ".exe" : "")))).trim() + simd: simd } -const mmseqsBinary = join(binPath, "mmseqs" + (platform == "win32" ? "" : ("-" + app.os.simd)) + (platform == "win32" ? ".bat" : "")); +const mmseqsBinary = join(binPath, "mmseqs" + (platform == "win32" || platform == "darwin" ? "" : ("-" + app.os.simd)) + (platform == "win32" ? ".bat" : "")); const backendBinary = join(binPath, "mmseqs-web-backend" + (platform == "win32" ? ".exe" : "")); app.mmseqsVersion = String(execFileSync(mmseqsBinary, ["version"])).trim() diff --git a/package-lock.json b/package-lock.json index 8b9fa69..64297fd 100755 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "css-loader": "^5.2.1", "del": "^6.0.0", "devtron": "^1.4.0", - "electron": "^11.4.3", + "electron": "^12.0.4", "electron-builder": "^22.10.5", "electron-debug": "^3.2.0", "electron-devtools-installer": "^3.1.1", @@ -2023,9 +2023,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "12.20.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.8.tgz", - "integrity": "sha512-uxDkaUGwXNDHu5MHqs+FAsmOjNoNibDF1cu4668QG96mQldQfgV3M+UyntXWWrtXSh13jFxEdNUdoLWH46mLKQ==", + "version": "14.14.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.40.tgz", + "integrity": "sha512-2HoZZGylcnz19ZSbvWhgWHqvprw1ZGHanxIrDWYykPD4CauLW4gcyLzCVfUN2kv/1t1F3CurQIdi+s1l9+XgEA==", "dev": true }, "node_modules/@types/plist": { @@ -6095,14 +6095,14 @@ } }, "node_modules/electron": { - "version": "11.4.3", - "resolved": "https://registry.npmjs.org/electron/-/electron-11.4.3.tgz", - "integrity": "sha512-RhCWJqiYK5oIRGOheilhg/nngCgk0fPgaf00KvbxorlvFZAz8OeMT5ShCpVsMSoyYhk4XEnn4orRly5ltaFYJg==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.4.tgz", + "integrity": "sha512-A8Lq3YMZ1CaO1z5z5nsyFxIwkgwXLHUwL2pf9MVUHpq7fv3XUewCMD98EnLL3DdtiyCvw5KMkeT1WGsZh8qFug==", "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^1.0.1", - "@types/node": "^12.0.12", + "@types/node": "^14.6.2", "extract-zip": "^1.0.3" }, "bin": { @@ -20473,9 +20473,9 @@ "dev": true }, "@types/node": { - "version": "12.20.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.8.tgz", - "integrity": "sha512-uxDkaUGwXNDHu5MHqs+FAsmOjNoNibDF1cu4668QG96mQldQfgV3M+UyntXWWrtXSh13jFxEdNUdoLWH46mLKQ==", + "version": "14.14.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.40.tgz", + "integrity": "sha512-2HoZZGylcnz19ZSbvWhgWHqvprw1ZGHanxIrDWYykPD4CauLW4gcyLzCVfUN2kv/1t1F3CurQIdi+s1l9+XgEA==", "dev": true }, "@types/plist": { @@ -23826,13 +23826,13 @@ } }, "electron": { - "version": "11.4.3", - "resolved": "https://registry.npmjs.org/electron/-/electron-11.4.3.tgz", - "integrity": "sha512-RhCWJqiYK5oIRGOheilhg/nngCgk0fPgaf00KvbxorlvFZAz8OeMT5ShCpVsMSoyYhk4XEnn4orRly5ltaFYJg==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.4.tgz", + "integrity": "sha512-A8Lq3YMZ1CaO1z5z5nsyFxIwkgwXLHUwL2pf9MVUHpq7fv3XUewCMD98EnLL3DdtiyCvw5KMkeT1WGsZh8qFug==", "dev": true, "requires": { "@electron/get": "^1.0.1", - "@types/node": "^12.0.12", + "@types/node": "^14.6.2", "extract-zip": "^1.0.3" } }, diff --git a/package.json b/package.json index 470c05a..0bf1a9e 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,10 @@ { "from": "resources/${os}", "to": "resources/bin" + }, + { + "from": "resources/${os}/${arch}", + "to": "resources/bin" } ], "dmg": { @@ -81,7 +85,7 @@ "css-loader": "^5.2.1", "del": "^6.0.0", "devtron": "^1.4.0", - "electron": "^11.4.3", + "electron": "^12.0.4", "electron-builder": "^22.10.5", "electron-debug": "^3.2.0", "electron-devtools-installer": "^3.1.1",