mirror of
https://github.com/latentPrion/cppbessot.git
synced 2026-04-17 18:44:23 +00:00
Add auto-generation notices for generated files
This directs new devs to look for the source files instead of wasting time editing generated files.
This commit is contained in:
20
cmake/scripts/prepend_cppbessot_notice.cmake
Normal file
20
cmake/scripts/prepend_cppbessot_notice.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
if(NOT DEFINED CPPBESSOT_TARGET_FILE OR "${CPPBESSOT_TARGET_FILE}" STREQUAL "")
|
||||
message(FATAL_ERROR "CPPBESSOT_TARGET_FILE is required")
|
||||
endif()
|
||||
|
||||
# Some CMake command invocations can pass wrapped quotes through -D values.
|
||||
set(_target_file "${CPPBESSOT_TARGET_FILE}")
|
||||
string(REGEX REPLACE "^\"(.*)\"$" "\\1" _target_file "${_target_file}")
|
||||
|
||||
if(NOT EXISTS "${_target_file}")
|
||||
message(FATAL_ERROR "Target file does not exist: ${_target_file}")
|
||||
endif()
|
||||
|
||||
file(READ "${_target_file}" _content)
|
||||
|
||||
if(_content MATCHES "AUTO-GENERATED BY CppBeSsot")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(_notice "/*\n * AUTO-GENERATED BY CppBeSsot.\n * Direct edits are pointless: this file is regenerated.\n * Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.\n */\n\n")
|
||||
file(WRITE "${_target_file}" "${_notice}${_content}")
|
||||
Reference in New Issue
Block a user