mirror of
https://github.com/servo/servo.git
synced 2025-06-30 12:03:38 +01:00
Bootstrap from official static.rust-lang.org when SNI is available
This commit is contained in:
parent
1f4c0c63de
commit
664f2829a9
3 changed files with 26 additions and 15 deletions
|
@ -27,7 +27,7 @@ from mach.decorators import (
|
|||
)
|
||||
|
||||
import servo.bootstrap as bootstrap
|
||||
from servo.command_base import CommandBase, BIN_SUFFIX, cd
|
||||
from servo.command_base import CommandBase, BIN_SUFFIX, cd, STATIC_RUST_LANG_ORG_DIST
|
||||
from servo.util import delete, download_bytes, download_file, extract, host_triple
|
||||
|
||||
|
||||
|
@ -71,7 +71,8 @@ class MachCommands(CommandBase):
|
|||
rust_dir = path.join(self.context.sharedir, "rust", self.rust_path())
|
||||
install_dir = path.join(self.context.sharedir, "rust", self.rust_install_dir())
|
||||
version = self.rust_stable_version() if stable else "nightly"
|
||||
static_s3 = "https://static-rust-lang-org.s3.amazonaws.com/dist"
|
||||
|
||||
nightly_dist = STATIC_RUST_LANG_ORG_DIST + "/" + self.rust_nightly_date()
|
||||
|
||||
if not force and path.exists(path.join(rust_dir, "rustc", "bin", "rustc" + BIN_SUFFIX)):
|
||||
print("Rust compiler already downloaded.", end=" ")
|
||||
|
@ -87,15 +88,15 @@ class MachCommands(CommandBase):
|
|||
# giving a directory name that will be the same as the tarball name (rustc is
|
||||
# in that directory).
|
||||
if stable:
|
||||
base_url = static_s3
|
||||
elif not self.config["build"]["llvm-assertions"]:
|
||||
base_url = STATIC_RUST_LANG_ORG_DIST
|
||||
elif self.config["build"]["llvm-assertions"]:
|
||||
base_url = nightly_dist
|
||||
else:
|
||||
import toml
|
||||
channel = "%s/%s/channel-rust-nightly.toml" % (static_s3, self.rust_nightly_date())
|
||||
channel = nightly_dist + "/channel-rust-nightly.toml"
|
||||
nightly_commit_hash = toml.load(urllib2.urlopen(channel))["pkg"]["rustc"]["git_commit_hash"]
|
||||
|
||||
base_url = "https://s3.amazonaws.com/rust-lang-ci/rustc-builds-alt/" + nightly_commit_hash
|
||||
else:
|
||||
base_url = "%s/%s" % (static_s3, self.rust_nightly_date())
|
||||
|
||||
rustc_url = base_url + "/rustc-%s-%s.tar.gz" % (version, host_triple())
|
||||
tgz_file = rust_dir + '-rustc.tar.gz'
|
||||
|
@ -130,9 +131,9 @@ class MachCommands(CommandBase):
|
|||
tarball = "rust-std-%s-%s.tar.gz" % (version, target_triple)
|
||||
tgz_file = path.join(install_dir, tarball)
|
||||
if self.use_stable_rust():
|
||||
std_url = static_s3 + "/" + tarball
|
||||
std_url = STATIC_RUST_LANG_ORG_DIST + "/" + tarball
|
||||
else:
|
||||
std_url = static_s3 + "/" + self.rust_nightly_date() + "/" + tarball
|
||||
std_url = nightly_dist + "/" + tarball
|
||||
|
||||
download_file("Host rust library for target %s" % target_triple, std_url, tgz_file)
|
||||
print("Extracting Rust stdlib for target %s..." % target_triple)
|
||||
|
@ -167,8 +168,9 @@ class MachCommands(CommandBase):
|
|||
if path.isdir(docs_dir):
|
||||
shutil.rmtree(docs_dir)
|
||||
docs_name = self.rust_path().replace("rustc-", "rust-docs-")
|
||||
docs_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s/rust-docs-nightly-%s.tar.gz"
|
||||
% (self.rust_nightly_date(), host_triple()))
|
||||
docs_url = "%s/%s/rust-docs-nightly-%s.tar.gz" % (
|
||||
STATIC_RUST_LANG_ORG_DIST, self.rust_nightly_date(), host_triple()
|
||||
)
|
||||
tgz_file = path.join(rust_root, 'doc.tar.gz')
|
||||
|
||||
download_file("Rust docs", docs_url, tgz_file)
|
||||
|
@ -202,8 +204,7 @@ class MachCommands(CommandBase):
|
|||
os.makedirs(cargo_dir)
|
||||
|
||||
tgz_file = "cargo-nightly-%s.tar.gz" % host_triple()
|
||||
nightly_url = "https://static-rust-lang-org.s3.amazonaws.com/dist/%s/%s" % \
|
||||
(self.rust_nightly_date(), tgz_file)
|
||||
nightly_url = "%s/%s/%s" % (STATIC_RUST_LANG_ORG_DIST, self.rust_nightly_date(), tgz_file)
|
||||
|
||||
download_file("Cargo nightly", nightly_url, tgz_file)
|
||||
|
||||
|
|
|
@ -25,6 +25,16 @@ import toml
|
|||
from servo.packages import WINDOWS_MSVC as msvc_deps
|
||||
from servo.util import host_triple, host_platform
|
||||
|
||||
try:
|
||||
from ssl import HAS_SNI
|
||||
except ImportError:
|
||||
HAS_SNI = False
|
||||
|
||||
if HAS_SNI:
|
||||
STATIC_RUST_LANG_ORG_DIST = "https://static.rust-lang.org/dist"
|
||||
else:
|
||||
STATIC_RUST_LANG_ORG_DIST = "https://static-rust-lang-org.s3.amazonaws.com/dist"
|
||||
|
||||
BIN_SUFFIX = ".exe" if sys.platform == "win32" else ""
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from mach.decorators import (
|
|||
Command,
|
||||
)
|
||||
|
||||
from servo.command_base import CommandBase, cd, call
|
||||
from servo.command_base import CommandBase, cd, call, STATIC_RUST_LANG_ORG_DIST
|
||||
from servo.build_commands import notify_build_done
|
||||
|
||||
|
||||
|
@ -262,7 +262,7 @@ class MachCommands(CommandBase):
|
|||
description='Update the Rust version to latest Nightly',
|
||||
category='devenv')
|
||||
def rustup(self):
|
||||
url = "https://static-rust-lang-org.s3.amazonaws.com/dist/channel-rust-nightly-date.txt"
|
||||
url = STATIC_RUST_LANG_ORG_DIST + "/channel-rust-nightly-date.txt"
|
||||
nightly_date = urllib2.urlopen(url).read()
|
||||
filename = path.join(self.context.topdir, "rust-toolchain")
|
||||
with open(filename, "w") as f:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue