From f7da81f01bb6273aaa0eae42f5a620cce3fddc08 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 22 Aug 2019 21:46:40 +0000 Subject: [PATCH] Bug 1574056 - Make `mach vendor rust` use now native `cargo vendor`. r=chmanchester Note that cargo vendor always uses the native version even when cargo-vendor was already installed, so there is no concern wrt that. Differential Revision: https://phabricator.services.mozilla.com/D43007 --HG-- extra : moz-landing-system : lando --- python/mozbuild/mozbuild/vendor_rust.py | 49 +++---------------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/python/mozbuild/mozbuild/vendor_rust.py b/python/mozbuild/mozbuild/vendor_rust.py index 406ecfa850f0..702900bb9635 100644 --- a/python/mozbuild/mozbuild/vendor_rust.py +++ b/python/mozbuild/mozbuild/vendor_rust.py @@ -34,31 +34,13 @@ class VendorRust(MozbuildObject): def check_cargo_version(self, cargo): ''' - Ensure that cargo is new enough. cargo 0.12 added support - for source replacement, which is required for vendoring to work. + Ensure that cargo is new enough. cargo 1.37 added support + for the vendor command. ''' out = subprocess.check_output([cargo, '--version']).splitlines()[0] if not out.startswith('cargo'): return False - return LooseVersion(out.split()[1]) >= b'0.13' - - def check_cargo_vendor_version(self, cargo): - ''' - Ensure that cargo-vendor is new enough. cargo-vendor 0.1.13 and newer - strips out .cargo-ok, .orig and .rej files, and deals with [patch] - replacements in Cargo.toml files which we want. Version 0.1.14 and up - handles local modifications to vendored crates (bug 1323557). - ''' - for l in subprocess.check_output([cargo, 'install', '--list']).splitlines(): - # The line looks like one of the following: - # cargo-vendor v0.1.12: - # cargo-vendor v0.1.12 (file:///path/to/local/build/cargo-vendor): - # and we want to extract the version part of it - m = re.match('cargo-vendor v((\d+\.)*\d+)', l) - if m: - version = m.group(1) - return LooseVersion(version) >= b'0.1.23' - return False + return LooseVersion(out.split()[1]) >= b'1.37' def check_modified_files(self): ''' @@ -115,30 +97,10 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore- cargo = self.get_cargo_path() if not self.check_cargo_version(cargo): self.log(logging.ERROR, 'cargo_version', {}, - 'Cargo >= 0.13 required (install Rust 1.12 or newer)') + 'Cargo >= 1.37 required (install Rust 1.37 or newer)') return None else: self.log(logging.DEBUG, 'cargo_version', {}, 'cargo is new enough') - have_vendor = any(l.strip() == 'vendor' for l in subprocess.check_output( - [cargo, '--list']).splitlines()) - if not have_vendor: - self.log(logging.INFO, 'installing', {}, - 'Installing cargo-vendor (this may take a few minutes)...') - env = self.check_openssl() - self.run_process(args=[cargo, 'install', 'cargo-vendor'], - append_env=env) - elif not self.check_cargo_vendor_version(cargo): - self.log( - logging.INFO, 'cargo_vendor', {}, - ('cargo-vendor >= 0.1.23 required; ' - 'force-reinstalling (this may take a few minutes)...') - ) - env = self.check_openssl() - self.run_process(args=[cargo, 'install', '--force', 'cargo-vendor'], - append_env=env) - else: - self.log(logging.DEBUG, 'cargo_vendor', {}, - 'sufficiently new cargo-vendor is already installed') return cargo @@ -360,8 +322,7 @@ license file's hash. # changes. See bug 1324462 subprocess.check_call([cargo, 'update', '-p', 'gkrust'], cwd=self.topsrcdir) - subprocess.check_call([cargo, 'vendor', '--quiet', '--sync', - 'Cargo.lock'] + [vendor_dir], cwd=self.topsrcdir) + subprocess.check_call([cargo, 'vendor', '--quiet', vendor_dir], cwd=self.topsrcdir) if not self._check_licenses(vendor_dir): self.log(