]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Add cli option --keep-stage
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Mon, 12 Dec 2016 22:21:42 +0000 (23:21 +0100)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Mon, 12 Dec 2016 23:05:12 +0000 (00:05 +0100)
This option is intended to be used like:

./x.py build --stage 1 --keep-stage 0

Which skips all stage 0 steps, so that stage 1 can be recompiled
directly (even if for example libcore has changes).

This is useful when working on `cfg(not(stage0))` parts of the
libraries, or when re-running stage 1 tests in libraries in general.

src/bootstrap/flags.rs
src/bootstrap/step.rs

index 7a2d56fc5d3cc87dbea07c046e2fffba709b6261..e57ff30483329445d3a0ff79869e650bdfbaf636 100644 (file)
@@ -29,6 +29,7 @@
 pub struct Flags {
     pub verbose: bool,
     pub stage: Option<u32>,
+    pub keep_stage: Option<u32>,
     pub build: String,
     pub host: Vec<String>,
     pub target: Vec<String>,
@@ -68,6 +69,7 @@ pub fn parse(args: &[String]) -> Flags {
         opts.optmulti("", "host", "host targets to build", "HOST");
         opts.optmulti("", "target", "target targets to build", "TARGET");
         opts.optopt("", "stage", "stage to build", "N");
+        opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
         opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
         opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
         opts.optflag("h", "help", "print this help message");
@@ -258,6 +260,7 @@ pub fn parse(args: &[String]) -> Flags {
         Flags {
             verbose: m.opt_present("v"),
             stage: m.opt_str("stage").map(|j| j.parse().unwrap()),
+            keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()),
             build: m.opt_str("build").unwrap_or_else(|| {
                 env::var("BUILD").unwrap()
             }),
index 884cc7da8eaf8f6f39492a313540602263bdc205..d001b95cd6a553d02722a706d36665c2e441778e 100644 (file)
@@ -871,6 +871,10 @@ fn run(&self, steps: &[Step<'a>]) {
 
         // And finally, iterate over everything and execute it.
         for step in order.iter() {
+            if self.build.flags.keep_stage.map_or(false, |s| step.stage <= s) {
+                self.build.verbose(&format!("keeping step {:?}", step));
+                continue;
+            }
             self.build.verbose(&format!("executing step {:?}", step));
             (self.rules[step.name].run)(step);
         }