浏览代码

cargo-online-mode configure argument

Passing --enable-cargo-online-mode during configure allows cargo to make
network requests while building Tor or running tests. If this flag is
not supplied, the dependencies need to be available in the form of a
local mirror.
Sebastian Hahn 8 年之前
父节点
当前提交
d6f9a4f11a
共有 4 个文件被更改,包括 12 次插入3 次删除
  1. 8 0
      configure.ac
  2. 1 1
      src/rust/tor_util/include.am
  3. 2 1
      src/test/include.am
  4. 1 1
      src/test/test_rust.sh

+ 8 - 0
configure.ac

@@ -57,6 +57,8 @@ AC_ARG_ENABLE(memory-sentinels,
    AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
    AS_HELP_STRING(--disable-memory-sentinels, [disable code that tries to prevent some kinds of memory access bugs. For fuzzing only.]))
 AC_ARG_ENABLE(rust,
 AC_ARG_ENABLE(rust,
    AS_HELP_STRING(--enable-rust, [enable rust integration]))
    AS_HELP_STRING(--enable-rust, [enable rust integration]))
+AC_ARG_ENABLE(cargo-online-mode,
+   AS_HELP_STRING(--enable-cargo-online-mode, [Allow cargo to make network requests to fetch crates. For builds with rust only.]))
 
 
 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
 if test "x$enable_coverage" != "xyes" -a "x$enable_asserts_in_tests" = "xno" ; then
     AC_MSG_ERROR([Can't disable assertions outside of coverage build])
     AC_MSG_ERROR([Can't disable assertions outside of coverage build])
@@ -267,6 +269,12 @@ if test "x$enable_rust" = "xyes"; then
   fi
   fi
 
 
   AC_DEFINE([HAVE_RUST], 1, [have Rust])
   AC_DEFINE([HAVE_RUST], 1, [have Rust])
+  if test "x$enable_cargo_online_mode" = "xyes"; then
+    CARGO_ONLINE=
+  else
+    CARGO_ONLINE=--frozen
+  fi
+  AC_SUBST(CARGO_ONLINE)
 fi
 fi
 
 
 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
 ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [

+ 1 - 1
src/rust/tor_util/include.am

@@ -7,6 +7,6 @@ EXTRA_DIST +=\
 src/rust/target/release/libtor_util.a: FORCE
 src/rust/target/release/libtor_util.a: FORCE
 	( cd "$(abs_top_srcdir)/src/rust/tor_util" ; \
 	( cd "$(abs_top_srcdir)/src/rust/tor_util" ; \
 		CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
 		CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
-		$(CARGO) build --release --quiet --frozen )
+		$(CARGO) build --release --quiet $(CARGO_ONLINE) )
 
 
 FORCE:
 FORCE:

+ 2 - 1
src/test/include.am

@@ -7,7 +7,8 @@ TESTS_ENVIRONMENT = \
 	export abs_top_srcdir="$(abs_top_srcdir)"; \
 	export abs_top_srcdir="$(abs_top_srcdir)"; \
 	export builddir="$(builddir)"; \
 	export builddir="$(builddir)"; \
 	export TESTING_TOR_BINARY="$(TESTING_TOR_BINARY)"; \
 	export TESTING_TOR_BINARY="$(TESTING_TOR_BINARY)"; \
-	export CARGO="$(CARGO)";
+	export CARGO="$(CARGO)"; \
+	export CARGO_ONLINE="$(CARGO_ONLINE)";
 
 
 TESTSCRIPTS = \
 TESTSCRIPTS = \
 	src/test/fuzz_static_testcases.sh \
 	src/test/fuzz_static_testcases.sh \

+ 1 - 1
src/test/test_rust.sh

@@ -7,7 +7,7 @@ exitcode=0
 
 
 for crate in $crates; do
 for crate in $crates; do
     cd "${abs_top_srcdir:-.}/src/rust/${crate}"
     cd "${abs_top_srcdir:-.}/src/rust/${crate}"
-    "${CARGO:-cargo}" test --frozen || exitcode=1
+    "${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} || exitcode=1
 done
 done
 
 
 exit $exitcode
 exit $exitcode