Skip to content

Commit cc8a249

Browse files
authored
Method to add multiple includes: build.includes(...) (#550)
1 parent 5268359 commit cc8a249

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,35 @@ impl Build {
337337
self
338338
}
339339

340+
/// Add multiple directories to the `-I` include path.
341+
///
342+
/// # Example
343+
///
344+
/// ```no_run
345+
/// # use std::path::Path;
346+
/// # let condition = true;
347+
/// #
348+
/// let mut extra_dir = None;
349+
/// if condition {
350+
/// extra_dir = Some(Path::new("/path/to"));
351+
/// }
352+
///
353+
/// cc::Build::new()
354+
/// .file("src/foo.c")
355+
/// .includes(extra_dir)
356+
/// .compile("foo");
357+
/// ```
358+
pub fn includes<P>(&mut self, dirs: P) -> &mut Build
359+
where
360+
P: IntoIterator,
361+
P::Item: AsRef<Path>,
362+
{
363+
for dir in dirs {
364+
self.include(dir);
365+
}
366+
self
367+
}
368+
340369
/// Specify a `-D` variable with an optional value.
341370
///
342371
/// # Example

0 commit comments

Comments
 (0)