# Botcraft downloads assets into its source directory. Give each version and # patch set its own build-local checkout, including for out-of-tree builds. find_package(Git REQUIRED) set(_upstream "${CMAKE_CURRENT_SOURCE_DIR}/3rd/Botcraft") execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD WORKING_DIRECTORY "${_upstream}" OUTPUT_VARIABLE _revision OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY) set(_inputs "${_revision}") set(_patches) foreach(_name inventory-sync item-frame-spawn player-eye-height) set(_patch "${CMAKE_CURRENT_SOURCE_DIR}/patches/Botcraft-${_name}.patch") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_patch}") file(SHA256 "${_patch}" _digest) string(APPEND _inputs " ${_digest}") list(APPEND _patches "${_patch}") endforeach() string(SHA256 _key "${_inputs}") string(SUBSTRING "${_key}" 0 16 _key) set(BILICRAFT_BOTCRAFT_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/Botcraft-${_key}") set(_copy "${BILICRAFT_BOTCRAFT_SOURCE_DIR}") if(NOT EXISTS "${_copy}/.git") execute_process(COMMAND "${GIT_EXECUTABLE}" clone --no-checkout --no-hardlinks "${_upstream}" "${_copy}" COMMAND_ERROR_IS_FATAL ANY) endif() if(NOT EXISTS "${_copy}/.git/bilicraft-patched") execute_process(COMMAND "${GIT_EXECUTABLE}" checkout --detach "${_revision}" WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY) execute_process(COMMAND "${GIT_EXECUTABLE}" apply ${_patches} WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY) file(TOUCH "${_copy}/.git/bilicraft-patched") endif() # Reuse an initialized Asio checkout and downloaded game assets when available. # On a fresh machine Botcraft fetches them in its build-local checkout. if(EXISTS "${_upstream}/3rdparty/asio/.git" AND NOT EXISTS "${_copy}/3rdparty/asio/.git") execute_process(COMMAND "${GIT_EXECUTABLE}" -c protocol.file.allow=always -c "submodule.3rdparty/asio.url=${_upstream}/3rdparty/asio" submodule update --init -- 3rdparty/asio WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY) endif() set(_assets "Assets/${BOTCRAFT_GAME_VERSION}/minecraft") if(IS_DIRECTORY "${_upstream}/${_assets}" AND NOT EXISTS "${_copy}/${_assets}") file(COPY "${_upstream}/${_assets}" DESTINATION "${_copy}/Assets/${BOTCRAFT_GAME_VERSION}") endif()