Move mustache templates into Cppbessot main dir

This commit is contained in:
2026-02-28 04:13:44 -04:00
parent fd5541e057
commit 13da012766
6 changed files with 19 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake") include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake")
set(_CPPBESSOT_DB_GEN_CPP_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_add_db_gen_cpp_target version) function(cppbessot_add_db_gen_cpp_target version)
# Purpose: Register C++ model generation target using checked-in templates. # Purpose: Register C++ model generation target using checked-in templates.
@@ -12,9 +13,14 @@ function(cppbessot_add_db_gen_cpp_target version)
# - Files under `<version>/generated-cpp-source`. # - Files under `<version>/generated-cpp-source`.
cppbessot_validate_schema_version("${version}") cppbessot_validate_schema_version("${version}")
cppbessot_get_version_dir(_version_dir "${version}") cppbessot_get_version_dir(_version_dir "${version}")
if(DEFINED CPPBESSOT_MODULE_ROOT AND NOT "${CPPBESSOT_MODULE_ROOT}" STREQUAL "")
set(_module_root "${CPPBESSOT_MODULE_ROOT}")
else()
get_filename_component(_module_root "${_CPPBESSOT_DB_GEN_CPP_DIR}/.." ABSOLUTE)
endif()
set(_openapi_file "${_version_dir}/openapi/openapi.yaml") set(_openapi_file "${_version_dir}/openapi/openapi.yaml")
set(_template_dir "${_version_dir}/openapi/templates/cpp-odb-json") set(_template_dir "${_module_root}/openapi/templates/cpp-odb-json")
set(_template_config "${_template_dir}/config.yaml") set(_template_config "${_template_dir}/config.yaml")
set(_output_dir "${_version_dir}/generated-cpp-source") set(_output_dir "${_version_dir}/generated-cpp-source")

View File

@@ -1,6 +1,7 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake") include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake")
set(_CPPBESSOT_DB_GEN_MIGRATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_add_db_gen_migrations_target from_version to_version) function(cppbessot_add_db_gen_migrations_target from_version to_version)
# Purpose: Register migration SQL generation between two schema versions. # Purpose: Register migration SQL generation between two schema versions.
@@ -29,7 +30,7 @@ function(cppbessot_add_db_gen_migrations_target from_version to_version)
-DCPPBESSOT_FROM_VERSION_DIR=${_from_dir} -DCPPBESSOT_FROM_VERSION_DIR=${_from_dir}
-DCPPBESSOT_TO_VERSION_DIR=${_to_dir} -DCPPBESSOT_TO_VERSION_DIR=${_to_dir}
-DCPPBESSOT_MIGRATION_DIR=${_migration_dir} -DCPPBESSOT_MIGRATION_DIR=${_migration_dir}
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/run_odb_migrations.cmake" -P "${_CPPBESSOT_DB_GEN_MIGRATIONS_DIR}/scripts/run_odb_migrations.cmake"
COMMENT "Generating DB migrations: ${from_version} -> ${to_version}" COMMENT "Generating DB migrations: ${from_version} -> ${to_version}"
VERBATIM VERBATIM
) )

View File

@@ -1,6 +1,7 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake") include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake")
set(_CPPBESSOT_DB_GEN_ODB_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_add_db_gen_odb_target version) function(cppbessot_add_db_gen_odb_target version)
# Purpose: Register ODB ORM generation target for sqlite and postgre backends. # Purpose: Register ODB ORM generation target for sqlite and postgre backends.
@@ -17,7 +18,7 @@ function(cppbessot_add_db_gen_odb_target version)
COMMAND "${CMAKE_COMMAND}" COMMAND "${CMAKE_COMMAND}"
-DCPPBESSOT_ODB_EXECUTABLE=${CPPBESSOT_ODB_EXECUTABLE} -DCPPBESSOT_ODB_EXECUTABLE=${CPPBESSOT_ODB_EXECUTABLE}
-DCPPBESSOT_VERSION_DIR=${_version_dir} -DCPPBESSOT_VERSION_DIR=${_version_dir}
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/run_odb_logic.cmake" -P "${_CPPBESSOT_DB_GEN_ODB_DIR}/scripts/run_odb_logic.cmake"
DEPENDS db_gen_cpp_headers DEPENDS db_gen_cpp_headers
COMMENT "Generating ODB ORM sources for ${version} (sqlite + postgre)" COMMENT "Generating ODB ORM sources for ${version} (sqlite + postgre)"
VERBATIM VERBATIM

View File

