Skip to content

build: force AIO rebuild on HEAD change or manual delete#2251

Merged
alandtse merged 1 commit into
community-shaders:devfrom
alandtse:fix/aio-deploy-staleness-clean
May 2, 2026
Merged

build: force AIO rebuild on HEAD change or manual delete#2251
alandtse merged 1 commit into
community-shaders:devfrom
alandtse:fix/aio-deploy-staleness-clean

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented May 1, 2026

Summary

  • When git HEAD changes (branch switch or new commit), wipe the entire AIO staging directory and clear all deploy/prepare stamps so cmake --build re-copies every file with a fresh timestamp
  • Adds an always-on configure-time guard: if AIO_DIR is missing (manual delete), clear prepare_aio.stamp and copy_shaders.stamp so PREPARE_AIO unconditionally reruns on the next build

Problem

copy_if_different skips content-identical files, leaving them with old timestamps. A manual package install gives deployed files a newer timestamp than those stale AIO files, causing robocopy /XO to silently skip them — deployed shaders stay wrong even after a full rebuild.

Test plan

  • Delete AIO directory manually, run BuildRelease.bat — AIO should be recreated and all files deployed
  • Switch branches, run BuildRelease.bat — AIO should be wiped and redeployed from scratch
  • Normal rebuild on same branch — incremental, only changed files deployed, in-game edits protected by /XO

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced build system cache invalidation to automatically clean up stale build artifacts and trigger fresh rebuilds when source code changes or deployment state becomes outdated, ensuring more reliable build processes.

When git HEAD changes (branch switch or new commit), wipe the entire
AIO directory and clear all deploy/prepare stamps so cmake --build
re-copies every file with a fresh timestamp. Without this,
copy_if_different leaves content-identical files with old timestamps
that a manual package install's newer timestamps beat under robocopy
/XO, silently preventing deployment.

Also add an always-on configure-time guard: if AIO_DIR is missing
(e.g. after a manual delete), clear prepare_aio.stamp and
copy_shaders.stamp so PREPARE_AIO unconditionally reruns on the
next cmake --build.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

CMakeLists.txt now includes proactive cache invalidation logic that removes stamp files when the AIO directory is missing or when the git HEAD changes, forcing re-execution of AIO preparation and shader copying build targets.

Changes

Cohort / File(s) Summary
Build Cache Invalidation
CMakeLists.txt
Added logic to invalidate cached incremental deployment state by detecting missing AIO directory or git HEAD changes, then clearing related stamp files and deployment inputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop, hop, the cache must be cleared,
When git commits appear,
Stamp files vanish in the night,
Builds run fresh and bright!
No stale artifacts we fear. 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'build: force AIO rebuild on HEAD change or manual delete' directly and accurately reflects the main changes: forcing AIO rebuild when git HEAD changes or the directory is manually deleted, which are the two core scenarios addressed in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
CMakeLists.txt (1)

613-619: ⚡ Quick win

Use ${GIT_EXECUTABLE} here instead of assuming git is on PATH.

This execute_process() bypasses the earlier find_package(Git) result. On setups where CMake resolved Git but the shell cannot invoke plain git, HEAD-change invalidation becomes a no-op.

Proposed fix
-    execute_process(
-        COMMAND git rev-parse --short HEAD
-        WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
-        OUTPUT_VARIABLE _git_head
-        ERROR_QUIET
-        OUTPUT_STRIP_TRAILING_WHITESPACE
-    )
+    set(_git_head "")
+    if(GIT_FOUND)
+        execute_process(
+            COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
+            WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+            OUTPUT_VARIABLE _git_head
+            ERROR_QUIET
+            OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
+    endif()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CMakeLists.txt` around lines 613 - 619, The execute_process call that runs
"git rev-parse --short HEAD" should use the Git executable discovered by
find_package(Git) instead of the literal "git"; update the COMMAND in the
execute_process invocation that sets OUTPUT_VARIABLE _git_head to use
${GIT_EXECUTABLE} so the logic respects the earlier find_package(Git) resolution
and avoids PATH-related failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CMakeLists.txt`:
- Around line 497-505: When clearing the AIO_DIR stamps, also restage the plugin
binary so PREPARE_AIO will include $<TARGET_FILE:${PROJECT_NAME}> and
$<TARGET_PDB_FILE:${PROJECT_NAME}>: alongside removing prepare_aio.stamp and
copy_shaders.stamp, delete or touch the stamp/outputs that track
${PROJECT_NAME}’s staging (so its POST_BUILD/copy step will re-run), or
explicitly remove the staged plugin files so PREPARE_AIO will re-copy them;
apply the same change for the duplicate block referenced around lines 639-648
(same PREPARE_AIO/copy_shaders handling).

---

Nitpick comments:
In `@CMakeLists.txt`:
- Around line 613-619: The execute_process call that runs "git rev-parse --short
HEAD" should use the Git executable discovered by find_package(Git) instead of
the literal "git"; update the COMMAND in the execute_process invocation that
sets OUTPUT_VARIABLE _git_head to use ${GIT_EXECUTABLE} so the logic respects
the earlier find_package(Git) resolution and avoids PATH-related failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 35acd99d-4e65-4ffb-8853-8f24c94f24d5

📥 Commits

Reviewing files that changed from the base of the PR and between 34ca30f and 2767a43.

📒 Files selected for processing (1)
  • CMakeLists.txt

Comment thread CMakeLists.txt
Comment on lines +497 to +505
# If AIO was manually (or programmatically) deleted, the stamp is stale —
# clear it so cmake --build re-runs PREPARE_AIO to recreate the directory.
if(NOT EXISTS "${AIO_DIR}")
file(
REMOVE
"${CMAKE_CURRENT_BINARY_DIR}/prepare_aio.stamp"
"${CMAKE_CURRENT_BINARY_DIR}/copy_shaders.stamp"
)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Restage the plugin binary when you invalidate ${AIO_DIR}.

Deleting ${AIO_DIR} and only clearing the stamp files reruns PREPARE_AIO, but that target does not copy $<TARGET_FILE:${PROJECT_NAME}> / $<TARGET_PDB_FILE:${PROJECT_NAME}> back into AIO. If ${PROJECT_NAME} is already up to date after a branch switch or manual delete, its POST_BUILD hook will not fire, so the recreated AIO folder/archive can be missing the plugin binary.

Proposed fix
     list(
         APPEND _prepare_aio_cmds
         COMMAND
         ${CMAKE_COMMAND}
         -E
         make_directory
         "${AIO_DIR}/SKSE/Plugins"
+        COMMAND
+        ${CMAKE_COMMAND}
+        -E
+        copy_if_different
+        "$<TARGET_FILE:${PROJECT_NAME}>"
+        "${AIO_DIR}/SKSE/Plugins/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
+        COMMAND
+        ${CMAKE_COMMAND}
+        -E
+        copy_if_different
+        "$<TARGET_PDB_FILE:${PROJECT_NAME}>"
+        "${AIO_DIR}/SKSE/Plugins/$<TARGET_PDB_FILE_NAME:${PROJECT_NAME}>"
     )

Also applies to: 639-648

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CMakeLists.txt` around lines 497 - 505, When clearing the AIO_DIR stamps,
also restage the plugin binary so PREPARE_AIO will include
$<TARGET_FILE:${PROJECT_NAME}> and $<TARGET_PDB_FILE:${PROJECT_NAME}>: alongside
removing prepare_aio.stamp and copy_shaders.stamp, delete or touch the
stamp/outputs that track ${PROJECT_NAME}’s staging (so its POST_BUILD/copy step
will re-run), or explicitly remove the staged plugin files so PREPARE_AIO will
re-copy them; apply the same change for the duplicate block referenced around
lines 639-648 (same PREPARE_AIO/copy_shaders handling).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit c7228bc into community-shaders:dev May 2, 2026
14 checks passed
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 15, 2026
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 16, 2026
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