Skip to content

Commit

Permalink
added a function to remove flags (#885)
Browse files Browse the repository at this point in the history
* added a function to remove flags

* Reword/expand `remove_flag` doc comment.

---------

Co-authored-by: Thom Chiovoloni <thom@shift.click>
  • Loading branch information
raisfeld-ori and thomcc authored Nov 11, 2023
1 parent 4c0062d commit bb1220d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ impl Build {
self
}

/// Removes a compiler flag that was added by [`Build::flag`].
///
/// Will not remove flags added by other means (default flags,
/// flags from env, and so on).
///
/// # Example
/// ```
/// cc::Build::new()
/// .file("src/foo.c")
/// .flag("unwanted_flag")
/// .remove_flag("unwanted_flag");
/// ```
pub fn remove_flag(&mut self, flag: &str) -> &mut Build {
self.flags.retain(|other_flag| &**other_flag != flag);
self
}

/// Add a flag to the invocation of the ar
///
/// # Example
Expand Down

0 comments on commit bb1220d

Please sign in to comment.