Bug 1324435 - mozboot: ensure win32 rust support. r?ted
If we have rustup installed, use it to check the available
target platforms and install 32-bit windows support if we're
on the (default 64-bit) windows platform.
This catches systems where the mozillabuild bootstrapper was
run before it installed this, so rustup is available, but the
i686 target library isn't.
MozReview-Commit-ID: 9bE2OQnmvxs
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -562,16 +562,19 @@ class BaseBootstrapper(object):
'cmd': cmd,
})
def ensure_rust_modern(self):
modern, version = self.is_rust_modern()
if modern:
print('Your version of Rust (%s) is new enough.' % version)
+ rustup = self.which('rustup')
+ if rustup:
+ self.ensure_rust_targets(rustup)
return
if not version:
# Rust wasn't in PATH. Check the standard location.
cargo_home, cargo_bin = self.cargo_home()
try_rustc = os.path.join(cargo_bin, 'rustc' + rust.exe_suffix())
try_cargo = os.path.join(cargo_bin, 'cargo' + rust.exe_suffix())
have_rustc = os.path.exists(try_rustc)
@@ -596,16 +599,29 @@ class BaseBootstrapper(object):
if not modern:
print(RUST_UPGRADE_FAILED % (MODERN_RUST_VERSION, after))
sys.exit(1)
else:
# No rustup. Download and run the installer.
print('Will try to install Rust.')
self.install_rust()
+ def ensure_rust_targets(self, rustup):
+ """Make sure appropriate cross target libraries are installed."""
+ target_list = subprocess.check_output([rustup, 'target', 'list'])
+ targets = [line.split()[0] for line in target_list.splitlines()
+ if 'installed' in line or 'default' in line]
+ print('Rust supports %s targets.' % ', '.join(targets))
+
+ # Support 32-bit Windows on 64-bit Windows.
+ win32 = 'i686-pc-windows-msvc'
+ win64 = 'x86_64-pc-windows-msvc'
+ if rust.platform() == win64 and not win32 in targets:
+ subprocess.check_call([rustup, 'target', 'add', win32])
+
def upgrade_rust(self, rustup):
"""Upgrade Rust.
Invoke rustup from the given path to update the rust install."""
subprocess.check_call([rustup, 'update'])
def install_rust(self):
"""Download and run the rustup installer."""