Auto merge of #6306 - metajack:shared-target-dir, r=mbrubeck

This speeds up `./mach build --dev` followed by `./mach build-cef` by
25%. When rust-lang/cargo#497 is fixed, this speedup will increase
dramatically.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6306)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-15 13:08:14 -06:00
commit d6263c9b6e
14 changed files with 31 additions and 30 deletions

View file

@ -147,7 +147,7 @@ class MachCommands(CommandBase):
opts = params or []
features = []
base_path = path.join("components", "servo", "target")
base_path = self.get_target_dir()
release_path = path.join(base_path, "release", "servo")
dev_path = path.join(base_path, "debug", "servo")

View file

@ -130,8 +130,14 @@ class CommandBase(object):
self._cargo_build_id = open(filename).read().strip()
return self._cargo_build_id
def get_target_dir(self):
if "CARGO_TARGET_DIR" in os.environ:
return os.environ["CARGO_TARGET_DIR"]
else:
return path.join(self.context.topdir, "target")
def get_binary_path(self, release, dev):
base_path = path.join("components", "servo", "target")
base_path = self.get_target_dir()
release_path = path.join(base_path, "release", "servo")
dev_path = path.join(base_path, "debug", "servo")
@ -199,6 +205,9 @@ class CommandBase(object):
if "CARGO_HOME" not in env:
env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"]
if "CARGO_TARGET_DIR" not in env:
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target")
if extra_lib:
if sys.platform == "darwin":
env["DYLD_LIBRARY_PATH"] = "%s%s%s" % \

View file

@ -137,8 +137,7 @@ class MachCommands(CommandBase):
if not path.exists(path.join(self.config["tools"]["rust-root"], "doc")):
Registrar.dispatch("bootstrap-rust-docs", context=self.context)
rust_docs = path.join(self.config["tools"]["rust-root"], "doc")
docs = path.join(
self.context.topdir, "components", "servo", "target", "doc")
docs = path.join(self.get_target_dir(), "doc")
if not path.exists(docs):
os.makedirs(docs)
@ -167,4 +166,4 @@ class MachCommands(CommandBase):
self.doc([])
import webbrowser
webbrowser.open("file://" + path.abspath(path.join(
self.servo_crate(), "target", "doc", "servo", "index.html")))
self.get_target_dir(), "doc", "servo", "index.html")))

View file

@ -50,12 +50,11 @@ class MachCommands(CommandBase):
def find_test(self, prefix):
target_contents = os.listdir(path.join(
self.context.topdir, "components", "servo", "target", "debug"))
self.get_target_dir(), "debug"))
for filename in target_contents:
if filename.startswith(prefix + "-"):
filepath = path.join(
self.context.topdir, "components", "servo",
"target", "debug", filename)
self.get_target_dir(), "debug", filename)
if path.isfile(filepath) and os.access(filepath, os.X_OK):
return filepath