From a600072fbaa05016153174231fde61e8e696f573 Mon Sep 17 00:00:00 2001 From: ori raisfeld Date: Sat, 7 Oct 2023 18:31:04 +0300 Subject: [PATCH 1/2] added a function to remove flags --- src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 219d82cd7..baa8a615f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -428,6 +428,21 @@ impl Build { self } + /// removes a compiler flag that was added by [`Build::flag`] + /// + /// # 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 From 1ea7ca87d0d986c466bb9b32237ae44a2af7d82d Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sat, 11 Nov 2023 14:55:50 -0800 Subject: [PATCH 2/2] Reword/expand `remove_flag` doc comment. --- src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index baa8a615f..e69f3b70d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -428,7 +428,10 @@ impl Build { self } - /// removes a compiler flag that was added by [`Build::flag`] + /// 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 /// ```