Skip to content

Commit 576a17e

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 38aba2c commit 576a17e

File tree

6 files changed

+112
-94
lines changed

6 files changed

+112
-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
@@ -47,9 +47,10 @@ use crate::utils::helpers::{self, dir_is_empty, exe, libdir, mtime, output, syml
4747
mod core;
4848
mod utils;
4949

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

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

73-
#[derive(Clone, Debug)]
74-
pub struct ChangeInfo {
75-
/// Represents the ID of PR caused major change on bootstrap.
76-
pub change_id: usize,
77-
pub severity: ChangeSeverity,
78-
/// Provides a short summary of the change that will guide developers
79-
/// on "how to handle/behave" in response to the changes.
80-
pub summary: &'static str,
81-
}
82-
83-
#[derive(Clone, Debug)]
84-
pub enum ChangeSeverity {
85-
/// Used when build configurations continue working as before.
86-
Info,
87-
/// Used when the default value of an option changes, or support for an option is removed entirely,
88-
/// potentially requiring developers to update their build configurations.
89-
Warning,
90-
}
91-
92-
impl ToString for ChangeSeverity {
93-
fn to_string(&self) -> String {
94-
match self {
95-
ChangeSeverity::Info => "INFO".to_string(),
96-
ChangeSeverity::Warning => "WARNING".to_string(),
97-
}
98-
}
99-
}
100-
101-
/// Keeps track of major changes made to the bootstrap configuration.
102-
///
103-
/// If you make any major changes (such as adding new values or changing default values),
104-
/// please ensure adding `ChangeInfo` to the end(because the list must be sorted by the merge date)
105-
/// of this list.
106-
pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
107-
ChangeInfo {
108-
change_id: 115898,
109-
severity: ChangeSeverity::Info,
110-
summary: "Implementation of this change-tracking system. Ignore this.",
111-
},
112-
ChangeInfo {
113-
change_id: 116998,
114-
severity: ChangeSeverity::Info,
115-
summary: "Removed android-ndk r15 support in favor of android-ndk r25b.",
116-
},
117-
ChangeInfo {
118-
change_id: 117435,
119-
severity: ChangeSeverity::Info,
120-
summary: "New option `rust.parallel-compiler` added to config.toml.",
121-
},
122-
ChangeInfo {
123-
change_id: 116881,
124-
severity: ChangeSeverity::Warning,
125-
summary: "Default value of `download-ci-llvm` was changed for `codegen` profile.",
126-
},
127-
ChangeInfo {
128-
change_id: 117813,
129-
severity: ChangeSeverity::Info,
130-
summary: "Use of the `if-available` value for `download-ci-llvm` is deprecated; prefer using the new `if-unchanged` value.",
131-
},
132-
];
133-
13474
/// Extra --check-cfg to add when building
13575
/// (Mode restriction, config name, config values (if any))
13676
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
@@ -1900,31 +1840,6 @@ fn envify(s: &str) -> String {
19001840
.collect()
19011841
}
19021842

1903-
pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
1904-
if !CONFIG_CHANGE_HISTORY.iter().any(|config| config.change_id == current_id) {
1905-
// If the current change-id is greater than the most recent one, return
1906-
// an empty list (it may be due to switching from a recent branch to an
1907-
// older one); otherwise, return the full list (assuming the user provided
1908-
// the incorrect change-id by accident).
1909-
if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
1910-
if &current_id > &config.change_id {
1911-
return Vec::new();
1912-
}
1913-
}
1914-
1915-
return CONFIG_CHANGE_HISTORY.to_vec();
1916-
}
1917-
1918-
let index =
1919-
CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id).unwrap();
1920-
1921-
CONFIG_CHANGE_HISTORY
1922-
.iter()
1923-
.skip(index + 1) // Skip the current_id and IDs before it
1924-
.cloned()
1925-
.collect()
1926-
}
1927-
19281843
/// Computes a hash representing the state of a repository/submodule and additional input.
19291844
///
19301845
/// It uses `git diff` for the actual changes, and `git status` for including the untracked
+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

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
pub(crate) mod cache;
66
pub(crate) mod cc_detect;
7+
pub(crate) mod change_tracker;
78
pub(crate) mod channel;
89
pub(crate) mod dylib;
910
pub(crate) mod exec;

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)