summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2025-01-14 14:55:11 +0100
committerDavid Lönnhager <david.l@mullvad.net>2025-01-24 17:35:03 +0100
commit919ef3d1df2a41eabf7763e84935e1c6f162a90b (patch)
tree900da7ae27692cae9d0090b3f61b7a69cc2867d1
parentebd035676df303390130283fddfdc471d5996e38 (diff)
downloadmullvadvpn-919ef3d1df2a41eabf7763e84935e1c6f162a90b.tar.xz
mullvadvpn-919ef3d1df2a41eabf7763e84935e1c6f162a90b.zip
Remove DAITA feature toggle from `wireguard-go-rs/build.rs`
-rw-r--r--wireguard-go-rs/build.rs37
1 files changed, 16 insertions, 21 deletions
diff --git a/wireguard-go-rs/build.rs b/wireguard-go-rs/build.rs
index ad485be28d..a2129d8641 100644
--- a/wireguard-go-rs/build.rs
+++ b/wireguard-go-rs/build.rs
@@ -20,10 +20,10 @@ fn main() -> anyhow::Result<()> {
println!("cargo::rerun-if-changed=libwg");
match target_os.as_str() {
- "windows" => build_desktop_lib(Os::Windows, true)?,
- "linux" => build_desktop_lib(Os::Linux, true)?,
- "macos" => build_desktop_lib(Os::Macos, true)?,
- "android" => build_android_dynamic_lib(true)?,
+ "windows" => build_desktop_lib(Os::Windows)?,
+ "linux" => build_desktop_lib(Os::Linux)?,
+ "macos" => build_desktop_lib(Os::Macos)?,
+ "android" => build_android_dynamic_lib()?,
_ => {}
}
@@ -33,7 +33,7 @@ fn main() -> anyhow::Result<()> {
#[derive(PartialEq, Eq, Clone, Copy)]
enum Os {
Windows,
- MacOs,
+ Macos,
Linux,
}
@@ -89,7 +89,7 @@ fn host_arch() -> anyhow::Result<Arch> {
}
/// Compile libwg as a library and place it in `OUT_DIR`.
-fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
+fn build_desktop_lib(target_os: Os) -> anyhow::Result<()> {
let out_dir = env::var("OUT_DIR").context("Missing OUT_DIR")?;
let target_arch =
env::var("CARGO_CFG_TARGET_ARCH").context("Missing 'CARGO_CFG_TARGET_ARCH")?;
@@ -118,9 +118,8 @@ fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
.nth(3)
.context("Failed to find target dir")?;
- if daita {
- build_shared_maybenot_lib(target_dir).context("Failed to build maybenot")?;
- }
+ // building maybenot is required for DAITA - wireguard-go will link to it at runtime.
+ build_shared_maybenot_lib(target_dir).context("Failed to build maybenot")?;
let dll_path = target_dir.join("libwg.dll");
@@ -134,7 +133,7 @@ fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
.args(["build", "-v"])
.arg("-o")
.arg(&dll_path)
- .args(if daita { &["--tags", "daita"][..] } else { &[] });
+ .args(["--tags", "daita"]);
// Build dynamic lib
go_build.args(["-buildmode", "c-shared"]);
@@ -159,7 +158,7 @@ fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
let out_file = format!("{out_dir}/libwg.a");
go_build
.args(["build", "-v", "-o", &out_file])
- .args(if daita { &["--tags", "daita"][..] } else { &[] });
+ .args(["--tags", "daita"]);
// Build static lib
go_build.args(["-buildmode", "c-archive"]);
@@ -181,7 +180,7 @@ fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
let out_file = format!("{out_dir}/libwg.a");
go_build
.args(["build", "-v", "-o", &out_file])
- .args(if daita { &["--tags", "daita"][..] } else { &[] });
+ .args(["--tags", "daita"]);
// Build static lib
go_build.args(["-buildmode", "c-archive"]);
@@ -215,10 +214,8 @@ fn build_desktop_lib(target_os: Os, daita: bool) -> anyhow::Result<()> {
exec(go_build)?;
- // if daita is enabled, also enable the corresponding rust feature flag
- if daita {
- println!(r#"cargo::rustc-cfg=daita"#);
- }
+ // Enable the DAITA (rust) feature flag
+ println!(r#"cargo::rustc-cfg=daita"#);
Ok(())
}
@@ -400,7 +397,7 @@ fn gather_exports(go_src_path: impl AsRef<Path>) -> anyhow::Result<Vec<String>>
/// Compile libwg as a dynamic library for android and place it in [`android_output_path`].
// NOTE: We use dynamic linking as Go cannot produce static binaries specifically for Android.
-fn build_android_dynamic_lib(daita: bool) -> anyhow::Result<()> {
+fn build_android_dynamic_lib() -> anyhow::Result<()> {
let out_dir = env::var("OUT_DIR").context("Missing OUT_DIR")?;
let target_triple = env::var("TARGET").context("Missing 'TARGET'")?;
let target = AndroidTarget::from_str(&target_triple)?;
@@ -451,10 +448,8 @@ fn build_android_dynamic_lib(daita: bool) -> anyhow::Result<()> {
println!("cargo::rustc-link-search={}", android_output_path.display());
println!("cargo::rustc-link-lib=dylib=wg");
- // If daita is enabled, also enable the corresponding rust feature flag
- if daita {
- println!(r#"cargo::rustc-cfg=daita"#);
- }
+ // Enable the DAITA (rust) feature flag
+ println!(r#"cargo::rustc-cfg=daita"#);
Ok(())
}