diff options
| author | Alexander Saprykin <xelfium@gmail.com> | 2018-05-26 13:27:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-26 13:27:14 +0200 |
| commit | 4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5 (patch) | |
| tree | d95c9490352eb73f078d34a33bc4bb44ac9fa48b /scripts/cmake/vcpkg_execute_required_process.cmake | |
| parent | fb689bd13dd6ba563a885d71fff1dd2b32a615db (diff) | |
| parent | 2ac7527b40b1dbeb7856b9f763362c1e139e2ca9 (diff) | |
| download | vcpkg-4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5.tar.gz vcpkg-4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5.zip | |
Merge pull request #1 from Microsoft/master
Update vcpkg from upstream
Diffstat (limited to 'scripts/cmake/vcpkg_execute_required_process.cmake')
| -rw-r--r-- | scripts/cmake/vcpkg_execute_required_process.cmake | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/scripts/cmake/vcpkg_execute_required_process.cmake b/scripts/cmake/vcpkg_execute_required_process.cmake index 7feff08b2..5b8922c14 100644 --- a/scripts/cmake/vcpkg_execute_required_process.cmake +++ b/scripts/cmake/vcpkg_execute_required_process.cmake @@ -1,21 +1,63 @@ -# Usage: vcpkg_execute_required_process(COMMAND <cmd> [<args>...] WORKING_DIRECTORY </path/to/dir> LOGNAME <my_log_name>) +## # vcpkg_execute_required_process +## +## Execute a process with logging and fail the build if the command fails. +## +## ## Usage +## ```cmake +## vcpkg_execute_required_process( +## COMMAND <${PERL}> [<arguments>...] +## WORKING_DIRECTORY <${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg> +## LOGNAME <build-${TARGET_TRIPLET}-dbg> +## ) +## ``` +## ## Parameters +## ### COMMAND +## The command to be executed, along with its arguments. +## +## ### WORKING_DIRECTORY +## The directory to execute the command in. +## +## ### LOGNAME +## The prefix to use for the log files. +## +## This should be a unique name for different triplets so that the logs don't conflict when building multiple at once. +## +## ## Examples +## +## * [ffmpeg](https://github.com/Microsoft/vcpkg/blob/master/ports/ffmpeg/portfile.cmake) +## * [openssl](https://github.com/Microsoft/vcpkg/blob/master/ports/openssl/portfile.cmake) +## * [boost](https://github.com/Microsoft/vcpkg/blob/master/ports/boost/portfile.cmake) +## * [qt5](https://github.com/Microsoft/vcpkg/blob/master/ports/qt5/portfile.cmake) function(vcpkg_execute_required_process) cmake_parse_arguments(vcpkg_execute_required_process "" "WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN}) - #debug_message("vcpkg_execute_required_process(${vcpkg_execute_required_process_COMMAND})") + set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log") + set(LOG_ERR "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log") execute_process( COMMAND ${vcpkg_execute_required_process_COMMAND} - OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log - ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log + OUTPUT_FILE ${LOG_OUT} + ERROR_FILE ${LOG_ERR} RESULT_VARIABLE error_code WORKING_DIRECTORY ${vcpkg_execute_required_process_WORKING_DIRECTORY}) - #debug_message("error_code=${error_code}") - file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}" NATIVE_BUILDTREES_DIR) if(error_code) + set(LOGS) + file(READ "${LOG_OUT}" out_contents) + file(READ "${LOG_ERR}" err_contents) + if(out_contents) + list(APPEND LOGS "${LOG_OUT}") + endif() + if(err_contents) + list(APPEND LOGS "${LOG_ERR}") + endif() + set(STRINGIFIED_LOGS) + foreach(LOG ${LOGS}) + file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG) + list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n") + endforeach() message(FATAL_ERROR " Command failed: ${vcpkg_execute_required_process_COMMAND}\n" " Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n" " See logs for more information:\n" - " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-out.log\n" - " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-err.log\n") + ${STRINGIFIED_LOGS} + ) endif() endfunction() |
