rust: save cargo and CARGO_HOME to variables

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".
pull/2804/head
Jason Ish 9 years ago committed by Victor Julien
parent 4be031394b
commit 14951e3f00

@ -2007,9 +2007,15 @@
CFLAGS="${CFLAGS} -I../rust/gen/c-headers" CFLAGS="${CFLAGS} -I../rust/gen/c-headers"
AC_SUBST(RUST_SURICATA_LIB) AC_SUBST(RUST_SURICATA_LIB)
AC_SUBST(RUST_LDADD) 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"]) AC_CHECK_FILES([$srcdir/rust/vendor], [have_rust_vendor="yes"])
if test "x$have_rust_vendor" = "xyes"; then if test "x$have_rust_vendor" = "xyes"; then
rust_vendor_comment="" rust_vendor_comment=""
fi fi
fi fi
fi fi

@ -29,15 +29,17 @@ all-local:
if HAVE_PYTHON if HAVE_PYTHON
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \ cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
$(HAVE_PYTHON) ./gen-c-headers.py && \ $(HAVE_PYTHON) ./gen-c-headers.py && \
cargo build $(RELEASE) $(FROZEN) --features "$(FEATURES)" CARGO_HOME=$(CARGO_HOME) $(CARGO) build $(RELEASE) $(FROZEN) \
--features "$(FEATURES)"
else else
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \ 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 endif
clean-local: clean-local:
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \ cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
cargo clean CARGO_HOME=$(CARGO_HOME) $(CARGO) clean
distclean-local: distclean-local:
rm -rf vendor rm -rf vendor
@ -45,14 +47,14 @@ distclean-local:
check: check:
cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \ cd $(top_srcdir)/rust && CARGO_TARGET_DIR=$(abs_builddir)/target \
cargo test CARGO_HOME=$(CARGO_HOME) $(CARGO) test
Cargo.lock: Cargo.toml Cargo.lock: Cargo.toml
cargo update CARGO_HOME=$(CARGO_HOME) $(CARGO) update
if HAVE_CARGO_VENDOR if HAVE_CARGO_VENDOR
vendor: vendor:
cargo vendor > /dev/null CARGO_HOME=$(CARGO_HOME) $(CARGO) vendor > /dev/null
else else
vendor: vendor:
endif endif

Loading…
Cancel
Save