diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-08-06 14:05:55 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-08-07 13:48:28 +0200 |
| commit | 26fddca7799ad01425458262d5ca774ded1ce96f (patch) | |
| tree | ceb46758c7720bda6c732020c5763abb42f997dc | |
| parent | 4626c3d2cdf4be2ac6eb9f2ab9e4d6c972cbebf4 (diff) | |
| download | mullvadvpn-26fddca7799ad01425458262d5ca774ded1ce96f.tar.xz mullvadvpn-26fddca7799ad01425458262d5ca774ded1ce96f.zip | |
Fix build.rs for mullvad-nsis treating target arch as host
| -rw-r--r-- | Cargo.lock | 24 | ||||
| -rw-r--r-- | mullvad-nsis/Cargo.toml | 4 | ||||
| -rw-r--r-- | mullvad-nsis/build.rs | 32 | ||||
| -rw-r--r-- | mullvad-nsis/include/mullvad-nsis.h | 24 |
4 files changed, 50 insertions, 34 deletions
diff --git a/Cargo.lock b/Cargo.lock index 1de4ace145..2e3b8d636e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,24 +562,6 @@ dependencies = [ [[package]] name = "cbindgen" -version = "0.24.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b922faaf31122819ec80c4047cc684c6979a087366c069611e33649bf98e18d" -dependencies = [ - "heck 0.4.1", - "indexmap 1.9.3", - "log", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 1.0.109", - "tempfile", - "toml 0.5.11", -] - -[[package]] -name = "cbindgen" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff" @@ -2867,7 +2849,7 @@ version = "0.0.0" dependencies = [ "anyhow", "async-trait", - "cbindgen 0.28.0", + "cbindgen", "chrono", "futures", "http 1.1.0", @@ -3018,7 +3000,7 @@ name = "mullvad-ios" version = "0.0.0" dependencies = [ "async-trait", - "cbindgen 0.28.0", + "cbindgen", "futures", "hyper", "hyper-util", @@ -3129,7 +3111,7 @@ dependencies = [ name = "mullvad-nsis" version = "0.0.0" dependencies = [ - "cbindgen 0.24.5", + "cbindgen", "mullvad-paths", "talpid-platform-metadata", ] diff --git a/mullvad-nsis/Cargo.toml b/mullvad-nsis/Cargo.toml index 87343f6a9e..f226d093cc 100644 --- a/mullvad-nsis/Cargo.toml +++ b/mullvad-nsis/Cargo.toml @@ -17,5 +17,5 @@ crate-type = ["staticlib"] mullvad-paths = { path = "../mullvad-paths" } talpid-platform-metadata = { path = "../talpid-platform-metadata" } -[target.i686-pc-windows-msvc.build-dependencies] -cbindgen = { version = "0.24.3", default-features = false } +[target.'cfg(target_os = "windows")'.build-dependencies] +cbindgen = { version = "0.28.0", default-features = false } diff --git a/mullvad-nsis/build.rs b/mullvad-nsis/build.rs index db54faa78a..27472227c9 100644 --- a/mullvad-nsis/build.rs +++ b/mullvad-nsis/build.rs @@ -1,13 +1,29 @@ -fn main() { - #[cfg(all(target_arch = "x86", target_os = "windows"))] - { - use std::env; +#[cfg(target_os = "windows")] +mod inner { + use cbindgen::Language; + + pub fn main() { + let target_triple = std::env::var("TARGET").expect("Missing 'TARGET'"); - let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - let mut config: cbindgen::Config = Default::default(); - config.language = cbindgen::Language::Cxx; - cbindgen::generate_with_config(&crate_dir, config) + if !target_triple.contains("i686-pc-windows") { + return; + } + + let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + cbindgen::Builder::new() + .with_language(Language::Cxx) + .with_crate(crate_dir) + .generate() .unwrap() .write_to_file("include/mullvad-nsis.h"); } } + +#[cfg(not(target_os = "windows"))] +mod inner { + pub fn main() {} +} + +fn main() { + inner::main() +} diff --git a/mullvad-nsis/include/mullvad-nsis.h b/mullvad-nsis/include/mullvad-nsis.h index ef55b2fc73..3847df273b 100644 --- a/mullvad-nsis/include/mullvad-nsis.h +++ b/mullvad-nsis/include/mullvad-nsis.h @@ -14,15 +14,33 @@ enum class Status { extern "C" { +/// Creates a privileged directory at the specified Windows path. +/// +/// # SAFETY +/// path needs to be a windows path encoded as a string of u16 that terminates in 0 (two +/// nul-bytes). The string is also not allowed to be greater than `MAX_PATH_SIZE`. +Status create_privileged_directory(const uint16_t *path); + /// Writes the system's app data path into `buffer` when `Status::Ok` is returned. /// If `buffer` is `null`, or if the buffer is too small, `InsufficientBufferSize` /// is returned, and the required buffer size (in chars) is returned in `buffer_size`. /// On success, `buffer_size` is set to the length of the string, including /// the final null terminator. +/// +/// # SAFETY +/// if `buffer` is not null, it must point to a valid memory location that can hold +/// at least `buffer_size` number of `u16` values. Status get_system_local_appdata(uint16_t *buffer, uintptr_t *buffer_size); -Status create_privileged_directory(const uint16_t* path); - +/// Writes the system's version data into `buffer` when `Status::Ok` is +/// returned. If `buffer` is `null`, or if the buffer is too small, +/// `InsufficientBufferSize` is returned, and the required buffer size (in +/// chars) is returned in `buffer_size`. On success, `buffer_size` is set to the +/// length of the string, including the final null terminator. +/// +/// # Safety +/// If `buffer` is not null, it must point to a valid memory location that can hold +/// at least `*buffer_size` number of `u16` values. `buffer_size` must be a valid pointer. Status get_system_version(uint16_t *buffer, uintptr_t *buffer_size); -} // extern "C" +} // extern "C" |
