diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-01-15 09:31:00 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-01-24 17:35:03 +0100 |
| commit | c9c9e12376bb8e6691f4f56d970d23907637cfb2 (patch) | |
| tree | 14c5ba431503aba137fa99b27895837c378fe603 | |
| parent | 04772fccb6229e97309096f62ca1fa86fbe3ccca (diff) | |
| download | mullvadvpn-c9c9e12376bb8e6691f4f56d970d23907637cfb2.tar.xz mullvadvpn-c9c9e12376bb8e6691f4f56d970d23907637cfb2.zip | |
Compile `wireguard-go-rs` from unsupported host is a hard error
| -rw-r--r-- | wireguard-go-rs/build.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/wireguard-go-rs/build.rs b/wireguard-go-rs/build.rs index 676927aef6..235cadbb5e 100644 --- a/wireguard-go-rs/build.rs +++ b/wireguard-go-rs/build.rs @@ -64,18 +64,19 @@ impl AndroidTarget { } } -fn host_os() -> anyhow::Result<Os> { +const fn host_os() -> Os { // this ugliness is a limitation of rust, where we can't directly // access the target triple of the build script. - if cfg!(target_os = "windows") { - Ok(Os::Windows) + const HOST: Os = if cfg!(target_os = "windows") { + Os::Windows } else if cfg!(target_os = "linux") { - Ok(Os::Linux) + Os::Linux } else if cfg!(target_os = "macos") { - Ok(Os::Macos) + Os::Macos } else { - bail!("Unsupported host OS") - } + panic!("Unsupported host OS") + }; + HOST } fn host_arch() -> anyhow::Result<Arch> { @@ -104,7 +105,7 @@ fn build_desktop_lib(target_os: Os) -> anyhow::Result<()> { go_build.env("CGO_ENABLED", "1").current_dir("./libwg"); // are we cross compiling? - let cross_compiling = host_os()? != target_os || host_arch()? != target_arch; + let cross_compiling = host_os() != target_os || host_arch()? != target_arch; match target_arch { Arch::Amd64 => go_build.env("GOARCH", "amd64"), |
