Skip to content

Commit bb1220d

Browse files
raisfeld-orithomcc
andauthored
added a function to remove flags (#885)
* added a function to remove flags * Reword/expand `remove_flag` doc comment. --------- Co-authored-by: Thom Chiovoloni <thom@shift.click>
1 parent 4c0062d commit bb1220d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,24 @@ impl Build {
431431
self
432432
}
433433

434+
/// Removes a compiler flag that was added by [`Build::flag`].
435+
///
436+
/// Will not remove flags added by other means (default flags,
437+
/// flags from env, and so on).
438+
///
439+
/// # Example
440+
/// ```
441+
/// cc::Build::new()
442+
/// .file("src/foo.c")
443+
/// .flag("unwanted_flag")
444+
/// .remove_flag("unwanted_flag");
445+
/// ```
446+
447+
pub fn remove_flag(&mut self, flag: &str) -> &mut Build {
448+
self.flags.retain(|other_flag| &**other_flag != flag);
449+
self
450+
}
451+
434452
/// Add a flag to the invocation of the ar
435453
///
436454
/// # Example

0 commit comments

Comments
 (0)