bug 1396993 - Look in ~/.cargo/bin for rustc+cargo even they're not in PATH. r?rillian draft
authorTed Mielczarek <ted@mielczarek.org>
Tue, 05 Sep 2017 16:38:18 -0400
changeset 659974 7221be103dfb45d789eedfdab5dc53a779623745
parent 656220 614b4b9ca5e450ec5bf06bb7cbb957a113295f2f
child 659977 2fc3dff99145c549280b532f87fc5c9c28aa3197
push id78255
push userbmo:ted@mielczarek.org
push dateWed, 06 Sep 2017 12:57:35 +0000
reviewersrillian
bugs1396993
milestone57.0a1
bug 1396993 - Look in ~/.cargo/bin for rustc+cargo even they're not in PATH. r?rillian 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 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', rustup_path('rustc'), allow_missing=True)
+cargo = check_prog('CARGO', 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(
         version=Version(info.get('release', '0')),