]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Consistently format block error messages. 2567/head
authorDavid Wells <wellsd2@rpi.edu>
Sat, 30 Apr 2016 21:11:32 +0000 (17:11 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 1 May 2016 14:12:35 +0000 (10:12 -0400)
cmake/macros/macro_deal_ii_invoke_autopilot.cmake
cmake/macros/macro_decorate_with_stars.cmake [new file with mode: 0644]
cmake/setup_custom_targets.cmake
tests/quick_tests/run.cmake

index 48bed628e602e12f68823656c2bdb5c6f08d6856..4ff78eab1ea0a036f40a63383a67460b24a79b48 100644 (file)
@@ -128,8 +128,8 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
         COMMAND
            ${CMAKE_COMMAND} -E echo ''
         && ${CMAKE_COMMAND} -E echo '***************************************************************************'
-        && ${CMAKE_COMMAND} -E echo '**  Error: No Mac OSX developer certificate specified'
-        && ${CMAKE_COMMAND} -E echo '**  Please reconfigure with -DOSX_CERTIFICATE_NAME="<...>"'
+        && ${CMAKE_COMMAND} -E echo '**           Error: No Mac OSX developer certificate specified           **'
+        && ${CMAKE_COMMAND} -E echo '**         Please reconfigure with -DOSX_CERTIFICATE_NAME="<...>"        **'
         && ${CMAKE_COMMAND} -E echo '***************************************************************************'
         && ${CMAKE_COMMAND} -E echo ''
         COMMENT "Digitally signing ${TARGET}"
diff --git a/cmake/macros/macro_decorate_with_stars.cmake b/cmake/macros/macro_decorate_with_stars.cmake
new file mode 100644 (file)
index 0000000..950905d
--- /dev/null
@@ -0,0 +1,50 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2016 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Formats a string to be of length 75 and surrounded with '**'s, and, if
+# necessary, centered with extra spaces. This allows for nicer looking output
+# messages: for example, the middle two lines of
+#
+# ***************************************************************************
+# **    Error: Could not build and install disabled component examples.    **
+# **        Please reconfigure with -DDEAL_II_COMPONENT_EXAMPLES=ON        **
+# ***************************************************************************
+#
+# could be built automatically with this macro. If the line is too long to fit
+# in such a box then decorate it with just two stars at the beginning.
+#
+# Usage:
+#     DECORATE_WITH_STARS(message decorated_message)
+#
+#
+MACRO(DECORATE_WITH_STARS _message _decorated_message)
+  STRING(LENGTH ${_message} _message_length)
+  SET(_line_length 75)
+  MATH(EXPR _unpadded_line_length "${_line_length} - 6")
+
+  IF(${_message_length} LESS ${_unpadded_line_length})
+    MATH(EXPR _left_pad_size "(${_unpadded_line_length} - ${_message_length} + 1)/2")
+    MATH(EXPR _right_pad_size "(${_unpadded_line_length} - ${_message_length})/2")
+    # Unfortunately, it looks like taking substrings is the only way to pad
+    # strings with run time dependent length.
+    SET(_pad_strings_values "                                              ")
+    STRING(SUBSTRING "${_pad_strings_values}" 0 "${_left_pad_size}" _left_pad)
+    STRING(SUBSTRING "${_pad_strings_values}" 0 "${_right_pad_size}" _right_pad)
+    SET(${_decorated_message} "** ${_left_pad}${_message}${_right_pad} **")
+  ELSE()
+    SET(${_decorated_message} "** ${_message}")
+  ENDIF()
+ENDMACRO()
index c3d9e58b4f947aafc60ed9ddc73c28d9c7448fd4..ceeb425566f2e011acdf3d619e1aacba6b45c6a9 100644 (file)
@@ -60,13 +60,24 @@ FOREACH(_component compat_files documentation examples parameter_gui)
     _add_custom_target(${_component})
   ELSE()
     STRING(TOUPPER ${_component} _componentuppercase)
+
+    SET(_error_description_message
+      "Error: Could not ${_description_string} disabled component ${_component}.")
+    DECORATE_WITH_STARS(${_error_description_message}
+      _decorated_error_description_message)
+
+    SET(_reconfiguration_help_message
+      "Please reconfigure with -DDEAL_II_COMPONENT_${_componentuppercase}=ON")
+    DECORATE_WITH_STARS(${_reconfiguration_help_message}
+      _decorated_reconfiguration_help_message)
+
     ADD_CUSTOM_TARGET(${_component}
       COMMAND
            ${CMAKE_COMMAND} -E echo ''
         && ${CMAKE_COMMAND} -E echo ''
         && ${CMAKE_COMMAND} -E echo '***************************************************************************'
-        && ${CMAKE_COMMAND} -E echo "**  Error: Could not ${_description_string} disabled component \"${_component}\"."
-        && ${CMAKE_COMMAND} -E echo "**  Please reconfigure with -DDEAL_II_COMPONENT_${_componentuppercase}=ON"
+        && ${CMAKE_COMMAND} -E echo "${_decorated_error_description_message}"
+        && ${CMAKE_COMMAND} -E echo "${_decorated_reconfiguration_help_message}"
         && ${CMAKE_COMMAND} -E echo '***************************************************************************'
         && ${CMAKE_COMMAND} -E echo ''
         && ${CMAKE_COMMAND} -E echo ''
@@ -81,8 +92,8 @@ IF(NOT DEAL_II_COMPONENT_PACKAGE)
          ${CMAKE_COMMAND} -E echo ''
       && ${CMAKE_COMMAND} -E echo ''
       && ${CMAKE_COMMAND} -E echo '***************************************************************************'
-      && ${CMAKE_COMMAND} -E echo "**  Error: Could not generate binary package. The component is disabled."
-      && ${CMAKE_COMMAND} -E echo "**  Please reconfigure with -DDEAL_II_COMPONENT_PACKAGE=ON"
+      && ${CMAKE_COMMAND} -E echo '**  Error: Could not generate binary package. The component is disabled. **'
+      && ${CMAKE_COMMAND} -E echo '**        Please reconfigure with -DDEAL_II_COMPONENT_PACKAGE=ON         **'
       && ${CMAKE_COMMAND} -E echo '***************************************************************************'
       && ${CMAKE_COMMAND} -E echo ''
       && ${CMAKE_COMMAND} -E echo ''
index 349367e5873c4970fb6deb9d90e0b1d5bbab1ea3..b6822ccb240f5026e3552c7311ccbfcb725d0300 100644 (file)
@@ -24,7 +24,7 @@ EXECUTE_PROCESS(COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --outpu
 IF(NOT "${res_var}" STREQUAL "0")
   MESSAGE("
 ***************************************************************************
-**                 Error: Some of the quick tests failed.
+**                 Error: Some of the quick tests failed.                **
 ***************************************************************************
 
 Please scroll up or check the file tests/quick_tests/quicktests.log for the

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.