Skip to content

Commit

Permalink
servo: Merge #6306 - Use Cargo's target directory sharing (from metaj…
Browse files Browse the repository at this point in the history
…ack: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.

Source-Repo: https://github.com/servo/servo
Source-Revision: d6263c9b6e969fde4c644034e684a39d68667ad9

UltraBlame original commit: 42376672d55b8b2f7f08473d1ab24888896d0256
  • Loading branch information
marco-c committed Sep 30, 2019
1 parent 49e33b8 commit 2d3c5b1
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion servo/cargo-nightly-build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2015-04-14
2015-06-15
2 changes: 1 addition & 1 deletion servo/components/servo/.cargo/config
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 3 additions & 8 deletions servo/components/util/resource_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,23 @@ pub fn resources_dir_path() -> PathBuf {
path.pop();
path.push("resources");
if !path.is_dir() {
path.pop();

path.pop();
path.pop();
path.pop();
path.push("resources");
if !path.is_dir() {
if !path.is_dir() {

path.pop();
path.pop();
path.push("resources");
if !path.is_dir() {
path.pop();
path.pop();
path.push("resources");
}
}
}
path
}
}
}


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 {
Expand Down
4 changes: 2 additions & 2 deletions servo/etc/ci/upload_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion servo/ports/cef/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ crate-type = ["dylib"]
log = "*"
url = "*"
libc = "*"
objc = "0.1"

[dependencies.servo]
path = "../../components/servo"
Expand Down Expand Up @@ -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 = "*"
Expand Down
4 changes: 2 additions & 2 deletions servo/ports/gonk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion servo/python/servo/build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def build(self, target=None, release=False, dev=False, jobs=None,
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")

Expand Down
11 changes: 10 additions & 1 deletion servo/python/servo/command_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ def cargo_build_id(self):
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")

Expand Down Expand Up @@ -199,6 +205,9 @@ def build_env(self, gonk=False, hosts_file_path=None):
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" % \
Expand Down
5 changes: 2 additions & 3 deletions servo/python/servo/post_build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def doc(self, params):
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)

Expand Down Expand Up @@ -167,4 +166,4 @@ def serve_docs(self):
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")))
5 changes: 2 additions & 3 deletions servo/python/servo/testing_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def ensure_built_tests(self):

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
Expand Down
3 changes: 1 addition & 2 deletions servo/python/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

"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/*",

Expand Down
2 changes: 1 addition & 1 deletion servo/tests/power/PowerMeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2d3c5b1

Please sign in to comment.