Bug 1519319 - Use toolchain_search_path to look for rust toolchains. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 11 Jan 2019 15:48:20 +0000
changeset 453565 82ed24e46ee4
parent 453564 8bb28e416102
child 453566 027d42f23d2d
push id35360
push usernbeleuzu@mozilla.com
push dateSat, 12 Jan 2019 09:39:47 +0000
treeherdermozilla-central@cb35977ae7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1519319
milestone66.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 1519319 - Use toolchain_search_path to look for rust toolchains. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D16292
build/moz.configure/rust.configure
build/moz.configure/toolchain.configure
--- a/build/moz.configure/rust.configure
+++ b/build/moz.configure/rust.configure
@@ -1,30 +1,23 @@
 # -*- 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.
 js_option(env='RUSTC', nargs=1, help='Path to the rust compiler')
 js_option(env='CARGO', nargs=1, help='Path to the Cargo package manager')
 
-rustc = check_prog('RUSTC', add_rustup_path('rustc'),
+rustc = check_prog('RUSTC', ['rustc'], paths=toolchain_search_path,
                    input='RUSTC', allow_missing=True)
-cargo = check_prog('CARGO', add_rustup_path('cargo'),
+cargo = check_prog('CARGO', ['cargo'], paths=toolchain_search_path,
                    input='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:])
@@ -260,17 +253,17 @@ set_config('RUST_TARGET_ENV_NAME', rust_
 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)
 
 # Rustdoc is required by Rust tests below.
 js_option(env='RUSTDOC', nargs=1, help='Path to the rustdoc program')
 
-rustdoc = check_prog('RUSTDOC', add_rustup_path('rustdoc'),
+rustdoc = check_prog('RUSTDOC', ['rustdoc'], paths=toolchain_search_path,
                      input='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 and running of Rust tests during `make check`')
 
 
@@ -279,17 +272,17 @@ def rust_tests(enable_rust_tests, rustdo
     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)
 
 # cbindgen is needed by the style system build.
-cbindgen = check_prog('CBINDGEN', add_rustup_path('cbindgen'), paths=toolchain_search_path,
+cbindgen = check_prog('CBINDGEN', ['cbindgen'], paths=toolchain_search_path,
                       when=depends(build_project)
                       (lambda build_project: build_project != 'js'))
 
 
 @depends_if(cbindgen)
 @checking('cbindgen version')
 @imports(_from='textwrap', _import='dedent')
 def cbindgen_version(cbindgen):
@@ -308,17 +301,17 @@ def cbindgen_version(cbindgen):
         '''.format(version, cbindgen_min_version, cbindgen)))
 
     return version
 
 
 # Bindgen can use rustfmt to format Rust file, but it's not required.
 js_option(env='RUSTFMT', nargs=1, help='Path to the rustfmt program')
 
-rustfmt = check_prog('RUSTFMT', add_rustup_path('rustfmt'),
+rustfmt = check_prog('RUSTFMT', ['rustfmt'], paths=toolchain_search_path,
                      input='RUSTFMT', allow_missing=True)
 
 js_option(env='WIN64_LINK', nargs=1, help='Path to link.exe that targets win64')
 js_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/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -809,16 +809,20 @@ def toolchain_search_path_for(host_or_ta
         mozbuild_state_dir = environ.get('MOZBUILD_STATE_PATH',
                                          os.path.expanduser(os.path.join('~', '.mozbuild')))
         bootstrap_clang_path = os.path.join(mozbuild_state_dir, 'clang', 'bin')
         result.append(bootstrap_clang_path)
 
         bootstrap_cbindgen_path = os.path.join(mozbuild_state_dir, 'cbindgen')
         result.append(bootstrap_cbindgen_path)
 
+        # Also add the rustup install directory for cargo/rustc.
+        rustup_path = os.path.expanduser(os.path.join('~', '.cargo', 'bin'))
+        result.append(rustup_path)
+
         return result
     return toolchain_search_path
 
 
 toolchain_search_path = toolchain_search_path_for(target)
 host_toolchain_search_path = toolchain_search_path_for(host)