Add 'mach check' and 'mach check-geckolib'

This commit is contained in:
Simon Sapin 2017-05-13 15:02:47 +02:00
parent d2fa2ae934
commit f693582ba9
2 changed files with 66 additions and 19 deletions

View file

@ -133,7 +133,6 @@ Mach tools to orchestrate the build and other tasks.
### Normal build
To build Servo in development mode. This is useful for development, but
the resulting binary is very slow.
@ -159,6 +158,20 @@ real-world use, add the `--release` flag to create an optimized build:
./mach run --release tests/html/about-mozilla.html
```
### Checking for build errors, without building
If youre making changes to one crate that cause build errors in another crate,
consider this instead of a full build:
```sh
./mach check
```
It will run `cargo check`, which runs the analysis phase of the compiler
(and so shows build errors if any) but skips the code generation phase.
This can be a lot faster than a full build,
though of course it doesnt produce a binary you can run.
### Building for Android target
``` sh

View file

@ -9,6 +9,7 @@
from __future__ import print_function, unicode_literals
from os import path, getcwd, listdir
from time import time
import sys
import urllib2
@ -21,10 +22,43 @@ from mach.decorators import (
)
from servo.command_base import CommandBase, cd, call
from servo.build_commands import notify_build_done
@CommandProvider
class MachCommands(CommandBase):
def run_cargo(self, params, geckolib=False, check=False):
if geckolib:
self.set_use_stable_rust()
crate_dir = path.join('ports', 'geckolib')
else:
crate_dir = path.join('components', 'servo')
self.ensure_bootstrapped()
self.ensure_clobbered()
env = self.build_env(geckolib=geckolib)
if not params:
params = []
if check:
params = ['check'] + params
build_start = time()
if self.context.topdir == getcwd():
with cd(crate_dir):
status = call(['cargo'] + params, env=env)
else:
status = call(['cargo'] + params, env=env)
elapsed = time() - build_start
notify_build_done(self.config, elapsed, status == 0)
if check and status == 0:
print('Finished checking, binary NOT updated. Consider ./mach build before ./mach run')
return status
@Command('cargo',
description='Run Cargo',
category='devenv')
@ -32,15 +66,7 @@ class MachCommands(CommandBase):
'params', default=None, nargs='...',
help="Command-line arguments to be passed through to Cargo")
def cargo(self, params):
if not params:
params = []
self.ensure_bootstrapped()
if self.context.topdir == getcwd():
with cd(path.join('components', 'servo')):
return call(["cargo"] + params, env=self.build_env())
return call(['cargo'] + params, env=self.build_env())
return self.run_cargo(params)
@Command('cargo-geckolib',
description='Run Cargo with the same compiler version and root crate as build-geckolib',
@ -49,17 +75,25 @@ class MachCommands(CommandBase):
'params', default=None, nargs='...',
help="Command-line arguments to be passed through to Cargo")
def cargo_geckolib(self, params):
if not params:
params = []
return self.run_cargo(params, geckolib=True)
self.set_use_stable_rust()
self.ensure_bootstrapped()
env = self.build_env(geckolib=True)
@Command('check',
description='Run "cargo check"',
category='devenv')
@CommandArgument(
'params', default=None, nargs='...',
help="Command-line arguments to be passed through to cargo check")
def check(self, params):
return self.run_cargo(params, check=True)
if self.context.topdir == getcwd():
with cd(path.join('ports', 'geckolib')):
return call(["cargo"] + params, env=env)
return call(['cargo'] + params, env=env)
@Command('check-geckolib',
description='Run "cargo check" with the same compiler version and root crate as build-geckolib',
category='devenv')
@CommandArgument(
'params', default=None, nargs='...',
help="Command-line arguments to be passed through to cargo check")
def check_geckolib(self, params):
return self.run_cargo(params, check=True, geckolib=True)
@Command('cargo-update',
description='Same as update-cargo',