Skip to content

Commit

Permalink
Merge remote-tracking branch 'Ch00k/apple-silicon'
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Feb 26, 2021
2 parents b09da89 + 0c09344 commit ae3dfbc
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 32 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 1 addition & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"uuid": "^3.0.1"
},
"optionalDependencies": {
"grpc-tools": "^1.10.0",
"nseventmonitor": "^1.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
38 changes: 26 additions & 12 deletions gui/scripts/build-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
6 changes: 3 additions & 3 deletions talpid-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 5 additions & 1 deletion wireguard/build-wireguard-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae3dfbc

Please sign in to comment.