Skip to content

Commit 76df4d8

Browse files
committed
Add support for -isystem, -iquote, -idirafter include flags
Fixes #114
1 parent e94a533 commit 76df4d8

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

src/lib.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,17 @@ impl Library {
518518
}
519519
};
520520

521+
let mut dirs = Vec::new();
522+
let statik = config.is_static(name);
523+
521524
let words = split_flags(output);
525+
526+
// Handle single-character arguments like `-I/usr/include`
522527
let parts = words
523528
.iter()
524529
.filter(|l| l.len() > 2)
525530
.map(|arg| (&arg[0..2], &arg[2..]))
526531
.collect::<Vec<_>>();
527-
528-
let mut dirs = Vec::new();
529-
let statik = config.is_static(name);
530532
for &(flag, val) in &parts {
531533
match flag {
532534
"-L" => {
@@ -570,6 +572,7 @@ impl Library {
570572
}
571573
}
572574

575+
// Handle multi-character arguments with space-separated value like `-framework foo`
573576
let mut iter = words.iter().flat_map(|arg| {
574577
if arg.starts_with("-Wl,") {
575578
arg[4..].split(',').collect()
@@ -578,13 +581,20 @@ impl Library {
578581
}
579582
});
580583
while let Some(part) = iter.next() {
581-
if part != "-framework" {
582-
continue;
583-
}
584-
if let Some(lib) = iter.next() {
585-
let meta = format!("rustc-link-lib=framework={}", lib);
586-
config.print_metadata(&meta);
587-
self.frameworks.push(lib.to_string());
584+
match part {
585+
"-framework" => {
586+
if let Some(lib) = iter.next() {
587+
let meta = format!("rustc-link-lib=framework={}", lib);
588+
config.print_metadata(&meta);
589+
self.frameworks.push(lib.to_string());
590+
}
591+
}
592+
"-isystem" | "-iquote" | "-idirafter" => {
593+
if let Some(inc) = iter.next() {
594+
self.include_paths.push(PathBuf::from(inc));
595+
}
596+
}
597+
_ => (),
588598
}
589599
}
590600
}

tests/foo.pc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Description: A dynamic binary instrumentation framework
1212
Version: 3.10.0.SVN
1313
Requires:
1414
Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc
15-
Cflags: -I${includedir}
15+
Cflags: -I${includedir} -isystem /usr/foo
1616

tests/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ fn output_ok() {
9999
assert!(lib.libs.contains(&"gcc".to_string()));
100100
assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string()));
101101
assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind")));
102+
assert!(lib
103+
.include_paths
104+
.contains(&PathBuf::from("/usr/include/valgrind")));
105+
assert!(lib.include_paths.contains(&PathBuf::from("/usr/foo")));
102106
}
103107

104108
#[test]

0 commit comments

Comments
 (0)