Skip to content
This repository was archived by the owner on Jun 30, 2020. It is now read-only.

Commit a023708

Browse files
committed
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.
1 parent ce30807 commit a023708

14 files changed

+31
-30
lines changed

cargo-nightly-build

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2015-04-14
1+
2015-06-15

components/servo/.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
paths = ["../../support/android-rs-glue"]
22

33
[target.arm-linux-androideabi]
4-
linker = "../../support/android-rs-glue/apk-builder/target/debug/apk-builder"
4+
linker = "../../target/debug/apk-builder"
55
ar = "arm-linux-androideabi-ar"

components/util/resource_files.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,29 @@ pub fn resources_dir_path() -> PathBuf {
2121
Some(ref path) => PathBuf::from(path),
2222
None => {
2323
// FIXME: Find a way to not rely on the executable being
24-
// under `<servo source>/components/servo/target`
25-
// or `<servo source>/components/servo/target/release`.
24+
// under `<servo source>[/$target_triple]/target/debug`
25+
// or `<servo source>[/$target_triple]/target/release`.
2626
let mut path = env::current_exe().ok().expect("can't get exe path");
2727
path.pop();
2828
path.push("resources");
2929
if !path.is_dir() { // resources dir not in same dir as exe?
30-
path.pop();
30+
// exe is probably in target/{debug,release} so we need to go back to topdir
3131
path.pop();
3232
path.pop();
3333
path.pop();
3434
path.push("resources");
35-
if !path.is_dir() { // self_exe_path() is probably in .../target/release
35+
if !path.is_dir() {
36+
// exe is probably in target/$target_triple/{debug,release} so go back one more
3637
path.pop();
3738
path.pop();
3839
path.push("resources");
39-
if !path.is_dir() { // self_exe_path() is probably in .../target/release
40-
path.pop();
41-
path.pop();
42-
path.push("resources");
43-
}
4440
}
4541
}
4642
path
4743
}
4844
}
4945
}
5046

