summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrii Yurchuk <ay@mntw.re>2021-02-10 18:48:28 +0100
committerAndrii Yurchuk <ay@mntw.re>2021-02-26 19:03:00 +0100
commitc7717f006e8f2e255e521a53c5c86eaaec6a616c (patch)
tree422bc321ac6566bc4787e26d9443741e8e9acec8
parentb09da89cf6a974e3ba8bd6b0cfebebb3765d5a50 (diff)
downloadmullvadvpn-c7717f006e8f2e255e521a53c5c86eaaec6a616c.tar.xz
mullvadvpn-c7717f006e8f2e255e521a53c5c86eaaec6a616c.zip
Allow building on Apple Silicon
-rw-r--r--.gitignore1
-rw-r--r--CHANGELOG.md1
-rw-r--r--Cargo.lock10
-rw-r--r--README.md22
-rwxr-xr-xbuild_mi_proto.sh22
-rw-r--r--gui/package.json4
-rwxr-xr-xgui/scripts/build-proto.sh36
-rw-r--r--talpid-core/Cargo.toml6
-rwxr-xr-xwireguard/build-wireguard-go.sh6
9 files changed, 85 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 3cbba48396..b8eb7c92ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@
/dist-assets/sslocal
/dist-assets/sslocal.exe
/dist-assets/shell-completions/
+/dist-assets/mi_proto/
/windows/**/bin/
/windows/**/*.user
/android/keystore.properties
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8d9eed6e3..8777efde54 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@ Line wrap the file at 100 chars. Th
- Enable isolation of the Electron renderer process to protect against potentially malicious third
party dependencies.
- Add 51820 to list of WireGuard ports in app settings.
+- Add support for Apple Silicon
#### Android
- Allow reaching the API server when connecting, disconnecting or in a blocked state.
diff --git a/Cargo.lock b/Cargo.lock
index 7f415361ec..17c7d5c4bc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -945,9 +945,9 @@ dependencies = [
[[package]]
name = "ioctl-sys"
-version = "0.5.2"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e2c4b26352496eaaa8ca7cfa9bd99e93419d3f7983dc6e99c2a35fe9e33504a"
+checksum = "1c429fffa658f288669529fc26565f728489a2e39bc7b24a428aaaf51355182e"
[[package]]
name = "iovec"
@@ -1725,8 +1725,7 @@ dependencies = [
[[package]]
name = "pfctl"
version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9bfaa4493763cdea373bba96f1ae88f2012f97293ed58bfcc2ca09737132c833"
+source = "git+https://github.com/mullvad/pfctl-rs.git#351b0ed6a27ca7bdae4c223b1e69096aff197a0b"
dependencies = [
"derive_builder",
"errno",
@@ -3105,8 +3104,7 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "tun"
version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25229e5c4fd761c0e5cd7ae4dfcbaf0d98ded8a4367434f255639d6e554cf564"
+source = "git+https://github.com/Ch00k/rust-tun.git?branch=bump-ioctl#b7e4de6e9f8c0ed74125d94aae56968dd4045b00"
dependencies = [
"ioctl-sys",
"libc",
diff --git a/README.md b/README.md
index 8bed95414e..38abe444b5 100644
--- a/README.md
+++ b/README.md
@@ -297,6 +297,28 @@ This should produce an installer exe, pkg or rpm+deb file in the `dist/` directo
Building this requires at least 1GB of memory.
+#### Apple ARM64 (aka Apple Silicon)
+
+Due to inability to build the management interface proto files on ARM64 (see
+[this](https://github.com/grpc/grpc-node/issues/1497) issue) the Apple ARM64 build must be done in 2 stages:
+
+1. Build management interface proto files on a non-ARM64 platform
+2. Use the built proto files during the main build by setting the `MI_PROTO_BUILD_DIR` environment variable
+ to the path the proto files
+
+To build the management interface proto files there is a script (execute it on a non-ARM64 platform):
+
+```bash
+./build_mi_proto.sh
+```
+
+After that transfer the resulting build directory to your Apple ARM64 platform, set the value of
+`MI_PROTO_BUILD_DIR` to the transfer destination, and run `./build.sh`:
+
+```bash
+MI_PROTO_BUILD_DIR=/Users/doe/mullvadvpn-app/dist-assets/mi_proto ./build.sh --dev-build
+```
+
If you want to build each component individually, or run in development mode, read the following
sections.
diff --git a/build_mi_proto.sh b/build_mi_proto.sh
new file mode 100755
index 0000000000..178ddf31a4
--- /dev/null
+++ b/build_mi_proto.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+# This script is used to build the management interface proto files to later use them on the platforms
+# unsupported by grpc-tools (e.g. Apple Silicon).
+
+set -eu
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PROTO_BUILD_DIR="$SCRIPT_DIR/dist-assets/mi_proto"
+
+pushd "$SCRIPT_DIR/gui"
+npm ci
+npm run build-proto
+popd
+
+mkdir -p "$PROTO_BUILD_DIR"
+cp gui/src/main/management_interface/* $PROTO_BUILD_DIR
+cp gui/build/src/main/management_interface/* $PROTO_BUILD_DIR
+
+echo ""
+echo "Management interface proto files built successfully."
+echo "Build directory: $PROTO_BUILD_DIR"
diff --git a/gui/package.json b/gui/package.json
index 026ca36e28..da507c4fd9 100644
--- a/gui/package.json
+++ b/gui/package.json
@@ -32,6 +32,7 @@
"uuid": "^3.0.1"
},
"optionalDependencies": {
+ "grpc-tools": "^1.10.0",
"nseventmonitor": "^1.0.0"
},
"devDependencies": {
@@ -67,7 +68,7 @@
"chai-spies": "^1.0.0",
"cross-env": "^5.1.3",
"electron": "^11.2.3",
- "electron-builder": "^22.8.0",
+ "electron-builder": "^22.10.4",
"electron-devtools-installer": "^3.1.1",
"electron-mocha": "^9.3.3",
"electron-notarize": "^0.1.1",
@@ -76,7 +77,6 @@
"eslint-plugin-react": "^7.18.3",
"gettext-extractor": "^3.5.2",
"grpc_tools_node_protoc_ts": "^5.1.1",
- "grpc-tools": "^1.10.0",
"gulp": "^4.0.2",
"gulp-inject-string": "^1.1.2",
"gulp-sourcemaps": "^3.0.0",
diff --git a/gui/scripts/build-proto.sh b/gui/scripts/build-proto.sh
index a6cf6a5d94..5a09d111e3 100755
--- a/gui/scripts/build-proto.sh
+++ b/gui/scripts/build-proto.sh
@@ -5,6 +5,8 @@ set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
+PLATFORM="$(uname -s)-$(uname -m)"
+MI_PROTO_BUILD_DIR=${MI_PROTO_BUILD_DIR:-}
NODE_MODULES_DIR="$(cd ../node_modules/.bin && pwd)"
PROTO_DIR="../../mullvad-management-interface/proto"
PROTO_FILENAME="management_interface.proto"
@@ -19,15 +21,27 @@ fi
mkdir -p $DESTINATION_DIR
mkdir -p $TYPES_DESTINATION_DIR
-"$NODE_MODULES_DIR/grpc_tools_node_protoc" \
- --js_out=import_style=commonjs,binary:$DESTINATION_DIR \
- --grpc_out=generate_package_definition:$DESTINATION_DIR \
- --proto_path=$PROTO_DIR \
- $PROTO_DIR/$PROTO_FILENAME
-
-"$NODE_MODULES_DIR/grpc_tools_node_protoc" \
- --plugin=protoc-gen-ts=$TS_PROTOC_PLUGIN \
- --ts_out=generate_package_definition:$TYPES_DESTINATION_DIR \
- --proto_path=$PROTO_DIR \
- $PROTO_DIR/$PROTO_FILENAME
+if [[ "${PLATFORM}" == "Darwin-arm64" ]]; then
+ if [[ -n "${MI_PROTO_BUILD_DIR}" ]]; then
+ cp $MI_PROTO_BUILD_DIR/*.js $DESTINATION_DIR
+ cp $MI_PROTO_BUILD_DIR/*.ts $TYPES_DESTINATION_DIR
+ else
+ >&2 echo "Building management interface proto files on Apple Silicon is not supported"
+ >&2 echo "(see https://github.com/grpc/grpc-node/issues/1497)."
+ >&2 echo "Please build the proto files on another platform using build_mi_proto.sh script,"
+ >&2 echo "and set MI_PROTO_BUILD_DIR environment variable to the directory of the build."
+ exit 1
+ fi
+else
+ "$NODE_MODULES_DIR/grpc_tools_node_protoc" \
+ --js_out=import_style=commonjs,binary:$DESTINATION_DIR \
+ --grpc_out=generate_package_definition:$DESTINATION_DIR \
+ --proto_path=$PROTO_DIR \
+ $PROTO_DIR/$PROTO_FILENAME
+ "$NODE_MODULES_DIR/grpc_tools_node_protoc" \
+ --plugin=protoc-gen-ts=$TS_PROTOC_PLUGIN \
+ --ts_out=generate_package_definition:$TYPES_DESTINATION_DIR \
+ --proto_path=$PROTO_DIR \
+ $PROTO_DIR/$PROTO_FILENAME
+fi
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml
index 1b2123a06e..c88e0ba3d2 100644
--- a/talpid-core/Cargo.toml
+++ b/talpid-core/Cargo.toml
@@ -59,14 +59,14 @@ byteorder = "1"
nftnl = { version = "0.6", features = ["nftnl-1-1-0"] }
mnl = { version = "0.2.0", features = ["mnl-1-0-4"] }
which = { version = "4.0", default-features = false }
-tun = "0.5"
+tun = { git = "https://github.com/Ch00k/rust-tun.git", branch = "bump-ioctl" }
talpid-dbus = { path = "../talpid-dbus" }
[target.'cfg(target_os = "macos")'.dependencies]
-pfctl = "0.4"
+pfctl = { git = "https://github.com/mullvad/pfctl-rs.git" }
system-configuration = "0.4"
-tun = "0.5"
+tun = { git = "https://github.com/Ch00k/rust-tun.git", branch = "bump-ioctl" }
[target.'cfg(windows)'.dependencies]
diff --git a/wireguard/build-wireguard-go.sh b/wireguard/build-wireguard-go.sh
index 5b1cb3f0ce..cd696e23b2 100755
--- a/wireguard/build-wireguard-go.sh
+++ b/wireguard/build-wireguard-go.sh
@@ -72,7 +72,11 @@ function unix_target_triple {
if [[ ("${platform}" == "Linux") ]]; then
echo "x86_64-unknown-linux-gnu"
elif [[ ("${platform}" == "Darwin") ]]; then
- echo "x86_64-apple-darwin"
+ local arch="$(uname -m)"
+ if [[ ("${arch}" == "arm64") ]]; then
+ arch="aarch64"
+ fi
+ echo "${arch}-apple-darwin"
else
echo "Can't deduce target dir for $platform"
return 1