Skip to content

Commit cbc5e4d

Browse files
committed
Auto merge of #76626 - jyn514:x.py-changelog, r=Mark-Simulacrum
Add a changelog for x.py and nag contributors until they read it Add a changelog for x.py - Add a changelog and instructions for updating it - Use `changelog-seen` in `config.toml` and `VERSION` in bootstrap to determine whether the changelog has been read. There's no way to tie reading the changelog to updating the version, so unfortunately they still have to update `config.toml` manually. Actually reading the changelog is optional, anyone can set `changelog-seen = N` without reading (although it's not recommended). - Nag people if they haven't read the x.py changelog + Print message twice to make sure it's seen - Give different error messages depending on whether the version needs to be updated or added Closes #76617 r? `@Mark-Simulacrum`
2 parents c113030 + fe6fc55 commit cbc5e4d

File tree

5 files changed

+96
-1
lines changed

5 files changed

+96
-1
lines changed

config.toml.example

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
# a custom configuration file can also be specified with `--config` to the build
1010
# system.
1111

12+
# Keeps track of the last version of `x.py` used.
13+
# If it does not match the version that is currently running,
14+
# `x.py` will prompt you to update it and read the changelog.
15+
# See `src/bootstrap/CHANGELOG.md` for more information.
16+
changelog-seen = 1
17+
1218
# =============================================================================
1319
# Global Settings
1420
# =============================================================================

src/bootstrap/CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to bootstrap will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6+
7+
## [Non-breaking changes since the last major version]
8+
9+
- Add a changelog for x.py [#76626](https://github.com/rust-lang/rust/pull/76626)
10+
- Optionally, download LLVM from CI on Linux and NixOS
11+
+ [#76439](https://github.com/rust-lang/rust/pull/76349)
12+
+ [#76667](https://github.com/rust-lang/rust/pull/76667)
13+
+ [#76708](https://github.com/rust-lang/rust/pull/76708)
14+
- Distribute rustc sources as part of `rustc-dev` [#76856](https://github.com/rust-lang/rust/pull/76856)
15+
- Make the default stage for x.py configurable [#76625](https://github.com/rust-lang/rust/pull/76625)
16+
- Add a dedicated debug-logging option [#76588](https://github.com/rust-lang/rust/pull/76588)
17+
- Add sample defaults for x.py [#76628](https://github.com/rust-lang/rust/pull/76628)
18+
19+
## [Version 0] - 2020-09-11
20+
21+
This is the first changelog entry, and it does not attempt to be an exhaustive list of features in x.py.
22+
Instead, this documents the changes to bootstrap in the past 2 months.
23+
24+
- Improve defaults in `x.py` [#73964](https://github.com/rust-lang/rust/pull/73964)
25+
(see [blog post] for details)
26+
- Set `ninja = true` by default [#74922](https://github.com/rust-lang/rust/pull/74922)
27+
- Avoid trying to inversely cross-compile for build triple from host triples [#76415](https://github.com/rust-lang/rust/pull/76415)
28+
- Allow blessing expect-tests in tools [#75975](https://github.com/rust-lang/rust/pull/75975)
29+
- `x.py check` checks tests/examples/benches [#76258](https://github.com/rust-lang/rust/pull/76258)
30+
- Fix `rust.use-lld` when linker is not set [#76326](https://github.com/rust-lang/rust/pull/76326)
31+
- Build tests with LLD if `use-lld = true` was passed [#76378](https://github.com/rust-lang/rust/pull/76378)
32+
33+
[blog post]: https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html

src/bootstrap/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,20 @@ are:
313313
`Config` struct.
314314
* Adding a sanity check? Take a look at `bootstrap/sanity.rs`.
315315

316+
If you make a major change, please remember to:
317+
318+
+ Update `VERSION` in `src/bootstrap/main.rs`.
319+
* Update `changelog-seen = N` in `config.toml.example`.
320+
* Add an entry in `src/bootstrap/CHANGELOG.md`.
321+
322+
A 'major change' includes
323+
324+
* A new option or
325+
* A change in the default options.
326+
327+
Changes that do not affect contributors to the compiler or users
328+
building rustc from source don't need an update to `VERSION`.
329+
316330
If you have any questions feel free to reach out on the `#t-infra` channel in
317331
the [Rust Zulip server][rust-zulip] or ask on internals.rust-lang.org. When
318332
you encounter bugs, please file issues on the rust-lang/rust issue tracker.

src/bootstrap/bin/main.rs

+35
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,40 @@ use bootstrap::{Build, Config};
1212
fn main() {
1313
let args = env::args().skip(1).collect::<Vec<_>>();
1414
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+
1521
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 = {}` to `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)
1651
}

src/bootstrap/config.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ macro_rules! check_ci_llvm {
4242
/// `config.toml.example`.
4343
#[derive(Default)]
4444
pub struct Config {
45+
pub changelog_seen: Option<usize>,
4546
pub ccache: Option<String>,
4647
/// Call Build::ninja() instead of this.
4748
pub ninja_in_file: bool,
@@ -273,6 +274,7 @@ impl Target {
273274
#[derive(Deserialize, Default)]
274275
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
275276
struct TomlConfig {
277+
changelog_seen: Option<usize>,
276278
build: Option<Build>,
277279
install: Option<Install>,
278280
llvm: Option<Llvm>,
@@ -283,7 +285,10 @@ struct TomlConfig {
283285
}
284286

285287
impl Merge for TomlConfig {
286-
fn merge(&mut self, TomlConfig { build, install, llvm, rust, dist, target, profile: _ }: Self) {
288+
fn merge(
289+
&mut self,
290+
TomlConfig { build, install, llvm, rust, dist, target, profile: _, changelog_seen: _ }: Self,
291+
) {
287292
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>) {
288293
if let Some(new) = y {
289294
if let Some(original) = x {
@@ -572,6 +577,8 @@ impl Config {
572577
toml.merge(included_toml);
573578
}
574579

580+
config.changelog_seen = toml.changelog_seen;
581+
575582
let build = toml.build.unwrap_or_default();
576583

577584
// If --target was specified but --host wasn't specified, don't run any host-only tests.

0 commit comments

Comments
 (0)