From a3a5d18188efa8ace769cb5754d42658cc901549 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 11 Dec 2024 18:37:10 +0000 Subject: [PATCH] fixup! chore(ffi): avoid hardcoding clang version cargo fmt --- bindings/matrix-sdk-crypto-ffi/build.rs | 21 +++++++++++---------- bindings/matrix-sdk-ffi/build.rs | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/bindings/matrix-sdk-crypto-ffi/build.rs b/bindings/matrix-sdk-crypto-ffi/build.rs index f1166e76b57..c22ffefd1ab 100644 --- a/bindings/matrix-sdk-crypto-ffi/build.rs +++ b/bindings/matrix-sdk-crypto-ffi/build.rs @@ -1,6 +1,5 @@ -use std::{env, error::Error}; -use std::path::PathBuf; -use std::process::Command; +use std::{env, error::Error, path::PathBuf, process::Command}; + use vergen::EmitBuilder; /// Adds a temporary workaround for an issue with the Rust compiler and Android @@ -13,10 +12,14 @@ fn setup_x86_64_android_workaround() { let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set"); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); if target_arch == "x86_64" && target_os == "android" { - // Configure rust to statically link against the `libclang_rt.builtins` supplied with clang. + // Configure rust to statically link against the `libclang_rt.builtins` supplied + // with clang. - // cargo-ndk sets CC_x86_64-linux-android to the path to `clang`, within the Android NDK. - let clang_path = PathBuf::from(env::var("CC_x86_64-linux-android").expect("CC_x86_64-linux-android not set")); + // cargo-ndk sets CC_x86_64-linux-android to the path to `clang`, within the + // Android NDK. + let clang_path = PathBuf::from( + env::var("CC_x86_64-linux-android").expect("CC_x86_64-linux-android not set"), + ); // clang_path should now look something like // `.../sdk/ndk/28.0.12674087/toolchains/llvm/prebuilt/linux-x86_64/bin/clang`. @@ -37,10 +40,8 @@ fn setup_x86_64_android_workaround() { /// Run the clang binary at `clang_path`, and return its major version number fn get_clang_major_version(clang_path: &PathBuf) -> String { - let clang_output = Command::new(clang_path) - .arg("-dumpversion") - .output() - .expect("failed to start clang"); + let clang_output = + Command::new(clang_path).arg("-dumpversion").output().expect("failed to start clang"); if !clang_output.status.success() { panic!("failed to run clang: {}", String::from_utf8_lossy(&clang_output.stderr)); diff --git a/bindings/matrix-sdk-ffi/build.rs b/bindings/matrix-sdk-ffi/build.rs index c3175c2470d..d06db9f8171 100644 --- a/bindings/matrix-sdk-ffi/build.rs +++ b/bindings/matrix-sdk-ffi/build.rs @@ -1,6 +1,5 @@ -use std::{env, error::Error}; -use std::path::PathBuf; -use std::process::Command; +use std::{env, error::Error, path::PathBuf, process::Command}; + use vergen::EmitBuilder; /// Adds a temporary workaround for an issue with the Rust compiler and Android @@ -13,10 +12,14 @@ fn setup_x86_64_android_workaround() { let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set"); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set"); if target_arch == "x86_64" && target_os == "android" { - // Configure rust to statically link against the `libclang_rt.builtins` supplied with clang. + // Configure rust to statically link against the `libclang_rt.builtins` supplied + // with clang. - // cargo-ndk sets CC_x86_64-linux-android to the path to `clang`, within the Android NDK. - let clang_path = PathBuf::from(env::var("CC_x86_64-linux-android").expect("CC_x86_64-linux-android not set")); + // cargo-ndk sets CC_x86_64-linux-android to the path to `clang`, within the + // Android NDK. + let clang_path = PathBuf::from( + env::var("CC_x86_64-linux-android").expect("CC_x86_64-linux-android not set"), + ); // clang_path should now look something like // `.../sdk/ndk/28.0.12674087/toolchains/llvm/prebuilt/linux-x86_64/bin/clang`. @@ -37,10 +40,8 @@ fn setup_x86_64_android_workaround() { /// Run the clang binary at `clang_path`, and return its major version number fn get_clang_major_version(clang_path: &PathBuf) -> String { - let clang_output = Command::new(clang_path) - .arg("-dumpversion") - .output() - .expect("failed to start clang"); + let clang_output = + Command::new(clang_path).arg("-dumpversion").output().expect("failed to start clang"); if !clang_output.status.success() { panic!("failed to run clang: {}", String::from_utf8_lossy(&clang_output.stderr));