From 779b651a10e60d309a60ff7cd2d5124269fa21a7 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sat, 26 Mar 2016 07:06:01 +0100 Subject: [PATCH] make expand_instantiations more robust 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 | 9 ++++++++- cmake/scripts/expand_instantiations.cc | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/macros/macro_expand_instantiations.cmake b/cmake/macros/macro_expand_instantiations.cmake index d6bb62ab17..775f1da261 100644 --- a/cmake/macros/macro_expand_instantiations.cmake +++ b/cmake/macros/macro_expand_instantiations.cmake @@ -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}) diff --git a/cmake/scripts/expand_instantiations.cc b/cmake/scripts/expand_instantiations.cc index d63669dd98..01f1143596 100644 --- a/cmake/scripts/expand_instantiations.cc +++ b/cmake/scripts/expand_instantiations.cc @@ -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); } -- 2.39.5