Skip to content

Commit fb42a45

Browse files
authored
Rollup merge of #131647 - jieyouxu:unicode-table-generator, r=Mark-Simulacrum
Register `src/tools/unicode-table-generator` as a runnable tool It seems like `src/tools/unicode-table-generator` is not currently managed by bootstrap. This PR wires it up with bootstrap as a runnable tool. This tool seems to take two possible args: 1. (Mandatory) path to `library/core/src/unicode/unicode_data.rs`, and 2. (Optional) path to generate a test file. I only passed the mandatory path to `unicode_data.rs` in bootstrap and didn't do anything about (2). I'm not sure about how this tool is supposed to be run. `Cargo.lock` is modified because I renamed `unicode-table-generator`'s bin name to match the tool name, as bootstrap's tool running logic expects the bin name to be derived from the tool name. I also added a triagebot message to remind to not manually edit the library source file and edit the tool then regenerate instead, but this should probably be a tidy check (if that's desirable then that can be in a follow-up PR, though may be overkill). Helps with #131640 but does not close it because still no docs. r? `@Mark-Simulacrum` (since I think you authored this tool?)
2 parents 17ac4c8 + be89da5 commit fb42a45

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -5570,13 +5570,6 @@ dependencies = [
55705570
"version_check",
55715571
]
55725572

5573-
[[package]]
5574-
name = "unicode-bdd"
5575-
version = "0.1.0"
5576-
dependencies = [
5577-
"ucd-parse",
5578-
]
5579-
55805573
[[package]]
55815574
name = "unicode-bidi"
55825575
version = "0.3.15"
@@ -5626,6 +5619,13 @@ version = "1.12.0"
56265619
source = "registry+https://github.com/rust-lang/crates.io-index"
56275620
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
56285621

5622+
[[package]]
5623+
name = "unicode-table-generator"
5624+
version = "0.1.0"
5625+
dependencies = [
5626+
"ucd-parse",
5627+
]
5628+
56295629
[[package]]
56305630
name = "unicode-width"
56315631
version = "0.1.14"

src/bootstrap/src/core/build_steps/run.rs

+22
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,25 @@ impl Step for GenerateCompletions {
283283
run.builder.ensure(GenerateCompletions);
284284
}
285285
}
286+
287+
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
288+
pub struct UnicodeTableGenerator;
289+
290+
impl Step for UnicodeTableGenerator {
291+
type Output = ();
292+
const ONLY_HOSTS: bool = true;
293+
294+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
295+
run.path("src/tools/unicode-table-generator")
296+
}
297+
298+
fn make_run(run: RunConfig<'_>) {
299+
run.builder.ensure(UnicodeTableGenerator);
300+
}
301+
302+
fn run(self, builder: &Builder<'_>) {
303+
let mut cmd = builder.tool_cmd(Tool::UnicodeTableGenerator);
304+
cmd.arg(builder.src.join("library/core/src/unicode/unicode_data.rs"));
305+
cmd.run(builder);
306+
}
307+
}

src/bootstrap/src/core/build_steps/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ bootstrap_tool!(
360360
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
361361
RustcPerfWrapper, "src/tools/rustc-perf-wrapper", "rustc-perf-wrapper";
362362
WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization";
363+
UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator";
363364
);
364365

365366
/// These are the submodules that are required for rustbook to work due to

src/bootstrap/src/core/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ impl<'a> Builder<'a> {
10101010
run::GenerateCopyright,
10111011
run::GenerateWindowsSys,
10121012
run::GenerateCompletions,
1013+
run::UnicodeTableGenerator,
10131014
),
10141015
Kind::Setup => {
10151016
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)

src/tools/unicode-table-generator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "unicode-bdd"
2+
name = "unicode-table-generator"
33
version = "0.1.0"
44
edition = "2021"
55

src/tools/unicode-table-generator/src/range_search.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ const fn bitset_search<
1616
let bucket_idx = (needle / 64) as usize;
1717
let chunk_map_idx = bucket_idx / CHUNK_SIZE;
1818
let chunk_piece = bucket_idx % CHUNK_SIZE;
19-
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
20-
// feature stabilizes.
19+
// FIXME(const-hack): Revert to `slice::get` when slice indexing becomes possible in const.
2120
let chunk_idx = if chunk_map_idx < chunk_idx_map.len() {
2221
chunk_idx_map[chunk_map_idx]
2322
} else {
2423
return false;
2524
};
2625
let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize;
27-
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
28-
// feature stabilizes.
26+
// FIXME(const-hack): Revert to `slice::get` when slice indexing becomes possible in const.
2927
let word = if idx < bitset_canonical.len() {
3028
bitset_canonical[idx]
3129
} else {

triagebot.toml

+9
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,15 @@ instead.
679679
"""
680680
cc = ["@calebzulawski", "@programmerjake"]
681681

682+
[mentions."library/core/src/unicode/unicode_data.rs"]
683+
message = """
684+
`library/core/src/unicode/unicode_data.rs` is generated by
685+
`src/tools/unicode-table-generator` via `./x run
686+
src/tools/unicode-table-generator`. If you want to modify `unicode_data.rs`,
687+
please modify the tool then regenerate the library source file with the tool
688+
instead of editing the library source file manually.
689+
"""
690+
682691
[mentions."src/librustdoc/clean/types.rs"]
683692
cc = ["@camelid"]
684693

0 commit comments

Comments
 (0)