summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-05-02 12:11:36 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-05-16 20:43:16 -0400
commitb75f98ee0d0420ab608b7ae7b1cef21e47c7eea3 (patch)
treeee3093872887d074bb1c72ef54635fe45ab4f5a4
parent24d6a729e923df6f6777434ff83a65c1385829d3 (diff)
downloadtor-fix-rust-tests.tar.xz
tor-fix-rust-tests.zip
Use cargo global cache instead of builddirmisc-rustfix-rust-tests
This also removes CARGO_TARGET_DIR in favor of setting build.target-dir in .cargo/config.
-rw-r--r--changes/cargo_global_cache4
-rw-r--r--configure.ac5
-rw-r--r--src/rust/.cargo/config.in4
-rw-r--r--src/rust/tor_rust/include.am21
4 files changed, 24 insertions, 10 deletions
diff --git a/changes/cargo_global_cache b/changes/cargo_global_cache
new file mode 100644
index 000000000..b81495081
--- /dev/null
+++ b/changes/cargo_global_cache
@@ -0,0 +1,4 @@
+ o Minor features (Rust):
+ - --enable-cargo-online-mode now uses the global cargo cache instead of the
+ build directory. This is to be consistent with other Rust programs.
+ Override with CARGO_HOME.
diff --git a/configure.ac b/configure.ac
index 928968531..1caf0ad11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -465,6 +465,11 @@ if test "x$enable_rust" = "xyes"; then
if test "x$enable_cargo_online_mode" = "xyes"; then
CARGO_ONLINE=
RUST_DL=#
+
+ # assume that the user knows what they want if CARGO_HOME is set
+ if test -z "$CARGO_HOME"; then
+ AC_MSG_WARN([Cargo online mode is enabled. Cargo will download into ~/.cargo. Set CARGO_HOME to override this. Note that relative CARGO_HOME paths are not supported by Tor's build system.])
+ fi
else
CARGO_ONLINE=--frozen
RUST_DL=
diff --git a/src/rust/.cargo/config.in b/src/rust/.cargo/config.in
index 1689f0ab1..ea6f81ccd 100644
--- a/src/rust/.cargo/config.in
+++ b/src/rust/.cargo/config.in
@@ -3,3 +3,7 @@
@RUST_DL@[source.vendored-sources]
@RUST_DL@directory = '@TOR_RUST_DEPENDENCIES@'
+
+[build]
+# not a no-op, fixes out-of-source builds
+target-dir = './target'
diff --git a/src/rust/tor_rust/include.am b/src/rust/tor_rust/include.am
index c02324cb7..4d950af8a 100644
--- a/src/rust/tor_rust/include.am
+++ b/src/rust/tor_rust/include.am
@@ -5,20 +5,21 @@ EXTRA_DIST +=\
EXTRA_CARGO_OPTIONS=
src/rust/target/release/@TOR_RUST_STATIC_NAME@: FORCE
- ( cd "$(abs_top_builddir)/src/rust" ; \
- CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
- CARGO_HOME="$(abs_top_builddir)/src/rust" \
+ ## check that CARGO_HOME is not relative (it will be interpreted
+ ## relative to $abs_top_builddir/src/rust instead of $abs_top_builddir)
+ if [ -n "$$CARGO_HOME" ] && [ "$${CARGO_HOME:1:1}" != / ]; then \
+ echo "Tor's build system only supports absolute path (or unset) CARGO_HOME."; \
+ fi
+ ( cd "$(abs_top_builddir)/src/rust" || exit ; \
$(CARGO) build --release $(EXTRA_CARGO_OPTIONS) \
- $(CARGO_ONLINE) \
- --manifest-path "$(abs_top_srcdir)/src/rust/tor_rust/Cargo.toml" )
+ $(CARGO_ONLINE) \
+ --manifest-path "$(abs_top_srcdir)/src/rust/tor_rust/Cargo.toml" )
distclean-rust:
- ( cd "$(abs_top_builddir)/src/rust" ; \
- CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
- CARGO_HOME="$(abs_top_builddir)/src/rust" \
+ ( cd "$(abs_top_builddir)/src/rust" || exit ; \
$(CARGO) clean $(EXTRA_CARGO_OPTIONS) \
- $(CARGO_ONLINE) \
- --manifest-path "$(abs_top_srcdir)/src/rust/tor_rust/Cargo.toml" )
+ $(CARGO_ONLINE) \
+ --manifest-path "$(abs_top_srcdir)/src/rust/tor_rust/Cargo.toml" )
rm -rf "$(abs_top_builddir)/src/rust/registry"
if USE_RUST