diff options
Diffstat (limited to 'python/servo')
-rw-r--r-- | python/servo/bootstrap_commands.py | 51 | ||||
-rw-r--r-- | python/servo/command_base.py | 7 |
2 files changed, 44 insertions, 14 deletions
diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 37ae5d5b826..6c262de3e1a 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -117,7 +117,7 @@ class MachCommands(CommandBase): help='Force download even if a snapshot already exists') def bootstrap_rustc(self, force=False): rust_dir = path.join( - self.context.sharedir, "rust", *self.rust_snapshot_path().split("/")) + self.context.sharedir, "rust", self.rust_snapshot_path()) if not force and path.exists(path.join(rust_dir, "rustc", "bin", "rustc")): print("Snapshot Rust compiler already downloaded.", end=" ") print("Use |bootstrap-rust --force| to download again.") @@ -127,16 +127,43 @@ class MachCommands(CommandBase): shutil.rmtree(rust_dir) os.makedirs(rust_dir) - snapshot_url = ("https://servo-rust.s3.amazonaws.com/%s.tar.gz" - % self.rust_snapshot_path()) - tgz_file = rust_dir + '.tar.gz' + date = self.rust_snapshot_path().split("/")[0] + install_dir = path.join(self.context.sharedir, "rust", date) - download_file("Rust snapshot", snapshot_url, tgz_file) + # The Rust compiler is hosted on the nightly server under the date with a name + # rustc-nightly-HOST-TRIPLE.tar.gz. We just need to pull down and extract it, + # giving a directory name that will be the same as the tarball name (rustc is + # in that directory). + snapshot_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s.tar.gz" + % self.rust_snapshot_path()) + tgz_file = rust_dir + '-rustc.tar.gz' + + download_file("Rust compiler", snapshot_url, tgz_file) + + print("Extracting Rust compiler...") + extract(tgz_file, install_dir) + + # Each Rust stdlib has a name of the form `rust-std-nightly-TRIPLE.tar.gz`, with + # a directory of the name `rust-std-TRIPLE` inside and then a `lib` directory. + # This `lib` directory needs to be extracted and merged with the `rustc/lib` + # directory from the host compiler above. + # TODO: make it possible to request an additional cross-target to add to this + # list. + stdlibs = [host_triple(), "arm-linux-androideabi"] + for target in stdlibs: + snapshot_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/%s/rust-std-nightly-%s.tar.gz" + % (date, target)) + tgz_file = install_dir + ('rust-std-nightly-%s.tar.gz' % target) + + download_file("Host rust library for target %s" % target, snapshot_url, tgz_file) + print("Extracting Rust stdlib for target %s..." % target) + extract(tgz_file, install_dir) + shutil.copytree(path.join(install_dir, "rust-std-nightly-%s" % target, + "rust-std-%s" % target, "lib", "rustlib", target), + path.join(install_dir, "rustc-nightly-%s" % host_triple(), + "rustc", "lib", "rustlib", target)) + shutil.rmtree(path.join(install_dir, "rust-std-nightly-%s" % target)) - print("Extracting Rust snapshot...") - snap_dir = path.join(rust_dir, - path.basename(tgz_file).replace(".tar.gz", "")) - extract(tgz_file, rust_dir, movedir=snap_dir) print("Snapshot Rust ready.") @Command('bootstrap-rust-docs', @@ -149,7 +176,7 @@ class MachCommands(CommandBase): self.ensure_bootstrapped() hash_dir = path.join(self.context.sharedir, "rust", self.rust_snapshot_path().split("/")[0]) - docs_dir = path.join(hash_dir, self.rust_snapshot_path().split("/")[1], "doc") + docs_dir = path.join(hash_dir, "doc") if not force and path.exists(docs_dir): print("Snapshot Rust docs already downloaded.", end=" ") print("Use |bootstrap-rust-docs --force| to download again.") @@ -158,8 +185,8 @@ class MachCommands(CommandBase): if path.isdir(docs_dir): shutil.rmtree(docs_dir) docs_name = self.rust_snapshot_path().replace("rustc-", "rust-docs-") - snapshot_url = ("https://servo-rust.s3.amazonaws.com/%s.tar.gz" - % docs_name) + snapshot_url = ("https://static-rust-lang-org.s3.amazonaws.com/dist/rust-docs-nightly-%s.tar.gz" + % host_triple()) tgz_file = path.join(hash_dir, 'doc.tar.gz') download_file("Rust docs", snapshot_url, tgz_file) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index e702d3f76e3..b3b24f8df46 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -97,7 +97,7 @@ class CommandBase(object): self.config["tools"].setdefault("cargo-root", "") if not self.config["tools"]["system-rust"]: self.config["tools"]["rust-root"] = path.join( - context.sharedir, "rust", *self.rust_snapshot_path().split("/")) + context.sharedir, "rust", self.rust_snapshot_path()) if not self.config["tools"]["system-cargo"]: self.config["tools"]["cargo-root"] = path.join( context.sharedir, "cargo", self.cargo_build_id()) @@ -127,7 +127,8 @@ class CommandBase(object): filename = path.join(self.context.topdir, "rust-snapshot-hash") with open(filename) as f: snapshot_hash = f.read().strip() - self._rust_snapshot_path = "%s-%s" % (snapshot_hash, host_triple()) + self._rust_snapshot_path = ("%s/rustc-nightly-%s" % + (snapshot_hash, host_triple())) return self._rust_snapshot_path def cargo_build_id(self): @@ -337,6 +338,8 @@ class CommandBase(object): if not self.config["tools"]["system-rust"] and \ not path.exists(path.join( self.config["tools"]["rust-root"], "rustc", "bin", "rustc")): + print("looking for rustc at %s" % path.join( + self.config["tools"]["rust-root"], "rustc", "bin", "rustc")) Registrar.dispatch("bootstrap-rust", context=self.context) if not self.config["tools"]["system-cargo"] and \ not path.exists(path.join( |