mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
build(cmake): skip download if target file exists #14844)
This commit is contained in:
parent
980d50d90e
commit
9c7e04eb3b
73
third-party/cmake/DownloadAndExtractFile.cmake
vendored
73
third-party/cmake/DownloadAndExtractFile.cmake
vendored
@ -59,41 +59,48 @@ string(REPLACE ";" "-" fname "${fname}")
|
||||
set(file ${DOWNLOAD_DIR}/${fname})
|
||||
message(STATUS "file: ${file}")
|
||||
|
||||
message(STATUS "downloading...
|
||||
src='${URL}'
|
||||
dst='${file}'
|
||||
timeout='${timeout_msg}'")
|
||||
set(EXISTING_SHA256 "")
|
||||
if(EXISTS ${file})
|
||||
file(SHA256 ${file} EXISTING_SHA256)
|
||||
endif()
|
||||
|
||||
file(DOWNLOAD ${URL} ${file}
|
||||
${timeout_args}
|
||||
${hash_args}
|
||||
STATUS status
|
||||
LOG log)
|
||||
|
||||
list(GET status 0 status_code)
|
||||
list(GET status 1 status_string)
|
||||
|
||||
if(NOT status_code EQUAL 0)
|
||||
# Retry on certain errors, e.g. CURLE_COULDNT_RESOLVE_HOST, which is often
|
||||
# seen with libtermkey (www.leonerd.org.uk).
|
||||
if((status_code EQUAL 6) # "Couldn't resolve host name"
|
||||
OR (status_code EQUAL 7)) # "Couldn't connect to server"
|
||||
message(STATUS "warning: retrying '${URL}' (${status_string}, status ${status_code})")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10)
|
||||
file(DOWNLOAD ${URL} ${file}
|
||||
${timeout_args}
|
||||
${hash_args}
|
||||
STATUS status
|
||||
LOG log)
|
||||
list(GET status 0 status_code)
|
||||
list(GET status 1 status_string)
|
||||
endif()
|
||||
if(NOT EXISTING_SHA256 STREQUAL ${EXPECTED_SHA256})
|
||||
message(STATUS "downloading...
|
||||
src='${URL}'
|
||||
dst='${file}'
|
||||
timeout='${timeout_msg}'")
|
||||
|
||||
file(DOWNLOAD ${URL} ${file}
|
||||
${timeout_args}
|
||||
${hash_args}
|
||||
STATUS status
|
||||
LOG log)
|
||||
|
||||
list(GET status 0 status_code)
|
||||
list(GET status 1 status_string)
|
||||
|
||||
if(NOT status_code EQUAL 0)
|
||||
message(FATAL_ERROR "error: downloading '${URL}' failed
|
||||
status_code: ${status_code}
|
||||
status_string: ${status_string}
|
||||
log: ${log}
|
||||
")
|
||||
# Retry on certain errors, e.g. CURLE_COULDNT_RESOLVE_HOST, which is often
|
||||
# seen with libtermkey (www.leonerd.org.uk).
|
||||
if((status_code EQUAL 6) # "Couldn't resolve host name"
|
||||
OR (status_code EQUAL 7)) # "Couldn't connect to server"
|
||||
message(STATUS "warning: retrying '${URL}' (${status_string}, status ${status_code})")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10)
|
||||
file(DOWNLOAD ${URL} ${file}
|
||||
${timeout_args}
|
||||
${hash_args}
|
||||
STATUS status
|
||||
LOG log)
|
||||
list(GET status 0 status_code)
|
||||
list(GET status 1 status_string)
|
||||
endif()
|
||||
if(NOT status_code EQUAL 0)
|
||||
message(FATAL_ERROR "error: downloading '${URL}' failed
|
||||
status_code: ${status_code}
|
||||
status_string: ${status_string}
|
||||
log: ${log}
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user