bug 1396993 - Look in ~/.cargo/bin for rustc+cargo even they're not in PATH. r=rillian
authorTed Mielczarek <ted@mielczarek.org>
Tue, 05 Sep 2017 16:38:18 -0400
changeset 393818 4a93894dd13faa7acafc2c175e6e1ddea32c2599
parent 393817 bce38a7817ee39ccd38f57f73f5acf81a41e1f69
child 393819 ada1b4b1951bbe29bae0f0259c17adff1f31de7e
push id32983
push userebalazs@mozilla.com
push dateMon, 27 Nov 2017 21:58:04 +0000
treeherdermozilla-central@f5f03ee9e6ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1396993
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1396993 - Look in ~/.cargo/bin for rustc+cargo even they're not in PATH. r=rillian rustup installs rustc+cargo to ~/.cargo/bin by default, so make configure look there to avoid the annoying case where someone installed rust and cargo (possibly via `mach bootstrap`) but forgot to add ~/.cargo/bin to their PATH. MozReview-Commit-ID: GZOcFdFmzA5
build/moz.configure/rust.configure
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -1,18 +1,24 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+@imports(_from='os.path', _import='expanduser')
+def add_rustup_path(what):
+    # rustup installs rustc/cargo into ~/.cargo/bin by default,
+    # so look there if the binaries aren't in $PATH.
+    return [what, os.path.join(expanduser('~/.cargo/bin'), what)]
+
 # Rust is required by `rust_compiler` below. We allow_missing here
 # to propagate failures to the better error message there.
-rustc = check_prog('RUSTC', ['rustc'], allow_missing=True)
-cargo = check_prog('CARGO', ['cargo'], allow_missing=True)
+rustc = check_prog('RUSTC', add_rustup_path('rustc'), allow_missing=True)
+cargo = check_prog('CARGO', add_rustup_path('cargo'), allow_missing=True)
 
 
 @depends_if(rustc)
 @checking('rustc version', lambda info: info.version)
 def rustc_info(rustc):
     out = check_cmd_output(rustc, '--version', '--verbose').splitlines()
     info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:])
     return namespace(