From 8bb291bbd93dc411bc19e5dfac5b0fef39a71606 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 9 Oct 2024 09:15:18 -0500 Subject: [PATCH] updated build system --- cmake/versions.cmake | 12 +++--- scripts/options.sh | 2 +- .../include/utils/db/sqlite}/db_common.hpp | 38 +++++++------------ .../include/utils/db/sqlite}/db_delete.hpp | 16 ++++---- .../include/utils/db/sqlite}/db_insert.hpp | 14 ++++--- .../include/utils/db/sqlite}/db_select.hpp | 16 ++++---- .../include/utils/db/sqlite}/db_update.hpp | 16 ++++---- .../utils/db/sqlite}/db_where_limit_t.hpp | 14 ++++--- .../include/utils/db/sqlite}/db_where_t.hpp | 14 ++++--- .../src/utils/db/sqlite}/db_common.cpp | 10 +++-- .../src/utils/db/sqlite}/db_delete.cpp | 10 +++-- .../src/utils/db/sqlite}/db_insert.cpp | 10 +++-- .../src/utils/db/sqlite}/db_select.cpp | 10 +++-- .../src/utils/db/sqlite}/db_update.cpp | 10 +++-- 14 files changed, 107 insertions(+), 85 deletions(-) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_common.hpp (87%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_delete.hpp (82%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_insert.hpp (84%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_select.hpp (85%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_update.hpp (85%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_where_limit_t.hpp (94%) rename {repertory/librepertory/include/database => support/include/utils/db/sqlite}/db_where_t.hpp (93%) rename {repertory/librepertory/src/database => support/src/utils/db/sqlite}/db_common.cpp (89%) rename {repertory/librepertory/src/database => support/src/utils/db/sqlite}/db_delete.cpp (94%) rename {repertory/librepertory/src/database => support/src/utils/db/sqlite}/db_insert.cpp (94%) rename {repertory/librepertory/src/database => support/src/utils/db/sqlite}/db_select.cpp (96%) rename {repertory/librepertory/src/database => support/src/utils/db/sqlite}/db_update.cpp (96%) diff --git a/cmake/versions.cmake b/cmake/versions.cmake index fb10e730..aefb4bcb 100644 --- a/cmake/versions.cmake +++ b/cmake/versions.cmake @@ -1,15 +1,15 @@ set(BINUTILS_VERSION 2.41) -set(BOOST2_MAJOR_VERSION 1) -set(BOOST2_MINOR_VERSION 76) -set(BOOST2_PATCH_VERSION 0) set(BOOST_MAJOR_VERSION 1) set(BOOST_MINOR_VERSION 85) set(BOOST_PATCH_VERSION 0) +set(BOOST2_MAJOR_VERSION 1) +set(BOOST2_MINOR_VERSION 76) +set(BOOST2_PATCH_VERSION 0) set(CPP_HTTPLIB_VERSION 0.16.3) -set(CURL2_VERSION 8_9_1) set(CURL_VERSION 8.9.1) -set(EXPAT2_VERSION 2_6_2) +set(CURL2_VERSION 8_9_1) set(EXPAT_VERSION 2.6.2) +set(EXPAT2_VERSION 2_6_2) set(GCC_VERSION 14.2.0) set(GTEST_VERSION 1.15.2) set(ICU_VERSION 75-1) @@ -21,7 +21,7 @@ set(OPENSSL_VERSION 3.3.1) set(PKG_CONFIG_VERSION 0.29.2) set(PUGIXML_VERSION 1.14) set(SPDLOG_VERSION 1.14.1) -set(SQLITE2_VERSION 3.46.1) set(SQLITE_VERSION 3460100) +set(SQLITE2_VERSION 3.46.1) set(STDUUID_VERSION 1.2.3) set(ZLIB_VERSION 1.3.1) diff --git a/scripts/options.sh b/scripts/options.sh index 6a24e91b..2170d5b6 100755 --- a/scripts/options.sh +++ b/scripts/options.sh @@ -26,7 +26,7 @@ PROJECT_CLEANUP[LIBSODIUM]="3rd_party/libsodium-*:3rd_party/libsodium*" PROJECT_CLEANUP[OPENSSL]="3rd_party/openssl-*" PROJECT_CLEANUP[PUGIXML]="3rd_party/pugixml-*" PROJECT_CLEANUP[SPDLOG]="3rd_party/spdlog-*" -PROJECT_CLEANUP[SQLITE]="3rd_party/sqlite*" +PROJECT_CLEANUP[SQLITE]="3rd_party/sqlite*:include/utils/db:src/utils/db" PROJECT_CLEANUP[STDUUID]="3rd_party/stduuid-*" PROJECT_CLEANUP[TESTING]="3rd_party/googletest-*" PROJECT_CLEANUP[WINFSP]="3rd_party/winfsp-*" diff --git a/repertory/librepertory/include/database/db_common.hpp b/support/include/utils/db/sqlite/db_common.hpp similarity index 87% rename from repertory/librepertory/include/database/db_common.hpp rename to support/include/utils/db/sqlite/db_common.hpp index 19dcb493..ea02ba17 100644 --- a/repertory/librepertory/include/database/db_common.hpp +++ b/support/include/utils/db/sqlite/db_common.hpp @@ -19,12 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_COMMON_HPP_ -#define INCLUDE_DATABASE_DB_COMMON_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "utils/error_utils.hpp" - -namespace repertory::db { +namespace repertory::utils::db::sqlite { using db_types_t = std::variant; struct sqlite3_deleter { @@ -187,14 +186,7 @@ private: mutable std::int32_t res_; private: - void set_res(std::int32_t res, std::string_view function) const { - if (res != SQLITE_OK && res != SQLITE_DONE && res != SQLITE_ROW) { - utils::error::raise_error(function, "failed to step|" + - std::to_string(res) + '|' + - sqlite3_errstr(res)); - } - res_ = res; - } + void set_res(std::int32_t res) const { res_ = res; } public: [[nodiscard]] auto ok() const -> bool { @@ -208,30 +200,28 @@ public: } [[nodiscard]] auto get_row(std::optional> &row) const -> bool { - constexpr const auto *function_name = - static_cast(__FUNCTION__); - row.reset(); + if (not has_row()) { return false; } row = db_row{context_}; - set_res(sqlite3_step(context_->stmt.get()), function_name); + set_res(sqlite3_step(context_->stmt.get())); return true; } [[nodiscard]] auto has_row() const -> bool { return res_ == SQLITE_ROW; } void next_row() const { - constexpr const auto *function_name = - static_cast(__FUNCTION__); - - if (has_row()) { - set_res(sqlite3_step(context_->stmt.get()), function_name); + if (not has_row()) { + return; } + + set_res(sqlite3_step(context_->stmt.get())); } }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_COMMON_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_ diff --git a/repertory/librepertory/include/database/db_delete.hpp b/support/include/utils/db/sqlite/db_delete.hpp similarity index 82% rename from repertory/librepertory/include/database/db_delete.hpp rename to support/include/utils/db/sqlite/db_delete.hpp index a986bb04..9cf8984f 100644 --- a/repertory/librepertory/include/database/db_delete.hpp +++ b/support/include/utils/db/sqlite/db_delete.hpp @@ -19,14 +19,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_DELETE_HPP_ -#define INCLUDE_DATABASE_DB_DELETE_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -#include "database/db_where_t.hpp" +#include "utils/db/sqlite/db_where_t.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { class db_delete final { public: struct context final : db_context_t { @@ -59,6 +60,7 @@ public: [[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t; }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_DELETE_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_ diff --git a/repertory/librepertory/include/database/db_insert.hpp b/support/include/utils/db/sqlite/db_insert.hpp similarity index 84% rename from repertory/librepertory/include/database/db_insert.hpp rename to support/include/utils/db/sqlite/db_insert.hpp index 34d81af2..95770249 100644 --- a/repertory/librepertory/include/database/db_insert.hpp +++ b/support/include/utils/db/sqlite/db_insert.hpp @@ -19,12 +19,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_INSERT_HPP_ -#define INCLUDE_DATABASE_DB_INSERT_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { class db_insert final { public: struct context final : db_context_t { @@ -59,6 +60,7 @@ public: [[nodiscard]] auto go() const -> db_result; }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_INSERT_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_ diff --git a/repertory/librepertory/include/database/db_select.hpp b/support/include/utils/db/sqlite/db_select.hpp similarity index 85% rename from repertory/librepertory/include/database/db_select.hpp rename to support/include/utils/db/sqlite/db_select.hpp index 8beb9e99..e5fd47d9 100644 --- a/repertory/librepertory/include/database/db_select.hpp +++ b/support/include/utils/db/sqlite/db_select.hpp @@ -19,14 +19,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_SELECT_HPP_ -#define INCLUDE_DATABASE_DB_SELECT_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_SELECT_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_SELECT_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -#include "database/db_where_limit_t.hpp" +#include "utils/db/sqlite/db_where_limit_t.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { class db_select final { public: struct context final : db_context_t { @@ -73,6 +74,7 @@ public: [[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t; }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_SELECT_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_SELECT_HPP_ diff --git a/repertory/librepertory/include/database/db_update.hpp b/support/include/utils/db/sqlite/db_update.hpp similarity index 85% rename from repertory/librepertory/include/database/db_update.hpp rename to support/include/utils/db/sqlite/db_update.hpp index 7608a2fc..b44279ca 100644 --- a/repertory/librepertory/include/database/db_update.hpp +++ b/support/include/utils/db/sqlite/db_update.hpp @@ -19,14 +19,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_UPDATE_HPP_ -#define INCLUDE_DATABASE_DB_UPDATE_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -#include "database/db_where_limit_t.hpp" +#include "utils/db/sqlite/db_where_limit_t.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { class db_update final { public: struct context final : db_context_t { @@ -70,6 +71,7 @@ public: [[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t; }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_UPDATE_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_UPDATE_HPP_ diff --git a/repertory/librepertory/include/database/db_where_limit_t.hpp b/support/include/utils/db/sqlite/db_where_limit_t.hpp similarity index 94% rename from repertory/librepertory/include/database/db_where_limit_t.hpp rename to support/include/utils/db/sqlite/db_where_limit_t.hpp index baa7d580..f3545ed2 100644 --- a/repertory/librepertory/include/database/db_where_limit_t.hpp +++ b/support/include/utils/db/sqlite/db_where_limit_t.hpp @@ -19,12 +19,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_ -#define INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_LIMIT_T_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_LIMIT_T_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { template struct db_next_limit_t final { @@ -209,6 +210,7 @@ template struct db_where_with_limit_t final { }; } }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_WHERE_LIMIT_T_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_LIMIT_T_HPP_ diff --git a/repertory/librepertory/include/database/db_where_t.hpp b/support/include/utils/db/sqlite/db_where_t.hpp similarity index 93% rename from repertory/librepertory/include/database/db_where_t.hpp rename to support/include/utils/db/sqlite/db_where_t.hpp index ea729e5a..98381ac1 100644 --- a/repertory/librepertory/include/database/db_where_t.hpp +++ b/support/include/utils/db/sqlite/db_where_t.hpp @@ -19,12 +19,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_DATABASE_DB_WHERE_T_HPP_ -#define INCLUDE_DATABASE_DB_WHERE_T_HPP_ +#ifndef REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_ +#define REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_ +#if defined(PROJECT_ENABLE_SQLITE) -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -namespace repertory::db { +namespace repertory::utils::db::sqlite { template struct db_next_t final { @@ -185,6 +186,7 @@ template struct db_where_t final { }; } }; -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite -#endif // INCLUDE_DATABASE_DB_WHERE_T_HPP_ +#endif // defined(PROJECT_ENABLE_SQLITE) +#endif // REPERTORY_INCLUDE_UTILS_DB_SQLITE_DB_WHERE_T_HPP_ diff --git a/repertory/librepertory/src/database/db_common.cpp b/support/src/utils/db/sqlite/db_common.cpp similarity index 89% rename from repertory/librepertory/src/database/db_common.cpp rename to support/src/utils/db/sqlite/db_common.cpp index 7c8be381..dc7d8eee 100644 --- a/repertory/librepertory/src/database/db_common.cpp +++ b/support/src/utils/db/sqlite/db_common.cpp @@ -19,9 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "database/db_common.hpp" +#include "utils/db/sqlite/db_common.hpp" -namespace repertory::db { +#if defined(PROJECT_ENABLE_SQLITE) + +namespace repertory::utils::db::sqlite { auto execute_sql(sqlite3 &db3, const std::string &sql, std::string &err) -> bool { char *err_msg{nullptr}; @@ -45,4 +47,6 @@ void set_journal_mode(sqlite3 &db3) { sqlite3_exec(&db3, "PRAGMA journal_mode = WAL;PRAGMA synchronous = NORMAL;", nullptr, nullptr, nullptr); } -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite + +#endif // defined(PROJECT_ENABLE_SQLITE) diff --git a/repertory/librepertory/src/database/db_delete.cpp b/support/src/utils/db/sqlite/db_delete.cpp similarity index 94% rename from repertory/librepertory/src/database/db_delete.cpp rename to support/src/utils/db/sqlite/db_delete.cpp index 2749742c..7b5a0718 100644 --- a/repertory/librepertory/src/database/db_delete.cpp +++ b/support/src/utils/db/sqlite/db_delete.cpp @@ -19,9 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "database/db_delete.hpp" +#include "utils/db/sqlite/db_delete.hpp" -namespace repertory::db { +#if defined(PROJECT_ENABLE_SQLITE) + +namespace repertory::utils::db::sqlite { auto db_delete::dump() const -> std::string { std::stringstream query; query << "DELETE FROM \"" << context_->table_name << "\""; @@ -92,4 +94,6 @@ auto db_delete::where(std::string column_name) const -> context::w_t::cn_t { return context_->where->where(column_name); } -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite + +#endif // defined(PROJECT_ENABLE_SQLITE) diff --git a/repertory/librepertory/src/database/db_insert.cpp b/support/src/utils/db/sqlite/db_insert.cpp similarity index 94% rename from repertory/librepertory/src/database/db_insert.cpp rename to support/src/utils/db/sqlite/db_insert.cpp index 7b3ab5ce..1978c7cc 100644 --- a/repertory/librepertory/src/database/db_insert.cpp +++ b/support/src/utils/db/sqlite/db_insert.cpp @@ -19,9 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "database/db_insert.hpp" +#include "utils/db/sqlite/db_insert.hpp" -namespace repertory::db { +#if defined(PROJECT_ENABLE_SQLITE) + +namespace repertory::utils::db::sqlite { auto db_insert::column_value(std::string column_name, db_types_t value) -> db_insert & { context_->values[column_name] = value; @@ -97,4 +99,6 @@ auto db_insert::go() const -> db_result { return {context_, res}; } -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite + +#endif // defined(PROJECT_ENABLE_SQLITE) diff --git a/repertory/librepertory/src/database/db_select.cpp b/support/src/utils/db/sqlite/db_select.cpp similarity index 96% rename from repertory/librepertory/src/database/db_select.cpp rename to support/src/utils/db/sqlite/db_select.cpp index 7bbcf2b7..2b34ee7e 100644 --- a/repertory/librepertory/src/database/db_select.cpp +++ b/support/src/utils/db/sqlite/db_select.cpp @@ -19,9 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "database/db_select.hpp" +#include "utils/db/sqlite/db_select.hpp" -namespace repertory::db { +#if defined(PROJECT_ENABLE_SQLITE) + +namespace repertory::utils::db::sqlite { auto db_select::column(std::string column_name) -> db_select & { context_->columns.push_back(column_name); return *this; @@ -149,4 +151,6 @@ auto db_select::where(std::string column_name) const -> context::w_t::cn_t { return context_->where->where(column_name); } -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite + +#endif // defined(PROJECT_ENABLE_SQLITE) diff --git a/repertory/librepertory/src/database/db_update.cpp b/support/src/utils/db/sqlite/db_update.cpp similarity index 96% rename from repertory/librepertory/src/database/db_update.cpp rename to support/src/utils/db/sqlite/db_update.cpp index 8c049b50..f939f60d 100644 --- a/repertory/librepertory/src/database/db_update.cpp +++ b/support/src/utils/db/sqlite/db_update.cpp @@ -19,9 +19,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "database/db_update.hpp" +#include "utils/db/sqlite/db_update.hpp" -namespace repertory::db { +#if defined(PROJECT_ENABLE_SQLITE) + +namespace repertory::utils::db::sqlite { auto db_update::column_value(std::string column_name, db_types_t value) -> db_update & { context_->column_values[column_name] = value; @@ -159,4 +161,6 @@ auto db_update::where(std::string column_name) const -> context::w_t::cn_t { return context_->where->where(column_name); } -} // namespace repertory::db +} // namespace repertory::utils::db::sqlite + +#endif // defined(PROJECT_ENABLE_SQLITE)