mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 00:02:47 +08:00
Simplify (and fix?) build.rs HAVE_XXX detection
Since none of the compiles(xxx) calls are to particularly complex code, we can just use `rsconf` directly to test for the presence of the symbols or headers as needed. Note that it seems at least some of the previous detection was not working correctly; in particular HAVE_PIPE2 was evaluating to false on my WSL install where pipe2(2) was available (caught because it revealed some compilation errors in that conditional compilation path after porting). I kept the cfg names and the tests themselves mostly as-is, though we might want to change that to conform with the rust convention of lowercase cfg names and decide whether we want to prefix all these with have_, fish_, or nothing at all. Also the posix_spawn() test should probably check for the symbol `posix_spawn()` rather than the header `spawn.h` since we don't use it via the header but rather via the symbol (but in reality they're almost certainly going to give the same result).
This commit is contained in:
parent
e02c572738
commit
33f33c5f41
17
build.rs
17
build.rs
|
@ -55,19 +55,6 @@ fn main() {
|
||||||
.include(&build_dir)
|
.include(&build_dir)
|
||||||
.compile("flibc.a");
|
.compile("flibc.a");
|
||||||
|
|
||||||
if compiles("src/cfg/w_exitcode.cpp") {
|
|
||||||
println!("cargo:rustc-cfg=HAVE_WAITSTATUS_SIGNAL_RET");
|
|
||||||
}
|
|
||||||
if compiles("src/cfg/eventfd.c") {
|
|
||||||
println!("cargo:rustc-cfg=HAVE_EVENTFD");
|
|
||||||
}
|
|
||||||
if compiles("src/cfg/pipe2.c") {
|
|
||||||
println!("cargo:rustc-cfg=HAVE_PIPE2");
|
|
||||||
}
|
|
||||||
if compiles("src/cfg/spawn.c") {
|
|
||||||
println!("cargo:rustc-cfg=FISH_USE_POSIX_SPAWN");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut build = cc::Build::new();
|
let mut build = cc::Build::new();
|
||||||
// Add to the default library search path
|
// Add to the default library search path
|
||||||
build.flag_if_supported("-L/usr/local/lib/");
|
build.flag_if_supported("-L/usr/local/lib/");
|
||||||
|
@ -102,6 +89,10 @@ fn detect_cfgs(target: Target) {
|
||||||
("gettext", &have_gettext),
|
("gettext", &have_gettext),
|
||||||
// See if the system headers provide the thread-safe localeconv_l(3) alternative to localeconv(3).
|
// See if the system headers provide the thread-safe localeconv_l(3) alternative to localeconv(3).
|
||||||
("localeconv_l", &|target| Ok(target.has_symbol_in::<String>("localeconv_l", &[]))),
|
("localeconv_l", &|target| Ok(target.has_symbol_in::<String>("localeconv_l", &[]))),
|
||||||
|
("FISH_USE_POSIX_SPAWN", &|target| Ok(target.has_header("spawn.h"))),
|
||||||
|
("HAVE_PIPE2", &|target| Ok(target.has_symbol_in::<String>("pipe2", &[]))),
|
||||||
|
("HAVE_EVENTFD", &|target| Ok(target.has_header("sys/eventfd.h"))),
|
||||||
|
("HAVE_WAITSTATUS_SIGNAL_RET", &|target| Ok(target.r#if("WEXITSTATUS(0x007f) == 0x7f", "sys/wait.h"))),
|
||||||
] {
|
] {
|
||||||
match handler(&target) {
|
match handler(&target) {
|
||||||
Err(e) => rsconf::warn!("{}: {}", name, e),
|
Err(e) => rsconf::warn!("{}: {}", name, e),
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#include <sys/eventfd.h>
|
|
|
@ -1,2 +0,0 @@
|
||||||
#include <unistd.h>
|
|
||||||
int ok = pipe2(0, 0);
|
|
|
@ -1 +0,0 @@
|
||||||
#include <spawn.h>
|
|
|
@ -1,2 +0,0 @@
|
||||||
#include <sys/wait.h>
|
|
||||||
static_assert(WEXITSTATUS(0x007f) == 0x7f, "");
|
|
Loading…
Reference in New Issue
Block a user