Skip to contentSkip to conversation

rust: Use grep -Ev rather than relying on GNU grep

PATCH Applied Matthew Maurer 5 participants 6 messages Sep 28, 2023 – Oct 15, 2023 Rust

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: Use grep -Ev rather than relying on GNU grep

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

---
 rust/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/Makefile +2 -2
index 87958e864be0..e6fb7cafc0bc 100644
@@ -336,13 +336,13 @@ quiet_cmd_bindgen = BINDGEN $@
 		$(bindgen_target_cflags) $(bindgen_target_extra)
 
 $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
-    $(shell grep -v '^#\|^$$' $(srctree)/$(src)/bindgen_parameters)
+    $(shell grep -Ev '^#|^$$' $(srctree)/$(src)/bindgen_parameters)
 $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
     $(src)/bindgen_parameters FORCE
 	$(call if_changed_dep,bindgen)
 
 $(obj)/uapi/uapi_generated.rs: private bindgen_target_flags = \
-    $(shell grep -v '^#\|^$$' $(srctree)/$(src)/bindgen_parameters)
+    $(shell grep -Ev '^#|^$$' $(srctree)/$(src)/bindgen_parameters)
 $(obj)/uapi/uapi_generated.rs: $(src)/uapi/uapi_helper.h \
     $(src)/bindgen_parameters FORCE
 	$(call if_changed_dep,bindgen)
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Matthew Maurer

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

---

Reviewed-by on v1 1/1
#2 lore raw
In reply to Matthew Maurer
Quoted 8 lines · Matthew Maurer

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

---
[...]

reviewer Reviewed-by Tested-by on v1 1/1
#3 lore raw
In reply to Matthew Maurer
Quoted 7 lines · Matthew Maurer

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

LGTM. I tested this in my Android build.

reviewer
#4 lore raw
Quoted 11 lines · Alice Ryhl
Quoted 7 lines · Matthew Maurer

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

LGTM. I tested this in my Android build.

Also tested in a non-Android build. Works both places.

Quoted 2 lines
Applied
#5 lore raw
In reply to Matthew Maurer
Quoted 7 lines · Matthew Maurer

While GNU grep supports '\|' when in basic regular expression mode, not all grep implementations do (notably toybox grep, used to build the Android kernel, does not). Switching to grep -Ev enables extended regular expresions which includes support for the '|' operator.

Applied to rust-next (with typo fixed) -- thanks everyone!

Cheers,
Miguel