Make build system more independent of current directory.

This commit is contained in:
Simon Sapin 2014-12-02 14:33:23 -08:00
parent ff4877b473
commit cc4ea7507f
8 changed files with 14 additions and 9 deletions

View file

@ -6,6 +6,8 @@
set -e
cd "$(dirname $0)/../.."
mkdir -p components/servo/target/doc
./mach bootstrap-rust
# Ordered so that:

View file

@ -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())

View file

@ -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

View file

@ -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',

View file

@ -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',

View file

@ -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)

View file

@ -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)

View file

@ -248,7 +248,7 @@ fn make_test(reftest: Reftest) -> TestDescAndFn {
fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec<u8>) {
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.