Skip to content

fix: avoid full rebuild by writing BuildVer.h only when content changes#1164

Open
MrTheShy wants to merge 2 commits intosmartcmd:mainfrom
MrTheShy:reduce-compile-time
Open

fix: avoid full rebuild by writing BuildVer.h only when content changes#1164
MrTheShy wants to merge 2 commits intosmartcmd:mainfrom
MrTheShy:reduce-compile-time

Conversation

@MrTheShy
Copy link
Contributor

@MrTheShy MrTheShy commented Mar 11, 2026

Description

Fix incremental builds being ignored — every build was triggering a full recompilation due to prebuild.ps1 unconditionally touching BuildVer.h.

Changes

Previous Behavior

Every build performed a full recompilation of all translation units, regardless of whether any source files had actually changed.

Root Cause

prebuild.ps1 used Set-Content to overwrite BuildVer.h on every build, updating its file timestamp even when the content was completely identical. Since BuildVer.h is included across many source files, MSBuild considered all of them out of date and recompiled everything from scratch.

New Behavior

Incremental builds work correctly. BuildVer.h is only written to disk if its content has actually changed (i.e. a new commit was made, the branch changed, or uncommitted changes appeared/disappeared). Unchanged builds skip the write entirely and leave the file timestamp untouched.

Fix Implementation

In prebuild.ps1, replaced the unconditional Set-Content call with a comparison between the newly generated content and the existing file content. The file is only written if the two differ.

AI Use Disclosure

No AI was used to write the code in this PR. The PR Message was done by ai

Previously, prebuild.ps1 unconditionally overwrote BuildVer.h on every
build using Set-Content, updating its timestamp even when the content
was identical. This caused MSBuild to treat all files depending on
BuildVer.h as out of date, triggering a full rebuild every time.

Fix: compare the new content with the existing file before writing.
BuildVer.h is now only written if sha, branch, or dev suffix has
actually changed.

Also removed the `git restore` call from postbuild.ps1 as it is no
longer needed.
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.

1 participant