Skip to content

Basic crate for accessing task names at build time. #2052

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cbiffle
Copy link
Collaborator

@cbiffle cbiffle commented Apr 29, 2025

This allows tasks to refer to other tasks by name, which we need very rarely, but has come up for fault reporting.

@cbiffle cbiffle requested a review from hawkw April 29, 2025 20:06
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real complaints except for the formatting stuff CI is bothered about!

Comment on lines 19 to 26
for name in &task_names {
writeln!(task_file, " {name:?},").unwrap();
}
writeln!(task_file, "];").unwrap();

let longest = task_names.iter().map(|s| s.len()).max()
.unwrap_or(0);
writeln!(task_file, "pub const MAX_TASK_NAME: usize = {longest};").unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I might suggest the use of quote! rather than manually writeln!ing Rust source strings in new code, but...this is so trivial I dunno if I care. 🤷‍♀️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the ideal lib.rs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk, it could have more comments.

@cbiffle cbiffle force-pushed the cbiffle/task-names branch from 829d54c to 8f52d8e Compare April 29, 2025 20:27
//!
//! `TASK_NAMES` is a `static` array of `&str`.
//!
//! `MASK_TASK_NAME` is a `const` `usize` giving the number of bytes in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

Suggested change
//! `MASK_TASK_NAME` is a `const` `usize` giving the number of bytes in the
//! `MAX_TASK_NAME` is a `const` `usize` giving the number of bytes in the

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This allows tasks to refer to other tasks by name, which we need _very
rarely,_ but has come up for fault reporting.
@cbiffle cbiffle force-pushed the cbiffle/task-names branch from 8f52d8e to 53d5022 Compare April 29, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants