Skip to content

Commit 588c2f6

Browse files
committed
Add ARM GCC include dirs
1 parent b5a1453 commit 588c2f6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

stm32-bindings-gen/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ impl Gen {
270270
builder = builder.clang_arg(*arg);
271271
}
272272

273+
for arg in arm_sysroot_args() {
274+
builder = builder.clang_arg(arg);
275+
}
276+
273277
if !spec.allowlist.is_empty() {
274278
for pattern in spec.allowlist {
275279
builder = builder
@@ -394,3 +398,24 @@ impl Gen {
394398
triple.trim().to_ascii_lowercase().starts_with("thumb")
395399
}
396400
}
401+
402+
fn arm_sysroot_args() -> Vec<String> {
403+
if let Ok(output) = Command::new("arm-none-eabi-gcc")
404+
.arg("-print-sysroot")
405+
.output()
406+
{
407+
if output.status.success() {
408+
if let Ok(path) = String::from_utf8(output.stdout) {
409+
let trimmed = path.trim();
410+
if !trimmed.is_empty() {
411+
return vec![
412+
format!("--sysroot={trimmed}"),
413+
format!("-I{trimmed}/include"),
414+
format!("-I{trimmed}/include/c++/11.2.1"), // adjust compiler version if needed
415+
];
416+
}
417+
}
418+
}
419+
}
420+
Vec::new()
421+
}

0 commit comments

Comments
 (0)