Skip to content

Make CMake old-file cleanup safer/more specific #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmake/cppgraphqlgen-update-client-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ endforeach()

# Don't update the files in the source directory if no files were generated in the binary directory.
if(NOT FILE_NAMES)
message(FATAL_ERROR "Schema generation failed!")
message(FATAL_ERROR "Client generation failed!")
endif()

# Support if() IN_LIST operator: https://cmake.org/cmake/help/latest/policy/CMP0057.html
Expand All @@ -48,8 +48,10 @@ cmake_policy(SET CMP0057 NEW)
file(GLOB OLD_FILES ${CLIENT_SOURCE_DIR}/*.h ${CLIENT_SOURCE_DIR}/*.cpp)
foreach(OLD_FILE ${OLD_FILES})
get_filename_component(OLD_FILE ${OLD_FILE} NAME)
if(NOT OLD_FILE IN_LIST FILE_NAMES)
file(REMOVE "${CLIENT_SOURCE_DIR}/${OLD_FILE}")
if(NOT OLD_FILE IN_LIST FILE_NAMES AND
NOT OLD_FILE STREQUAL "${CLIENT_PREFIX}Client.h" AND
NOT OLD_FILE STREQUAL "${CLIENT_PREFIX}Client.cpp")
message(WARNING "Unexpected file in ${CLIENT_TARGET} client sources: ${OLD_FILE}")
endif()
endforeach()

Expand Down
7 changes: 6 additions & 1 deletion cmake/cppgraphqlgen-update-schema-files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.cpp)
foreach(OLD_FILE ${OLD_FILES})
get_filename_component(OLD_FILE ${OLD_FILE} NAME)
if(NOT OLD_FILE IN_LIST FILE_NAMES)
file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}")
if(OLD_FILE MATCHES "Object\\.h$" OR OLD_FILE MATCHES "Object\\.cpp$")
file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}")
elseif(NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.h" AND
NOT OLD_FILE STREQUAL "${SCHEMA_PREFIX}Schema.cpp")
message(WARNING "Unexpected file in ${SCHEMA_TARGET} GraphQL schema sources: ${OLD_FILE}")
endif()
endif()
endforeach()

Expand Down