From 468e3c44b1d600c018092adeab8ccdc243339fa1 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Tue, 28 Jul 2026 18:07:44 +0200 Subject: [PATCH] AssetLibrary --- .../Include/Engine/Asset/AssetHelper.hpp | 15 +++- .../Include/Engine/Asset/AssetLibrary.hpp | 78 +++++++++++++++++++ Bigfoot/Tests/CMakeLists.txt | 2 + Bigfoot/Tests/Engine/Asset/Asset.cpp | 7 +- Bigfoot/Tests/Engine/Asset/AssetContainer.cpp | 5 +- Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp | 74 ++++++++++++++++++ Bigfoot/Tests/Engine/CMakeLists.txt | 6 ++ .../Misc/AssetsForTesting/Asset/AssetA.cpp | 11 +++ .../AssetsForTesting}/Asset/AssetA_fwd.cpp | 2 +- .../Misc/AssetsForTesting/Asset/AssetB.cpp | 11 +++ .../AssetsForTesting}/Asset/AssetB_fwd.cpp | 2 +- .../Misc/AssetsForTesting/Asset/AssetC.cpp | 11 +++ .../AssetsForTesting}/Asset/AssetC_fwd.cpp | 2 +- .../Misc/AssetsForTesting/CMakeLists.txt | 15 ++++ .../AssetsForTesting}/Asset/AssetA.fbs | 2 +- .../AssetsForTesting}/Asset/AssetA.hpp | 2 +- .../AssetsForTesting}/Asset/AssetA_fwd.hpp | 2 +- .../Asset/AssetA_generated.hpp | 2 +- .../AssetsForTesting}/Asset/AssetB.fbs | 4 +- .../AssetsForTesting}/Asset/AssetB.hpp | 2 +- .../AssetsForTesting}/Asset/AssetB_fwd.hpp | 2 +- .../Asset/AssetB_generated.hpp | 6 +- .../AssetsForTesting}/Asset/AssetC.fbs | 6 +- .../AssetsForTesting}/Asset/AssetC.hpp | 2 +- .../AssetsForTesting}/Asset/AssetC_fwd.hpp | 2 +- .../Asset/AssetC_generated.hpp | 10 +-- Bigfoot/Tests/Misc/CMakeLists.txt | 1 + Bigfoot/Tests/System/CMakeLists.txt | 5 ++ Bigfoot/Tests/Utils/CMakeLists.txt | 5 ++ CMake/Package.cmake | 57 +++++++++++++- 30 files changed, 316 insertions(+), 35 deletions(-) create mode 100644 Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp create mode 100644 Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp create mode 100644 Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA.cpp rename Bigfoot/Tests/{Engine/EngineTests => Misc/AssetsForTesting}/Asset/AssetA_fwd.cpp (84%) create mode 100644 Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB.cpp rename Bigfoot/Tests/{Engine/EngineTests => Misc/AssetsForTesting}/Asset/AssetB_fwd.cpp (84%) create mode 100644 Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC.cpp rename Bigfoot/Tests/{Engine/EngineTests => Misc/AssetsForTesting}/Asset/AssetC_fwd.cpp (84%) create mode 100644 Bigfoot/Tests/Misc/AssetsForTesting/CMakeLists.txt rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetA.fbs (71%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetA.hpp (94%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetA_fwd.hpp (91%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetA_generated.hpp (99%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetB.fbs (81%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetB.hpp (94%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetB_fwd.hpp (91%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetB_generated.hpp (98%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetC.fbs (85%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetC.hpp (94%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetC_fwd.hpp (91%) rename Bigfoot/Tests/{Engine/Include/EngineTests => Misc/AssetsForTesting/Include/AssetsForTesting}/Asset/AssetC_generated.hpp (98%) create mode 100644 Bigfoot/Tests/Misc/CMakeLists.txt diff --git a/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetHelper.hpp b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetHelper.hpp index 063619d..dbff676 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetHelper.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetHelper.hpp @@ -7,9 +7,12 @@ #ifndef BIGFOOT_ENGINE_ASSET_ASSETHELPER_HPP #define BIGFOOT_ENGINE_ASSET_ASSETHELPER_HPP #include +#include #include #include +#include + #define ASSET_SOFT_REF_DECL(AssetName, AssetType) \ namespace flatbuffers \ { \ @@ -28,8 +31,6 @@ ASSET_SOFT_REF_DECL(AssetName, AssetType) \ ASSET_HARD_REF_DECL(AssetName, AssetType) -#define ASSET_DECL(AssetName, AssetType) ASSET_REF_DECL(AssetName, AssetType) - /****************************************************************************************/ #define ASSET_SOFT_REF_IMPL(AssetName, AssetType) \ @@ -62,5 +63,13 @@ ASSET_SOFT_REF_IMPL(AssetName, AssetType) \ ASSET_HARD_REF_IMPL(AssetName, AssetType) -#define ASSET_IMPL(AssetName, AssetType) ASSET_REF_IMPL(AssetName, AssetType) +/****************************************************************************************/ + +#define ASSET_CONTAINER(AssetType) \ + namespace Bigfoot \ + { \ + AssetContainer MAKE_UNIQUE_VARIABLE_NAME(AssetType##Container); \ + const bool MAKE_UNIQUE_VARIABLE_NAME(inserted) = \ + g_assetLibrary.Insert(&MAKE_UNIQUE_VARIABLE_NAME(AssetType##Container)); \ + } #endif diff --git a/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp new file mode 100644 index 0000000..dbdb47d --- /dev/null +++ b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp @@ -0,0 +1,78 @@ +/********************************************************************* + * \file AssetLibrary.hpp + * + * \author Romain BOULLARD + * \date July 2026 + *********************************************************************/ +#ifndef BIGFOOT_ENGINE_ASSET_ASSETLIBRARY_HPP +#define BIGFOOT_ENGINE_ASSET_ASSETLIBRARY_HPP +#include +#include + +#include +#include + +namespace Bigfoot +{ +class AssetLibrary +{ + public: + AssetLibrary() = default; + + AssetLibrary(const AssetLibrary& p_library) = default; + AssetLibrary(AssetLibrary&& p_library) = default; + + ~AssetLibrary() = default; + + template + [[nodiscard]] + bool Insert(AssetContainer* p_assetContainer) + { + static const AssetTypeID typeID = ASSET::GetTypeID(); + if (m_assetContainers.contains(typeID)) + { + return false; + } + + const auto inserted = m_assetContainers.emplace(typeID, p_assetContainer); + + return inserted.second; + } + + template + [[nodiscard]] + AssetContainer* Get() + { + static const AssetTypeID typeID = ASSET::GetTypeID(); + if (const auto container = m_assetContainers.find(typeID); container != m_assetContainers.end()) + { + return eastl::any_cast*>(container->second); + } + + return nullptr; + } + + template + [[nodiscard]] + const AssetContainer* Get() const + { + static const AssetTypeID typeID = ASSET::GetTypeID(); + if (const auto container = m_assetContainers.find(typeID); container != m_assetContainers.end()) + { + return eastl::any_cast*>(container->second); + } + + return nullptr; + } + + AssetLibrary& operator=(const AssetLibrary& p_library) = default; + AssetLibrary& operator=(AssetLibrary&& p_library) = default; + + private: + std::unordered_map m_assetContainers; +}; + +inline AssetLibrary g_assetLibrary; +} // namespace Bigfoot + +#endif diff --git a/Bigfoot/Tests/CMakeLists.txt b/Bigfoot/Tests/CMakeLists.txt index 8eca193..cbbb5ea 100644 --- a/Bigfoot/Tests/CMakeLists.txt +++ b/Bigfoot/Tests/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Misc) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/System) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Engine) \ No newline at end of file diff --git a/Bigfoot/Tests/Engine/Asset/Asset.cpp b/Bigfoot/Tests/Engine/Asset/Asset.cpp index 4a8f49e..4867d64 100644 --- a/Bigfoot/Tests/Engine/Asset/Asset.cpp +++ b/Bigfoot/Tests/Engine/Asset/Asset.cpp @@ -6,10 +6,9 @@ *********************************************************************/ #include -#include -#include -#include - +#include +#include +#include #include namespace Bigfoot diff --git a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp index ba625fe..a694905 100644 --- a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp +++ b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp @@ -1,13 +1,12 @@ /********************************************************************* - * \file BigFile.cpp + * \file AssetContainer.cpp * * \author Romain BOULLARD * \date December 2025 *********************************************************************/ #include -#include - +#include #include namespace Bigfoot diff --git a/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp b/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp new file mode 100644 index 0000000..ad96349 --- /dev/null +++ b/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp @@ -0,0 +1,74 @@ +/********************************************************************* + * \file AssetLibrary.cpp + * + * \author Romain BOULLARD + * \date July 2026 + *********************************************************************/ +#include + +#include +#include +#include +#include + +namespace Bigfoot +{ +class AssetLibraryFixture: public ::testing::Test +{ + protected: + void SetUp() override + { + std::ignore = m_library.Insert(&m_containerA); + std::ignore = m_library.Insert(&m_containerB); + } + + AssetContainer m_containerA; + AssetContainer m_containerB; + + AssetLibrary m_library; +}; + +/****************************************************************************************/ + +TEST_F(AssetLibraryFixture, Insert_ShouldReturnTrueIfTheContainerHasBeenInserted) +{ + AssetContainer containerC; + EXPECT_TRUE(m_library.Insert(&containerC)); +} + +/****************************************************************************************/ + +TEST_F(AssetLibraryFixture, Insert_ShouldReturnFalseIfTheContainerHasNotBeenInserted) +{ + EXPECT_FALSE(m_library.Insert(&m_containerA)); // Duplicate +} + +/****************************************************************************************/ + +TEST_F(AssetLibraryFixture, Get_ShouldReturnTheContainersIfTheyAreInTheLibrary) +{ + const AssetContainer* containerA = m_library.Get(); + const AssetContainer* containerB = m_library.Get(); + + EXPECT_EQ(&m_containerA, containerA); + EXPECT_EQ(&m_containerB, containerB); +} + +/****************************************************************************************/ + +TEST_F(AssetLibraryFixture, Get_ShouldReturnNullptrIfTheContainersAreNotInTheLibrary) +{ + const AssetContainer* containerC = m_library.Get(); + + EXPECT_EQ(nullptr, containerC); +} + +/****************************************************************************************/ + +TEST_F(AssetLibraryFixture, GlobalAssetLibraryShouldHaveAssetsRegistered) +{ + EXPECT_NE(g_assetLibrary.Get(), nullptr); + EXPECT_NE(g_assetLibrary.Get(), nullptr); + EXPECT_NE(g_assetLibrary.Get(), nullptr); +} +} // namespace Bigfoot diff --git a/Bigfoot/Tests/Engine/CMakeLists.txt b/Bigfoot/Tests/Engine/CMakeLists.txt index f2dd9ed..89333e5 100644 --- a/Bigfoot/Tests/Engine/CMakeLists.txt +++ b/Bigfoot/Tests/Engine/CMakeLists.txt @@ -1,7 +1,13 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME) project(${PackageName}Tests) +set(Dependencies) +set(BigfootDependencies + AssetsForTesting) + bigfoot_create_package_tests( + "${Dependencies}" + "${BigfootDependencies}" "") bigfoot_create_bigfile("Tests/Bigfoot") \ No newline at end of file diff --git a/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA.cpp new file mode 100644 index 0000000..02e9957 --- /dev/null +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA.cpp @@ -0,0 +1,11 @@ +/********************************************************************* + * \file AssetA.cpp + * + * \author Romain BOULLARD + * \date July 2026 + *********************************************************************/ +#include + +#include + +ASSET_CONTAINER(AssetA) diff --git a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetA_fwd.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA_fwd.cpp similarity index 84% rename from Bigfoot/Tests/Engine/EngineTests/Asset/AssetA_fwd.cpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA_fwd.cpp index 22a8589..2d3a1d5 100644 --- a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetA_fwd.cpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetA_fwd.cpp @@ -4,6 +4,6 @@ * \author Romain BOULLARD * \date May 2026 *********************************************************************/ -#include +#include ASSET_REF_IMPL(AssetA, ::Bigfoot::AssetA) diff --git a/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB.cpp new file mode 100644 index 0000000..9353ebc --- /dev/null +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB.cpp @@ -0,0 +1,11 @@ +/********************************************************************* + * \file AssetB.cpp + * + * \author Romain BOULLARD + * \date July 2026 + *********************************************************************/ +#include + +#include + +ASSET_CONTAINER(AssetB) diff --git a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetB_fwd.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB_fwd.cpp similarity index 84% rename from Bigfoot/Tests/Engine/EngineTests/Asset/AssetB_fwd.cpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB_fwd.cpp index fae7cb7..3082736 100644 --- a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetB_fwd.cpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetB_fwd.cpp @@ -4,6 +4,6 @@ * \author Romain BOULLARD * \date May 2026 *********************************************************************/ -#include +#include ASSET_REF_IMPL(AssetB, ::Bigfoot::AssetB) diff --git a/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC.cpp new file mode 100644 index 0000000..ae822b4 --- /dev/null +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC.cpp @@ -0,0 +1,11 @@ +/********************************************************************* + * \file AssetC.cpp + * + * \author Romain BOULLARD + * \date July 2026 + *********************************************************************/ +#include + +#include + +ASSET_CONTAINER(AssetC) diff --git a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetC_fwd.cpp b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC_fwd.cpp similarity index 84% rename from Bigfoot/Tests/Engine/EngineTests/Asset/AssetC_fwd.cpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC_fwd.cpp index 619f5cf..6f95f05 100644 --- a/Bigfoot/Tests/Engine/EngineTests/Asset/AssetC_fwd.cpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Asset/AssetC_fwd.cpp @@ -4,6 +4,6 @@ * \author Romain BOULLARD * \date May 2026 *********************************************************************/ -#include +#include ASSET_REF_IMPL(AssetC, ::Bigfoot::AssetC) diff --git a/Bigfoot/Tests/Misc/AssetsForTesting/CMakeLists.txt b/Bigfoot/Tests/Misc/AssetsForTesting/CMakeLists.txt new file mode 100644 index 0000000..c38a828 --- /dev/null +++ b/Bigfoot/Tests/Misc/AssetsForTesting/CMakeLists.txt @@ -0,0 +1,15 @@ +get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME) +project(${PackageName}) + +set(PublicDependencies) +set(PrivateDependencies) +set(BigfootPublicDependencies) +set(BigfootPrivateDependencies + Engine) + +bigfoot_create_package_tests_helper_lib( + "${PublicDependencies}" + "${PrivateDependencies}" + "${BigfootPublicDependencies}" + "${BigfootPrivateDependencies}" + "") \ No newline at end of file diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.fbs b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.fbs similarity index 71% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.fbs rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.fbs index 6ea9315..844f89b 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.fbs +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.fbs @@ -1,6 +1,6 @@ include "Engine/Asset/Reference.fbs"; -native_include "EngineTests/Asset/AssetA_fwd.hpp"; +native_include "AssetsForTesting/Asset/AssetA_fwd.hpp"; namespace Flat.Bigfoot; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.hpp similarity index 94% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.hpp index b88d0eb..2a733c7 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA.hpp @@ -8,7 +8,7 @@ #define BIGFOOT_ENGINETESTS_ASSET_ASSETA_HPP #include -#include +#include namespace Bigfoot { diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_fwd.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_fwd.hpp similarity index 91% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_fwd.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_fwd.hpp index 9045207..3cadfd7 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_fwd.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_fwd.hpp @@ -13,6 +13,6 @@ namespace Bigfoot class AssetA; } // namespace Bigfoot -ASSET_DECL(AssetA, ::Bigfoot::AssetA) +ASSET_REF_DECL(AssetA, ::Bigfoot::AssetA) #endif diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_generated.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_generated.hpp similarity index 99% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_generated.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_generated.hpp index 4d34735..62f4185 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetA_generated.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetA_generated.hpp @@ -16,7 +16,7 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && #include "Engine/Asset/Reference.hpp" #include "System/UUID/UUID.hpp" #include "Engine/Asset/Reference.hpp" -#include "EngineTests/Asset/AssetA_fwd.hpp" +#include "AssetsForTesting/Asset/AssetA_fwd.hpp" #include "Engine/Asset/Reference_generated.hpp" #include "EASTL/unique_ptr.h" diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.fbs b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.fbs similarity index 81% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.fbs rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.fbs index 7819e1c..efe2ecc 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.fbs +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.fbs @@ -1,8 +1,8 @@ include "Engine/Asset/Reference.fbs"; -include "EngineTests/Asset/AssetA.fbs"; +include "AssetsForTesting/Asset/AssetA.fbs"; -native_include "EngineTests/Asset/AssetB_fwd.hpp"; +native_include "AssetsForTesting/Asset/AssetB_fwd.hpp"; namespace Flat.Bigfoot; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.hpp similarity index 94% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.hpp index 6c97ac2..0be86ef 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB.hpp @@ -8,7 +8,7 @@ #define BIGFOOT_ENGINETESTS_ASSET_ASSETB_HPP #include -#include +#include namespace Bigfoot { diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_fwd.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_fwd.hpp similarity index 91% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_fwd.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_fwd.hpp index a8b4b2c..5b2d3c3 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_fwd.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_fwd.hpp @@ -13,6 +13,6 @@ namespace Bigfoot class AssetB; } // namespace Bigfoot -ASSET_DECL(AssetB, ::Bigfoot::AssetB) +ASSET_REF_DECL(AssetB, ::Bigfoot::AssetB) #endif diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_generated.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_generated.hpp similarity index 98% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_generated.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_generated.hpp index 96d8cef..bbafa1c 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetB_generated.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetB_generated.hpp @@ -16,10 +16,10 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && #include "Engine/Asset/Reference.hpp" #include "System/UUID/UUID.hpp" #include "Engine/Asset/Reference.hpp" -#include "EngineTests/Asset/AssetA_fwd.hpp" -#include "EngineTests/Asset/AssetB_fwd.hpp" +#include "AssetsForTesting/Asset/AssetA_fwd.hpp" +#include "AssetsForTesting/Asset/AssetB_fwd.hpp" #include "Engine/Asset/Reference_generated.hpp" -#include "EngineTests/Asset/AssetA_generated.hpp" +#include "AssetsForTesting/Asset/AssetA_generated.hpp" #include "EASTL/unique_ptr.h" #include "EASTL/string.h" diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.fbs b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.fbs similarity index 85% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.fbs rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.fbs index 9106333..c4a1069 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.fbs +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.fbs @@ -1,9 +1,9 @@ include "Engine/Asset/Reference.fbs"; -include "EngineTests/Asset/AssetA.fbs"; -include "EngineTests/Asset/AssetB.fbs"; +include "AssetsForTesting/Asset/AssetA.fbs"; +include "AssetsForTesting/Asset/AssetB.fbs"; -native_include "EngineTests/Asset/AssetC_fwd.hpp"; +native_include "AssetsForTesting/Asset/AssetC_fwd.hpp"; namespace Flat.Bigfoot; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.hpp similarity index 94% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.hpp index 561f8ea..cde010e 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC.hpp @@ -8,7 +8,7 @@ #define BIGFOOT_ENGINETESTS_ASSET_ASSETC_HPP #include -#include +#include namespace Bigfoot { diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_fwd.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_fwd.hpp similarity index 91% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_fwd.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_fwd.hpp index 49c334f..974e334 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_fwd.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_fwd.hpp @@ -13,6 +13,6 @@ namespace Bigfoot class AssetC; } // namespace Bigfoot -ASSET_DECL(AssetC, ::Bigfoot::AssetC) +ASSET_REF_DECL(AssetC, ::Bigfoot::AssetC) #endif diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_generated.hpp b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_generated.hpp similarity index 98% rename from Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_generated.hpp rename to Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_generated.hpp index d34da2d..111199a 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/Asset/AssetC_generated.hpp +++ b/Bigfoot/Tests/Misc/AssetsForTesting/Include/AssetsForTesting/Asset/AssetC_generated.hpp @@ -16,12 +16,12 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && #include "Engine/Asset/Reference.hpp" #include "System/UUID/UUID.hpp" #include "Engine/Asset/Reference.hpp" -#include "EngineTests/Asset/AssetA_fwd.hpp" -#include "EngineTests/Asset/AssetB_fwd.hpp" -#include "EngineTests/Asset/AssetC_fwd.hpp" +#include "AssetsForTesting/Asset/AssetA_fwd.hpp" +#include "AssetsForTesting/Asset/AssetB_fwd.hpp" +#include "AssetsForTesting/Asset/AssetC_fwd.hpp" #include "Engine/Asset/Reference_generated.hpp" -#include "EngineTests/Asset/AssetA_generated.hpp" -#include "EngineTests/Asset/AssetB_generated.hpp" +#include "AssetsForTesting/Asset/AssetA_generated.hpp" +#include "AssetsForTesting/Asset/AssetB_generated.hpp" #include "EASTL/unique_ptr.h" #include "EASTL/string.h" diff --git a/Bigfoot/Tests/Misc/CMakeLists.txt b/Bigfoot/Tests/Misc/CMakeLists.txt new file mode 100644 index 0000000..66cec06 --- /dev/null +++ b/Bigfoot/Tests/Misc/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/AssetsForTesting) \ No newline at end of file diff --git a/Bigfoot/Tests/System/CMakeLists.txt b/Bigfoot/Tests/System/CMakeLists.txt index 6c98a7c..07d7c3d 100644 --- a/Bigfoot/Tests/System/CMakeLists.txt +++ b/Bigfoot/Tests/System/CMakeLists.txt @@ -1,5 +1,10 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME) project(${PackageName}Tests) +set(Dependencies) +set(BigfootDependencies) + bigfoot_create_package_tests( + "${Dependencies}" + "${BigfootDependencies}" "") \ No newline at end of file diff --git a/Bigfoot/Tests/Utils/CMakeLists.txt b/Bigfoot/Tests/Utils/CMakeLists.txt index eb59da7..d6c67dd 100644 --- a/Bigfoot/Tests/Utils/CMakeLists.txt +++ b/Bigfoot/Tests/Utils/CMakeLists.txt @@ -1,7 +1,12 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME) project(${PackageName}Tests) +set(Dependencies) +set(BigfootDependencies) + bigfoot_create_package_tests( + "${Dependencies}" + "${BigfootDependencies}" "") bigfoot_create_logger() \ No newline at end of file diff --git a/CMake/Package.cmake b/CMake/Package.cmake index dadf476..566875a 100644 --- a/CMake/Package.cmake +++ b/CMake/Package.cmake @@ -51,7 +51,7 @@ function(bigfoot_create_package_lib PackagePublicDependencies PackagePrivateDepe set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Bigfoot/${ParentFolder}) endfunction() -function(bigfoot_create_package_tests ParentFolder) +function(bigfoot_create_package_tests PackageDependencies PackageBigfootDependencies ParentFolder) add_executable(${PROJECT_NAME}) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) @@ -59,7 +59,9 @@ function(bigfoot_create_package_tests ParentFolder) target_link_libraries(${PROJECT_NAME} PRIVATE BigfootCompileAndLinkFlags + ${PackageDependencies} $ + $ gtest::gtest) bigfoot_compile_flatbuffers() @@ -153,6 +155,59 @@ function(bigfoot_create_package_tests ParentFolder) set_target_properties(${PROJECT_NAME}Fixture PROPERTIES FOLDER UtilityTargets/Tests/Bigfoot/${ParentFolder}) endfunction() +function(bigfoot_create_package_tests_helper_lib PackagePublicDependencies PackagePrivateDependencies PackageBigfootPublicDependencies PackageBigfootPrivateDependencies ParentFolder) + add_library(${PROJECT_NAME} STATIC) + + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) + + target_link_libraries(${PROJECT_NAME} + PRIVATE + BigfootCompileAndLinkFlags + PUBLIC + ${PackagePublicDependencies} + $ + + PRIVATE + ${PackagePrivateDependencies} + $) + + bigfoot_compile_flatbuffers() + + file(GLOB_RECURSE _SOURCES + CONFIGURE_DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ) + + file(GLOB_RECURSE _HEADERS + CONFIGURE_DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp + ) + + file(GLOB_RECURSE _OTHERS + CONFIGURE_DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/*.fbs + ${CMAKE_CURRENT_SOURCE_DIR}/*.sql + ) + + target_sources(${PROJECT_NAME} + PRIVATE + ${_SOURCES} + ${_OTHERS} + PUBLIC + FILE_SET HEADERS + BASE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/Include + FILES + ${_HEADERS} + ) + + source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX Src FILES ${_SOURCES} ${_HEADERS} ${_OTHERS}) + + set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Tests/Bigfoot/${ParentFolder}) +endfunction() + function(bigfoot_create_package_benchmarks ParentFolder) add_executable(${PROJECT_NAME})