mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Keep pyexpander generated files out of build directory
The previous behavior of the pyexpander check (in VTKmCheckPyexpander.cmake) was to generate the file in the binary directory and then remove it from there iff the check failed. This caused two problems. The first is that if the check failed then the file was deleted and there was no file to copy to the source as the instructions suggested. The second is that if the check succeeded the build would then use the files in the build directory rather than the source directory, and if the programmer accidently modified the binary files (because, for example, if a build error occured there), the configure system would not catch that. This change in behavior was that if the check failed, the file is renamed to have a .save extension so that the file remains and can be easily copied back to the source directory if that is appropriate. If the check succeeds, the generated file is removed and a file with the extension .check is touched. That .check file is used as a make target to signal that the test has been performed.
This commit is contained in:
parent
1f587a32a9
commit
d91f66acab
@ -63,9 +63,22 @@ execute_process(
|
||||
|
||||
if(${diff_result})
|
||||
# If diff returned non-zero, it failed and the two files are different.
|
||||
file(REMOVE ${GENERATED_FILE})
|
||||
get_filename_component(filename ${SOURCE_FILE} NAME)
|
||||
# Move the generated file so that the build does not confuse it with the
|
||||
# files in the source directory.
|
||||
file(REMOVE ${GENERATED_FILE}.save)
|
||||
file(RENAME ${GENERATED_FILE} ${GENERATED_FILE}.save)
|
||||
message(SEND_ERROR
|
||||
"The source file ${filename} does not match the generated file. If you have modified this file directly, then you have messed up. Modify the ${filename}.in file instead and then copy the pyexpander result to ${filename}. If you modified ${filename}.in, then you might just need to copy the pyresult back to the source directory. If you have not modifed either, then you have likely checked out an inappropriate change. Check the git logs to see what changes were made.
|
||||
If the changes have resulted from modifying ${filename}.in, then you can finish by copying ${GENERATED_FILE} to ${SOURCE_FILE}.")
|
||||
If the changes have resulted from modifying ${filename}.in, then you can finish by moving ${GENERATED_FILE}.save over ${SOURCE_FILE}")
|
||||
else()
|
||||
# Now that we have done the comparison, remove the generated file so there is
|
||||
# no confusion between the generated files and the source files checked into
|
||||
# the repository.
|
||||
file(REMOVE ${GENERATED_FILE})
|
||||
# Pyexpander successfully checked, so touch a file to tell make when the
|
||||
# check was last successfully performed.
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${GENERATED_FILE}.checked
|
||||
)
|
||||
endif()
|
||||
|
@ -135,7 +135,7 @@ function(vtkm_pyexpander_generated_file generated_file_name)
|
||||
# If pyexpander is available, add targets to build and check
|
||||
if(PYEXPANDER_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}.checked
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPYEXPANDER_COMMAND=${PYEXPANDER_COMMAND}
|
||||
-DSOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${generated_file_name}
|
||||
@ -143,10 +143,10 @@ function(vtkm_pyexpander_generated_file generated_file_name)
|
||||
-P ${CMAKE_SOURCE_DIR}/CMake/VTKmCheckPyexpander.cmake
|
||||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${generated_file_name}.in
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${generated_file_name}
|
||||
COMMENT "Checking validity of ${generated_file_name}"
|
||||
)
|
||||
add_custom_target(check_${generated_file_name} ALL
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}
|
||||
COMMENT "Checking validity of ${generated_file_name}"
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}.checked
|
||||
)
|
||||
endif()
|
||||
endfunction(vtkm_pyexpander_generated_file)
|
||||
|
Loading…
Reference in New Issue
Block a user