[PATCH v2] rust: Use awk instead of recent xargs

Matthew Maurer posted 1 patch 2 years, 2 months ago
rust/Makefile | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH v2] rust: Use awk instead of recent xargs
Posted by Matthew Maurer 2 years, 2 months ago
`awk` is already required by the kernel build, and the `xargs` feature
used in current Rust detection is not present in all `xargs` (notably,
toybox based xargs, used in the Android kernel build).

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---

I absorbed the grep and cut into the awk command as well, as Joe Perches
suggested.

rust/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/Makefile b/rust/Makefile
index 87958e864be0..c4e583e9e443 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -364,9 +364,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers.c FORCE
 quiet_cmd_exports = EXPORTS $@
       cmd_exports = \
 	$(NM) -p --defined-only $< \
-		| grep -E ' (T|R|D) ' | cut -d ' ' -f 3 \
-		| xargs -Isymbol \
-		echo 'EXPORT_SYMBOL_RUST_GPL(symbol);' > $@
+		| awk '/ (T|R|D) / {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@
 
 $(obj)/exports_core_generated.h: $(obj)/core.o FORCE
 	$(call if_changed,exports)
-- 
2.42.0.582.g8ccd20d70d-goog
Re: [PATCH v2] rust: Use awk instead of recent xargs
Posted by Miguel Ojeda 2 years, 2 months ago
On Thu, Sep 28, 2023 at 10:50 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> `awk` is already required by the kernel build, and the `xargs` feature
> used in current Rust detection is not present in all `xargs` (notably,
> toybox based xargs, used in the Android kernel build).
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

Applied to `rust-next` -- thanks everyone!

Cheers,
Miguel
Re: [PATCH v2] rust: Use awk instead of recent xargs
Posted by Alice Ryhl 2 years, 2 months ago
On Thu, Sep 28, 2023 at 10:50 PM Matthew Maurer <mmaurer@google.com> wrote:
>
> `awk` is already required by the kernel build, and the `xargs` feature
> used in current Rust detection is not present in all `xargs` (notably,
> toybox based xargs, used in the Android kernel build).
>
> Signed-off-by: Matthew Maurer <mmaurer@google.com>

Tested both in an Android and non-Android build.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Alice Ryhl <aliceryhl@google.com>
Re: [PATCH v2] rust: Use awk instead of recent xargs
Posted by Martin Rodriguez Reboredo 2 years, 2 months ago
On 9/28/23 17:49, Matthew Maurer wrote:
> `awk` is already required by the kernel build, and the `xargs` feature
> used in current Rust detection is not present in all `xargs` (notably,
> toybox based xargs, used in the Android kernel build).
> 
> Signed-off-by: Matthew Maurer <mmaurer@google.com>
> ---
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>