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.
This commit is contained in:
Johannes Altmanninger
2023-09-15 11:56:03 +02:00
parent 3020c90856
commit 618834c4b5
2 changed files with 17 additions and 0 deletions

View File

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

View File

@@ -1,3 +1,6 @@
#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <term.h>
@@ -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; }