Skip to content

Commit

Permalink
Guess fcntl feature from _fcntl_r symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Oct 18, 2023
1 parent d7ba8f3 commit 9786890
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::{collections::HashMap, path::Path, process::Command};

const FEATURES: &[&str] = &["socketpair", "pipe2", "fcntl"];
const FEATURES: &[(&str, &str)] = &[
("socketpair", "socketpair"),
("pipe2", "pipe2"),
("_fcntl_r", "fcntl"),
];

fn main() {
if std::env::var("DOCS_RS").is_ok() {
Expand Down Expand Up @@ -33,14 +37,14 @@ fn main() {
.collect::<HashMap<_, _>>();

for line in nm_result {
for (feature, enabled) in &mut features {
if line == format!("00000000 T {}", feature) {
for ((symbol, _), enabled) in &mut features {
if line == format!("00000000 T {}", symbol) {
*enabled = true;
}
}
}

for (feature, _) in features.iter().filter(|(_, enabled)| !**enabled) {
for ((_, feature), _) in features.iter().filter(|(_, enabled)| !**enabled) {
println!("cargo:rustc-cfg=feature=\"{}\"", feature);
}
}

0 comments on commit 9786890

Please sign in to comment.