Add command to show firmware Git hash #167

Open
atse wants to merge 2 commits from atse/thermostat:show-firmware-ver into master
Contributor

Also shows repo dirty status. Makes debugging firmware easier.

Also shows repo dirty status. Makes debugging firmware easier.
atse added 1 commit 2025-02-03 12:28:22 +08:00
atse added 1 commit 2025-02-03 12:32:38 +08:00
esavkin reviewed 2025-02-03 17:06:06 +08:00
@ -0,0 +13,4 @@
impl FirmwareSummary {
pub const fn get() -> FirmwareSummary {
if let Some(rev) = option_env!("NIX_DRV_DIRTY_REV") {
Owner

Is there environment variables in the firmware?
And I think it's better to use some different variable/approach, because now it depends on Nix, which may be absent during build process. Consider using git directly or invert the dependency, or combine both - let Nix insert the revision and if absent, default to git info.

~~Is there environment variables in the firmware?~~ And I think it's better to use some different variable/approach, because now it depends on Nix, which may be absent during build process. Consider using git directly or invert the dependency, or combine both - let Nix insert the revision and if absent, default to git info.
Owner

Agree. You can add logic to fetch the git info if the NIX_DRV_DIRTY_REV environment variable is not set.
(as nix does not copy the .git folder, you cannot call git cmd in build.rs during nix build stage.)

Agree. You can add logic to fetch the git info if the NIX_DRV_DIRTY_REV environment variable is not set. (as nix does not copy the .git folder, you cannot call git cmd in build.rs during nix build stage.)
sb10q reviewed 2025-02-05 18:04:05 +08:00
@ -0,0 +27,4 @@
} else {
FirmwareSummary {
git_hash: Some(rev),
git_dirty: Some(false),
Owner

Do we really need to parse this here? Why not just send the string verbatim? What is consuming that string?

Do we really need to parse this here? Why not just send the string verbatim? What is consuming that string?
sb10q reviewed 2025-02-05 18:04:18 +08:00
@ -16,2 +16,4 @@
// instead of when any part of the source code changes.
println!("cargo:rerun-if-changed=memory.x");
built::write_built_file().expect("Failed to acquire build-time information");
Owner

Maybe this shouldn't be a hard error?

Maybe this shouldn't be a hard error?
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u show-firmware-ver:atse-show-firmware-ver
git checkout atse-show-firmware-ver
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/thermostat#167
No description provided.