Use Cargo's target directory sharing.

This speeds up `./mach build --dev` followed by `./mach build-cef` by a
large amount, and also speeds up other build combos found in our CI.
This commit is contained in:
Jack Moffitt 2015-06-08 16:09:08 -06:00
parent ce30807be5
commit a0237085c6
14 changed files with 31 additions and 30 deletions

View file

@ -1 +1 @@
2015-04-14
2015-06-15

View file

@ -1,5 +1,5 @@
paths = ["../../support/android-rs-glue"]
[target.arm-linux-androideabi]
linker = "../../support/android-rs-glue/apk-builder/target/debug/apk-builder"
linker = "../../target/debug/apk-builder"
ar = "arm-linux-androideabi-ar"

View file

@ -21,26 +21,22 @@ pub fn resources_dir_path() -> PathBuf {
Some(ref path) => PathBuf::from(path),
None => {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
// under `<servo source>[/$target_triple]/target/debug`
// or `<servo source>[/$target_triple]/target/release`.
let mut path = env::current_exe().ok().expect("can't get exe path");
path.pop();
path.push("resources");
if !path.is_dir() { // resources dir not in same dir as exe?
path.pop();
// exe is probably in target/{debug,release} so we need to go back to topdir
path.pop();
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() { // self_exe_path() is probably in .../target/release
if !path.is_dir() {
// exe is probably in target/$target_triple/{debug,release} so go back one more
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() { // self_exe_path() is probably in .../target/release
path.pop();
path.pop();
path.push("resources");
}
}
}
path
@ -48,7 +44,6 @@ pub fn resources_dir_path() -> PathBuf {
}
}
pub fn read_resource_file(relative_path_components: &[&str]) -> io::Result<Vec<u8>> {
let mut path = resources_dir_path();
for component in relative_path_components {

View file

@ -10,7 +10,7 @@ cd "$(dirname $0)/../.."
./mach doc
# etc/doc.servo.org/index.html overwrites $(mach rust-root)/doc/index.html
cp etc/doc.servo.org/* components/servo/target/doc/
cp etc/doc.servo.org/* target/doc/
ghp-import -n components/servo/target/doc
ghp-import -n target/doc
git push -qf https://${TOKEN}@github.com/servo/doc.servo.org.git gh-pages

View file

@ -12,7 +12,6 @@ crate-type = ["dylib"]
log = "*"
url = "*"
libc = "*"
objc = "0.1"
[dependencies.servo]
path = "../../components/servo"
@ -72,6 +71,7 @@ git = "https://github.com/servo/rust-stb-image"
git = "https://github.com/servo/gleam"
[target.x86_64-apple-darwin.dependencies]
objc = "0.1"
cocoa = "*"
core-foundation = "*"
core-graphics = "*"

View file

@ -51,7 +51,7 @@ Run `./mach build-gonk` from the root directory
## Copy the files to the Flame
To reduce the size of libmozjs.so (`ports/gonk/target/arm-linux-androideabi/build/mozjs-sys-*/out/libmozjs.so`),
To reduce the size of libmozjs.so (`target/arm-linux-androideabi/build/mozjs-sys-*/out/libmozjs.so`),
you can run `strip` on it. Use the one in your toolchain (`$ANDROID_TOOLCHAIN/bin/arm-linux-androideabi-strip libmozjs.so`).
Make sure the device is on, connected to wifi, with high or no screen timeout.
@ -64,7 +64,7 @@ adb remount
adb push /path/to/stripped/mozjs.so system/lib
# Copy b2s
adb push ports/gonk/target/arm-linux-androideabi system/bin
adb push target/arm-linux-androideabi system/bin
# Copy resources
adb shell mkdir sdcard/servo

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

@ -47,12 +47,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

View file

@ -36,8 +36,7 @@ ignored_files = [
# Generated and upstream code combined with our own. Could use cleanup
"components/script/dom/bindings/codegen/*",
"components/style/properties/mod.rs",
"components/servo/target/*",
"ports/gonk/target/*",
"target/*",
"ports/gonk/src/native_window_glue.cpp",
"ports/cef/*",

View file

@ -44,7 +44,7 @@ def PowerCollector(OutputDir, Benchmarks, LayoutThreads, Renderer):
power_dir, "power-Layout%d-set%d.csv" % (layoutT, ExpNum))
TimeFiles = path.join(
time_dir, "time-Layout%d-set%d.csv" % (layoutT, ExpNum))
ServoCmd = "(time ../../components/servo/target/release/servo -x -y %d %s %s) 2> %s" % \
ServoCmd = "(time ../../target/release/servo -x -y %d %s %s) 2> %s" % \
(layoutT, Renderer, Benchmarks, TimeFiles)
Metrics = path.join(
etc_dir, "metrics-Layout%d-set%d-css.csv" % (layoutT, ExpNum))

View file

@ -8,7 +8,7 @@ ssl-type=none
# prefs-root=/path/to/gecko-src/testing/profiles/
# [servo]
# binary=/path/to/servo-src/components/servo/target/servo
# binary=/path/to/servo-src/target/release/servo
# exclude=testharness # Because it needs a special testharness.js
# [chrome]

View file

@ -40,7 +40,7 @@ def set_defaults(paths, kwargs):
if kwargs["binary"] is None:
bin_dir = "release" if kwargs["release"] else "debug"
bin_path = servo_path("components", "servo", "target", bin_dir, "servo")
bin_path = servo_path("target", bin_dir, "servo")
kwargs["binary"] = bin_path