mirror of
https://github.com/latentPrion/cppbessot.git
synced 2026-06-23 15:18:37 +00:00
Something from adversarial review
This commit is contained in:
@@ -20,7 +20,7 @@ function(cppbessot_add_db_gen_zod_target schema_dir)
|
||||
|
||||
add_custom_target(db_gen_zod
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${_output_dir}"
|
||||
COMMAND "${CPPBESSOT_NPX_EXECUTABLE}" --no-install openapi-zod-client
|
||||
COMMAND "${CPPBESSOT_NPX_EXECUTABLE}" --yes openapi-zod-client
|
||||
"${_openapi_file}"
|
||||
--output "${_output_file}"
|
||||
--export-schemas
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
function(cppbessot_odb_find_object_headers out_var include_dir)
|
||||
file(GLOB _headers "${include_dir}/*/model/*.h")
|
||||
if(NOT _headers)
|
||||
message(FATAL_ERROR "No model headers found under ${include_dir}")
|
||||
endif()
|
||||
|
||||
set(_object_headers "")
|
||||
foreach(_header IN LISTS _headers)
|
||||
file(READ "${_header}" _header_contents)
|
||||
if(_header_contents MATCHES "#pragma db object")
|
||||
list(APPEND _object_headers "${_header}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT _object_headers)
|
||||
message(FATAL_ERROR "No ODB object headers found under ${include_dir}")
|
||||
endif()
|
||||
|
||||
set(${out_var} "${_object_headers}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cppbessotOdbHeaderDiscovery.cmake")
|
||||
|
||||
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
|
||||
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
|
||||
@@ -8,10 +9,7 @@ if(NOT DEFINED CPPBESSOT_VERSION_DIR OR CPPBESSOT_VERSION_DIR STREQUAL "")
|
||||
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()
|
||||
cppbessot_odb_find_object_headers(_object_headers "${_include_dir}")
|
||||
|
||||
foreach(_backend IN ITEMS sqlite pgsql)
|
||||
if(_backend STREQUAL "sqlite")
|
||||
@@ -25,7 +23,7 @@ foreach(_backend IN ITEMS sqlite pgsql)
|
||||
|
||||
execute_process(
|
||||
COMMAND "${CPPBESSOT_ODB_EXECUTABLE}" -I "${_include_dir}" --std c++11 -d "${_backend}" -q
|
||||
-o "${_out_dir}" --changelog-dir "${_out_dir}" ${_headers}
|
||||
-o "${_out_dir}" --changelog-dir "${_out_dir}" ${_object_headers}
|
||||
RESULT_VARIABLE _result
|
||||
OUTPUT_VARIABLE _stdout
|
||||
ERROR_VARIABLE _stderr
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cppbessotOdbHeaderDiscovery.cmake")
|
||||
|
||||
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
|
||||
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
|
||||
@@ -89,22 +90,7 @@ endfunction()
|
||||
cppbessot_migration_resolve_backends(_migration_backends)
|
||||
|
||||
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()
|
||||
|
||||
set(_object_headers "")
|
||||
foreach(_header IN LISTS _to_headers)
|
||||
file(READ "${_header}" _header_contents)
|
||||
if(_header_contents MATCHES "#pragma db object")
|
||||
list(APPEND _object_headers "${_header}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT _object_headers)
|
||||
message(FATAL_ERROR "No ODB object headers found under ${_to_include_dir}")
|
||||
endif()
|
||||
cppbessot_odb_find_object_headers(_object_headers "${_to_include_dir}")
|
||||
|
||||
set(_empty_changelog_dir "${CPPBESSOT_MIGRATION_DIR}/.empty-baseline")
|
||||
file(MAKE_DIRECTORY "${_empty_changelog_dir}")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cppbessotOdbHeaderDiscovery.cmake")
|
||||
|
||||
if(NOT DEFINED CPPBESSOT_ODB_EXECUTABLE OR CPPBESSOT_ODB_EXECUTABLE STREQUAL "")
|
||||
message(FATAL_ERROR "CPPBESSOT_ODB_EXECUTABLE is required")
|
||||
@@ -8,10 +9,7 @@ if(NOT DEFINED CPPBESSOT_VERSION_DIR OR CPPBESSOT_VERSION_DIR STREQUAL "")
|
||||
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()
|
||||
cppbessot_odb_find_object_headers(_object_headers "${_include_dir}")
|
||||
|
||||
foreach(_backend IN ITEMS sqlite pgsql)
|
||||
if(_backend STREQUAL "sqlite")
|
||||
@@ -28,7 +26,7 @@ foreach(_backend IN ITEMS sqlite pgsql)
|
||||
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}
|
||||
-o "${_ddl_dir}" --changelog-dir "${_changelog_dir}" ${_object_headers}
|
||||
RESULT_VARIABLE _result
|
||||
OUTPUT_VARIABLE _stdout
|
||||
ERROR_VARIABLE _stderr
|
||||
|
||||
Reference in New Issue
Block a user