diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-12-19 21:46:07 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-12-21 09:13:50 +0000 |
commit | 1c630316ec573e3cb02690aed3515f78e1cae34f (patch) | |
tree | fdba5d250c3fbd605bbedfafbc00af9cbba8a0e4 /Meta/CMake | |
parent | 917e32d31adcb930bf6fb88f28ea1cc9cd45dc75 (diff) | |
download | serenity-1c630316ec573e3cb02690aed3515f78e1cae34f.zip |
CMake: Fall back to the Web Archive when downloading files
Diffstat (limited to 'Meta/CMake')
-rw-r--r-- | Meta/CMake/utils.cmake | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 290f74fc9c..6863783b22 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -221,22 +221,36 @@ function(invoke_generator name generator version_file header implementation) set(CURRENT_LIB_GENERATED ${CURRENT_LIB_GENERATED} PARENT_SCOPE) endfunction() -function(download_file url path) +function(download_file_multisource urls path) if (NOT EXISTS "${path}") get_filename_component(file "${path}" NAME) - message(STATUS "Downloading file ${file} from ${url}") - file(DOWNLOAD "${url}" "${path}" INACTIVITY_TIMEOUT 10 STATUS download_result) - list(GET download_result 0 status_code) - list(GET download_result 1 error_message) + foreach(url ${urls}) + message(STATUS "Downloading file ${file} from ${url}") + + file(DOWNLOAD "${url}" "${path}" INACTIVITY_TIMEOUT 10 STATUS download_result) + list(GET download_result 0 status_code) + list(GET download_result 1 error_message) + + if (status_code EQUAL 0) + break() + endif() - if (NOT status_code EQUAL 0) file(REMOVE "${path}") - message(FATAL_ERROR "Failed to download ${url}: ${error_message}") + message(WARNING "Failed to download ${url}: ${error_message}") + endforeach() + + if (NOT status_code EQUAL 0) + message(FATAL_ERROR "Failed to download ${path} from any source") endif() endif() endfunction() +function(download_file url path) + # If the timestamp doesn't match exactly, the Web Archive should redirect to the closest archived file automatically. + download_file_multisource("${url};https://web.archive.org/web/99991231235959/${url}" "${path}") +endfunction() + function(extract_path dest_dir zip_path source_path dest_path) if (EXISTS "${zip_path}" AND NOT EXISTS "${dest_path}") if (CMAKE_VERSION VERSION_LESS 3.18.0) |