Skip to content

Commit a7dcb98

Browse files
committed
move CONFIG_CHANGE_HISTORY to its own module
Because bootstrap lib is already large and complicated, this should make the "bumping change-id" process easier. Signed-off-by: onur-ozkan <[email protected]>
1 parent 63a4410 commit a7dcb98

File tree

6 files changed

+113
-94
lines changed

6 files changed

+113
-94
lines changed

src/bootstrap/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Some general areas that you may be interested in modifying are:
183183

184184
If you make a major change on bootstrap configuration, please remember to:
185185

186-
+ Update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/lib.rs`.
186+
+ Update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs`.
187187
* Update `change-id = {pull-request-id}` in `config.example.toml`.
188188

189189
A 'major change' includes

src/bootstrap/src/core/build_steps/setup.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2+
use crate::t;
3+
use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY;
24
use crate::Config;
3-
use crate::{t, CONFIG_CHANGE_HISTORY};
45
use sha2::Digest;
56
use std::env::consts::EXE_SUFFIX;
67
use std::fmt::Write as _;

src/bootstrap/src/lib.rs

+4-89
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ use crate::utils::helpers::{self, dir_is_empty, exe, libdir, mtime, output, syml
4646
mod core;
4747
mod utils;
4848

49-
pub use crate::core::builder::PathSet;
50-
pub use crate::core::config::flags::Subcommand;
51-
pub use crate::core::config::Config;
49+
pub use core::builder::PathSet;
50+
pub use core::config::flags::Subcommand;
51+
pub use core::config::Config;
52+
pub use utils::change_tracker::{find_recent_config_change_ids, CONFIG_CHANGE_HISTORY};
5253

5354
const LLVM_TOOLS: &[&str] = &[
5455
"llvm-cov", // used to generate coverage report
@@ -69,67 +70,6 @@ const LLVM_TOOLS: &[&str] = &[
6970
/// LLD file names for all flavors.
7071
const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
7172

72-
#[derive(Clone, Debug)]
73-
pub struct ChangeInfo {
74-
/// Represents the ID of PR caused major change on bootstrap.
75-
pub change_id: usize,
76-
pub severity: ChangeSeverity,
77-
/// Provides a short summary of the change that will guide developers
78-
/// on "how to handle/behave" in response to the changes.
79-
pub summary: &'static str,
80-
}
81-
82-
#[derive(Clone, Debug)]
83-
pub enum ChangeSeverity {
84-
/// Used when build configurations continue working as before.
85-
Info,
86-
/// Used when the default value of an option changes, or support for an option is removed entirely,
87-
/// potentially requiring developers to update their build configurations.
88-
Warning,
89-
}
90-
91-
impl ToString for ChangeSeverity {
92-
fn to_string(&self) -> String {
93-
match self {
94-
ChangeSeverity::Info => "INFO".to_string(),
95-
ChangeSeverity::Warning => "WARNING".to_string(),
96-
}
97-
}
98-
}
99-
100-
/// Keeps track of major changes made to the bootstrap configuration.
101-
///
102-
/// If you make any major changes (such as adding new values or changing default values),
103-
/// please ensure adding `ChangeInfo` to the end(because the list must be sorted by the merge date)
104-
/// of this list.
105-
pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
106-
ChangeInfo {
107-
change_id: 115898,
108-
severity: ChangeSeverity::Info,
109-
summary: "Implementation of this change-tracking system. Ignore this.",
110-
},
111-
ChangeInfo {
112-
change_id: 116998,
113-
severity: ChangeSeverity::Info,
114-
summary: "Removed android-ndk r15 support in favor of android-ndk r25b.",
115-
},
116-
ChangeInfo {
117-
change_id: 117435,
118-
severity: ChangeSeverity::Info,
119-
summary: "New option `rust.parallel-compiler` added to config.toml.",
120-
},
121-
ChangeInfo {
122-
change_id: 116881,
123-
severity: ChangeSeverity::Warning,
124-
summary: "Default value of `download-ci-llvm` was changed for `codegen` profile.",
125-
},
126-
ChangeInfo {
127-
change_id: 117813,
128-
severity: ChangeSeverity::Info,
129-
summary: "Use of the `if-available` value for `download-ci-llvm` is deprecated; prefer using the new `if-unchanged` value.",
130-
},
131-
];
132-
13373
/// Extra --check-cfg to add when building
13474
/// (Mode restriction, config name, config values (if any))
13575
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
@@ -1898,28 +1838,3 @@ fn envify(s: &str) -> String {
18981838
.flat_map(|c| c.to_uppercase())
18991839
.collect()
19001840
}
1901-
1902-
pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
1903-
if !CONFIG_CHANGE_HISTORY.iter().any(|config| config.change_id == current_id) {
1904-
// If the current change-id is greater than the most recent one, return
1905-
// an empty list (it may be due to switching from a recent branch to an
1906-
// older one); otherwise, return the full list (assuming the user provided
1907-
// the incorrect change-id by accident).
1908-
if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
1909-
if &current_id > &config.change_id {
1910-
return Vec::new();
1911-
}
1912-
}
1913-
1914-
return CONFIG_CHANGE_HISTORY.to_vec();
1915-
}
1916-
1917-
let index =
1918-
CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id).unwrap();
1919-
1920-
CONFIG_CHANGE_HISTORY
1921-
.iter()
1922-
.skip(index + 1) // Skip the current_id and IDs before it
1923-
.cloned()
1924-
.collect()
1925-
}
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//! This module facilitates the tracking system for major changes made to the bootstrap,
2+
//! with the goal of keeping developers synchronized with important modifications in
3+
//! the bootstrap.
4+
5+
#[derive(Clone, Debug)]
6+
pub struct ChangeInfo {
7+
/// Represents the ID of PR caused major change on bootstrap.
8+
pub change_id: usize,
9+
pub severity: ChangeSeverity,
10+
/// Provides a short summary of the change that will guide developers
11+
/// on "how to handle/behave" in response to the changes.
12+
pub summary: &'static str,
13+
}
14+
15+
#[derive(Clone, Debug)]
16+
pub enum ChangeSeverity {
17+
/// Used when build configurations continue working as before.
18+
Info,
19+
/// Used when the default value of an option changes, or support for an option is removed entirely,
20+
/// potentially requiring developers to update their build configurations.
21+
Warning,
22+
}
23+
24+
impl ToString for ChangeSeverity {
25+
fn to_string(&self) -> String {
26+
match self {
27+
ChangeSeverity::Info => "INFO".to_string(),
28+
ChangeSeverity::Warning => "WARNING".to_string(),
29+
}
30+
}
31+
}
32+
33+
pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
34+
if !CONFIG_CHANGE_HISTORY.iter().any(|config| config.change_id == current_id) {
35+
// If the current change-id is greater than the most recent one, return
36+
// an empty list (it may be due to switching from a recent branch to an
37+
// older one); otherwise, return the full list (assuming the user provided
38+
// the incorrect change-id by accident).
39+
if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
40+
if &current_id > &config.change_id {
41+
return Vec::new();
42+
}
43+
}
44+
45+
return CONFIG_CHANGE_HISTORY.to_vec();
46+
}
47+
48+
let index =
49+
CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id).unwrap();
50+
51+
CONFIG_CHANGE_HISTORY
52+
.iter()
53+
.skip(index + 1) // Skip the current_id and IDs before it
54+
.cloned()
55+
.collect()
56+
}
57+
58+
/// Keeps track of major changes made to the bootstrap configuration.
59+
///
60+
/// If you make any major changes (such as adding new values or changing default values),
61+
/// please ensure adding `ChangeInfo` to the end(because the list must be sorted by the merge date)
62+
/// of this list.
63+
pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
64+
ChangeInfo {
65+
change_id: 115898,
66+
severity: ChangeSeverity::Info,
67+
summary: "Implementation of this change-tracking system. Ignore this.",
68+
},
69+
ChangeInfo {
70+
change_id: 116998,
71+
severity: ChangeSeverity::Info,
72+
summary: "Removed android-ndk r15 support in favor of android-ndk r25b.",
73+
},
74+
ChangeInfo {
75+
change_id: 117435,
76+
severity: ChangeSeverity::Info,
77+
summary: "New option `rust.parallel-compiler` added to config.toml.",
78+
},
79+
ChangeInfo {
80+
change_id: 116881,
81+
severity: ChangeSeverity::Warning,
82+
summary: "Default value of `download-ci-llvm` was changed for `codegen` profile.",
83+
},
84+
ChangeInfo {
85+
change_id: 117813,
86+
severity: ChangeSeverity::Info,
87+
summary: "Use of the `if-available` value for `download-ci-llvm` is deprecated; prefer using the new `if-unchanged` value.",
88+
},
89+
];

