diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-05-29 14:25:01 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-05-29 14:25:01 +0200 |
| commit | 9be611007baa7493a0e0eea641a9805d8de9c7a9 (patch) | |
| tree | 94e28ef060c27e3394a2f5db73e6ff312dd5af6b | |
| parent | fd5f24e1cfcb9abbfc402d138acbc6440f134fea (diff) | |
| parent | 417583b750f94f23acbd3013dc8ece17c2432476 (diff) | |
| download | mullvadvpn-9be611007baa7493a0e0eea641a9805d8de9c7a9.tar.xz mullvadvpn-9be611007baa7493a0e0eea641a9805d8de9c7a9.zip | |
Merge branch 'arm-mac-build-universal-1'
| -rwxr-xr-x | env.sh | 6 | ||||
| -rw-r--r-- | gui/package-lock.json | 2 | ||||
| -rw-r--r-- | gui/package.json | 2 | ||||
| -rw-r--r-- | gui/tasks/distribution.js | 11 | ||||
| -rwxr-xr-x | wireguard/build-wireguard-go.sh | 21 |
5 files changed, 33 insertions, 9 deletions
@@ -30,6 +30,12 @@ case "$ENV_TARGET" in ;; x86_64-*-darwin*) export MACOSX_DEPLOYMENT_TARGET="10.7" + + if [[ $HOST != "$ENV_TARGET" ]]; then + # Required for building daemon + SDKROOT=$(xcrun --show-sdk-path) + export SDKROOT + fi ;; aarch64-*-darwin*) export MACOSX_DEPLOYMENT_TARGET="11.0" diff --git a/gui/package-lock.json b/gui/package-lock.json index 5abc9b9378..4195b9d9e9 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -55,7 +55,7 @@ "chai-spies": "^1.0.0", "cross-env": "^7.0.3", "electron": "^23.2.0", - "electron-builder": "^23.3.3", + "electron-builder": "^23.6.0", "electron-devtools-installer": "^3.2.0", "electron-mocha": "^11.0.2", "electron-notarize": "^1.2.1", diff --git a/gui/package.json b/gui/package.json index d903ac2da7..0d8fadc2f8 100644 --- a/gui/package.json +++ b/gui/package.json @@ -61,7 +61,7 @@ "chai-spies": "^1.0.0", "cross-env": "^7.0.3", "electron": "^23.2.0", - "electron-builder": "^23.3.3", + "electron-builder": "^23.6.0", "electron-devtools-installer": "^3.2.0", "electron-mocha": "^11.0.2", "electron-notarize": "^1.2.1", diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js index 3eb26cb876..fa27093e93 100644 --- a/gui/tasks/distribution.js +++ b/gui/tasks/distribution.js @@ -57,6 +57,7 @@ const config = { 'node_modules/', '!node_modules/grpc-tools', '!node_modules/@types', + '!node_modules/nseventmonitor/build/Release', ], // Make sure that all files declared in "extraResources" exists and abort if they don't. @@ -284,6 +285,16 @@ function packMac() { return true; }, + beforePack: async (context) => { + try { + // `@electron/universal` tries to lipo together libraries built for the same architecture + // if they're present for both targets. So make sure we remove libraries for other archs. + // Remove the workaround once the issue has been fixed: + // https://github.com/electron/universal/issues/41#issuecomment-1496288834 + await fs.promises.rm('node_modules/nseventmonitor/lib/binding/Release', { recursive: true }); + } catch {} + config.beforePack?.(context); + }, afterPack: (context) => { config.afterPack?.(context); diff --git a/wireguard/build-wireguard-go.sh b/wireguard/build-wireguard-go.sh index 739116b41b..f800634f73 100755 --- a/wireguard/build-wireguard-go.sh +++ b/wireguard/build-wireguard-go.sh @@ -97,16 +97,23 @@ function build_unix { export CC=aarch64-linux-gnu-gcc fi - # Apple silicon - if [[ "$1" == "aarch64-apple-darwin" ]]; then + # Environment flags for cross compiling on macOS + if [[ "$1" == *-apple-darwin ]]; then export CGO_ENABLED=1 export GOOS=darwin - export GOARCH=arm64 - export CC="$(xcrun -sdk $SDKROOT --find clang) -arch $GOARCH -isysroot $SDKROOT" - export CFLAGS="-isysroot $SDKROOT -arch $GOARCH -I$SDKROOT/usr/include" + + local arch=x86_64 + export GOARCH=amd64 + if [[ "$1" == aarch64-* ]]; then + arch=arm64 + export GOARCH=arm64 + fi + + export CC="$(xcrun -sdk $SDKROOT --find clang) -arch $arch -isysroot $SDKROOT" + export CFLAGS="-isysroot $SDKROOT -arch $arch -I$SDKROOT/usr/include" export LD_LIBRARY_PATH="$SDKROOT/usr/lib" - export CGO_CFLAGS="-isysroot $SDKROOT -arch $GOARCH" - export CGO_LDFLAGS="-isysroot $SDKROOT -arch $GOARCH" + export CGO_CFLAGS="-isysroot $SDKROOT -arch $arch" + export CGO_LDFLAGS="-isysroot $SDKROOT -arch $arch" fi fi |
