Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register src/tools/unicode-table-generator as a runnable tool #131647

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5584,13 +5584,6 @@ dependencies = [
"version_check",
]

[[package]]
name = "unicode-bdd"
version = "0.1.0"
dependencies = [
"ucd-parse",
]

[[package]]
name = "unicode-bidi"
version = "0.3.15"
Expand Down Expand Up @@ -5640,6 +5633,13 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"

[[package]]
name = "unicode-table-generator"
version = "0.1.0"
dependencies = [
"ucd-parse",
]

[[package]]
name = "unicode-width"
version = "0.1.14"
Expand Down
22 changes: 22 additions & 0 deletions src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,25 @@ impl Step for GenerateCompletions {
run.builder.ensure(GenerateCompletions);
}
}

#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
pub struct UnicodeTableGenerator;

impl Step for UnicodeTableGenerator {
type Output = ();
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/unicode-table-generator")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(UnicodeTableGenerator);
}

fn run(self, builder: &Builder<'_>) {
let mut cmd = builder.tool_cmd(Tool::UnicodeTableGenerator);
cmd.arg(builder.src.join("library/core/src/unicode/unicode_data.rs"));
cmd.run(builder);
}
}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ bootstrap_tool!(
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
RustcPerfWrapper, "src/tools/rustc-perf-wrapper", "rustc-perf-wrapper";
WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization";
UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator";
);

/// These are the submodules that are required for rustbook to work due to
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ impl<'a> Builder<'a> {
run::GenerateCopyright,
run::GenerateWindowsSys,
run::GenerateCompletions,
run::UnicodeTableGenerator,
),
Kind::Setup => {
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/unicode-table-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "unicode-bdd"
name = "unicode-table-generator"
version = "0.1.0"
edition = "2021"

Expand Down
6 changes: 2 additions & 4 deletions src/tools/unicode-table-generator/src/range_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ const fn bitset_search<
let bucket_idx = (needle / 64) as usize;
let chunk_map_idx = bucket_idx / CHUNK_SIZE;
let chunk_piece = bucket_idx % CHUNK_SIZE;
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
// feature stabilizes.
// FIXME(const-hack): Revert to `slice::get` when slice indexing becomes possible in const.
let chunk_idx = if chunk_map_idx < chunk_idx_map.len() {
chunk_idx_map[chunk_map_idx]
} else {
return false;
};
let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize;
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
// feature stabilizes.
// FIXME(const-hack): Revert to `slice::get` when slice indexing becomes possible in const.
let word = if idx < bitset_canonical.len() {
bitset_canonical[idx]
} else {
Expand Down
9 changes: 9 additions & 0 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,15 @@ instead.
"""
cc = ["@calebzulawski", "@programmerjake"]

[mentions."library/core/src/unicode/unicode_data.rs"]
message = """
`library/core/src/unicode/unicode_data.rs` is generated by
`src/tools/unicode-table-generator` via `./x run
src/tools/unicode-table-generator`. If you want to modify `unicode_data.rs`,
please modify the tool then regenerate the library source file with the tool
instead of editing the library source file manually.
"""

[mentions."src/librustdoc/clean/types.rs"]
cc = ["@camelid"]

Expand Down
Loading