]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: save cargo and CARGO_HOME to variables
authorJason Ish <ish@unx.ca>
Tue, 20 Jun 2017 16:17:54 +0000 (10:17 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 26 Jun 2017 07:59:54 +0000 (09:59 +0200)
During configure, substitute the path of cargo, as well as the
value of CARGO_HOME as variables. This fixes the case where a
user might do:
  make
  sudo make install
Which will cause the cargo bits to be rebuilt, including
re-downloading external crates.

By saving these to variables we can be sure that the same
values are used during make install as were used during
make which prevents the Rust artifacts from being rebuild
during "sudo make install".

configure.ac
rust/Makefile.am

index 2720c58e2226a94a93f999d0f0d097b6dc3cc765..5f587a7277fe8e637a3c8b4e5703da0929024ef1 100644 (file)
           CFLAGS="${CFLAGS} -I../rust/gen/c-headers"
           AC_SUBST(RUST_SURICATA_LIB)
           AC_SUBST(RUST_LDADD)
+         AC_SUBST([CARGO], [$HAVE_CARGO])
+         if test "x$CARGO_HOME" = "x"; then
+           AC_SUBST([CARGO_HOME], [~/.cargo])
+         else
+           AC_SUBST([CARGO_HOME], [$CARGO_HOME])
+         fi
           AC_CHECK_FILES([$srcdir/rust/vendor], [have_rust_vendor="yes"])
           if test "x$have_rust_vendor" = "xyes"; then
-               rust_vendor_comment=""
+           rust_vendor_comment=""
           fi
         fi
       fi
index 8b67c7bed3fe140ac37a7e8dc0369d49e5ff05ae..9cf6eec83e25c05a0404d837853ae47a08c985e2 100644 (file)
@@ -29,15 +29,17 @@ all-local:
 if HAVE_PYTHON
        cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
                $(HAVE_PYTHON) ./gen-c-headers.py && \
-               cargo build $(RELEASE) $(FROZEN) --features "$(FEATURES)"
+               CARGO_HOME=$(CARGO_HOME) $(CARGO) build $(RELEASE) $(FROZEN) \
+                       --features "$(FEATURES)"
 else
        cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
-               cargo build $(RELEASE) $(FROZEN) --features "$(FEATURES)"
+               CARGO_HOME=$(CARGO_HOME) $(CARGO) build $(RELEASE) $(FROZEN) \
+                       --features "$(FEATURES)"
 endif
 
 clean-local:
        cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
-               cargo clean
+               CARGO_HOME=$(CARGO_HOME) $(CARGO) clean
 
 distclean-local:
        rm -rf vendor
@@ -45,14 +47,14 @@ distclean-local:
 
 check:
        cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
-               cargo test
+               CARGO_HOME=$(CARGO_HOME) $(CARGO) test
 
 Cargo.lock: Cargo.toml
-       cargo update
+       CARGO_HOME=$(CARGO_HOME) $(CARGO) update
 
 if HAVE_CARGO_VENDOR
 vendor:
-       cargo vendor > /dev/null
+       CARGO_HOME=$(CARGO_HOME) $(CARGO) vendor > /dev/null
 else
 vendor:
 endif