-
Notifications
You must be signed in to change notification settings - Fork 196
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
sys/task-names/build.rs
Outdated
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(); |
There was a problem hiding this comment.
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. 🤷♀️
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
829d54c
to
8f52d8e
Compare
sys/task-names/src/lib.rs
Outdated
//! | ||
//! `TASK_NAMES` is a `static` array of `&str`. | ||
//! | ||
//! `MASK_TASK_NAME` is a `const` `usize` giving the number of bytes in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
//! `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 |
There was a problem hiding this comment.
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.
8f52d8e
to
53d5022
Compare
This allows tasks to refer to other tasks by name, which we need very rarely, but has come up for fault reporting.