mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
CMake: Fall back to the Web Archive when downloading files
This commit is contained in:
parent
917e32d31a
commit
1c630316ec
1 changed files with 21 additions and 7 deletions
|
@ -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()
|
||||
|
||||
file(REMOVE "${path}")
|
||||
message(WARNING "Failed to download ${url}: ${error_message}")
|
||||
endforeach()
|
||||
|
||||
if (NOT status_code EQUAL 0)
|
||||
file(REMOVE "${path}")
|
||||
message(FATAL_ERROR "Failed to download ${url}: ${error_message}")
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue