Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit b8360b6

Browse files
committed
wild hack to get the cflags now in use
1 parent b6dec7c commit b8360b6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

build.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extern crate nix;
33

44
use std::env;
55
use std::path::PathBuf;
6+
use std::process::Command;
67

78
const HEADERS: &[&str] = &["linux/fs.h"];
89
const INCLUDED_TYPES: &[&str] = &["file_system_type"];
@@ -11,10 +12,30 @@ const INCLUDED_VARS: &[&str] = &[];
1112

1213
fn main() {
1314
let kernel = nix::sys::utsname::uname();
14-
let mut builder = bindgen::Builder::default().clang_arg(format!("-I/lib/modules/{}/build/include", kernel.release()));
15+
let mut builder = bindgen::Builder::default();
16+
17+
let output = String::from_utf8(
18+
Command::new("make")
19+
.arg("-C")
20+
.arg("kernel-cflags-finder")
21+
.arg("-s")
22+
.output()
23+
.unwrap()
24+
.stdout,
25+
).unwrap();
26+
assert!(!output.contains('"'));
27+
assert!(!output.contains('\''));
28+
29+
for arg in output.split(' ') {
30+
builder = builder.clang_arg(arg);
31+
}
1532

1633
for h in HEADERS {
17-
builder = builder.header(format!("/lib/modules/{}/build/include/{}", kernel.release(), h.to_string()));
34+
builder = builder.header(format!(
35+
"/lib/modules/{}/build/include/{}",
36+
kernel.release(),
37+
h.to_string()
38+
));
1839
}
1940

2041
for t in INCLUDED_TYPES {

0 commit comments

Comments
 (0)