Skip to content

Commit

Permalink
[vcpkg] Use spaces instead of semicolons in the output (microsoft#7080)
Browse files Browse the repository at this point in the history
* Use spaces instead of semicolons in the output

* Add prettify_command macro

* Move pretty_command macro to a separate file
  • Loading branch information
Pospelove authored and vicroms committed Jul 1, 2019
1 parent 77cfd20 commit b26cb1a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/cmake/vcpkg_common_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ include(vcpkg_get_windows_sdk)
include(vcpkg_replace_string)
include(vcpkg_from_git)
include(vcpkg_test_cmake)
include(vcpkg_prettify_command)
4 changes: 3 additions & 1 deletion scripts/cmake/vcpkg_execute_build_process.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
## ## Examples
##
## * [icu](https://github.com/Microsoft/vcpkg/blob/master/ports/icu/portfile.cmake)
include(vcpkg_prettify_command)
function(vcpkg_execute_build_process)
cmake_parse_arguments(_ebp "" "WORKING_DIRECTORY;LOGNAME" "COMMAND;NO_PARALLEL_COMMAND" ${ARGN})

Expand Down Expand Up @@ -131,8 +132,9 @@ function(vcpkg_execute_build_process)
file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG)
list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n")
endforeach()
vcpkg_prettify_command(_ebp_COMMAND _ebp_COMMAND_PRETTY)
message(FATAL_ERROR
" Command failed: ${_ebp_COMMAND}\n"
" Command failed: ${_ebp_COMMAND_PRETTY}\n"
" Working Directory: ${_ebp_WORKING_DIRECTORY}\n"
" See logs for more information:\n"
${STRINGIFIED_LOGS})
Expand Down
4 changes: 3 additions & 1 deletion scripts/cmake/vcpkg_execute_required_process.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
## * [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)
include(vcpkg_prettify_command)
function(vcpkg_execute_required_process)
cmake_parse_arguments(vcpkg_execute_required_process "" "WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN})
set(LOG_OUT "${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log")
Expand All @@ -53,8 +54,9 @@ function(vcpkg_execute_required_process)
file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG)
list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n")
endforeach()
vcpkg_prettify_command(vcpkg_execute_required_process_COMMAND vcpkg_execute_required_process_COMMAND_PRETTY)
message(FATAL_ERROR
" Command failed: ${vcpkg_execute_required_process_COMMAND}\n"
" Command failed: ${vcpkg_execute_required_process_COMMAND_PRETTY}\n"
" Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n"
" Error code: ${error_code}\n"
" See logs for more information:\n"
Expand Down
4 changes: 3 additions & 1 deletion scripts/cmake/vcpkg_execute_required_process_repeat.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Usage: vcpkg_execute_required_process_repeat(COUNT <num> COMMAND <cmd> [<args>...] WORKING_DIRECTORY </path/to/dir> LOGNAME <my_log_name>)
include(vcpkg_prettify_command)
function(vcpkg_execute_required_process_repeat)
cmake_parse_arguments(vcpkg_execute_required_process_repeat "" "COUNT;WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN})
#debug_message("vcpkg_execute_required_process_repeat(${vcpkg_execute_required_process_repeat_COMMAND})")
Expand All @@ -18,8 +19,9 @@ function(vcpkg_execute_required_process_repeat)
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}\n"
" 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"
Expand Down
26 changes: 26 additions & 0 deletions scripts/cmake/vcpkg_prettify_command.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## # vcpkg_prettify_command
##
## Turns list of command arguments into a formatted string.
##
## ## Usage
## ```cmake
## vcpkg_prettify_command()
## ```
##
## ## Examples
##
## * `scripts/cmake/vcpkg_execute_build_process.cmake`
## * `scripts/cmake/vcpkg_execute_required_process.cmake`
## * `scripts/cmake/vcpkg_execute_required_process_repeat.cmake`

macro(vcpkg_prettify_command INPUT_VAR OUTPUT_VAR)
set(${OUTPUT_VAR} "")
foreach(v ${${INPUT_VAR}})
if(${v} MATCHES "( )")
list(APPEND ${OUTPUT_VAR} \"${v}\")
else()
list(APPEND ${OUTPUT_VAR} ${v})
endif()
endforeach()
list(JOIN ${OUTPUT_VAR} " " ${OUTPUT_VAR})
endmacro()

0 comments on commit b26cb1a

Please sign in to comment.