]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/bin/main.rs
clarify that `changelog-seen = 1` goes to the beginning of config.toml
[rust.git] / src / bootstrap / bin / main.rs
1 //! rustbuild, the Rust build system
2 //!
3 //! This is the entry point for the build system used to compile the `rustc`
4 //! compiler. Lots of documentation can be found in the `README.md` file in the
5 //! parent directory, and otherwise documentation can be found throughout the `build`
6 //! directory in each respective module.
7
8 use std::env;
9
10 use bootstrap::{Build, Config};
11
12 fn main() {
13     let args = env::args().skip(1).collect::<Vec<_>>();
14     let config = Config::parse(&args);
15
16     let changelog_suggestion = check_version(&config);
17     if let Some(suggestion) = &changelog_suggestion {
18         println!("{}", suggestion);
19     }
20
21     Build::new(config).build();
22
23     if let Some(suggestion) = changelog_suggestion {
24         println!("{}", suggestion);
25         println!("note: this message was printed twice to make it more likely to be seen");
26     }
27 }
28
29 fn check_version(config: &Config) -> Option<String> {
30     const VERSION: usize = 1;
31
32     let mut msg = String::new();
33
34     let suggestion = if let Some(seen) = config.changelog_seen {
35         if seen != VERSION {
36             msg.push_str("warning: there have been changes to x.py since you last updated.\n");
37             format!("update `config.toml` to use `changelog-seen = {}` instead", VERSION)
38         } else {
39             return None;
40         }
41     } else {
42         msg.push_str("warning: x.py has made several changes recently you may want to look at\n");
43         format!("add `changelog-seen = {}` at the top of `config.toml`", VERSION)
44     };
45
46     msg.push_str("help: consider looking at the changes in `src/bootstrap/CHANGELOG.md`\n");
47     msg.push_str("note: to silence this warning, ");
48     msg.push_str(&suggestion);
49
50     Some(msg)
51 }