]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/bindgen: use temp file to generating bindings
authorJason Ish <jason.ish@oisf.net>
Wed, 19 Feb 2025 21:31:31 +0000 (15:31 -0600)
committerVictor Julien <victor@inliniac.net>
Fri, 21 Feb 2025 13:57:15 +0000 (14:57 +0100)
Prefixing a file with sed doesn't appear to be portable. Instead, make
use of a temporary file.

Fixes generating the bindings on FreeBSD and Mac.

rust/Makefile.am

index a751bb85a3aac8fb00466286bc070fdfdddfcc21..a258003a8af9d966976e2af3cdd45835b40c4cbd 100644 (file)
@@ -108,7 +108,7 @@ vendor:
 update-bindings:
 if HAVE_BINDGEN
        $(BINDGEN) \
-               -o sys/src/sys.rs \
+               -o sys/src/sys.rs.tmp \
                --rust-target 1.68 \
                --no-layout-tests \
                --disable-header-comment \
@@ -120,7 +120,9 @@ if HAVE_BINDGEN
                $(abs_top_srcdir)/src/bindgen.h \
                -- \
                -DHAVE_CONFIG_H -I../src -I../rust/gen $(CPPFLAGS)
-       sed -i '1i\// This file is automatically generated. Do not edit.\n' sys/src/sys.rs
+       printf "// This file is automatically generated. Do not edit.\n\n" > sys/src/sys.rs
+       cat sys/src/sys.rs.tmp >> sys/src/sys.rs
+       rm -f sys/src/sys.rs.tmp
 else
        @echo "error: bindgen not installed, can't update bindings"
        exit 1