Require should_run to be implemented.

This commit is contained in:
Mark Simulacrum 2017-07-14 06:30:16 -06:00
parent 270d1d69ed
commit 681b12316c
6 changed files with 64 additions and 2 deletions

View File

@ -70,7 +70,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
/// will execute. However, it does not get called in a "default" context
/// when we are not passed any paths; in that case, make_run is called
/// directly.
fn should_run(_builder: &Builder, _path: &Path) -> bool { false }
fn should_run(builder: &Builder, path: &Path) -> bool;
/// Build up a "root" rule, either as a default rule or from a path passed
/// to us.
@ -83,7 +83,13 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
_path: Option<&Path>,
_host: Interned<String>,
_target: Interned<String>,
) { unimplemented!() }
) {
// It is reasonable to not have an implementation of make_run for rules
// who do not want to get called from the root context. This means that
// they are likely dependencies (e.g., sysroot creation) or similar, and
// as such calling them from ./x.py isn't logical.
unimplemented!()
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@ -188,6 +194,11 @@ impl<'a> Builder<'a> {
}
impl Step for Libdir {
type Output = Interned<PathBuf>;
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
fn run(self, builder: &Builder) -> Interned<PathBuf> {
let compiler = self.compiler;
let lib = if compiler.stage >= 2 && builder.build.config.libdir_relative.is_some() {

View File

@ -1360,6 +1360,10 @@ pub struct RemoteCopyLibs {
impl Step for RemoteCopyLibs {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
fn run(self, builder: &Builder) {
let build = builder.build;
let compiler = self.compiler;
@ -1411,6 +1415,10 @@ pub struct Distcheck;
impl Step for Distcheck {
type Output = ();
fn should_run(_builder: &Builder, path: &Path) -> bool {
path.ends_with("distcheck")
}
/// Run "distcheck", a 'make check' from a tarball
fn run(self, builder: &Builder) {
let build = builder.build;

View File

@ -276,6 +276,10 @@ struct StdLink {
impl Step for StdLink {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Link all libstd rlibs/dylibs into the sysroot location.
///
/// Links those artifacts generated by `compiler` to a the `stage` compiler's
@ -503,6 +507,10 @@ pub struct TestLink {
impl Step for TestLink {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Same as `std_link`, only for libtest
fn run(self, builder: &Builder) {
let build = builder.build;
@ -691,6 +699,10 @@ struct RustcLink {
impl Step for RustcLink {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Same as `std_link`, only for librustc
fn run(self, builder: &Builder) {
let build = builder.build;
@ -743,6 +755,10 @@ pub struct Sysroot {
impl Step for Sysroot {
type Output = Interned<PathBuf>;
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Returns the sysroot for the `compiler` specified that *this build system
/// generates*.
///
@ -789,6 +805,10 @@ pub struct Assemble {
impl Step for Assemble {
type Output = Compiler;
fn should_run(_builder: &Builder, path: &Path) -> bool {
path.ends_with("src/rustc")
}
/// Prepare a new compiler from the artifacts in `stage`
///
/// This will assemble a compiler in `build/$host/stage$stage`. The compiler

View File

@ -107,6 +107,12 @@ pub struct Rustbook {
impl Step for Rustbook {
type Output = ();
// rustbook is never directly called, and only serves as a shim for the nomicon and the
// reference.
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Invoke `rustbook` for `target` for the doc book `name`.
///
/// This will not actually generate any documentation if the documentation has
@ -182,6 +188,11 @@ pub struct RustbookSrc {
impl Step for RustbookSrc {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
// RustbookSrc is also never run directly, only as a helper to other rules
false
}
/// Invoke `rustbook` for `target` for the doc book `name` from the `src` path.
///
/// This will not actually generate any documentation if the documentation has

View File

@ -55,6 +55,10 @@ impl Step for Llvm {
type Output = ();
const ONLY_HOSTS: bool = true;
fn should_run(_builder: &Builder, path: &Path) -> bool {
path.ends_with("src/llvm")
}
/// Compile LLVM for `target`.
fn run(self, builder: &Builder) {
let build = builder.build;

View File

@ -55,6 +55,10 @@ pub struct CleanTools {
impl Step for CleanTools {
type Output = ();
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Build a tool in `src/tools`
///
/// This will build the specified tool with the specified `host` compiler in
@ -89,6 +93,10 @@ pub struct ToolBuild {
impl Step for ToolBuild {
type Output = PathBuf;
fn should_run(_builder: &Builder, _path: &Path) -> bool {
false
}
/// Build a tool in `src/tools`
///
/// This will build the specified tool with the specified `host` compiler in