mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
Meta: Add a CMake function to download remote files during the build
This function will handle download failures. It doesn't support hashing for integrity yet, but if the download times out or otherwise fails, the build itself will fail. But default, file(DOWNLOAD) in CMake doesn't fail the build; we must pass in and check a STATUS variable.
This commit is contained in:
parent
b40308d0a4
commit
e805fce46e
Notes:
sideshowbarker
2024-07-17 20:12:50 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/e805fce46e7 Pull-request: https://github.com/SerenityOS/serenity/pull/12139
1 changed files with 16 additions and 0 deletions
|
@ -194,3 +194,19 @@ function(invoke_generator name generator version_file prefix header implementati
|
|||
add_custom_target("generate_${prefix}${name}" DEPENDS "${header}" "${implementation}")
|
||||
add_dependencies(all_generated "generate_${prefix}${name}")
|
||||
endfunction()
|
||||
|
||||
function(download_file url 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)
|
||||
|
||||
if (NOT status_code EQUAL 0)
|
||||
file(REMOVE "${path}")
|
||||
message(FATAL_ERROR "Failed to download ${url}: ${error_message}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
Loading…
Add table
Reference in a new issue