mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:17:35 +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)
|
set(CURRENT_LIB_GENERATED ${CURRENT_LIB_GENERATED} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(download_file url path)
|
function(download_file_multisource urls path)
|
||||||
if (NOT EXISTS "${path}")
|
if (NOT EXISTS "${path}")
|
||||||
get_filename_component(file "${path}" NAME)
|
get_filename_component(file "${path}" NAME)
|
||||||
message(STATUS "Downloading file ${file} from ${url}")
|
|
||||||
|
|
||||||
file(DOWNLOAD "${url}" "${path}" INACTIVITY_TIMEOUT 10 STATUS download_result)
|
foreach(url ${urls})
|
||||||
list(GET download_result 0 status_code)
|
message(STATUS "Downloading file ${file} from ${url}")
|
||||||
list(GET download_result 1 error_message)
|
|
||||||
|
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)
|
if (NOT status_code EQUAL 0)
|
||||||
file(REMOVE "${path}")
|
message(FATAL_ERROR "Failed to download ${path} from any source")
|
||||||
message(FATAL_ERROR "Failed to download ${url}: ${error_message}")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
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)
|
function(extract_path dest_dir zip_path source_path dest_path)
|
||||||
if (EXISTS "${zip_path}" AND NOT EXISTS "${dest_path}")
|
if (EXISTS "${zip_path}" AND NOT EXISTS "${dest_path}")
|
||||||
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
if (CMAKE_VERSION VERSION_LESS 3.18.0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue