Bug 1457524 part 3 - Check rustdoc for rust tests. r?froydnj draft
authorXidorn Quan <me@upsuper.org>
Wed, 02 May 2018 20:02:04 +1000
changeset 791725 de45a0c9fb5b2f3dda06a2e0734310a13b3f6144
parent 791724 dc1ec641b1368ef0c7ebc623f2bb94356df11fba
child 791726 d15aac4ccef60df533d4292a29d4574dad170959
push id108890
push userxquan@mozilla.com
push dateSat, 05 May 2018 00:42:49 +0000
reviewersfroydnj
bugs1457524
milestone61.0a1
Bug 1457524 part 3 - Check rustdoc for rust tests. r?froydnj MozReview-Commit-ID: 4qRccUcXq6O
build/moz.configure/rust.configure
build/mozconfig.rust
config/rules.mk
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -253,22 +253,33 @@ set_config('RUST_TARGET_ENV_NAME', rust_
 
 # This is used for putting source info into symbol files.
 set_config('RUSTC_COMMIT', depends(rustc_info)(lambda i: i.commit))
 
 # Until we remove all the other Rust checks in old-configure.
 add_old_configure_assignment('RUSTC', rustc)
 add_old_configure_assignment('RUST_TARGET', rust_target_triple)
 
+# Rustdoc is required by Rust tests below.
+rustdoc = check_prog('RUSTDOC', add_rustup_path('rustdoc'), allow_missing=True)
+
 # This option is separate from --enable-tests because Rust tests are particularly
 # expensive in terms of compile time (especially for code in libxul).
 option('--enable-rust-tests',
        help='Enable building of Rust tests, and build-time execution of them')
 
-set_config('MOZ_RUST_TESTS', depends('--enable-rust-tests')(lambda v: bool(v)))
+
+@depends('--enable-rust-tests', rustdoc)
+def rust_tests(enable_rust_tests, rustdoc):
+    if enable_rust_tests and not rustdoc:
+        die('--enable-rust-tests requires rustdoc')
+    return bool(enable_rust_tests)
+
+
+set_config('MOZ_RUST_TESTS', rust_tests)
 
 option(env='WIN64_LINK', nargs=1, help='Path to link.exe that targets win64')
 option(env='WIN64_LIB', nargs=1, help='Paths to libraries for the win64 linker')
 
 set_config('WIN64_LINK', depends('WIN64_LINK')(lambda x: x))
 set_config('WIN64_LIB', depends('WIN64_LIB')(lambda x: x))
 
 
--- a/build/mozconfig.rust
+++ b/build/mozconfig.rust
@@ -1,9 +1,10 @@
 # Options to enable rust in automation builds.
 
 TOOLTOOL_DIR=${TOOLTOOL_DIR:-$topsrcdir}
 
 # Tell configure to use the tooltool rustc.
 RUSTC="$TOOLTOOL_DIR/rustc/bin/rustc"
 CARGO="$TOOLTOOL_DIR/rustc/bin/cargo"
+RUSTDOC="$TOOLTOOL_DIR/rustc/bin/rustdoc"
 
 ac_add_options --enable-rust-simd
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -876,16 +876,17 @@ endif
 
 # We use the + prefix to pass down the jobserver fds to cargo, but we
 # don't use the prefix when make -n is used, so that cargo doesn't run
 # in that case)
 define RUN_CARGO
 $(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)env $(environment_cleaner) $(rust_unlock_unstable) $(rustflags_override) $(sccache_wrap) \
 	CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
 	RUSTC=$(RUSTC) \
+	RUSTDOC=$(RUSTDOC) \
 	MOZ_SRC=$(topsrcdir) \
 	MOZ_DIST=$(ABS_DIST) \
 	LIBCLANG_PATH="$(MOZ_LIBCLANG_PATH)" \
 	CLANG_PATH="$(MOZ_CLANG_PATH)" \
 	PKG_CONFIG_ALLOW_CROSS=1 \
 	RUST_BACKTRACE=full \
 	MOZ_TOPOBJDIR=$(topobjdir) \
 	$(cargo_incremental) \