]> git.proxmox.com Git - rustc.git/blobdiff - src/bootstrap/build/step.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / bootstrap / build / step.rs
index ba0095ce84980146dff3c10c620090ec9c5350f9..80fcc32e5371d5c4504e9d911750c0b6bee139a4 100644 (file)
@@ -25,26 +25,33 @@ macro_rules! targets {
             // compiler executable itself, not any of the support libraries
             (rustc, Rustc { stage: u32 }),
 
-            // Steps for the two main cargo builds, one for the standard library
-            // and one for the compiler itself. These are parameterized over the
-            // stage output they're going to be placed in along with the
-            // compiler which is producing the copy of libstd or librustc
-            (libstd, Libstd { stage: u32, compiler: Compiler<'a> }),
-            (librustc, Librustc { stage: u32, compiler: Compiler<'a> }),
-
-            // Links the standard library/librustc produced by the compiler
-            // provided into the host's directory also provided.
+            // Steps for the two main cargo builds. These are parameterized over
+            // the compiler which is producing the artifact.
+            (libstd, Libstd { compiler: Compiler<'a> }),
+            (libtest, Libtest { compiler: Compiler<'a> }),
+            (librustc, Librustc { compiler: Compiler<'a> }),
+
+            // Links the target produced by the compiler provided into the
+            // host's directory also provided.
             (libstd_link, LibstdLink {
-                stage: u32,
+                compiler: Compiler<'a>,
+                host: &'a str
+            }),
+            (libtest_link, LibtestLink {
                 compiler: Compiler<'a>,
                 host: &'a str
             }),
             (librustc_link, LibrustcLink {
-                stage: u32,
                 compiler: Compiler<'a>,
                 host: &'a str
             }),
 
+            // Various tools that we can build as part of the build.
+            (tool_linkchecker, ToolLinkchecker { stage: u32 }),
+            (tool_rustbook, ToolRustbook { stage: u32 }),
+            (tool_error_index, ToolErrorIndex { stage: u32 }),
+            (tool_cargotest, ToolCargoTest { stage: u32 }),
+
             // Steps for long-running native builds. Ideally these wouldn't
             // actually exist and would be part of build scripts, but for now
             // these are here.
@@ -53,11 +60,32 @@ macro_rules! targets {
             // with braces are unstable so we just pick something that works.
             (llvm, Llvm { _dummy: () }),
             (compiler_rt, CompilerRt { _dummy: () }),
+
+            // Steps for various pieces of documentation that we can generate,
+            // the 'doc' step is just a pseudo target to depend on a bunch of
+            // others.
             (doc, Doc { stage: u32 }),
             (doc_book, DocBook { stage: u32 }),
             (doc_nomicon, DocNomicon { stage: u32 }),
             (doc_style, DocStyle { stage: u32 }),
             (doc_standalone, DocStandalone { stage: u32 }),
+            (doc_std, DocStd { stage: u32 }),
+            (doc_test, DocTest { stage: u32 }),
+            (doc_rustc, DocRustc { stage: u32 }),
+            (doc_error_index, DocErrorIndex { stage: u32 }),
+
+            // Steps for running tests. The 'check' target is just a pseudo
+            // target to depend on a bunch of others.
+            (check, Check { stage: u32, compiler: Compiler<'a> }),
+            (check_linkcheck, CheckLinkcheck { stage: u32 }),
+            (check_cargotest, CheckCargoTest { stage: u32 }),
+
+            // Distribution targets, creating tarballs
+            (dist, Dist { stage: u32 }),
+            (dist_docs, DistDocs { stage: u32 }),
+            (dist_mingw, DistMingw { _dummy: () }),
+            (dist_rustc, DistRustc { stage: u32 }),
+            (dist_std, DistStd { compiler: Compiler<'a> }),
         }
     }
 }
@@ -127,10 +155,9 @@ fn top_level(build: &Build) -> Vec<Step> {
             }
             let host = t.target(host);
             if host.target == build.config.build {
-                targets.push(host.librustc(stage, host.compiler(stage)));
+                targets.push(host.librustc(host.compiler(stage)));
             } else {
-                targets.push(host.librustc_link(stage, t.compiler(stage),
-                                                host.target));
+                targets.push(host.librustc_link(t.compiler(stage), host.target));
             }
             for target in build.config.target.iter() {
                 if !build.flags.target.contains(target) {
@@ -139,11 +166,10 @@ fn top_level(build: &Build) -> Vec<Step> {
 
                 if host.target == build.config.build {
                     targets.push(host.target(target)
-                                     .libstd(stage, host.compiler(stage)));
+                                     .libtest(host.compiler(stage)));
                 } else {
                     targets.push(host.target(target)
-                                     .libstd_link(stage, t.compiler(stage),
-                                                  host.target));
+                                     .libtest_link(t.compiler(stage), host.target));
                 }
             }
         }
@@ -158,25 +184,37 @@ fn add_steps<'a>(build: &'a Build,
                  host: &Step<'a>,
                  target: &Step<'a>,
                  targets: &mut Vec<Step<'a>>) {
+    struct Context<'a> {
+        stage: u32,
+        compiler: Compiler<'a>,
+        _dummy: (),
+        host: &'a str,
+    }
     for step in build.flags.step.iter() {
-        let compiler = host.target(&build.config.build).compiler(stage);
-        match &step[..] {
-            "libstd" => targets.push(target.libstd(stage, compiler)),
-            "librustc" => targets.push(target.librustc(stage, compiler)),
-            "libstd-link" => targets.push(target.libstd_link(stage, compiler,
-                                                             host.target)),
-            "librustc-link" => targets.push(target.librustc_link(stage, compiler,
-                                                                 host.target)),
-            "rustc" => targets.push(host.rustc(stage)),
-            "llvm" => targets.push(target.llvm(())),
-            "compiler-rt" => targets.push(target.compiler_rt(())),
-            "doc-style" => targets.push(host.doc_style(stage)),
-            "doc-standalone" => targets.push(host.doc_standalone(stage)),
-            "doc-nomicon" => targets.push(host.doc_nomicon(stage)),
-            "doc-book" => targets.push(host.doc_book(stage)),
-            "doc" => targets.push(host.doc(stage)),
-            _ => panic!("unknown build target: `{}`", step),
+
+        // The macro below insists on hygienic access to all local variables, so
+        // we shove them all in a struct and subvert hygiene by accessing struct
+        // fields instead,
+        let cx = Context {
+            stage: stage,
+            compiler: host.target(&build.config.build).compiler(stage),
+            _dummy: (),
+            host: host.target,
+        };
+        macro_rules! add_step {
+            ($(($short:ident, $name:ident { $($arg:ident: $t:ty),* }),)*) => ({$(
+                let name = stringify!($short).replace("_", "-");
+                if &step[..] == &name[..] {
+                    targets.push(target.$short($(cx.$arg),*));
+                    continue
+                }
+                drop(name);
+            )*})
         }
+
+        targets!(add_step);
+
+        panic!("unknown step: {}", step);
     }
 }
 
@@ -209,36 +247,114 @@ impl<'a> Step<'a> {
             }
             Source::Rustc { stage } => {
                 let compiler = Compiler::new(stage - 1, &build.config.build);
-                vec![self.librustc(stage - 1, compiler)]
+                vec![self.librustc(compiler)]
             }
-            Source::Librustc { stage, compiler } => {
-                vec![self.libstd(stage, compiler), self.llvm(())]
+            Source::Librustc { compiler } => {
+                vec![self.libtest(compiler), self.llvm(())]
             }
-            Source::Libstd { stage: _, compiler } => {
+            Source::Libtest { compiler } => {
+                vec![self.libstd(compiler)]
+            }
+            Source::Libstd { compiler } => {
                 vec![self.compiler_rt(()),
                      self.rustc(compiler.stage).target(compiler.host)]
             }
-            Source::LibrustcLink { stage, compiler, host } => {
-                vec![self.librustc(stage, compiler),
-                     self.libstd_link(stage, compiler, host)]
+            Source::LibrustcLink { compiler, host } => {
+                vec![self.librustc(compiler),
+                     self.libtest_link(compiler, host)]
+            }
+            Source::LibtestLink { compiler, host } => {
+                vec![self.libtest(compiler), self.libstd_link(compiler, host)]
             }
-            Source::LibstdLink { stage, compiler, host } => {
-                vec![self.libstd(stage, compiler),
-                     self.target(host).rustc(stage)]
+            Source::LibstdLink { compiler, host } => {
+                vec![self.libstd(compiler),
+                     self.target(host).rustc(compiler.stage)]
             }
             Source::CompilerRt { _dummy } => {
                 vec![self.llvm(()).target(&build.config.build)]
             }
             Source::Llvm { _dummy } => Vec::new(),
+
+            // Note that all doc targets depend on artifacts from the build
+            // architecture, not the target (which is where we're generating
+            // docs into).
+            Source::DocStd { stage } => {
+                let compiler = self.target(&build.config.build).compiler(stage);
+                vec![self.libstd(compiler)]
+            }
+            Source::DocTest { stage } => {
+                let compiler = self.target(&build.config.build).compiler(stage);
+                vec![self.libtest(compiler)]
+            }
             Source::DocBook { stage } |
             Source::DocNomicon { stage } |
-            Source::DocStyle { stage } |
+            Source::DocStyle { stage } => {
+                vec![self.target(&build.config.build).tool_rustbook(stage)]
+            }
+            Source::DocErrorIndex { stage } => {
+                vec![self.target(&build.config.build).tool_error_index(stage)]
+            }
             Source::DocStandalone { stage } => {
-                vec![self.rustc(stage)]
+                vec![self.target(&build.config.build).rustc(stage)]
+            }
+            Source::DocRustc { stage } => {
+                vec![self.doc_test(stage)]
             }
             Source::Doc { stage } => {
                 vec![self.doc_book(stage), self.doc_nomicon(stage),
-                     self.doc_style(stage), self.doc_standalone(stage)]
+                     self.doc_style(stage), self.doc_standalone(stage),
+                     self.doc_std(stage),
+                     self.doc_error_index(stage)]
+            }
+            Source::Check { stage, compiler: _ } => {
+                vec![self.check_linkcheck(stage),
+                     self.dist(stage)]
+            }
+            Source::CheckLinkcheck { stage } => {
+                vec![self.tool_linkchecker(stage), self.doc(stage)]
+            }
+            Source::CheckCargoTest { stage } => {
+                vec![self.tool_cargotest(stage)]
+            }
+
+            Source::ToolLinkchecker { stage } => {
+                vec![self.libstd(self.compiler(stage))]
+            }
+            Source::ToolErrorIndex { stage } |
+            Source::ToolRustbook { stage } => {
+                vec![self.librustc(self.compiler(stage))]
+            }
+            Source::ToolCargoTest { stage } => {
+                vec![self.librustc(self.compiler(stage))]
+            }
+
+            Source::DistDocs { stage } => vec![self.doc(stage)],
+            Source::DistMingw { _dummy: _ } => Vec::new(),
+            Source::DistRustc { stage } => {
+                vec![self.rustc(stage)]
+            }
+            Source::DistStd { compiler } => {
+                vec![self.libtest(compiler)]
+            }
+
+            Source::Dist { stage } => {
+                let mut base = Vec::new();
+
+                for host in build.config.host.iter() {
+                    let host = self.target(host);
+                    base.push(host.dist_rustc(stage));
+                    if host.target.contains("windows-gnu") {
+                        base.push(host.dist_mingw(()));
+                    }
+
+                    let compiler = self.compiler(stage);
+                    for target in build.config.target.iter() {
+                        let target = self.target(target);
+                        base.push(target.dist_docs(stage));
+                        base.push(target.dist_std(compiler));
+                    }
+                }
+                return base
             }
         }
     }