@@ -1,6 +1,7 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake") include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake")
set(_CPPBESSOT_DB_GEN_SQL_DDL_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_add_db_gen_sql_ddl_target version) function(cppbessot_add_db_gen_sql_ddl_target version)
# Purpose: Register SQL DDL snapshot generation target for supported backends. # Purpose: Register SQL DDL snapshot generation target for supported backends.
@@ -17,7 +18,7 @@ function(cppbessot_add_db_gen_sql_ddl_target version)
COMMAND "${CMAKE_COMMAND}" COMMAND "${CMAKE_COMMAND}"
-DCPPBESSOT_ODB_EXECUTABLE=${CPPBESSOT_ODB_EXECUTABLE} -DCPPBESSOT_ODB_EXECUTABLE=${CPPBESSOT_ODB_EXECUTABLE}
-DCPPBESSOT_VERSION_DIR=${_version_dir} -DCPPBESSOT_VERSION_DIR=${_version_dir}
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/run_odb_sql_ddl.cmake" -P "${_CPPBESSOT_DB_GEN_SQL_DDL_DIR}/scripts/run_odb_sql_ddl.cmake"
DEPENDS db_gen_cpp_headers DEPENDS db_gen_cpp_headers
COMMENT "Generating SQL DDL snapshots for ${version} (sqlite + postgre)" COMMENT "Generating SQL DDL snapshots for ${version} (sqlite + postgre)"
VERBATIM VERBATIM

View File

@@ -4,6 +4,8 @@ if(NOT DEFINED CPPBESSOT_WORKDIR)
set(CPPBESSOT_WORKDIR "db" CACHE STRING "CppBeSSOT schema root folder, relative to PROJECT_SOURCE_DIR or absolute path") set(CPPBESSOT_WORKDIR "db" CACHE STRING "CppBeSSOT schema root folder, relative to PROJECT_SOURCE_DIR or absolute path")
endif() endif()
set(_CPPBESSOT_GENERATION_COMMON_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_abs_path out_var input_path) function(cppbessot_abs_path out_var input_path)
# Purpose: Resolve a path to an absolute path anchored at PROJECT_SOURCE_DIR # Purpose: Resolve a path to an absolute path anchored at PROJECT_SOURCE_DIR
# when the input is relative. # when the input is relative.
@@ -30,8 +32,8 @@ function(cppbessot_initialize_paths)
# - CPPBESSOT_CMAKE_DIR (PARENT_SCOPE): Absolute module directory path. # - CPPBESSOT_CMAKE_DIR (PARENT_SCOPE): Absolute module directory path.
# - CPPBESSOT_MODULE_ROOT (PARENT_SCOPE): Module root directory path. # - CPPBESSOT_MODULE_ROOT (PARENT_SCOPE): Module root directory path.
# - CPPBESSOT_WORKDIR_ABS (PARENT_SCOPE): Absolute schema root path. # - CPPBESSOT_WORKDIR_ABS (PARENT_SCOPE): Absolute schema root path.
get_filename_component(CPPBESSOT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) get_filename_component(CPPBESSOT_CMAKE_DIR "${_CPPBESSOT_GENERATION_COMMON_DIR}" ABSOLUTE)
get_filename_component(CPPBESSOT_MODULE_ROOT "${CPPBESSOT_CMAKE_DIR}/../.." ABSOLUTE) get_filename_component(CPPBESSOT_MODULE_ROOT "${CPPBESSOT_CMAKE_DIR}/.." ABSOLUTE)
cppbessot_abs_path(CPPBESSOT_WORKDIR_ABS "${CPPBESSOT_WORKDIR}") cppbessot_abs_path(CPPBESSOT_WORKDIR_ABS "${CPPBESSOT_WORKDIR}")
set(CPPBESSOT_CMAKE_DIR "${CPPBESSOT_CMAKE_DIR}" PARENT_SCOPE) set(CPPBESSOT_CMAKE_DIR "${CPPBESSOT_CMAKE_DIR}" PARENT_SCOPE)

View File

@@ -1,6 +1,7 @@
include_guard(GLOBAL) include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake") include("${CMAKE_CURRENT_LIST_DIR}/dbGenerationCommon.cmake")
set(_CPPBESSOT_DB_SCHEMA_CHECK_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(cppbessot_add_db_check_schema_changes_target) function(cppbessot_add_db_check_schema_changes_target)
# Purpose: Register a manual target that reports git-tracked schema changes. # Purpose: Register a manual target that reports git-tracked schema changes.
@@ -17,7 +18,7 @@ function(cppbessot_add_db_check_schema_changes_target)
-DCPPBESSOT_GIT_EXECUTABLE=${CPPBESSOT_GIT_EXECUTABLE} -DCPPBESSOT_GIT_EXECUTABLE=${CPPBESSOT_GIT_EXECUTABLE}
-DCPPBESSOT_WORKDIR_ABS=${_workdir} -DCPPBESSOT_WORKDIR_ABS=${_workdir}
-DCPPBESSOT_PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DCPPBESSOT_PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/check_schema_changes.cmake" -P "${_CPPBESSOT_DB_SCHEMA_CHECK_DIR}/scripts/check_schema_changes.cmake"
COMMENT "Checking for schema changes under ${CPPBESSOT_WORKDIR}" COMMENT "Checking for schema changes under ${CPPBESSOT_WORKDIR}"
VERBATIM VERBATIM
) )