Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use rustup to manage toolchains #17927

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

[WIP] Use rustup to manage toolchains

  • Loading branch information
shinglyu committed Aug 1, 2017
commit 7b67fa3b88cdbb9bb132d5e81c40a868f30c0a7e
@@ -27,7 +27,7 @@
)

import servo.bootstrap as bootstrap
from servo.command_base import CommandBase, BIN_SUFFIX, cd
from servo.command_base import CommandBase, BIN_SUFFIX, cd, call
from servo.util import delete, download_bytes, download_file, extract, host_triple


@@ -67,6 +67,20 @@ def bootstrap(self, force=False):
action='store_true',
help='Use stable rustc version')
def bootstrap_rustc(self, force=False, target=[], stable=False):
if self.has_rustup():
print("Found rustup, using rustup to manage rust toolchain")
self.bootstrap_rustc_rustup(force=force, target=target, stable=stable)
else:
print("No rustup, downloading rust toolchain")
self.bootstrap_rustc_vendor(force=force, target=target, stable=stable)

def bootstrap_rustc_rustup(self, force=False, target=[], stable=False):
# TODO: how do we install the stable toolchain with the override file?
with open("rust-toolchain", "rb") as fo:
toolchain_version = fo.read().rstrip()
call(["rustup", "install", toolchain_version])

def bootstrap_rustc_vendor(self, force=False, target=[], stable=False):
self.set_use_stable_rust(stable)
version = self.rust_version()
rust_path = self.rust_path()
@@ -420,6 +420,8 @@ def package_dir(package):
# Always build harfbuzz from source
env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true"

if self.has_rustup():
self.config["tools"]["rust-root"] = subprocess.check_output(["rustup", "which", "rustc"]).rstrip("rustc")
if not self.config["tools"]["system-rust"] \
or self.config["tools"]["rust-root"]:
env["RUST_ROOT"] = self.config["tools"]["rust-root"]
@@ -430,6 +432,8 @@ def package_dir(package):
extra_path += [path.join(self.config["tools"]["rust-root"], "bin")]
extra_lib += [path.join(self.config["tools"]["rust-root"], "lib")]

if self.has_rustup():
self.config["tools"]["cargo-root"] = subprocess.check_output(["rustup", "which", "cargo"]).rstrip("cargo")
if not self.config["tools"]["system-cargo"] \
or self.config["tools"]["cargo-root"]:
# This path is for when rust-root points to an unpacked installer
@@ -442,6 +446,7 @@ def package_dir(package):
if extra_path:
env["PATH"] = "%s%s%s" % (os.pathsep.join(extra_path), os.pathsep, env["PATH"])

# TODO: set this with rustup
env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"]
if self.config["build"]["incremental"]:
env["CARGO_INCREMENTAL"] = "1"
@@ -565,7 +570,26 @@ def handle_android_target(self, target):
return True
return False

def has_rustup(self):
# TODO: Cache the result and don't call subprocess everytime
try:
check_call(["rustup", "--version"])
self.config['tools']['rustup'] = True
return True

except OSError, subprocess.CalledProcessError:
return False

def ensure_bootstrapped(self, target=None):
if self.has_rustup():
try:
self.config["tools"]["rust-root"] = subprocess.check_output(["rustup", "which", "rustc"]).rstrip("rustc")
except subprocess.CalledProcessError:
Registrar.dispatch("bootstrap-rust", context=self.context, target=filter(None, [target]),
stable=self._use_stable_rust)
# TODO: should we also bootstrap cargo here? Maybe rustup
# install implies cargo as well?

if self.context.bootstrapped:
return

@@ -0,0 +1 @@
nightly-2017-07-17
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.