diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..13172cb --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,17 @@ +{ + "permissions": { + "allow": [ + "Bash(./EngineTests.exe)", + "Bash(echo \"EXIT: $?\")", + "Bash(cmake --build build-windows --target EngineTests --config Debug -- -m)", + "Bash(cmake --build build-windows --config Debug -- -m)", + "Bash(./SystemTests.exe)", + "Bash(./UtilsTests.exe)", + "Bash(cmake --build build-windows --target EngineBenchmarks --config RelWithDebInfo -- -m)", + "Bash(./EngineBenchmarks.exe --benchmark_counters_tabular=true)", + "Bash(cmake --build build-windows --target EngineBenchmarks --config Release -- -m)", + "Bash(./EngineBenchmarks.exe --benchmark_repetitions=10 --benchmark_report_aggregates_only=true)", + "Bash(cmake . -G \"Visual Studio 17 2022\")" + ] + } +} diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index b4c719d..4c3dfeb 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -18,7 +18,8 @@ jobs: build_type: ["Debug", "RelWithDebInfo", "Release"] unity_build: ["ON", "OFF"] conan_profile: ["./ConanProfiles/host/clang", "./ConanProfiles/host/clang_asan"] - name: "Build & Test ${{ matrix.build_type }} with ${{ matrix.conan_profile }} (Unity Build: ${{ matrix.unity_build }})" + toolmode: ["True", "False"] + name: "Build & Test ${{ matrix.build_type }} with ${{ matrix.conan_profile }} (Unity Build: ${{ matrix.unity_build }}, Toolmode: ${{ matrix.toolmode }})" steps: - name: Install Node.js run: apt-get update && apt-get install -y nodejs @@ -30,18 +31,18 @@ jobs: - name: Build run: | - conan install . --remote=bigfootpackages -pr:h=${{ matrix.conan_profile }} -pr:b=./ConanProfiles/build/clang --build=* -s build_type=${{ matrix.build_type }} -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=False -o bigfoot/*:vulkan=True - . ./build/${{ matrix.build_type }}/generators/conanbuild.sh - cmake -S . -B ./build/${{ matrix.build_type }} --toolchain ./build/${{ matrix.build_type }}/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -G "Ninja" - cmake --build build/${{ matrix.build_type }} --parallel $(nproc) - . ./build/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh + conan install . --remote=bigfootpackages -pr:h=${{ matrix.conan_profile }} -pr:b=./ConanProfiles/build/clang --build=* -s build_type=${{ matrix.build_type }} -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=False -o bigfoot/*:vulkan=True -o bigfoot/*:toolmode=${{ matrix.toolmode }} -of build-${{ matrix.toolmode }} + . ./build-${{ matrix.toolmode }}/${{ matrix.build_type }}/generators/conanbuild.sh + cmake -S . -B ./build-${{ matrix.toolmode }}/${{ matrix.build_type }} --toolchain ./build-${{ matrix.toolmode }}/${{ matrix.build_type }}/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -G "Ninja" + cmake --build build-${{ matrix.toolmode }}/${{ matrix.build_type }} --parallel $(nproc) + . ./build-${{ matrix.toolmode }}/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh - name: Unit Tests run: | - cd ./build/${{ matrix.build_type }} - . ../../build/${{ matrix.build_type }}/generators/conanbuild.sh + cd ./build-${{ matrix.toolmode }}/${{ matrix.build_type }} + . ../../build-${{ matrix.toolmode }}/${{ matrix.build_type }}/generators/conanbuild.sh xvfb-run ctest . --output-on-failure - . ../../build/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh + . ../../build-${{ matrix.toolmode }}/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh clang-format: runs-on: ubuntu-latest diff --git a/Bigfoot/Sources/Utils/Include/Utils/Assert/Assert.hpp b/Bigfoot/Sources/Utils/Include/Utils/Assert/Assert.hpp index f28fe6e..ef74771 100644 --- a/Bigfoot/Sources/Utils/Include/Utils/Assert/Assert.hpp +++ b/Bigfoot/Sources/Utils/Include/Utils/Assert/Assert.hpp @@ -20,7 +20,7 @@ #define BIGFOOT_FLUSH_LOG \ do \ { \ - if (Bigfoot::Singleton::HasInstance()) \ + if (Bigfoot::Singleton::HasInstance()) \ { \ Bigfoot::Singleton::GetInstance().Flush(); \ } \ diff --git a/Bigfoot/Sources/Utils/Include/Utils/TargetMacros.h b/Bigfoot/Sources/Utils/Include/Utils/TargetMacros.h index cfb649e..9c019b1 100644 --- a/Bigfoot/Sources/Utils/Include/Utils/TargetMacros.h +++ b/Bigfoot/Sources/Utils/Include/Utils/TargetMacros.h @@ -26,4 +26,16 @@ #define BIGFOOT_NOT_OPTIMIZED_ONLY(...) __VA_ARGS__ #define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_notOptimized #endif + +#if defined BIGFOOT_TOOLMODE +#define BIGFOOT_TOOLMODE_ONLY(...) __VA_ARGS__ +#define BIGFOOT_GAME_ONLY(...) +#define BIGFOOT_GAME_OR_TOOLMODE(p_game, p_toolmode) p_toolmode +#endif + +#if defined BIGFOOT_GAME +#define BIGFOOT_TOOLMODE_ONLY(...) +#define BIGFOOT_GAME_ONLY(...) __VA_ARGS__ +#define BIGFOOT_GAME_OR_TOOLMODE(p_game, p_toolmode) p_game +#endif #endif diff --git a/Bigfoot/Tests/Utils/TargetMacros.cpp b/Bigfoot/Tests/Utils/TargetMacros.cpp index 72f1aae..31975ed 100644 --- a/Bigfoot/Tests/Utils/TargetMacros.cpp +++ b/Bigfoot/Tests/Utils/TargetMacros.cpp @@ -23,4 +23,13 @@ TEST_F(TargetMacrosFixture, OptimizedOrNot) BIGFOOT_OPTIMIZED_ONLY(EXPECT_EQ(value, 1);) } +/****************************************************************************************/ + +TEST_F(TargetMacrosFixture, GameOrToolmode) +{ + constexpr std::uint32_t value = BIGFOOT_GAME_OR_TOOLMODE(1, 2); + BIGFOOT_GAME_ONLY(EXPECT_EQ(value, 1);) + BIGFOOT_TOOLMODE_ONLY(EXPECT_EQ(value, 2);) +} + } // namespace Bigfoot diff --git a/CMake/CustomTargets.cmake b/CMake/CustomTargets.cmake index 5008561..f2a4862 100644 --- a/CMake/CustomTargets.cmake +++ b/CMake/CustomTargets.cmake @@ -16,4 +16,5 @@ target_compile_definitions(BigfootCompileAndLinkFlags INTERFACE $<$:BIGFOOT_WINDOWS> $<$:BIGFOOT_LINUX> $<$:BIGFOOT_OPTIMIZED> - $<$:BIGFOOT_NOT_OPTIMIZED>) \ No newline at end of file + $<$:BIGFOOT_NOT_OPTIMIZED> + $,BIGFOOT_TOOLMODE,BIGFOOT_GAME>) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 38d0847..2e3e300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ option(ASAN OFF) option(COVERAGE OFF) option(TRACY ON) option(VULKAN ON) +option(TOOLMODE ON) set(AUTO_GENERATED_COMMENT "// AUTO-GENERATED DO NOT TOUCH") diff --git a/conanfile.py b/conanfile.py index f8bfa00..cdb81c7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,7 +23,8 @@ class Bigfoot(ConanFile): "build_tests": [True, False], "build_benchmarks": [True, False], "tracy": [True, False], - "vulkan": [True, False] + "vulkan": [True, False], + "toolmode": [True, False] } default_options = { "shared": False, @@ -34,6 +35,7 @@ class Bigfoot(ConanFile): "build_benchmarks": False, "tracy": False, "vulkan": True, + "toolmode": True, } generators = "CMakeDeps" @@ -100,6 +102,7 @@ class Bigfoot(ConanFile): tc.variables["BUILD_BENCHMARKS"] = self.options.build_benchmarks tc.variables["TRACY"] = self.options.tracy tc.variables["VULKAN"] = self.options.vulkan + tc.variables["TOOLMODE"] = self.options.toolmode tc.generate() diff --git a/generate_bigfoot.bat b/generate_bigfoot.bat index 4d92455..cf89f2d 100644 --- a/generate_bigfoot.bat +++ b/generate_bigfoot.bat @@ -1,5 +1,5 @@ @echo off -setlocal +setlocal enabledelayedexpansion REM ─── Validate argument ─────────────────────────────────────────────────────── if "%~1"=="force" set "build_option=--build=*" & goto :start @@ -25,16 +25,20 @@ if errorlevel 1 ( ) REM ─── Shared flags ──────────────────────────────────────────────────────────── -set "conan_common=--remote=bigfootpackages -pr:h=./ConanProfiles/host/msvc -pr:b=./ConanProfiles/build/msvc -of build-windows -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=True -o bigfoot/*:vulkan=True" +set "conan_common_base=--remote=bigfootpackages -pr:h=./ConanProfiles/host/msvc -pr:b=./ConanProfiles/build/msvc -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=True -o bigfoot/*:vulkan=True" -REM ─── Install dependencies for each build type ──────────────────────────────── +REM ─── Install dependencies for each build type/variant ──────────────────────── for %%C in (Release RelWithDebInfo Debug) do ( echo. echo [%%C] Installing dependencies... - conan install . %conan_common% %build_option% -s:h build_type=%%C - if errorlevel 1 ( - echo ERROR: conan install failed for build type %%C - exit /b 1 + for %%V in (toolmode game) do ( + set "toolmode_val=False" + if "%%V"=="toolmode" set "toolmode_val=True" + conan install . !conan_common_base! -of build-windows-%%V -o bigfoot/*:toolmode=!toolmode_val! %build_option% -s:h build_type=%%C + if errorlevel 1 ( + echo ERROR: conan install failed for build type %%C ^(%%V^) + exit /b 1 + ) ) echo [%%C] Done. ) @@ -45,16 +49,18 @@ echo All build types installed successfully. REM ─── Activate build environment and run CMake ──────────────────────────────── echo. echo Activating build environment and configuring CMake... -mkdir graphviz-windows 2>nul -powershell -ExecutionPolicy Bypass -Command "& 'build-windows/build/generators/conanbuild.ps1'; cmake -S . -B build-windows --toolchain build-windows/build/generators/conan_toolchain.cmake --graphviz=graphviz-windows/graph.dot; if ($LASTEXITCODE -ne 0) { Write-Host 'ERROR: CMake configuration failed'; exit 1 }" +for %%V in (toolmode game) do ( + mkdir graphviz-windows-%%V 2>nul -if errorlevel 1 ( - echo ERROR: Build environment or CMake step failed. - exit /b 1 + powershell -ExecutionPolicy Bypass -Command "& 'build-windows-%%V/build/generators/conanbuild.ps1'; cmake -S . -B build-windows-%%V --toolchain build-windows-%%V/build/generators/conan_toolchain.cmake --graphviz=graphviz-windows-%%V/graph.dot; if ($LASTEXITCODE -ne 0) { Write-Host 'ERROR: CMake configuration failed'; exit 1 }" + if errorlevel 1 ( + echo ERROR: Build environment or CMake step failed for %%V. + exit /b 1 + ) ) echo. echo CMake configuration successful. -endlocal \ No newline at end of file +endlocal diff --git a/generate_bigfoot.sh b/generate_bigfoot.sh index 81982bd..0a5bff7 100644 --- a/generate_bigfoot.sh +++ b/generate_bigfoot.sh @@ -51,22 +51,39 @@ else fi # ─── Shared flags ───────────────────────────────────────────────────────────── -conan_common=( +conan_common_toolmode=( --remote=bigfootpackages -pr:h=./ConanProfiles/host/clang -pr:b=./ConanProfiles/build/clang - -of build-linux + -of build-linux-toolmode -o "bigfoot/*:build_tests=True" -o "bigfoot/*:build_benchmarks=True" -o "bigfoot/*:tracy=True" -o "bigfoot/*:vulkan=True" + -o "bigfoot/*:toolmode=True" +) + +conan_common_game=( + --remote=bigfootpackages + -pr:h=./ConanProfiles/host/clang + -pr:b=./ConanProfiles/build/clang + -of build-linux-game + -o "bigfoot/*:build_tests=True" + -o "bigfoot/*:build_benchmarks=True" + -o "bigfoot/*:tracy=True" + -o "bigfoot/*:vulkan=True" + -o "bigfoot/*:toolmode=False" ) # ─── Install dependencies for each build type ───────────────────────────────── for build_type in "${build_types[@]}"; do echo echo "[${build_type}] Installing dependencies..." - if ! conan install . "${conan_common[@]}" ${build_option} -s:h "build_type=${build_type}"; then + if ! conan install . "${conan_common_toolmode[@]}" ${build_option} -s:h "build_type=${build_type}"; then + echo "ERROR: conan install failed for build type ${build_type}" + exit 1 + fi + if ! conan install . "${conan_common_game[@]}" ${build_option} -s:h "build_type=${build_type}"; then echo "ERROR: conan install failed for build type ${build_type}" exit 1 fi @@ -83,20 +100,23 @@ echo "Configuring CMake for each build type..." for build_type in "${build_types[@]}"; do echo echo "[${build_type}] Activating build environment..." - # shellcheck disable=SC1090 - source "build-linux/build/${build_type}/generators/conanbuild.sh" - mkdir -p "graphviz-linux/${build_type}" + for variant in toolmode game; do + # shellcheck disable=SC1090 + source "build-linux-${variant}/build/${build_type}/generators/conanbuild.sh" - echo "[${build_type}] Running CMake..." - if ! cmake -S . -B "build-linux/${build_type}" \ - --toolchain "build-linux/build/${build_type}/generators/conan_toolchain.cmake" \ - -DCMAKE_BUILD_TYPE="${build_type}" \ - -G "Ninja" \ - --graphviz="graphviz-linux/${build_type}/graph.dot"; then - echo "ERROR: CMake configuration failed for build type ${build_type}." - exit 1 - fi + mkdir -p "graphviz-linux-${variant}/${build_type}" + + echo "[${build_type}] Running CMake (${variant})..." + if ! cmake -S . -B "build-linux-${variant}/${build_type}" \ + --toolchain "build-linux-${variant}/build/${build_type}/generators/conan_toolchain.cmake" \ + -DCMAKE_BUILD_TYPE="${build_type}" \ + -G "Ninja" \ + --graphviz="graphviz-linux-${variant}/${build_type}/graph.dot"; then + echo "ERROR: CMake configuration failed for build type ${build_type} (${variant})." + exit 1 + fi + done echo "[${build_type}] Done." done diff --git a/generate_dependencies.bat b/generate_dependencies.bat deleted file mode 100644 index f7de8c6..0000000 --- a/generate_dependencies.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -setlocal - -REM Check if the correct number of arguments is provided -if "%~1"=="" ( - echo Usage: %0 "[force|missing]" - exit /b 1 -) - -REM Set the build option based on the argument -set build_option= -if "%~1"=="force" ( - set build_option=--build="*" -) else if "%~1"=="missing" ( - set build_option=--build=missing -) else ( - echo Invalid argument: %~1 - echo Usage: %0 "[force|missing]" - exit /b 1 -) - -REM Add the remote -conan remote add bigfootpackages https://conan.romainboullard.com/artifactory/api/conan/BigfootPackages - -REM Install the conan configuration -conan config install https://git.romainboullard.com/BigfootDev/ConanProfiles.git - -REM Install dependencies with the specified build option -conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=msvc -pr:b=msvc %build_option% -of build -s build_type=Release -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True -conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=msvcd -pr:b=msvcd %build_option% -of build -s build_type=RelWithDebInfo -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True -conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=msvcd -pr:b=msvcd %build_option% -of build -s build_type=Debug -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True - -endlocal diff --git a/generate_dependencies.sh b/generate_dependencies.sh deleted file mode 100644 index 6d90476..0000000 --- a/generate_dependencies.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Check if the correct number of arguments is provided -if [ -z "$1" ]; then - echo "Usage: $0 [force|missing]" - exit 1 -fi - -# Add the remote -conan remote add bigfootpackages https://conan.romainboullard.com/artifactory/api/conan/BigfootPackages - -# Install the conan configuration -conan config install https://git.romainboullard.com/BigfootDev/ConanProfiles.git - -# Set the build option based on the argument -if [ "$1" == "force" ]; then - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clang -pr:b=clang --build='*' -of build -s build_type=Release -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clangd -pr:b=clangd --build='*' -of build -s build_type=RelWithDebInfo -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clangd -pr:b=clangd --build='*' -of build -s build_type=Debug -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True -elif [ "$1" == "missing" ]; then - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clang -pr:b=clang --build=missing -of build -s build_type=Release -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clangd -pr:b=clangd --build=missing -of build -s build_type=RelWithDebInfo -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True - conan install . --deployer=full_deploy --remote=bigfootpackages -pr:h=clangd -pr:b=clangd --build=missing -of build -s build_type=Debug -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=True -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True -else - echo "Invalid argument: $1" - echo "Usage: $0 [force|missing]" - exit 1 -fi