From 8d7dcac56315f1b398245e846040b75e0b3a826c Mon Sep 17 00:00:00 2001 From: Jiga228 Date: Thu, 23 Oct 2025 23:04:33 +0700 Subject: [PATCH 1/4] Fix crash in Release configuration --- Core/Types/object_ptr.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Core/Types/object_ptr.hpp b/Core/Types/object_ptr.hpp index 3b8414b..aa1146f 100644 --- a/Core/Types/object_ptr.hpp +++ b/Core/Types/object_ptr.hpp @@ -154,9 +154,19 @@ static void add_owner(object_ptr& ptr) if (ptr_) counter::remove_object(ptr_); } - Ty* get() const noexcept { return ptr_.load(); } - Ty& operator*() const noexcept { return *ptr_; } - Ty* operator->() const noexcept { return ptr_.load(); } + Ty* get() const { return ptr_.load(); } + Ty& operator*() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return *ptr_; + } + Ty* operator->() const + { + if (!ptr_.load()) + throw std::runtime_error("Null pointer"); + return ptr_.load(); + } operator bool() const noexcept { return ptr_.load() != nullptr; } object_ptr& operator=(const object_ptr& ptr) { From 8965669d6aaa7451c2469887db10757c604162a8 Mon Sep 17 00:00:00 2001 From: Jiga228 Date: Fri, 24 Oct 2025 17:05:10 +0700 Subject: [PATCH 2/4] Add build modes. Engine - build framework only. Tests - build unit tests only. TestGame - build TestGame and engine libraries. All - build all. Add scripts for easy build projects in different modes. "build_tests.bat" - create build directory, configure tests project and build there. "build_Engine.bat" - create build directory, configure engine projects, build there and copy header files to "build/bin/include". --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++++--------- build_Engine.bat | 11 +++++++++++ build_tests.bat | 5 +++++ configurate Win32.bat | 2 +- configurate Win64.bat | 2 +- 5 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 build_Engine.bat create mode 100644 build_tests.bat diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bd95eb..366968c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,19 +6,41 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR}) +# Build mode +set(BUILD_MODE "All" CACHE STRING "Build mode: Engine / Tests / TestGame / All") +set_property(CACHE BUILD_MODE PROPERTY STRINGS "Engine" "Tests" "TestGame" "All") + if(NOT MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") endif() if(MSVC) - add_compile_options(/GR-) + add_compile_options(/GR-) else() - add_compile_options(-fno-rtti) + add_compile_options(-fno-rtti) endif() -add_subdirectory(FastRTTI) -add_subdirectory(glfw) -add_subdirectory(Core) -add_subdirectory(TestGame) -add_subdirectory(ProjectGenerator) -add_subdirectory(Tests) +if(BUILD_MODE STREQUAL "Engine") + add_subdirectory(FastRTTI) + add_subdirectory(glfw) + add_subdirectory(Core) + add_subdirectory(ProjectGenerator) + +elseif(BUILD_MODE STREQUAL "Tests") + add_subdirectory(Tests) + +elseif(BUILD_MODE STREQUAL "TestGame") + add_subdirectory(FastRTTI) + add_subdirectory(glfw) + add_subdirectory(Core) + add_subdirectory(TestGame) + +elseif(BUILD_MODE STREQUAL "All") + add_subdirectory(FastRTTI) + add_subdirectory(glfw) + add_subdirectory(Core) + add_subdirectory(ProjectGenerator) + add_subdirectory(TestGame) + add_subdirectory(Tests) + +endif() diff --git a/build_Engine.bat b/build_Engine.bat new file mode 100644 index 0000000..d6cbf48 --- /dev/null +++ b/build_Engine.bat @@ -0,0 +1,11 @@ +@echo off +mkdir .\build +cd build +cmake -DBUILD_MODE=Engine .. +cmake --build . --config Release +cd .. +mkdir ".\build\bin\include" +robocopy ".\Core" ".\build\bin\include\Core" *.h *.hpp /S +robocopy ".\Delegate" ".\build\bin\include\Delegate" *.h *.hpp /S +robocopy ".\FastRTTI" ".\build\bin\include\FastRTTI" *.h *.hpp /S +pause \ No newline at end of file diff --git a/build_tests.bat b/build_tests.bat new file mode 100644 index 0000000..bef0c34 --- /dev/null +++ b/build_tests.bat @@ -0,0 +1,5 @@ +@echo off +mkdir build +cd build +cmake -DBUILD_MODE=Tests .. +cmake --build . --config Release diff --git a/configurate Win32.bat b/configurate Win32.bat index ff63dcc..4a49a47 100644 --- a/configurate Win32.bat +++ b/configurate Win32.bat @@ -1,5 +1,5 @@ @echo off mkdir build cd build -cmake .. -A Win32 +cmake -DBUILD_MODE=All .. -A Win32 pause \ No newline at end of file diff --git a/configurate Win64.bat b/configurate Win64.bat index 2a1279f..08a7e36 100644 --- a/configurate Win64.bat +++ b/configurate Win64.bat @@ -1,5 +1,5 @@ @echo off mkdir build cd build -cmake .. -A x64 +cmake -DBUILD_MODE=All .. -A x64 pause \ No newline at end of file From 42c9706ca523b7d879c47bde586b9b569c07ca7c Mon Sep 17 00:00:00 2001 From: Danil <119668441+Jiga228@users.noreply.github.com> Date: Fri, 24 Oct 2025 17:09:58 +0700 Subject: [PATCH 3/4] Add tests for windows --- .github/workflows/windows-test.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/windows-test.yml diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml new file mode 100644 index 0000000..5dfb794 --- /dev/null +++ b/.github/workflows/windows-test.yml @@ -0,0 +1,24 @@ +# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml +name: CMake on a single platform + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build tests + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: build_tests.bat + - name: Start tests + run: ./build/bin/Release/Tests.exe + From e3fb9a13321b7f01d835b95f97289e0ad543d671 Mon Sep 17 00:00:00 2001 From: Danil <119668441+Jiga228@users.noreply.github.com> Date: Fri, 24 Oct 2025 17:12:58 +0700 Subject: [PATCH 4/4] Fix workflow --- .github/workflows/windows-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 5dfb794..197439b 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -18,7 +18,7 @@ jobs: - name: Build tests # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: build_tests.bat + run: ./build_tests.bat - name: Start tests run: ./build/bin/Release/Tests.exe