mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Fix build.rs formatting and prep it for further feature detections
This commit is contained in:
parent
99c6c76c5e
commit
3fab931e86
@ -83,9 +83,11 @@ fn main() -> miette::Result<()> {
|
|||||||
/// [0]: https://github.com/rust-lang/cargo/issues/5499
|
/// [0]: https://github.com/rust-lang/cargo/issues/5499
|
||||||
fn detect_features() {
|
fn detect_features() {
|
||||||
for (feature, detector) in [
|
for (feature, detector) in [
|
||||||
("bsd", detect_bsd),
|
// Ignore the first line, it just sets up the type inference. Model new entries after the
|
||||||
]
|
// second line.
|
||||||
{
|
("", &(|| Ok(false)) as &dyn Fn() -> miette::Result<bool>),
|
||||||
|
("bsd", &detect_bsd),
|
||||||
|
] {
|
||||||
match detector() {
|
match detector() {
|
||||||
Err(e) => eprintln!("{feature} detect: {e}"),
|
Err(e) => eprintln!("{feature} detect: {e}"),
|
||||||
Ok(true) => println!("cargo:rustc-cfg=feature=\"{feature}\""),
|
Ok(true) => println!("cargo:rustc-cfg=feature=\"{feature}\""),
|
||||||
@ -101,7 +103,8 @@ fn detect_features() {
|
|||||||
/// doesn't necessarily include less-popular forks nor does it group them into families more
|
/// doesn't necessarily include less-popular forks nor does it group them into families more
|
||||||
/// specific than "windows" vs "unix" so we can conditionally compile code for BSD systems.
|
/// specific than "windows" vs "unix" so we can conditionally compile code for BSD systems.
|
||||||
fn detect_bsd() -> miette::Result<bool> {
|
fn detect_bsd() -> miette::Result<bool> {
|
||||||
let uname = std::process::Command::new("uname").output()
|
let uname = std::process::Command::new("uname")
|
||||||
|
.output()
|
||||||
.map_err(|_| miette!("Error executing uname!"))?;
|
.map_err(|_| miette!("Error executing uname!"))?;
|
||||||
Ok(std::str::from_utf8(&uname.stdout)
|
Ok(std::str::from_utf8(&uname.stdout)
|
||||||
.map(|s| s.to_ascii_lowercase())
|
.map(|s| s.to_ascii_lowercase())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user