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 <jonathan.schwender@huawei.com>
This commit is contained in:
Jonathan Schwender 2024-07-04 11:21:49 +02:00 committed by GitHub
parent fb1c57da3e
commit 93fdb8263d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View file

@ -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");
}
}

View file

@ -6,8 +6,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;