]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: put all rust/cargo env vars in CARGO_ENV 12140/head
authorJason Ish <jason.ish@oisf.net>
Tue, 19 Nov 2024 17:28:03 +0000 (11:28 -0600)
committerVictor Julien <victor@inliniac.net>
Thu, 21 Nov 2024 05:55:13 +0000 (06:55 +0100)
To ensure that all calls to cargo use the same environment variables,
put the environment variables in CARGO_ENV so every call to cargo can
easily use the same vars.

The Cargo build system is smarter than make, it can detect a change in
an environment variable that affects the build, and the setting of
SURICATA_LUA_SYS_HEADER_DST changing could cause a rebuild.

Also update suricata-lua-sys, which is smarter about copying headers. It
will only copy if the destination does not exist, or the source header
is newer than the target, which can also prevent unnecessary rebuilds.

This is mainly to fix an issue where subsequent builds may fail,
especially when running an editor with a LSP enabled:

    Update lua crate to 0.1.0-alpha.5. This update will force a rewrite of
    the headers if the env var SURICATA_LUA_SYS_HEADER_DST changes. This
    fixes the issue where the headers may not be written.

    The cause is that Rust dependencies are cached, and if your editor is
    using rust-analyzer, it might cache the build without this var being
    set, so these headers are not available to Suricata. This crate update
    forces the re-run of the Lua build.rs if this env var changes, fixing
    this issue.

rust/Cargo.lock.in
rust/Cargo.toml.in
rust/Makefile.am

index b1ed92b8901376774ca59edd7d0d3925d52b19ef..e26389fde04f4f05ce914de98324d3f48bd7a238 100644 (file)
@@ -1048,9 +1048,9 @@ dependencies = [
 
 [[package]]
 name = "suricata-lua-sys"
-version = "0.1.0-alpha.3"
+version = "0.1.0-alpha.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aed3f46aa1b92feb15880f722bbce121e769bda1770f0090121cd6c920d89450"
+checksum = "2db6abfb8d28b60a0d984272123ed1bec6c45a5f729f6393921482007406babf"
 dependencies = [
  "fs_extra",
 ]
index aa734476dff86c627da46bdb2c8fa2e0f3d052eb..e7141e17a972bd5f498aab40406db55120e2afd5 100644 (file)
@@ -69,7 +69,7 @@ time = "~0.3.36"
 
 suricata-derive = { path = "./derive", version = "@PACKAGE_VERSION@" }
 
-suricata-lua-sys = { version = "0.1.0-alpha.3" }
+suricata-lua-sys = { version = "0.1.0-alpha.5" }
 
 [dev-dependencies]
 test-case = "~3.3.1"
index be80a806f1aacf49ca1137d003df46cd2dd91fc3..d53eb97090e11ce95a36424af2056ca455123d4b 100644 (file)
@@ -34,23 +34,24 @@ if RUST_CROSS_COMPILE
 RUST_TARGET = --target $(host_triplet)
 endif
 
-all-local: Cargo.toml
-       mkdir -p $(abs_top_builddir)/rust/gen
 if HAVE_CYGPATH
-       cd $(abs_top_srcdir)/rust && \
-               @rustup_home@ CARGO_HOME="$(CARGO_HOME)" \
+CARGO_ENV =    @rustup_home@ \
+               CARGO_HOME="$(CARGO_HOME)" \
                CARGO_TARGET_DIR="$(e_rustdir)/target" \
-               SURICATA_LUA_SYS_HEADER_DST="$(e_rustdir)/gen" \
-               $(CARGO) build $(RELEASE) \
-                       --features "$(RUST_FEATURES)" $(RUST_TARGET)
+               SURICATA_LUA_SYS_HEADER_DST="$(e_rustdir)/gen"
 else
-       cd $(abs_top_srcdir)/rust && \
-               @rustup_home@ CARGO_HOME="$(CARGO_HOME)" \
+CARGO_ENV =    @rustup_home@ \
+               CARGO_HOME="$(CARGO_HOME)" \
                CARGO_TARGET_DIR="$(abs_top_builddir)/rust/target" \
-               SURICATA_LUA_SYS_HEADER_DST="$(abs_top_builddir)/rust/gen" \
+               SURICATA_LUA_SYS_HEADER_DST="$(abs_top_builddir)/rust/gen"
+endif
+
+all-local: Cargo.toml
+       mkdir -p $(abs_top_builddir)/rust/gen
+       cd $(abs_top_srcdir)/rust && \
+               $(CARGO_ENV) \
                $(CARGO) build $(RELEASE) $(NIGHTLY_ARGS) \
                        --features "$(RUST_FEATURES)" $(RUST_TARGET)
-endif
        if test -e $(RUST_SURICATA_LIBDIR)/suricata.lib; then \
                cp -a $(RUST_SURICATA_LIBDIR)/suricata.lib \
                        $(RUST_SURICATA_LIBDIR)/${RUST_SURICATA_LIBNAME}; \
@@ -76,12 +77,11 @@ distclean-local:
 
 check:
        cd $(abs_top_srcdir)/rust && \
-               CARGO_HOME="$(CARGO_HOME)" @rustup_home@ \
-               CARGO_TARGET_DIR="$(abs_top_builddir)/rust/target" \
+               $(CARGO_ENV) \
                $(CARGO) test --all $(RELEASE) --features "$(RUST_FEATURES)"
 
 vendor:
-       CARGO_HOME="$(CARGO_HOME)" @rustup_home@ $(CARGO) vendor
+       $(CARGO_ENV) $(CARGO) vendor
 
 if HAVE_CBINDGEN
 gen/rust-bindings.h: $(RUST_SURICATA_LIB)