From 93fdb8263d14346d0757c2192527bc8c7c577572 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:21:49 +0200 Subject: [PATCH] Make task_info as `macos` specific (#32693) rust-analyzer breaks on Linux (when invoked without mach), because it tries to compile the c files, and doesn't find `mach_init.h` Since we don't need task_info on non-mac platforms, just make the crate empty on other platforms. Signed-off-by: Jonathan Schwender --- support/rust-task_info/build.rs | 10 +++++++--- support/rust-task_info/src/lib.rs | 5 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/support/rust-task_info/build.rs b/support/rust-task_info/build.rs index 4a05166e539..73d68fdd54b 100644 --- a/support/rust-task_info/build.rs +++ b/support/rust-task_info/build.rs @@ -3,7 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ fn main() { - cc::Build::new() - .file("src/task_info.c") - .compile("libtask_info.a"); + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + + if target_os == "macos" { + cc::Build::new() + .file("src/task_info.c") + .compile("libtask_info.a"); + } } diff --git a/support/rust-task_info/src/lib.rs b/support/rust-task_info/src/lib.rs index 62a1164ff1d..c2bef92feef 100644 --- a/support/rust-task_info/src/lib.rs +++ b/support/rust-task_info/src/lib.rs @@ -6,8 +6,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +//! A helper crate to get task information on macos. -#![crate_name = "task_info"] -#![crate_type = "rlib"] - +#[cfg(target_os = "macos")] pub mod task_basic_info;