the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1if(NOT DEFINED PROJECT_SOURCE_DIR OR NOT DEFINED OUTPUT_DIR OR NOT DEFINED CONFIGURATION)
2 message(FATAL_ERROR "CopyAssets.cmake requires PROJECT_SOURCE_DIR, OUTPUT_DIR, and CONFIGURATION.")
3endif()
4
5# Some generators may pass quoted values (e.g. "Debug"); normalize that.
6string(REPLACE "\"" "" PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
7string(REPLACE "\"" "" OUTPUT_DIR "${OUTPUT_DIR}")
8string(REPLACE "\"" "" CONFIGURATION "${CONFIGURATION}")
9
10set(_project_dir "${PROJECT_SOURCE_DIR}/Minecraft.Client")
11
12function(copy_tree_if_exists src_rel dst_rel)
13 set(_src "${_project_dir}/${src_rel}")
14 set(_dst "${OUTPUT_DIR}/${dst_rel}")
15
16 if(EXISTS "${_src}")
17 file(MAKE_DIRECTORY "${_dst}")
18 file(GLOB_RECURSE _files RELATIVE "${_src}" "${_src}/*")
19
20 foreach(_file IN LISTS _files) # if not a source file
21 if(NOT _file MATCHES "\\.(cpp|c|h|hpp|xml|lang)$")
22 set(_full_src "${_src}/${_file}")
23 set(_full_dst "${_dst}/${_file}")
24
25 if(IS_DIRECTORY "${_full_src}")
26 file(MAKE_DIRECTORY "${_full_dst}")
27 else()
28 get_filename_component(_dst_dir "${_full_dst}" DIRECTORY)
29 file(MAKE_DIRECTORY "${_dst_dir}")
30 execute_process(
31 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
32 "${_full_src}" "${_full_dst}"
33 )
34 endif()
35 endif()
36 endforeach()
37 endif()
38endfunction()
39
40function(ensure_dir rel_path)
41 file(MAKE_DIRECTORY "${OUTPUT_DIR}/${rel_path}")
42endfunction()
43
44function(copy_file_if_exists src_rel dst_rel)
45 set(_src "${PROJECT_SOURCE_DIR}/${src_rel}")
46 set(_dst "${OUTPUT_DIR}/${dst_rel}")
47
48 get_filename_component(_dst_dir "${_dst}" DIRECTORY)
49 file(MAKE_DIRECTORY "${_dst_dir}")
50
51 if(EXISTS "${_src}")
52 execute_process(
53 COMMAND "${CMAKE_COMMAND}" -E copy_if_different
54 "${_src}" "${_dst}"
55 )
56 endif()
57endfunction()
58
59function(copy_first_existing dst_rel)
60 set(_copied FALSE)
61 foreach(_candidate IN LISTS ARGN)
62 if(EXISTS "${PROJECT_SOURCE_DIR}/${_candidate}")
63 copy_file_if_exists("${_candidate}" "${dst_rel}")
64 set(_copied TRUE)
65 break()
66 endif()
67 endforeach()
68 if(NOT _copied)
69 message(WARNING "Runtime file not found for ${dst_rel}. Checked: ${ARGN}")
70 endif()
71endfunction()
72
73function(remove_directory_if_exists rel_path)
74 set(_dir "${OUTPUT_DIR}/${rel_path}")
75 if(EXISTS "${_dir}")
76 file(REMOVE_RECURSE "${_dir}")
77 endif()
78endfunction()
79
80copy_tree_if_exists("Durango/Sound" "Windows64/Sound")
81copy_tree_if_exists("music" "music")
82copy_tree_if_exists("Windows64/GameHDD" "Windows64/GameHDD")
83copy_file_if_exists("Minecraft.Client/Common/Media/MediaWindows64.arc" "Common/Media/MediaWindows64.arc")
84copy_tree_if_exists("Common/res" "Common/res")
85copy_tree_if_exists("Common/Trial" "Common/Trial")
86copy_tree_if_exists("Common/Tutorial" "Common/Tutorial")
87copy_tree_if_exists("DurangoMedia" "Windows64Media")
88copy_tree_if_exists("Windows64Media" "Windows64Media")
89
90remove_directory_if_exists("Windows64Media/Layout")
91
92# Some runtime code asserts if this directory tree is missing.
93ensure_dir("Windows64/GameHDD")
94
95# Keep legacy runtime redistributables in a familiar location.
96copy_tree_if_exists("Windows64/Miles/lib/redist64" "redist64")
97copy_tree_if_exists("Windows64/Iggy/lib/redist64" "redist64")
98
99# Runtime DLLs required at launch.
100copy_first_existing("iggy_w64.dll"
101 "Minecraft.Client/Windows64/Iggy/lib/redist64/iggy_w64.dll"
102 "x64/${CONFIGURATION}/iggy_w64.dll"
103)
104copy_first_existing("mss64.dll"
105 "Minecraft.Client/Windows64/Miles/lib/redist64/mss64.dll"
106 "x64/${CONFIGURATION}/mss64.dll"
107)