diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 2717c4a7..35f88b65 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -12,6 +12,16 @@ FetchContent_Declare( URL https://github.com/skypjack/entt/archive/master.zip ) +FetchContent_Declare( + loguru + URL https://github.com/emilk/loguru/archive/v2.1.0.zip +) + +FetchContent_Declare( + fmt + URL https://github.com/fmtlib/fmt/releases/download/6.0.0/fmt-6.0.0.zip +) + FetchContent_Declare( doom_st URL https://github.com/doom/strong_type/archive/1.0.2.tar.gz @@ -89,7 +99,7 @@ if (USE_SDL_ANTARA_WRAPPER) ) endif () -FetchContent_MakeAvailable(doctest entt doom_st expected range-v3 refl-cpp doom_meta nlohmann_json joboccara-pipes) +FetchContent_MakeAvailable(doctest entt doom_st expected range-v3 refl-cpp doom_meta nlohmann_json joboccara-pipes loguru fmt) if (USE_SFML_ANTARA_WRAPPER) FetchContent_MakeAvailable(SFML) endif () @@ -112,6 +122,12 @@ if (USE_SDL_ANTARA_WRAPPER) ) endif () +add_library(antara_log INTERFACE) +target_sources(antara_log INTERFACE ${loguru_SOURCE_DIR}/loguru.cpp) +target_include_directories(antara_log INTERFACE ${loguru_SOURCE_DIR}) +target_link_libraries(antara_log INTERFACE fmt::fmt) +add_library(antara::log ALIAS antara_log) + add_library(nlohmann_json INTERFACE) target_include_directories(nlohmann_json INTERFACE ${nlohmann_json_SOURCE_DIR}) add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index f1f4f103..3753cc1b 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -10,6 +10,7 @@ add_subdirectory(geometry) add_subdirectory(ecs) add_subdirectory(collisions) add_subdirectory(resources) +add_subdirectory(blockchain) add_subdirectory(scenes) add_subdirectory(world) diff --git a/modules/blockchain/CMakeLists.txt b/modules/blockchain/CMakeLists.txt new file mode 100644 index 00000000..ce016e7a --- /dev/null +++ b/modules/blockchain/CMakeLists.txt @@ -0,0 +1,38 @@ +add_library(antara_nspv STATIC) +target_sources(antara_nspv PRIVATE antara/gaming/blockchain/nspv.system.cpp) +target_include_directories(antara_nspv PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(antara_nspv PUBLIC antara::default_settings antara::ecs) +add_library(antara::nspv ALIAS antara_nspv) + +if (ANTARA_BUILD_UNIT_TESTS) + ##! antara blockchain tests + add_executable(antara_blockchain_tests) + target_link_libraries(antara_blockchain_tests PRIVATE doctest PUBLIC antara::nspv) + target_sources(antara_blockchain_tests PRIVATE + antara/gaming/blockchain/antara.blockchain.tests.cpp + antara/gaming/blockchain/nspv.system.tests.cpp) + set_target_properties(antara_blockchain_tests + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/unit_tests" + ) + + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR}/bin/unit_tests/nspv/) + + + target_enable_coverage(antara_blockchain_tests) + target_enable_tsan(antara_blockchain_tests) + target_enable_asan(antara_blockchain_tests) + target_enable_ubsan(antara_blockchain_tests) + + if (EMSCRIPTEN) + message(STATUS "Emscripten detected") + if (ENABLE_HTML_COMPILATION) + message(STATUS "Html compilation enabled") + set_target_properties(antara_blockchain_tests PROPERTIES LINK_FLAGS "-s FORCE_FILESYSTEM=1 -s EXIT_RUNTIME=1" + SUFFIX ".html") + else () + message(STATUS "Local js compilation") + set_target_properties(antara_blockchain_tests PROPERTIES LINK_FLAGS "-s FORCE_FILESYSTEM=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1") + endif () + endif () +endif () \ No newline at end of file diff --git a/modules/blockchain/antara/gaming/blockchain/antara.blockchain.tests.cpp b/modules/blockchain/antara/gaming/blockchain/antara.blockchain.tests.cpp new file mode 100644 index 00000000..caa05e4d --- /dev/null +++ b/modules/blockchain/antara/gaming/blockchain/antara.blockchain.tests.cpp @@ -0,0 +1,18 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include \ No newline at end of file diff --git a/modules/blockchain/antara/gaming/blockchain/nspv.system.cpp b/modules/blockchain/antara/gaming/blockchain/nspv.system.cpp new file mode 100644 index 00000000..bdc6d852 --- /dev/null +++ b/modules/blockchain/antara/gaming/blockchain/nspv.system.cpp @@ -0,0 +1,21 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include + +namespace antara::gaming::blockchain +{ +} \ No newline at end of file diff --git a/modules/blockchain/antara/gaming/blockchain/nspv.system.hpp b/modules/blockchain/antara/gaming/blockchain/nspv.system.hpp new file mode 100644 index 00000000..123e5088 --- /dev/null +++ b/modules/blockchain/antara/gaming/blockchain/nspv.system.hpp @@ -0,0 +1,40 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +namespace antara::gaming::blockchain { + class nspv final : public ecs::logic_update_system { + public: + nspv(entt::registry ®istry, + std::filesystem::path tools_path = antara::gaming::core::assets_real_path() / "tools") noexcept + : system(registry), tools_path_(std::move(tools_path)) { + this->disable(); + } + + void update() noexcept final {} + + private: + std::filesystem::path tools_path_; + }; +} + +REFL_AUTO(type(antara::gaming::blockchain::nspv)) \ No newline at end of file diff --git a/modules/blockchain/antara/gaming/blockchain/nspv.system.tests.cpp b/modules/blockchain/antara/gaming/blockchain/nspv.system.tests.cpp new file mode 100644 index 00000000..77a09c77 --- /dev/null +++ b/modules/blockchain/antara/gaming/blockchain/nspv.system.tests.cpp @@ -0,0 +1,31 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include +#include "nspv.system.hpp" + +namespace antara::gaming::blockchain::tests +{ + TEST_CASE("nspv system creation") + { + entt::registry entity_registry; + [[ maybe_unused ]] entt::dispatcher& dispatcher{entity_registry.set()}; + antara::gaming::ecs::system_manager mgr{entity_registry}; + + auto& nspv_system = mgr.create_system(std::filesystem::current_path() / "nspv/assets/tools"); + } +} \ No newline at end of file diff --git a/modules/blockchain/assets/tools/.gitkeep b/modules/blockchain/assets/tools/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/world/CMakeLists.txt b/modules/world/CMakeLists.txt index 680311bc..642d6a7f 100644 --- a/modules/world/CMakeLists.txt +++ b/modules/world/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(antara_world_shared_sources STATIC) target_sources(antara_world_shared_sources PRIVATE antara/gaming/world/world.app.cpp) target_include_directories(antara_world_shared_sources PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(antara_world_shared_sources PUBLIC antara::config antara::core antara::ecs) +target_link_libraries(antara_world_shared_sources PUBLIC antara::config antara::core antara::ecs antara::log) if (EMSCRIPTEN) if (ENABLE_HTML_COMPILATION) target_compile_definitions(antara_world_shared_sources PUBLIC EMSCRIPTEN_ONLY_WEB) diff --git a/modules/world/antara/gaming/world/world.app.cpp b/modules/world/antara/gaming/world/world.app.cpp index 7339eb94..d9b7e805 100644 --- a/modules/world/antara/gaming/world/world.app.cpp +++ b/modules/world/antara/gaming/world/world.app.cpp @@ -18,6 +18,9 @@ #include #endif +#define LOGURU_USE_FMTLIB 1 + +#include #include "antara/gaming/core/real.path.hpp" #include "antara/gaming/config/config.loading.hpp" #include "antara/gaming/config/config.game.maker.hpp" @@ -25,16 +28,14 @@ #include "antara/gaming/world/world.app.hpp" //LCOV_EXCL_START -void emscripten_antara_loop(void *world) -{ +void emscripten_antara_loop(void *world) { static_cast(world)->process_one_frame(); } //LCOV_EXCL_STOP -namespace antara::gaming::world -{ +namespace antara::gaming::world { //! Constructor - app::app(std::string config_maker_name) noexcept - { + app::app(std::string config_maker_name) noexcept { + LOG_SCOPE_FUNCTION(INFO); auto cfg_maker = config::load_configuration(core::assets_real_path() / "config", std::move(config_maker_name)); auto &canvas_2d_cmp = this->entity_registry_.set(cfg_maker); @@ -43,8 +44,8 @@ namespace antara::gaming::world } //! Public callbacks - void app::receive_quit_game(const event::quit_game &evt) noexcept - { + void app::receive_quit_game(const event::quit_game &evt) noexcept { + LOG_SCOPE_FUNCTION(INFO); this->is_running_ = false; this->game_return_value_ = evt.return_value_; //LCOV_EXCL_START @@ -54,8 +55,8 @@ namespace antara::gaming::world //LCOV_EXCL_STOP } - int app::run() noexcept - { + int app::run() noexcept { + LOG_SCOPE_FUNCTION(INFO); if (not system_manager_.nb_systems()) { return this->game_return_value_; } @@ -74,8 +75,11 @@ namespace antara::gaming::world return this->game_return_value_; } - void app::process_one_frame() - { + void app::process_one_frame() { this->system_manager_.update(); } + + app::~app() noexcept { + LOG_SCOPE_FUNCTION(INFO); + } } \ No newline at end of file diff --git a/modules/world/antara/gaming/world/world.app.hpp b/modules/world/antara/gaming/world/world.app.hpp index 15d18218..4a486b7f 100644 --- a/modules/world/antara/gaming/world/world.app.hpp +++ b/modules/world/antara/gaming/world/world.app.hpp @@ -29,7 +29,7 @@ namespace antara::gaming::world { public: app(std::string config_maker_name = "game.config.maker.json") noexcept; - + ~app() noexcept; //! Public callbacks void receive_quit_game(const event::quit_game &evt) noexcept; int run() noexcept;