mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 16:19:00 +08:00
6b117c9c7e
* [vcpkg docs] Change how documenting port functions works Instead of using `##`, use comment blocks for documentation. Also, add some minor docs and change RST -> MD so we actually get docs generated. * add CI stuff * regenerate docs * fix vcpkg_find_acquire_program to not use _execute_process
55 lines
2.4 KiB
CMake
55 lines
2.4 KiB
CMake
#[===[.md:
|
|
# vcpkg_execute_required_process_repeat
|
|
|
|
Execute a process until the command succeeds, or until the COUNT is reached.
|
|
|
|
## Usage
|
|
```cmake
|
|
vcpkg_execute_required_process_repeat(
|
|
COUNT <num>
|
|
COMMAND <cmd> [<arguments>]
|
|
WORKING_DIRECTORY <directory>
|
|
LOGNAME <name>
|
|
)
|
|
```
|
|
#]===]
|
|
|
|
include(vcpkg_prettify_command)
|
|
function(vcpkg_execute_required_process_repeat)
|
|
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
|
|
cmake_parse_arguments(PARSE_ARGV 0 vcpkg_execute_required_process_repeat "ALLOW_IN_DOWNLOAD_MODE" "COUNT;WORKING_DIRECTORY;LOGNAME" "COMMAND")
|
|
#debug_message("vcpkg_execute_required_process_repeat(${vcpkg_execute_required_process_repeat_COMMAND})")
|
|
if (DEFINED VCPKG_DOWNLOAD_MODE AND NOT vcpkg_execute_required_process_repeat_ALLOW_IN_DOWNLOAD_MODE)
|
|
message(FATAL_ERROR
|
|
[[
|
|
This command cannot be executed in Download Mode.
|
|
Halting portfile execution.
|
|
]])
|
|
endif()
|
|
set(SUCCESSFUL_EXECUTION FALSE)
|
|
foreach(loop_count RANGE ${vcpkg_execute_required_process_repeat_COUNT})
|
|
vcpkg_execute_in_download_mode(
|
|
COMMAND ${vcpkg_execute_required_process_repeat_COMMAND}
|
|
OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_repeat_LOGNAME}-out-${loop_count}.log
|
|
ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_repeat_LOGNAME}-err-${loop_count}.log
|
|
RESULT_VARIABLE error_code
|
|
WORKING_DIRECTORY ${vcpkg_execute_required_process_repeat_WORKING_DIRECTORY})
|
|
#debug_message("error_code=${error_code}")
|
|
file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}" NATIVE_BUILDTREES_DIR)
|
|
if(NOT error_code)
|
|
set(SUCCESSFUL_EXECUTION TRUE)
|
|
break()
|
|
endif()
|
|
endforeach(loop_count)
|
|
if (NOT SUCCESSFUL_EXECUTION)
|
|
vcpkg_prettify_command(vcpkg_execute_required_process_repeat_COMMAND vcpkg_execute_required_process_repeat_COMMAND_PRETTY)
|
|
message(FATAL_ERROR
|
|
" Command failed: ${vcpkg_execute_required_process_repeat_COMMAND_PRETTY}\n"
|
|
" Working Directory: ${vcpkg_execute_required_process_repeat_WORKING_DIRECTORY}\n"
|
|
" See logs for more information:\n"
|
|
" ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_repeat_LOGNAME}-out.log\n"
|
|
" ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_repeat_LOGNAME}-err.log\n"
|
|
)
|
|
endif()
|
|
endfunction()
|