51-
5247
pub fn read_resource_file(relative_path_components: &[&str]) -> io::Result<Vec<u8>> {
5348
let mut path = resources_dir_path();
5449
for component in relative_path_components {

etc/ci/upload_docs.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cd "$(dirname $0)/../.."
1010

1111
./mach doc
1212
# etc/doc.servo.org/index.html overwrites $(mach rust-root)/doc/index.html
13-
cp etc/doc.servo.org/* components/servo/target/doc/
13+
cp etc/doc.servo.org/* target/doc/
1414

15-
ghp-import -n components/servo/target/doc
15+
ghp-import -n target/doc
1616
git push -qf https://${TOKEN}@github.com/servo/doc.servo.org.git gh-pages

ports/cef/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ crate-type = ["dylib"]
1212
log = "*"
1313
url = "*"
1414
libc = "*"
15-
objc = "0.1"
1615

1716
[dependencies.servo]
1817
path = "../../components/servo"
@@ -72,6 +71,7 @@ git = "https://github.com/servo/rust-stb-image"
7271
git = "https://github.com/servo/gleam"
7372

7473
[target.x86_64-apple-darwin.dependencies]
74+
objc = "0.1"
7575
cocoa = "*"
7676
core-foundation = "*"
7777
core-graphics = "*"

ports/gonk/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Run `./mach build-gonk` from the root directory
5151

5252
## Copy the files to the Flame
5353

54-
To reduce the size of libmozjs.so (`ports/gonk/target/arm-linux-androideabi/build/mozjs-sys-*/out/libmozjs.so`),
54+
To reduce the size of libmozjs.so (`target/arm-linux-androideabi/build/mozjs-sys-*/out/libmozjs.so`),
5555
you can run `strip` on it. Use the one in your toolchain (`$ANDROID_TOOLCHAIN/bin/arm-linux-androideabi-strip libmozjs.so`).
5656

5757
Make sure the device is on, connected to wifi, with high or no screen timeout.
@@ -64,7 +64,7 @@ adb remount
6464
adb push /path/to/stripped/mozjs.so system/lib
6565
6666
# Copy b2s
67-
adb push ports/gonk/target/arm-linux-androideabi system/bin
67+
adb push target/arm-linux-androideabi system/bin
6868
6969
# Copy resources
7070
adb shell mkdir sdcard/servo

python/servo/build_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def build(self, target=None, release=False, dev=False, jobs=None,
147147
opts = params or []
148148
features = []
149149

150-
base_path = path.join("components", "servo", "target")
150+
base_path = self.get_target_dir()
151151
release_path = path.join(base_path, "release", "servo")
152152
dev_path = path.join(base_path, "debug", "servo")
153153

python/servo/command_base.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,14 @@ def cargo_build_id(self):
130130
self._cargo_build_id = open(filename).read().strip()
131131
return self._cargo_build_id
132132

133+
def get_target_dir(self):
134+
if "CARGO_TARGET_DIR" in os.environ:
135+
return os.environ["CARGO_TARGET_DIR"]
136+
else:
137+
return path.join(self.context.topdir, "target")
138+
133139
def get_binary_path(self, release, dev):
134-
base_path = path.join("components", "servo", "target")
140+
base_path = self.get_target_dir()
135141
release_path = path.join(base_path, "release", "servo")
136142
dev_path = path.join(base_path, "debug", "servo")
137143

@@ -199,6 +205,9 @@ def build_env(self, gonk=False, hosts_file_path=None):
199205
if "CARGO_HOME" not in env:
200206
env["CARGO_HOME"] = self.config["tools"]["cargo-home-dir"]
201207

208+
if "CARGO_TARGET_DIR" not in env:
209+
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target")
210+
202211
if extra_lib:
203212
if sys.platform == "darwin":
204213
env["DYLD_LIBRARY_PATH"] = "%s%s%s" % \

python/servo/post_build_commands.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ def doc(self, params):
137137
if not path.exists(path.join(self.config["tools"]["rust-root"], "doc")):
138138
Registrar.dispatch("bootstrap-rust-docs", context=self.context)
139139
rust_docs = path.join(self.config["tools"]["rust-root"], "doc")
140-
docs = path.join(
141-
self.context.topdir, "components", "servo", "target", "doc")
140+
docs = path.join(self.get_target_dir(), "doc")
142141
if not path.exists(docs):
143142
os.makedirs(docs)
144143

@@ -167,4 +166,4 @@ def serve_docs(self):
167166
self.doc([])
168167
import webbrowser
169168
webbrowser.open("file://" + path.abspath(path.join(
170-
self.servo_crate(), "target", "doc", "servo", "index.html")))
169+
self.get_target_dir(), "doc", "servo", "index.html")))

python/servo/testing_commands.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ def ensure_built_tests(self):
4747

4848
def find_test(self, prefix):
4949
target_contents = os.listdir(path.join(
50-
self.context.topdir, "components", "servo", "target", "debug"))
50+
self.get_target_dir(), "debug"))
5151
for filename in target_contents:
5252
if filename.startswith(prefix + "-"):
5353
filepath = path.join(
54-
self.context.topdir, "components", "servo",
55-
"target", "debug", filename)
54+
self.get_target_dir(), "debug", filename)
5655

5756
if path.isfile(filepath) and os.access(filepath, os.X_OK):
5857
return filepath

python/tidy.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
# Generated and upstream code combined with our own. Could use cleanup
3737
"components/script/dom/bindings/codegen/*",
3838
"components/style/properties/mod.rs",
39-
"components/servo/target/*",
40-
"ports/gonk/target/*",
39+
"target/*",
4140
"ports/gonk/src/native_window_glue.cpp",
4241
"ports/cef/*",
4342

tests/power/PowerMeasure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def PowerCollector(OutputDir, Benchmarks, LayoutThreads, Renderer):
4444
power_dir, "power-Layout%d-set%d.csv" % (layoutT, ExpNum))
4545
TimeFiles = path.join(
4646
time_dir, "time-Layout%d-set%d.csv" % (layoutT, ExpNum))
47-
ServoCmd = "(time ../../components/servo/target/release/servo -x -y %d %s %s) 2> %s" % \
47+
ServoCmd = "(time ../../target/release/servo -x -y %d %s %s) 2> %s" % \
4848
(layoutT, Renderer, Benchmarks, TimeFiles)
4949
Metrics = path.join(
5050
etc_dir, "metrics-Layout%d-set%d-css.csv" % (layoutT, ExpNum))

tests/wpt/harness/test/test.cfg.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ssl-type=none
88
# prefs-root=/path/to/gecko-src/testing/profiles/
99

1010
# [servo]
11-
# binary=/path/to/servo-src/components/servo/target/servo
11+
# binary=/path/to/servo-src/target/release/servo
1212
# exclude=testharness # Because it needs a special testharness.js
1313

1414
# [chrome]

tests/wpt/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def set_defaults(paths, kwargs):
4040

4141
if kwargs["binary"] is None:
4242
bin_dir = "release" if kwargs["release"] else "debug"
43-
bin_path = servo_path("components", "servo", "target", bin_dir, "servo")
43+
bin_path = servo_path("target", bin_dir, "servo")
4444

4545
kwargs["binary"] = bin_path
4646

0 commit comments

Comments
 (0)