Move files into /cmake/ instead of a cppbessot subdir of it

This commit is contained in:
2026-02-28 03:14:01 -04:00
parent 6891210867
commit 621195044f
14 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,50 @@
cmake_minimum_required(VERSION 3.16)
if(NOT DEFINED CPPBESSOT_GIT_EXECUTABLE OR CPPBESSOT_GIT_EXECUTABLE STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_GIT_EXECUTABLE is required")
endif()
if(NOT DEFINED CPPBESSOT_WORKDIR_ABS OR CPPBESSOT_WORKDIR_ABS STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_WORKDIR_ABS is required")
endif()
if(NOT DEFINED CPPBESSOT_PROJECT_SOURCE_DIR OR CPPBESSOT_PROJECT_SOURCE_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_PROJECT_SOURCE_DIR is required")
endif()
execute_process(
COMMAND "${CPPBESSOT_GIT_EXECUTABLE}" -C "${CPPBESSOT_PROJECT_SOURCE_DIR}" rev-parse --show-toplevel
RESULT_VARIABLE _top_result
OUTPUT_VARIABLE _git_toplevel
ERROR_VARIABLE _top_stderr
)
if(NOT _top_result EQUAL 0)
message(FATAL_ERROR "git rev-parse failed while checking schema changes.\n${_top_stderr}")
endif()
string(STRIP "${_git_toplevel}" _git_toplevel)
file(RELATIVE_PATH _workdir_rel "${_git_toplevel}" "${CPPBESSOT_WORKDIR_ABS}")
if(_workdir_rel MATCHES "^\\.\\.")
set(_workdir_rel "${CPPBESSOT_WORKDIR_ABS}")
endif()
execute_process(
COMMAND "${CPPBESSOT_GIT_EXECUTABLE}" -C "${CPPBESSOT_PROJECT_SOURCE_DIR}" status --porcelain -- "${_workdir_rel}"
RESULT_VARIABLE _result
OUTPUT_VARIABLE _output
ERROR_VARIABLE _stderr
)
if(NOT _result EQUAL 0)
message(FATAL_ERROR "git status failed while checking schema changes.\n${_stderr}")
endif()
string(STRIP "${_output}" _output)
if(NOT _output STREQUAL "")
if(DEFINED DB_SCHEMA_CHANGES_ARE_ERROR AND DB_SCHEMA_CHANGES_ARE_ERROR)
message(SEND_ERROR
"Detected changes under `${CPPBESSOT_WORKDIR_ABS}`. Create a new schema version folder and regenerate artifacts.")
else()
message(WARNING
"Detected changes under `${CPPBESSOT_WORKDIR_ABS}`. Consider creating a new schema version folder and regenerating artifacts.")
endif()
endif()

View File

@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.16)
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
endif()
if(NOT DEFINED CPPBESSOT_VERSION_DIR OR CPPBESSOT_VERSION_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_VERSION_DIR is required")
endif()
set(_include_dir "${CPPBESSOT_VERSION_DIR}/generated-cpp-source/include")
file(GLOB _headers "${_include_dir}/*/model/*.h")
if(NOT _headers)
message(FATAL_ERROR "No model headers found under ${_include_dir}")
endif()
foreach(_backend IN ITEMS sqlite pgsql)
if(_backend STREQUAL "sqlite")
set(_subdir sqlite)
else()
set(_subdir postgre)
endif()
set(_out_dir "${CPPBESSOT_VERSION_DIR}/generated-odb-source/${_subdir}")
file(MAKE_DIRECTORY "${_out_dir}")
execute_process(
COMMAND "${CPPBESSOT_ODB_EXECUTABLE}" -I "${_include_dir}" --std c++11 -d "${_backend}" -q
-o "${_out_dir}" --changelog-dir "${_out_dir}" ${_headers}
RESULT_VARIABLE _result
OUTPUT_VARIABLE _stdout
ERROR_VARIABLE _stderr
)
if(NOT _result EQUAL 0)
message(FATAL_ERROR
"ODB ORM generation failed for backend `${_backend}`.\n${_stdout}\n${_stderr}")
endif()
endforeach()

View File

@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.16)
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
endif()
if(NOT DEFINED CPPBESSOT_FROM_VERSION_DIR OR CPPBESSOT_FROM_VERSION_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_FROM_VERSION_DIR is required")
endif()
if(NOT DEFINED CPPBESSOT_TO_VERSION_DIR OR CPPBESSOT_TO_VERSION_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_TO_VERSION_DIR is required")
endif()
if(NOT DEFINED CPPBESSOT_MIGRATION_DIR OR CPPBESSOT_MIGRATION_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_MIGRATION_DIR is required")
endif()
set(_to_include_dir "${CPPBESSOT_TO_VERSION_DIR}/generated-cpp-source/include")
file(GLOB _to_headers "${_to_include_dir}/*/model/*.h")
if(NOT _to_headers)
message(FATAL_ERROR "No target-version headers found under ${_to_include_dir}")
endif()
foreach(_backend IN ITEMS sqlite pgsql)
if(_backend STREQUAL "sqlite")
set(_subdir sqlite)
else()
set(_subdir postgre)
endif()
set(_migration_backend_dir "${CPPBESSOT_MIGRATION_DIR}/${_subdir}")
file(MAKE_DIRECTORY "${_migration_backend_dir}")
foreach(_header IN LISTS _to_headers)
get_filename_component(_name "${_header}" NAME_WE)
set(_in_xml "${CPPBESSOT_FROM_VERSION_DIR}/generated-odb-source/${_subdir}/${_name}.xml")
set(_out_xml "${CPPBESSOT_TO_VERSION_DIR}/generated-odb-source/${_subdir}/${_name}.xml")
if(NOT EXISTS "${_in_xml}")
message(FATAL_ERROR "Missing changelog input for `${_name}`: ${_in_xml}")
endif()
execute_process(
COMMAND "${CPPBESSOT_ODB_EXECUTABLE}" -I "${_to_include_dir}" --std c++11 -d "${_backend}"
--generate-schema --schema-format sql -q
-o "${_migration_backend_dir}"
--changelog-in "${_in_xml}"
--changelog-out "${_out_xml}"
"${_header}"
RESULT_VARIABLE _result
OUTPUT_VARIABLE _stdout
ERROR_VARIABLE _stderr
)
if(NOT _result EQUAL 0)
message(FATAL_ERROR
"Migration generation failed for `${_name}` backend `${_backend}`.\n${_stdout}\n${_stderr}")
endif()
endforeach()
endforeach()

View File

@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.16)
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
endif()
if(NOT DEFINED CPPBESSOT_VERSION_DIR OR CPPBESSOT_VERSION_DIR STREQUAL "")
message(FATAL_ERROR "CPPBESSOT_VERSION_DIR is required")
endif()
set(_include_dir "${CPPBESSOT_VERSION_DIR}/generated-cpp-source/include")
file(GLOB _headers "${_include_dir}/*/model/*.h")
if(NOT _headers)
message(FATAL_ERROR "No model headers found under ${_include_dir}")
endif()
foreach(_backend IN ITEMS sqlite pgsql)
if(_backend STREQUAL "sqlite")
set(_subdir sqlite)
else()
set(_subdir postgre)
endif()
set(_ddl_dir "${CPPBESSOT_VERSION_DIR}/generated-sql-ddl/${_subdir}")
set(_changelog_dir "${CPPBESSOT_VERSION_DIR}/generated-odb-source/${_subdir}")
file(MAKE_DIRECTORY "${_ddl_dir}")
file(MAKE_DIRECTORY "${_changelog_dir}")
execute_process(
COMMAND "${CPPBESSOT_ODB_EXECUTABLE}" -I "${_include_dir}" --std c++11 -d "${_backend}"
--generate-schema --schema-format sql -q
-o "${_ddl_dir}" --changelog-dir "${_changelog_dir}" ${_headers}
RESULT_VARIABLE _result
OUTPUT_VARIABLE _stdout
ERROR_VARIABLE _stderr
)
if(NOT _result EQUAL 0)
message(FATAL_ERROR
"ODB SQL DDL generation failed for backend `${_backend}`.\n${_stdout}\n${_stderr}")
endif()
endforeach()