1 //! rustbuild, the Rust build system
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.
10 use bootstrap::{Build, Config, Subcommand};
13 let args = env::args().skip(1).collect::<Vec<_>>();
14 let config = Config::parse(&args);
16 let changelog_suggestion = check_version(&config);
18 // NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
19 // changelog warning, not the `x.py setup` message.
20 let suggest_setup = !config.config.exists() && !matches!(config.cmd, Subcommand::Setup { .. });
22 println!("warning: you have not made a `config.toml`");
23 println!("help: consider running `x.py setup` or copying `config.toml.example`");
24 } else if let Some(suggestion) = &changelog_suggestion {
25 println!("{}", suggestion);
28 Build::new(config).build();
31 println!("warning: you have not made a `config.toml`");
32 println!("help: consider running `x.py setup` or copying `config.toml.example`");
33 } else if let Some(suggestion) = &changelog_suggestion {
34 println!("{}", suggestion);
37 if suggest_setup || changelog_suggestion.is_some() {
38 println!("note: this message was printed twice to make it more likely to be seen");
42 fn check_version(config: &Config) -> Option<String> {
43 const VERSION: usize = 1;
45 let mut msg = String::new();
47 let suggestion = if let Some(seen) = config.changelog_seen {
49 msg.push_str("warning: there have been changes to x.py since you last updated.\n");
50 format!("update `config.toml` to use `changelog-seen = {}` instead", VERSION)
55 msg.push_str("warning: x.py has made several changes recently you may want to look at\n");
56 format!("add `changelog-seen = {}` to `config.toml`", VERSION)
59 msg.push_str("help: consider looking at the changes in `src/bootstrap/CHANGELOG.md`\n");
60 msg.push_str("note: to silence this warning, ");
61 msg.push_str(&suggestion);