]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make expand_instantiations more robust 2417/head
authorTimo Heister <timo.heister@gmail.com>
Sat, 26 Mar 2016 06:06:01 +0000 (07:06 +0100)
committerTimo Heister <timo.heister@gmail.com>
Sat, 26 Mar 2016 06:06:01 +0000 (07:06 +0100)
If the .inst.in files contains a mistake so that expand_instantiations
fails, the output will still be created and is then considered updated.
As a result, a second run of "make" happily continues without failing.
Fix this by creating a temporary file and only moving if the first call
succeededs.
Also make one error message more verbose.

cmake/macros/macro_expand_instantiations.cmake
cmake/scripts/expand_instantiations.cc

index d6bb62ab17f4239694d2aba52dea55870a12f2f8..775f1da261df6973cd3301e3d5c74d177f7dc33c 100644 (file)
@@ -45,6 +45,9 @@ MACRO(EXPAND_INSTANTIATIONS _target _inst_in_files)
       SET(_dependency)
     ENDIF()
 
+    # create a .inst.tmp file first and only move to the correct name if the
+    # first call succeeds. Otherwise we might be generating an incomplete
+    # .inst file
     ADD_CUSTOM_COMMAND(
       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}
       DEPENDS ${_dependency}
@@ -53,7 +56,11 @@ MACRO(EXPAND_INSTANTIATIONS _target _inst_in_files)
       COMMAND ${_command}
       ARGS ${CMAKE_BINARY_DIR}/${DEAL_II_SHARE_RELDIR}/template-arguments
            < ${CMAKE_CURRENT_SOURCE_DIR}/${_inst_in_file}
-           > ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}
+           > ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}.tmp
+      COMMAND ${CMAKE_COMMAND}
+      ARGS -E rename 
+           ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}.tmp
+           ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}
       )
 
     LIST(APPEND _inst_targets ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file})
index d63669dd98a601d1576e6102482e68fc9a90f1dd..01f114359649584a08b7382f6907040119583b28 100644 (file)
@@ -456,7 +456,7 @@ void process_instantiations ()
           names_and_type = split_string_list (*s, ':');
           if (names_and_type.size() != 2)
             {
-              std::cerr << "Invalid instantiation header" << std::endl;
+              std::cerr << "Invalid instantiation header: '"<< *s << "'" << std::endl;
               std::exit (1);
             }
 

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.