mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2026-05-06 15:59:36 -04:00
37545dfd5e
* Use assets.json as single source of truth for OpenRCT2 assets This ensures there's single source of truth for all downloadable assets. I figured the "version" information is actually redundant because we can embed the whole URL as the "zipversion", therefore this is dropped now. The newly-introdcued MSBuild task uses Roslyn-based code and I updated `DownloadDependency` task to RoslynCodeTaskFactory as well. * Rename OpenMSX to OpenMusic
53 lines
2.2 KiB
CMake
53 lines
2.2 KiB
CMake
function(download_openrct2_zip)
|
|
set(oneValueArgs DOWNLOAD_DIR ZIP_URL SHA256)
|
|
set(multiValueArgs SKIP_IF_EXISTS)
|
|
cmake_parse_arguments(DOWNLOAD_OPENRCT2 "${options}" "${oneValueArgs}"
|
|
"${multiValueArgs}" ${ARGN} )
|
|
|
|
get_filename_component(ZIP_FILE_NAME ${DOWNLOAD_OPENRCT2_ZIP_URL} NAME)
|
|
|
|
if (NOT EXISTS ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR})
|
|
set(DOWNLOAD_ZIP 1)
|
|
file(MAKE_DIRECTORY "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}")
|
|
else ()
|
|
if (EXISTS "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion")
|
|
file(READ "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion" DOWNLOAD_OPENRCT2_CACHED_VERSION)
|
|
if (NOT ${DOWNLOAD_OPENRCT2_CACHED_VERSION} STREQUAL ${DOWNLOAD_OPENRCT2_ZIP_URL})
|
|
message("Cache ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR} not up to date")
|
|
set(DOWNLOAD_ZIP 1)
|
|
endif ()
|
|
else ()
|
|
set(DOWNLOAD_ZIP 1)
|
|
endif ()
|
|
endif ()
|
|
|
|
foreach(check_exist_file_or_dir ${DOWNLOAD_OPENRCT2_SKIP_IF_EXISTS})
|
|
if (EXISTS ${check_exist_file_or_dir})
|
|
message("${check_exist_file_or_dir} exists, skipping download")
|
|
set(DOWNLOAD_ZIP 0)
|
|
break()
|
|
endif ()
|
|
endforeach(check_exist_file_or_dir)
|
|
|
|
if (DOWNLOAD_ZIP)
|
|
message("Downloading ${DOWNLOAD_OPENRCT2_ZIP_URL} to ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}")
|
|
file(DOWNLOAD
|
|
"${DOWNLOAD_OPENRCT2_ZIP_URL}" "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}"
|
|
EXPECTED_HASH SHA256=${DOWNLOAD_OPENRCT2_SHA256} SHOW_PROGRESS)
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR} ${CMAKE_COMMAND} -E tar xf ${ZIP_FILE_NAME})
|
|
else()
|
|
file(ARCHIVE_EXTRACT
|
|
INPUT "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}"
|
|
DESTINATION "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}"
|
|
)
|
|
endif()
|
|
file(WRITE
|
|
"${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion"
|
|
"${DOWNLOAD_OPENRCT2_ZIP_URL}"
|
|
)
|
|
file(REMOVE "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}")
|
|
endif ()
|
|
|
|
endfunction ()
|