From cfdad335bd2cdadb446f9e7a5fbd907506cdadbc Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 6 Mar 2015 23:19:37 +0530 Subject: [PATCH] Add support for $CARGO_HOME in servobuild --- python/servo/command_base.py | 20 ++++++++++++++++++-- servobuild.example | 8 +++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 4bcae97c11b..b8474c85044 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -51,6 +51,13 @@ class CommandBase(object): def __init__(self, context): self.context = context + def resolverelative(category, key): + # Allow ~ + self.config[category][key] = path.expanduser(self.config[category][key]) + # Resolve relative paths + self.config[category][key] = path.join(context.topdir, + self.config[category][key]) + if not hasattr(self.context, "bootstrapped"): self.context.bootstrapped = False @@ -64,8 +71,13 @@ class CommandBase(object): self.config.setdefault("tools", {}) self.config["tools"].setdefault("cache-dir", path.join(context.topdir, ".servo")) - # Allow "~" in cache-dir - context.sharedir = path.expanduser(self.config["tools"]["cache-dir"]) + resolverelative("tools", "cache-dir") + + self.config["tools"].setdefault("cargo-home-dir", + path.join(context.topdir, ".cargo")) + resolverelative("tools", "cargo-home-dir") + + context.sharedir = self.config["tools"]["cache-dir"] self.config["tools"].setdefault("system-rust", False) self.config["tools"].setdefault("system-cargo", False) @@ -126,6 +138,10 @@ class CommandBase(object): if extra_path: env["PATH"] = "%s%s%s" % ( os.pathsep.join(extra_path), os.pathsep, env["PATH"]) + + if "CARGO_HOME" not in env: + env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"] + if extra_lib: if sys.platform == "darwin": env["DYLD_LIBRARY_PATH"] = "%s%s%s" % \ diff --git a/servobuild.example b/servobuild.example index be490f2626e..1396c73126e 100644 --- a/servobuild.example +++ b/servobuild.example @@ -2,11 +2,17 @@ # Be sure to set the cache-dir correctly, otherwise extra snapshots # may get downloaded +# Paths starting with "./" are relative to the repo root + # Tool options [tools] # Where Rust compiler snapshots and other downloads will be stored. Can be # shared by multiple Servo reposities. Defaults to /.servo -cache-dir = "~/.servo" +cache-dir = "./.servo" + +# Where cargo stores all of its clones Defaults to /.cargo +cargo-home-dir = "./.cargo" + # If system-rust is true, will use rustc/rustdoc from the path, or if # rust-root is specified, will make sure that rust-root is in the path # when building. Similarly for Cargo. This takes care of PATH as well as