Bug 1471486 part 1 - Detect rustfmt like other rust executables. r?build-peer
MozReview-Commit-ID: 8LMdpdqbrFS
--- a/browser/config/mozconfigs/linux64/plain-opt
+++ b/browser/config/mozconfigs/linux64/plain-opt
@@ -1,12 +1,13 @@
export TOOLTOOL_DIR="$topsrcdir"
export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config"
CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo"
RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc"
RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc"
+RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt"
CC="${TOOLTOOL_DIR}/gcc/bin/gcc"
CXX="${TOOLTOOL_DIR}/gcc/bin/g++"
mk_add_options "export PATH=${TOOLTOOL_DIR}/gcc/bin:${PATH}"
mk_add_options "export LD_LIBRARY_PATH=${TOOLTOOL_DIR}/gcc/lib64:${TOOLTOOL_DIR}/gcc/lib32:${TOOLTOOL_DIR}/gcc/lib"
--- a/browser/config/mozconfigs/win64/plain-opt
+++ b/browser/config/mozconfigs/win64/plain-opt
@@ -1,12 +1,13 @@
TOOLTOOL_DIR=${topsrcdir}
export MAKECAB=$TOOLTOOL_DIR/makecab.exe
export LLVM_CONFIG="${TOOLTOOL_DIR}/clang/bin/llvm-config"
RUSTC="${TOOLTOOL_DIR}/rustc/bin/rustc"
CARGO="${TOOLTOOL_DIR}/rustc/bin/cargo"
RUSTDOC="${TOOLTOOL_DIR}/rustc/bin/rustdoc"
+RUSTFMT="${TOOLTOOL_DIR}/rustc/bin/rustfmt"
ac_add_options --target=x86_64-pc-mingw32
ac_add_options --host=x86_64-pc-mingw32
. $topsrcdir/build/win64/mozconfig.vs-latest
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -273,16 +273,19 @@ option('--enable-rust-tests',
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)
+# Bindgen can use rustfmt to format Rust file, but it's not required.
+rustfmt = check_prog('RUSTFMT', add_rustup_path('rustfmt'), allow_missing=True)
+
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))
@depends(target, rustc_info, c_compiler, 'WIN64_LINK', 'WIN64_LIB')
--- a/build/mozconfig.no-compile
+++ b/build/mozconfig.no-compile
@@ -10,16 +10,17 @@ NO_CACHE=1
unset CC
unset CXX
unset HOST_CC
unset HOST_CXX
unset LINKER
unset RUSTC
unset CARGO
unset RUSTDOC
+unset RUSTFMT
unset MAKECAB
unset TOOLCHAIN_PREFIX
unset BINDGEN_CFLAGS
unset LLVM_CONFIG
unset WIN64_LINK
unset WIN64_LIB
unset MOZ_STDCXX_COMPAT
--- a/build/mozconfig.rust
+++ b/build/mozconfig.rust
@@ -1,10 +1,11 @@
# 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"
+RUSTFMT="$TOOLTOOL_DIR/rustc/bin/rustfmt"
ac_add_options --enable-rust-simd
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -877,16 +877,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) \
+ RUSTFMT=$(RUSTFMT) \
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) \