diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-02-26 19:10:27 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-02-26 19:10:27 +0100 |
| commit | ae3dfbc048dd36f9acd41aebddd07b20ffa3c784 (patch) | |
| tree | 996bea79673ff07ff1f491932270186edc4285c0 | |
| parent | b09da89cf6a974e3ba8bd6b0cfebebb3765d5a50 (diff) | |
| parent | 0c093442ae4fe6701d45d18353160dc78e05249c (diff) | |
| download | mullvadvpn-ae3dfbc048dd36f9acd41aebddd07b20ffa3c784.tar.xz mullvadvpn-ae3dfbc048dd36f9acd41aebddd07b20ffa3c784.zip | |
Merge remote-tracking branch 'Ch00k/apple-silicon'
| -rw-r--r-- | Cargo.lock | 12 | ||||
| -rw-r--r-- | README.md | 34 | ||||
| -rwxr-xr-x | build.sh | 9 | ||||
| -rw-r--r-- | gui/package.json | 4 | ||||
| -rwxr-xr-x | gui/scripts/build-proto.sh | 36 | ||||
| -rw-r--r-- | talpid-core/Cargo.toml | 6 | ||||
| -rwxr-xr-x | wireguard/build-wireguard-go.sh | 6 |
7 files changed, 76 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock index 7f415361ec..9601349809 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" @@ -1724,9 +1724,9 @@ dependencies = [ [[package]] name = "pfctl" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfaa4493763cdea373bba96f1ae88f2012f97293ed58bfcc2ca09737132c833" +checksum = "26d091ecb01c905b5a31757cd43a6d00b484c835831e41e8b20385dec08514fc" dependencies = [ "derive_builder", "errno", @@ -3104,9 +3104,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "tun" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25229e5c4fd761c0e5cd7ae4dfcbaf0d98ded8a4367434f255639d6e554cf564" +checksum = "cde2c6cb9cc8643fda7ef1b093de76a682bccd6b2868eeea7e96afde072c44fd" dependencies = [ "ioctl-sys", "libc", @@ -297,6 +297,40 @@ 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 `MANAGEMENT_INTERFACE_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 +cd gui/scripts +npm ci +./build-proto.sh +``` + +After that copy the files from `gui/src/main/management_interface/` and `gui/build/src/main/management_interface/` +directories into a single directory on your Apple Silicon Mac, and set the value of +`MANAGEMENT_INTERFACE_PROTO_BUILD_DIR` to that directory while running the main build. + +On your Apple Silicon Mac install `protobuf` by running: + +```bash +brew install protobuf +``` + +When all is done run the main build. Assuming that you copied the proto files into `/tmp/management_interface_proto` +directory, the build command will look as follows: + +```bash +MANAGEMENT_INTERFACE_PROTO_BUILD_DIR=/tmp/management_interface_proto ./build.sh --dev-build +``` + If you want to build each component individually, or run in development mode, read the following sections. @@ -217,14 +217,7 @@ pushd "$SCRIPT_DIR/gui" echo "Installing JavaScript dependencies..." -# Add `--no-optional` flag when running on non-macOS environments because `npm ci` attempts to -# install optional dependencies that aren't even available on other platforms. -NPM_CI_ARGS="" -if [ "$(uname -s)" != "Darwin" ]; then - NPM_CI_ARGS+="--no-optional" -fi - -npm ci $NPM_CI_ARGS +npm ci ################################################################################ # Package release. 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..29e5f2793c 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)" +MANAGEMENT_INTERFACE_PROTO_BUILD_DIR=${MANAGEMENT_INTERFACE_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 "${MANAGEMENT_INTERFACE_PROTO_BUILD_DIR}" ]]; then + cp $MANAGEMENT_INTERFACE_PROTO_BUILD_DIR/*.js $DESTINATION_DIR + cp $MANAGEMENT_INTERFACE_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 MANAGEMENT_INTERFACE_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..7c01358484 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 = "0.5.1" talpid-dbus = { path = "../talpid-dbus" } [target.'cfg(target_os = "macos")'.dependencies] -pfctl = "0.4" +pfctl = "0.4.1" system-configuration = "0.4" -tun = "0.5" +tun = "0.5.1" [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 |
