2020-12-02 05:37:26 +08:00
|
|
|
#[===[.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>
|
|
|
|
)
|
|
|
|
```
|
|
|
|
#]===]
|
|
|
|
|
2019-07-02 04:30:24 +08:00
|
|
|
include(vcpkg_prettify_command)
|
2016-10-25 17:56:02 +08:00
|
|
|
function(vcpkg_execute_required_process_repeat)
|
2020-10-27 10:30:27 +08:00
|
|
|
# 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")
|
2016-10-25 17:56:02 +08:00
|
|
|
#debug_message("vcpkg_execute_required_process_repeat(${vcpkg_execute_required_process_repeat_COMMAND})")
|
2020-10-27 10:30:27 +08:00
|
|
|
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()
|
2017-03-21 07:10:45 +08:00
|
|
|
set(SUCCESSFUL_EXECUTION FALSE)
|
2016-10-25 17:56:02 +08:00
|
|
|
foreach(loop_count RANGE ${vcpkg_execute_required_process_repeat_COUNT})
|
2020-10-27 10:30:27 +08:00
|
|
|
vcpkg_execute_in_download_mode(
|
2016-10-25 17:56:02 +08:00
|
|
|
COMMAND ${vcpkg_execute_required_process_repeat_COMMAND}
|
2017-03-21 07:10:45 +08:00
|
|
|
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
|
2016-10-25 17:56:02 +08:00
|
|
|
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)
|
2017-03-21 07:10:45 +08:00
|
|
|
if (NOT SUCCESSFUL_EXECUTION)
|
2019-07-02 04:30:24 +08:00
|
|
|
vcpkg_prettify_command(vcpkg_execute_required_process_repeat_COMMAND vcpkg_execute_required_process_repeat_COMMAND_PRETTY)
|
2016-10-25 17:56:02 +08:00
|
|
|
message(FATAL_ERROR
|
2019-07-02 04:30:24 +08:00
|
|
|
" Command failed: ${vcpkg_execute_required_process_repeat_COMMAND_PRETTY}\n"
|
2016-10-25 17:56:02 +08:00
|
|
|
" 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()
|