[PATCH] rust: Use grep -Ev rather than relying on GNU grep

Matthew Maurer posted 1 patch 2 years, 2 months ago
rust/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Matthew Maurer 2 years, 2 months ago
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.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---
 rust/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/Makefile b/rust/Makefile
index 87958e864be0..e6fb7cafc0bc 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -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)
-- 
2.42.0.582.g8ccd20d70d-goog
Re: [PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Miguel Ojeda 2 years, 2 months ago
On Thu, Sep 28, 2023 at 10:14 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> 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.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

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

Cheers,
Miguel
Re: [PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Alice Ryhl 2 years, 2 months ago
On Thu, Sep 28, 2023 at 10:14 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> 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.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

LGTM. I tested this in my Android build.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Alice Ryhl <aliceryhl@google.com>
Re: [PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Alice Ryhl 2 years, 2 months ago
On Mon, Oct 2, 2023 at 9:51 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> On Thu, Sep 28, 2023 at 10:14 PM Matthew Maurer <mmaurer@google.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Matthew Maurer <mmaurer@google.com>
>
> LGTM. I tested this in my Android build.

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

> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Tested-by: Alice Ryhl <aliceryhl@google.com>
Re: [PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Martin Rodriguez Reboredo 2 years, 2 months ago
On 9/28/23 17:14, Matthew Maurer wrote:
> 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.
> 
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Re: [PATCH] rust: Use grep -Ev rather than relying on GNU grep
Posted by Trevor Gross 2 years, 2 months ago
On Thu, Sep 28, 2023 at 4:14 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> 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.
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---

Reviewed-by: Trevor Gross <tmgross@umich.edu>