src/bootstrap/src/utils/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//! support for a wide range of tasks and operations such as caching, tarballs, release
33
//! channels, job management, etc.
44
5+
pub mod change_tracker;
6+
57
pub(crate) mod cache;
68
pub(crate) mod cc_detect;
79
pub(crate) mod channel;

triagebot.toml

+15-3
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,23 @@ message = "The list of allowed third-party dependencies may have been modified!
583583
cc = ["@davidtwco", "@wesleywiser"]
584584

585585
[mentions."src/bootstrap/src/core/config"]
586-
message = "This PR modifies `src/bootstrap/src/core/config`. If appropriate, please also update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/lib.rs` and `change-id` in `config.example.toml`."
586+
message = """
587+
This PR modifies `src/bootstrap/src/core/config`.
588+
589+
If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs` and `change-id` in `config.example.toml`.
590+
"""
587591
[mentions."src/bootstrap/defaults"]
588-
message = "This PR modifies `src/bootstrap/defaults`. If appropriate, please also update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/lib.rs` and `change-id` in `config.example.toml`."
592+
message = """
593+
This PR modifies `src/bootstrap/defaults`.
594+
595+
If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs` and `change-id` in `config.example.toml`.
596+
"""
589597
[mentions."config.example.toml"]
590-
message = "This PR changes `config.example.toml`. If appropriate, please also update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/lib.rs` and `change-id` in `config.example.toml`."
598+
message = """
599+
This PR modifies `config.example.toml`.
600+
601+
If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs` and `change-id` in `config.example.toml`.
602+
"""
591603

592604
[mentions."src/bootstrap/defaults/config.compiler.toml"]
593605
message = "This PR changes src/bootstrap/defaults/config.compiler.toml. If appropriate, please also update `config.codegen.toml` so the defaults are in sync."

0 commit comments

Comments
 (0)