mirror of
https://github.com/servo/servo.git
synced 2025-06-13 19:04:30 +00:00
Automatically update cargo when necessary
This commit is contained in:
parent
75b340a243
commit
2ee516fa7c
3 changed files with 14 additions and 4 deletions
1
cargo-nightly-build
Normal file
1
cargo-nightly-build
Normal file
|
@ -0,0 +1 @@
|
|||
2014-10-21
|
|
@ -96,7 +96,8 @@ class MachCommands(CommandBase):
|
|||
action='store_true',
|
||||
help='Force download even if cargo already exists')
|
||||
def bootstrap_cargo(self, force=False):
|
||||
cargo_dir = path.join(self.context.sharedir, "cargo")
|
||||
cargo_dir = path.join(self.context.sharedir, "cargo",
|
||||
self.cargo_build_id())
|
||||
if not force and path.exists(path.join(cargo_dir, "bin", "cargo")):
|
||||
print("Cargo already downloaded.", end=" ")
|
||||
print("Use |bootstrap_cargo --force| to download again.")
|
||||
|
@ -104,11 +105,12 @@ class MachCommands(CommandBase):
|
|||
|
||||
if path.isdir(cargo_dir):
|
||||
shutil.rmtree(cargo_dir)
|
||||
os.mkdir(cargo_dir)
|
||||
os.makedirs(cargo_dir)
|
||||
|
||||
tgz_file = "cargo-nightly-%s.tar.gz" % host_triple()
|
||||
# FIXME(#3582): use https.
|
||||
nightly_url = "http://static.rust-lang.org/cargo-dist/2014-10-21/%s" % tgz_file
|
||||
nightly_url = "http://static.rust-lang.org/cargo-dist/%s/%s" % \
|
||||
(self.cargo_build_id(), tgz_file)
|
||||
|
||||
download("Cargo nightly", nightly_url, tgz_file)
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class CommandBase(object):
|
|||
context.sharedir, "rust", *self.rust_snapshot_path().split("/"))
|
||||
if not self.config["tools"]["system-cargo"]:
|
||||
self.config["tools"]["cargo-root"] = path.join(
|
||||
context.sharedir, "cargo")
|
||||
context.sharedir, "cargo", self.cargo_build_id())
|
||||
|
||||
self.config.setdefault("build", {})
|
||||
self.config["build"].setdefault("android", False)
|
||||
|
@ -85,6 +85,7 @@ class CommandBase(object):
|
|||
self.config["android"].setdefault("toolchain", "")
|
||||
|
||||
_rust_snapshot_path = None
|
||||
_cargo_build_id = None
|
||||
|
||||
def rust_snapshot_path(self):
|
||||
if self._rust_snapshot_path is None:
|
||||
|
@ -93,6 +94,12 @@ class CommandBase(object):
|
|||
self._rust_snapshot_path = "%s-%s" % (snapshot_hash, host_triple())
|
||||
return self._rust_snapshot_path
|
||||
|
||||
def cargo_build_id(self):
|
||||
if self._cargo_build_id is None:
|
||||
filename = path.join(self.context.topdir, "cargo-nightly-build")
|
||||
self._cargo_build_id = open(filename).read().strip()
|
||||
return self._cargo_build_id
|
||||
|
||||
def build_env(self):
|
||||
"""Return an extended environment dictionary."""
|
||||
env = os.environ.copy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue