Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,16 @@ if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST)
${CMAKE_SOURCE_DIR}/cmake/CleanupStaleEntries.cmake
)

# 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()
Comment on lines +497 to +505

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).


add_custom_target(
PREPARE_AIO
ALL
Expand Down Expand Up @@ -592,6 +602,58 @@ endif()

# Automatic deployment to CommunityShaders output directory.
if(AUTO_PLUGIN_DEPLOYMENT)
# Detect git HEAD changes (branch switch or new commit) and invalidate stale
# deploy state. BuildRelease.bat always reconfigures, so this runs on every
# build invocation. When HEAD changes we:
# 1. Touch all AIO files so robocopy /XO sees them as newer than any
# previously-deployed files (including manual package installs).
# 2. Delete deploy stamps so CMake re-runs the robocopy commands.
# Files the user intentionally edited in-game remain protected by /XO on
# subsequent builds (same HEAD = no touch, same stamp file exists).
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE _git_head
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(_git_head)
set(_git_head_stamp "${CMAKE_BINARY_DIR}/git-head.stamp")
set(_prev_git_head "")
if(EXISTS "${_git_head_stamp}")
file(READ "${_git_head_stamp}" _prev_git_head)
string(STRIP "${_prev_git_head}" _prev_git_head)
endif()
if(NOT "${_git_head}" STREQUAL "${_prev_git_head}")
message(
STATUS
"Git HEAD changed (${_prev_git_head} -> ${_git_head}): clearing AIO shaders and deploy stamps for full redeploy"
)
# Delete the entire AIO directory so PREPARE_AIO re-copies everything
# with fresh timestamps. Without this, copy_if_different skips
# content-identical files (shaders, textures, configs, etc.) and
# leaves them with old timestamps that deployed files (e.g. from a
# manual package install) may beat under /XO. The DLL is always
# rebuilt fresh by the C++ compile step so it doesn't need special
# handling.
file(REMOVE_RECURSE "${AIO_DIR}")
# Also clear the PREPARE_AIO / COPY_SHADERS stamps so cmake --build
# actually re-runs those targets.
file(
GLOB _build_stamps
"${CMAKE_BINARY_DIR}/*_deploy.stamp"
"${CMAKE_BINARY_DIR}/*_shaders_full.stamp"
"${CMAKE_BINARY_DIR}/*_shaders_only.stamp"
"${CMAKE_BINARY_DIR}/prepare_aio.stamp"
"${CMAKE_BINARY_DIR}/copy_shaders.stamp"
)
foreach(_stamp IN LISTS _build_stamps)
file(REMOVE "${_stamp}")
endforeach()
endif()
file(WRITE "${_git_head_stamp}" "${_git_head}")
endif()

set(DEPLOY_TARGET_HASHES)
if(WIN32)
foreach(DEPLOY_TARGET $ENV{CommunityShadersOutputDir})
Expand Down
Loading