From 618834c4b5cd6d094a9c7e9597584b85199ff3b3 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 15 Sep 2023 11:56:03 +0200 Subject: [PATCH] Port UVAR_FILE_SET_MTIME_HACK Notably this exposes config.h to Rust (for UVAR_FILE_SET_MTIME_HACK). In future we should move the CMake checks into build.rs so we can potentially get rid of CMake. --- fish-rust/build.rs | 5 +++++ fish-rust/src/compat.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/fish-rust/build.rs b/fish-rust/build.rs index a27eb3638..bef11e0e9 100644 --- a/fish-rust/build.rs +++ b/fish-rust/build.rs @@ -12,6 +12,11 @@ fn main() { cc::Build::new() .file("fish-rust/src/compat.c") + .include( + &std::env::var("FISH_BUILD_DIR") + // Add our default to potentially help tools that don't go through CMake. + .unwrap_or("./build".into()), + ) .compile("libcompat.a"); let rust_dir = env!("CARGO_MANIFEST_DIR"); diff --git a/fish-rust/src/compat.c b/fish-rust/src/compat.c index e403539bf..d28252cb1 100644 --- a/fish-rust/src/compat.c +++ b/fish-rust/src/compat.c @@ -1,3 +1,6 @@ +#include "config.h" + +#include #include #include #include @@ -47,3 +50,12 @@ uint64_t C_MNT_LOCAL() { return 0; #endif } + +static const bool uvar_file_set_mtime_hack = +#ifdef UVAR_FILE_SET_MTIME_HACK + true; +#else + false; +#endif +#undef UVAR_FILE_SET_MTIME_HACK +bool UVAR_FILE_SET_MTIME_HACK() { return uvar_file_set_mtime_hack; }