feat: add export / file packing
This commit is contained in:
@@ -4,6 +4,7 @@ add_subdirectory(third_party)
|
||||
add_library(destrum_assets
|
||||
"src/Assets/ModelFile.cpp"
|
||||
"src/Assets/TextureFile.cpp"
|
||||
"src/Assets/PackFile.cpp"
|
||||
)
|
||||
|
||||
add_library(destrum::assets ALIAS destrum_assets)
|
||||
@@ -297,6 +298,41 @@ function(destrum_cook_engine_assets GAME_TARGET GAME_OUTPUT_DIR)
|
||||
install(DIRECTORY "${_engine_runtime}/" DESTINATION "bin/assets/engine")
|
||||
endfunction()
|
||||
|
||||
# A folder (and zip) other people can run: the game exe, its DLLs and every cooked asset packed into assets.dpak
|
||||
function(destrum_add_export GAME_TARGET GAME_RUNTIME_DIR)
|
||||
set(_engine_runtime "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/assets_runtime")
|
||||
set(_export_root "${CMAKE_BINARY_DIR}/export/$<CONFIG>")
|
||||
set(_export_dir "${_export_root}/${GAME_TARGET}")
|
||||
|
||||
# The release VC++ runtime ships app-local, debug builds only run where Visual Studio is installed
|
||||
set(_system_libs)
|
||||
if (MSVC)
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
set(_system_libs "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}>")
|
||||
endif()
|
||||
|
||||
add_custom_target(_internal_export_${GAME_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf "${_export_dir}" "${_export_dir}.zip"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${_export_dir}"
|
||||
COMMAND TheChef
|
||||
--pack "${_export_dir}/assets.dpak"
|
||||
--mount "engine=${_engine_runtime}"
|
||||
--mount "game=${GAME_RUNTIME_DIR}"
|
||||
COMMAND TheChef --list "${_export_dir}/assets.dpak" --top 10
|
||||
COMMAND ${CMAKE_COMMAND} -E copy -t "${_export_dir}"
|
||||
"$<TARGET_FILE:${GAME_TARGET}>"
|
||||
"$<TARGET_RUNTIME_DLLS:${GAME_TARGET}>"
|
||||
"${_system_libs}"
|
||||
COMMAND ${CMAKE_COMMAND} -E chdir "${_export_root}"
|
||||
${CMAKE_COMMAND} -E tar cf "${GAME_TARGET}.zip" --format=zip "${GAME_TARGET}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Exported ${GAME_TARGET} to ${_export_dir}"
|
||||
COMMAND_EXPAND_LISTS
|
||||
VERBATIM
|
||||
)
|
||||
add_dependencies(_internal_export_${GAME_TARGET} ${GAME_TARGET})
|
||||
endfunction()
|
||||
|
||||
# OpenAL is a DLL, every exe that links the engine needs a copy next to it
|
||||
function(destrum_copy_runtime_dlls TARGET)
|
||||
if (WIN32)
|
||||
|
||||
Reference in New Issue
Block a user