diff options
| -rw-r--r-- | BuildInstructions.md | 29 | ||||
| -rwxr-xr-x | build-windows-modules.sh | 18 | ||||
| -rwxr-xr-x | build.sh | 28 | ||||
| -rw-r--r-- | scripts/utils/host | 7 |
4 files changed, 68 insertions, 14 deletions
diff --git a/BuildInstructions.md b/BuildInstructions.md index 560ce9ce90..48da8cdfbf 100644 --- a/BuildInstructions.md +++ b/BuildInstructions.md @@ -95,10 +95,13 @@ The host has to have the following installed: - `msbuild.exe` available in `%PATH%`. If you installed Visual Studio Community edition, the binary can be found under: + ``` - C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64 + C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\<arch> ``` + Where `<arch>` refers to the host architecture, either `amd64` or `arm64`. + - `bash` installed as well as a few base unix utilities, including `sed` and `tail`. You are recommended to use [Git for Windows]. @@ -125,6 +128,30 @@ for ARM64 on x64. This requires: rustup target add aarch64-pc-windows-msvc ``` +### Compiling *on* Windows Arm + +In addition to the above requirements: + +- `x86_64-pc-windows-msvc` is required to build `talpid-openvpn-plugin`: + + ```bash + rustup target add x86_64-pc-windows-msvc + ``` + +- `clang` is required (can be found in the Visual Studio installer) in `PATH`. + + `INCLUDE` also needs to include the correct headers for clang. This can be found by running + `vcvarsall.bat arm64` and typing `set INCLUDE`. + +- `grpc-tools` currently doesn't include ARM builds. The x64 binaries must be installed to build + the Electron app: + + ``` + pushd gui + npm install --target_arch=x64 grpc-tools + popd + ``` + ## macOS The host has to have the following installed: diff --git a/build-windows-modules.sh b/build-windows-modules.sh index d97dc3066e..6fcfc7ae85 100755 --- a/build-windows-modules.sh +++ b/build-windows-modules.sh @@ -2,12 +2,26 @@ set -eu +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR" + +source scripts/utils/host + +case $HOST in + x86_64-pc-windows-msvc) HOST_TARGET=x64;; + aarch64-pc-windows-msvc) HOST_TARGET=ARM64;; + *) + log_error "Unknown Windows target: $HOST" + exit 1 + ;; +esac + # List of solution configurations to build. # Default configurations generated by Visual Studio are "Release" and "Debug". CPP_BUILD_MODES=${CPP_BUILD_MODES:-"Debug"} # List of target platforms to build for. # Common platforms include "x86" and "x64". -CPP_BUILD_TARGETS=${CPP_BUILD_TARGETS:-"x64"} +CPP_BUILD_TARGETS=${CPP_BUILD_TARGETS:-"$HOST_TARGET"} IS_RELEASE=${IS_RELEASE:-"false"} @@ -54,7 +68,7 @@ function to_win_path { echo "$unixpath" | sed -e 's/^\///' -e 's/\//\\/g' # if it's an absolute path, transform the drive prefix else - # remove the cygrdive prefix if it's there + # remove the cygdrive prefix if it's there unixpath=$(echo "$unixpath" | sed -e 's/^\/cygdrive//') echo "$unixpath" | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/' fi @@ -203,10 +203,13 @@ function sign_win { # Build the daemon and other Rust/C++ binaries, optionally # sign them, and copy to `dist-assets/`. function build { - local current_target=${1:-""} - local for_target_string=" for local target $HOST" - if [[ -n $current_target ]]; then + local specified_target=${1:-""} + local current_target=${specified_target:-"$HOST"} + local for_target_string + if [[ -n $specified_target ]]; then for_target_string=" for $current_target" + else + for_target_string=" for local target $HOST" fi ################################################################################ @@ -216,8 +219,8 @@ function build { log_header "Building Rust code in $RUST_BUILD_MODE mode using $RUSTC_VERSION$for_target_string" local cargo_target_arg=() - if [[ -n $current_target ]]; then - cargo_target_arg+=(--target="$current_target") + if [[ -n $specified_target ]]; then + cargo_target_arg+=(--target="$specified_target") fi local cargo_crates_to_build=( -p mullvad-daemon --bin mullvad-daemon @@ -263,11 +266,11 @@ function build { ) fi - if [[ -n $current_target ]]; then - local cargo_output_dir="$CARGO_TARGET_DIR/$current_target/$RUST_BUILD_MODE" + if [[ -n $specified_target ]]; then + local cargo_output_dir="$CARGO_TARGET_DIR/$specified_target/$RUST_BUILD_MODE" # To make it easier to package multiple targets, the binaries are # located in a directory with the name of the target triple. - local destination_dir="dist-assets/$current_target" + local destination_dir="dist-assets/$specified_target" mkdir -p "$destination_dir" else local cargo_output_dir="$CARGO_TARGET_DIR/$RUST_BUILD_MODE" @@ -290,7 +293,12 @@ function build { # We ship x64 OpenVPN with ARM64, so we need an x64 talpid-openvpn-plugin # to include in the package. local source="$CARGO_TARGET_DIR/x86_64-pc-windows-msvc/$RUST_BUILD_MODE/talpid_openvpn_plugin.dll" - local destination="dist-assets/aarch64-pc-windows-msvc/talpid_openvpn_plugin.dll" + local destination + if [[ -n "$specified_target" ]]; then + destination="dist-assets/$specified_target/talpid_openvpn_plugin.dll" + else + destination="dist-assets/talpid_openvpn_plugin.dll" + fi log_info "Workaround: building x64 talpid-openvpn-plugin" cargo build --target x86_64-pc-windows-msvc "${CARGO_ARGS[@]}" -p talpid-openvpn-plugin --lib @@ -302,7 +310,7 @@ function build { } if [[ "$(uname -s)" == "MINGW"* ]]; then - for t in "${TARGETS[@]:-"x86_64-pc-windows-msvc"}"; do + for t in "${TARGETS[@]:-"$HOST"}"; do case $t in x86_64-pc-windows-msvc) CPP_BUILD_TARGET=x64;; aarch64-pc-windows-msvc) CPP_BUILD_TARGET=ARM64;; diff --git a/scripts/utils/host b/scripts/utils/host index 28301e636d..1d81b32464 100644 --- a/scripts/utils/host +++ b/scripts/utils/host @@ -16,6 +16,11 @@ case "$(uname -s)" in HOST="${arch}-apple-darwin" ;; MINGW*|MSYS_NT*) - HOST="x86_64-pc-windows-msvc" + arch="$(powershell -Command "(Get-CimInstance Win32_OperatingSystem).OSArchitecture")" + if [[ $arch == "ARM 64"* ]]; then + HOST="aarch64-pc-windows-msvc" + else + HOST="x86_64-pc-windows-msvc" + fi ;; esac |
