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

Don't dirty shadow.rs unless contents have changed #203

Closed
wants to merge 1 commit into from

Conversation

vlovich
Copy link

@vlovich vlovich commented Jan 31, 2025

Stop spurious rebuilds for any project that uses shadow-rs - even if no source has changed, because the shadow.rs file is blindly clobbered on every build, cargo thinks something has changed due to the directive to rebuild if shadow.rs changes. Instead, check if any of the new contents are actually different, ignoring the "Generation time" header.

Stop spurious rebuilds for any project that uses shadow-rs - even if no
source has changed, because the shadow.rs file is blindly clobbered on
every build, cargo thinks something has changed due to the directive to
rebuild if shadow.rs changes. Instead, check if any of the new contents
are actually different, ignoring the "Generation time" header.
@vlovich
Copy link
Author

vlovich commented Jan 31, 2025

I think this approach may be flawed since variables changing that you expect to cause a rebuild (e.g. amending the git commit) don't.

@vlovich vlovich marked this pull request as draft January 31, 2025 09:11
@baoyachi baoyachi marked this pull request as ready for review February 2, 2025 00:44
@baoyachi
Copy link
Owner

@vlovich
The modification to this piece of code cannot address the issue of being indirectly depended on as a common-crates. The intention of the build_pattern I designed is that BuildPattern::RealTime should enforce real-time builds. If real-time building is not desired, it is recommended to use BuildPattern::Lazy mode.

@baoyachi baoyachi marked this pull request as draft February 11, 2025 06:37
@baoyachi
Copy link
Owner

@vlovich Thx contribution.

I'll close it, and if there are any issues, can reopen it.

@baoyachi baoyachi closed this Feb 12, 2025
@vlovich
Copy link
Author

vlovich commented Feb 18, 2025

FWIW I think this PR is actually correct & the only thing missing is a rerun-if-changed on .git/HEAD. That feels like a much better default than Lazy / Realtime - if anything causes the shadow.rs contents to change then it's rebuilt & any changes to the git history do the same. Otherwise, there's no rebuild. This is different from Lazy (which never rebuilds in debug) and Realtime (which always rebuilds) and would work sanely for both debug & release builds.

@vlovich
Copy link
Author

vlovich commented Feb 18, 2025

BTW this is similar to what https://crates.io/crates/vergen does.

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.

2 participants