From cc4ea7507f9a4b51833f3134817d3870a6142d22 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 2 Dec 2014 14:33:23 -0800 Subject: [PATCH] Make build system more independent of current directory. --- etc/ci/upload_docs.sh | 2 ++ python/servo/build_commands.py | 8 ++++---- python/servo/command_base.py | 3 +++ python/servo/devenv_commands.py | 2 +- python/servo/post_build_commands.py | 2 +- python/servo/testing_commands.py | 2 +- tests/contenttest.rs | 2 +- tests/reftest.rs | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/etc/ci/upload_docs.sh b/etc/ci/upload_docs.sh index 3f4edd0ada0..5caf358fce7 100755 --- a/etc/ci/upload_docs.sh +++ b/etc/ci/upload_docs.sh @@ -6,6 +6,8 @@ set -e +cd "$(dirname $0)/../.." + mkdir -p components/servo/target/doc ./mach bootstrap-rust # Ordered so that: diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 7b8e2d4351c..1352877d048 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -73,7 +73,7 @@ class MachCommands(CommandBase): else: status = subprocess.call( ["cargo", "build"] + opts, - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) elapsed = time() - build_start print("Build completed in %0.2fs" % elapsed) @@ -106,7 +106,7 @@ class MachCommands(CommandBase): build_start = time() with cd(path.join("ports", "cef")): ret = subprocess.call(["cargo", "build"], - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) elapsed = time() - build_start print("CEF build completed in %0.2fs" % elapsed) @@ -126,7 +126,7 @@ class MachCommands(CommandBase): opts += ["-j", jobs] return subprocess.call( ["cargo", "test", "--no-run"], - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) @Command('clean', description='Clean the build directory.', @@ -147,4 +147,4 @@ class MachCommands(CommandBase): opts += ["-v"] return subprocess.call(["cargo", "clean"] + opts, - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 8dc872e8656..a34104b734e 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -142,6 +142,9 @@ class CommandBase(object): return env + def servo_crate(self): + return path.join(self.context.topdir, "components", "servo") + def ensure_bootstrapped(self): if self.context.bootstrapped: return diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 82db7f34efa..a6b9b997c18 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -22,7 +22,7 @@ class MachCommands(CommandBase): help="Command-line arguments to be passed through to Cargo") def cargo(self, params): return subprocess.call(["cargo"] + params, - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) @Command('update-cargo', description='Update Cargo dependencies', diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index faa4ba127af..972dea7429b 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -71,7 +71,7 @@ class MachCommands(CommandBase): def doc(self, params): self.ensure_bootstrapped() return subprocess.call(["cargo", "doc"] + params, - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) @Command('serve-docs', description='Locally serve Servo and Rust documentation', diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index aa091f9bc06..7d32d1e4808 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -107,7 +107,7 @@ class MachCommands(CommandBase): def cargo_test(component): return 0 != subprocess.call( ["cargo", "test", "-p", component] + test_name, - env=self.build_env(), cwd="components/servo") + env=self.build_env(), cwd=self.servo_crate()) for component in os.listdir("components"): ret = ret or cargo_test(component) diff --git a/tests/contenttest.rs b/tests/contenttest.rs index 17ba85b223f..438f8b5fccf 100644 --- a/tests/contenttest.rs +++ b/tests/contenttest.rs @@ -99,7 +99,7 @@ fn run_test(file: String) { let stderr = InheritFd(2); let args = ["-z", "-f", infile.as_slice()]; - let mut prc = match Command::new("components/servo/target/servo") + let mut prc = match Command::new(os::self_exe_path().unwrap().join("servo")) .args(args) .stdin(Ignored) .stdout(stdout) diff --git a/tests/reftest.rs b/tests/reftest.rs index 1c29a795419..28e6cd20f4c 100644 --- a/tests/reftest.rs +++ b/tests/reftest.rs @@ -248,7 +248,7 @@ fn make_test(reftest: Reftest) -> TestDescAndFn { fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec) { let png_filename = format!("/tmp/servo-reftest-{:06u}-{:u}.png", reftest.id, side); - let mut command = Command::new("components/servo/target/servo"); + let mut command = Command::new(os::self_exe_path().unwrap().join("servo")); command .args(reftest.servo_args.as_slice()) // Allows pixel perfect rendering of Ahem font for reftests.