aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPortal <93601172+PortalG@users.noreply.github.com>2026-03-05 02:30:22 -0500
committerGitHub <noreply@github.com>2026-03-05 14:30:22 +0700
commitfcc9970ec6148bf63a88f4fb1bf7f4abb4b107a2 (patch)
tree8a65ebd5048be937b5da3cdb450a945f27446714
parent053eb0119cc5d154a63b19cbddd8e8d91404068b (diff)
Replace CopyAssets.cmake with multithreaded Robocopy (and rsync) implementation. (#410)
* Replace CopyAssets.cmake with Robocopy implementation. * Replace CopyAssets.cmake with Robocopy implementation.
-rw-r--r--CMakeLists.txt62
-rw-r--r--cmake/CopyAssets.cmake107
2 files changed, 54 insertions, 115 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d83c5c8..916f1315 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -89,13 +89,59 @@ target_link_libraries(MinecraftClient PRIVATE
>
)
-add_custom_command(TARGET MinecraftClient POST_BUILD
- COMMAND "${CMAKE_COMMAND}"
- -DPROJECT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
- -DOUTPUT_DIR="$<TARGET_FILE_DIR:MinecraftClient>"
- -DCONFIGURATION=$<CONFIG>
- -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyAssets.cmake"
- VERBATIM
-)
+if(WIN32)
+ message(STATUS "Starting redist copy...")
+ execute_process(
+ COMMAND robocopy.exe
+ "${CMAKE_CURRENT_SOURCE_DIR}/x64/Release"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ /S /MT /R:0 /W:0 /NP
+ )
+ message(STATUS "Starting asset copy...")
+ execute_process(
+ COMMAND robocopy.exe
+ "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ /S /MT /R:0 /W:0 /NP
+ /XF "*.cpp" "*.c" "*.h" "*.hpp" "*.asm"
+ "*.xml" "*.lang" "*.vcxproj" "*.vcxproj.*" "*.sln"
+ "*.docx" "*.xls"
+ "*.bat" "*.cmd" "*.ps1" "*.py"
+ "*Test*"
+ /XD "Durango*" "Orbis*" "PS*" "Xbox"
+ )
+ message(STATUS "Patching Windows64Media...")
+ execute_process(
+ COMMAND robocopy.exe
+ "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/DurangoMedia"
+ "${CMAKE_CURRENT_BINARY_DIR}/Windows64Media"
+ /S /MT /R:0 /W:0 /NP
+ /XF "*.h" "*.xml" "*.lang" "*.bat"
+ )
+elseif(UNIX)
+ message(STATUS "Starting redist copy...")
+ execute_process(
+ COMMAND rsync -av "${CMAKE_CURRENT_SOURCE_DIR}/x64/Release/" "${CMAKE_CURRENT_BINARY_DIR}/"
+ )
+ message(STATUS "Starting asset copy...")
+ execute_process(
+ COMMAND rsync -av
+ "--exclude=*.cpp" "--exclude=*.c" "--exclude=*.h" "--exclude=*.hpp" "--exclude=*.asm"
+ "--exclude=*.xml" "--exclude=*.lang" "--exclude=*.vcxproj" "--exclude=*.vcxproj.*" "--exclude=*.sln"
+ "--exclude=*.docx" "--exclude=*.xls"
+ "--exclude=*.bat" "--exclude=*.cmd" "--exclude=*.ps1" "--exclude=*.py"
+ "--exclude=*Test*"
+ "--exclude=Durango*" "--exclude=Orbis*" "--exclude=PS*" "--exclude=Xbox"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/" "${CMAKE_CURRENT_BINARY_DIR}/"
+ )
+ message(STATUS "Patching Windows64Media...")
+ execute_process(
+ COMMAND rsync -av
+ "--exclude=*.h" "--exclude=*.xml" "--exclude=*.lang" "--exclude=*.bat"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/DurangoMedia/" "${CMAKE_CURRENT_BINARY_DIR}/Windows64Media/"
+ )
+else()
+ message(FATAL_ERROR "Redist and asset copying is only supported on Windows (Robocopy) and Unix systems (rsync).")
+endif()
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MinecraftClient)
diff --git a/cmake/CopyAssets.cmake b/cmake/CopyAssets.cmake
deleted file mode 100644
index a0252f73..00000000
--- a/cmake/CopyAssets.cmake
+++ /dev/null
@@ -1,107 +0,0 @@
-if(NOT DEFINED PROJECT_SOURCE_DIR OR NOT DEFINED OUTPUT_DIR OR NOT DEFINED CONFIGURATION)
- message(FATAL_ERROR "CopyAssets.cmake requires PROJECT_SOURCE_DIR, OUTPUT_DIR, and CONFIGURATION.")
-endif()
-
-# Some generators may pass quoted values (e.g. "Debug"); normalize that.
-string(REPLACE "\"" "" PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
-string(REPLACE "\"" "" OUTPUT_DIR "${OUTPUT_DIR}")
-string(REPLACE "\"" "" CONFIGURATION "${CONFIGURATION}")
-
-set(_project_dir "${PROJECT_SOURCE_DIR}/Minecraft.Client")
-
-function(copy_tree_if_exists src_rel dst_rel)
- set(_src "${_project_dir}/${src_rel}")
- set(_dst "${OUTPUT_DIR}/${dst_rel}")
-
- if(EXISTS "${_src}")
- file(MAKE_DIRECTORY "${_dst}")
- file(GLOB_RECURSE _files RELATIVE "${_src}" "${_src}/*")
-
- foreach(_file IN LISTS _files) # if not a source file
- if(NOT _file MATCHES "\\.(cpp|c|h|hpp|xml|lang)$")
- set(_full_src "${_src}/${_file}")
- set(_full_dst "${_dst}/${_file}")
-
- if(IS_DIRECTORY "${_full_src}")
- file(MAKE_DIRECTORY "${_full_dst}")
- else()
- get_filename_component(_dst_dir "${_full_dst}" DIRECTORY)
- file(MAKE_DIRECTORY "${_dst_dir}")
- execute_process(
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different
- "${_full_src}" "${_full_dst}"
- )
- endif()
- endif()
- endforeach()
- endif()
-endfunction()
-
-function(ensure_dir rel_path)
- file(MAKE_DIRECTORY "${OUTPUT_DIR}/${rel_path}")
-endfunction()
-
-function(copy_file_if_exists src_rel dst_rel)
- set(_src "${PROJECT_SOURCE_DIR}/${src_rel}")
- set(_dst "${OUTPUT_DIR}/${dst_rel}")
-
- get_filename_component(_dst_dir "${_dst}" DIRECTORY)
- file(MAKE_DIRECTORY "${_dst_dir}")
-
- if(EXISTS "${_src}")
- execute_process(
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different
- "${_src}" "${_dst}"
- )
- endif()
-endfunction()
-
-function(copy_first_existing dst_rel)
- set(_copied FALSE)
- foreach(_candidate IN LISTS ARGN)
- if(EXISTS "${PROJECT_SOURCE_DIR}/${_candidate}")
- copy_file_if_exists("${_candidate}" "${dst_rel}")
- set(_copied TRUE)
- break()
- endif()
- endforeach()
- if(NOT _copied)
- message(WARNING "Runtime file not found for ${dst_rel}. Checked: ${ARGN}")
- endif()
-endfunction()
-
-function(remove_directory_if_exists rel_path)
- set(_dir "${OUTPUT_DIR}/${rel_path}")
- if(EXISTS "${_dir}")
- file(REMOVE_RECURSE "${_dir}")
- endif()
-endfunction()
-
-copy_tree_if_exists("Durango/Sound" "Windows64/Sound")
-copy_tree_if_exists("music" "music")
-copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD")
-copy_file_if_exists("Minecraft.Client/Common/Media/MediaWindows64.arc" "Common/Media/MediaWindows64.arc")
-copy_tree_if_exists("Common/res" "Common/res")
-copy_tree_if_exists("Common/Trial" "Common/Trial")
-copy_tree_if_exists("Common/Tutorial" "Common/Tutorial")
-copy_tree_if_exists("DurangoMedia" "Windows64Media")
-copy_tree_if_exists("Windows64Media" "Windows64Media")
-
-remove_directory_if_exists("Windows64Media/Layout")
-
-# Some runtime code asserts if this directory tree is missing.
-ensure_dir("Windows64/GameHDD")
-
-# Keep legacy runtime redistributables in a familiar location.
-copy_tree_if_exists("Windows64/Miles/lib/redist64" "redist64")
-copy_tree_if_exists("Windows64/Iggy/lib/redist64" "redist64")
-
-# Runtime DLLs required at launch.
-copy_first_existing("iggy_w64.dll"
- "Minecraft.Client/Windows64/Iggy/lib/redist64/iggy_w64.dll"
- "x64/${CONFIGURATION}/iggy_w64.dll"
-)
-copy_first_existing("mss64.dll"
- "Minecraft.Client/Windows64/Miles/lib/redist64/mss64.dll"
- "x64/${CONFIGURATION}/mss64.dll"
-)