diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c02c8a3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "C_Cpp.default.compileCommands": "d:\\FluxEngine\\builddir/compile_commands.json", + "C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild", + "cmake.ignoreCMakeListsMissing": true +} \ No newline at end of file diff --git a/FluxEngine/meson.build b/FluxEngine/meson.build new file mode 100644 index 0000000..8a4d40a --- /dev/null +++ b/FluxEngine/meson.build @@ -0,0 +1,23 @@ +flux_inc = include_directories('src/public') + +flux_sources = files( + 'src/private/Application.cpp', + 'src/private/Log.cpp', +) + +spd = subproject('spdlog') +spdlog_dep = spd.get_variable('spdlog') + +flux_lib = library( + 'fluxengine', + flux_sources, + include_directories: flux_inc, + link_with : spdlog_dep, + version : meson.project_version(), + install : true, +) + +flux_dep = declare_dependency( + include_directories: flux_inc, + link_with : [ flux_lib, spdlog_dep ], +) diff --git a/FluxEngine/src/Flux/Application.cpp b/FluxEngine/src/private/Application.cpp similarity index 100% rename from FluxEngine/src/Flux/Application.cpp rename to FluxEngine/src/private/Application.cpp diff --git a/FluxEngine/src/Flux/EntryPoint.h b/FluxEngine/src/private/EntryPoint.h similarity index 100% rename from FluxEngine/src/Flux/EntryPoint.h rename to FluxEngine/src/private/EntryPoint.h diff --git a/FluxEngine/src/Flux/Log.cpp b/FluxEngine/src/private/Log.cpp similarity index 100% rename from FluxEngine/src/Flux/Log.cpp rename to FluxEngine/src/private/Log.cpp diff --git a/FluxEngine/src/Flux/Application.h b/FluxEngine/src/public/Application.h similarity index 100% rename from FluxEngine/src/Flux/Application.h rename to FluxEngine/src/public/Application.h diff --git a/FluxEngine/src/Flux/Core.h b/FluxEngine/src/public/Core.h similarity index 100% rename from FluxEngine/src/Flux/Core.h rename to FluxEngine/src/public/Core.h diff --git a/FluxEngine/src/Flux.h b/FluxEngine/src/public/Flux.h similarity index 100% rename from FluxEngine/src/Flux.h rename to FluxEngine/src/public/Flux.h diff --git a/FluxEngine/src/Flux/Log.h b/FluxEngine/src/public/Log.h similarity index 100% rename from FluxEngine/src/Flux/Log.h rename to FluxEngine/src/public/Log.h diff --git a/GenerateProjects.bat b/GenerateProjects.bat index 12bf84e..f8ba26f 100644 --- a/GenerateProjects.bat +++ b/GenerateProjects.bat @@ -1,2 +1,71 @@ -call .\vendor\bin\premake\premake5.exe vs2022 -PAUSE \ No newline at end of file +@echo off +setlocal enabledelayedexpansion + +rem ────────────────────────────────────────────────── +rem Defaults (override by passing [backend] [build]) +rem ────────────────────────────────────────────────── +set BUILD_DIR=builddir +set BACKEND=ninja +set BUILD=debug + +rem ────────────────────────────────────────────────── +rem Recognize help flags +rem ────────────────────────────────────────────────── +if /I "%~1"=="-?" goto usage +if /I "%~1"=="/?" goto usage +if /I "%~1"=="-h" goto usage +if /I "%~1"=="--help" goto usage + +rem ────────────────────────────────────────────────── +rem Parse positional arguments +rem ────────────────────────────────────────────────── +if not "%~1"=="" set BACKEND=%~1 +if not "%~2"=="" set BUILD=%~2 + +rem ────────────────────────────────────────────────── +rem Bootstrap Visual Studio if requested +rem ────────────────────────────────────────────────── +if /I "%BACKEND:~0,2%"=="vs" ( + echo [INFO] Initializing Visual Studio environment for %BACKEND%... + call "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 >nul 2>&1 + if errorlevel 1 ( + echo [ERROR] Failed to initialize VS environment. Check the vcvarsall.bat path. + exit /b 1 + ) +) + +rem ────────────────────────────────────────────────── +rem Configure or reconfigure with Meson +rem ────────────────────────────────────────────────── +if not exist "%BUILD_DIR%" ( + echo [INFO] Creating build directory "%BUILD_DIR%" with backend "%BACKEND%" and build "%BUILD%"... + meson setup "%BUILD_DIR%" --backend=%BACKEND% --buildtype=%BUILD% +) else ( + echo [INFO] Reconfiguring "%BUILD_DIR%" with backend "%BACKEND%" and build "%BUILD%"... + meson setup --reconfigure "%BUILD_DIR%" --backend=%BACKEND% --buildtype=%BUILD% +) + +if errorlevel 1 ( + echo [ERROR] Meson configuration failed. + exit /b 1 +) + +rem ────────────────────────────────────────────────── +rem Compile +rem ────────────────────────────────────────────────── +echo [INFO] Configuration succeeded—starting build... +meson compile -C "%BUILD_DIR%" +if errorlevel 1 ( + echo [ERROR] Build failed. + exit /b 1 +) + +echo [SUCCESS] Build completed successfully. +exit /b 0 + +:usage +echo Usage: %~nx0 [backend] [build] +echo. +echo backend ninja (default) ^| vs2022 ^| vs2019 ^| vs2017 +echo build debug (default) ^| debugoptimized ^| release ^| relwithdebinfo +exit /b 0 diff --git a/Sandbox/meson.build b/Sandbox/meson.build new file mode 100644 index 0000000..0d1e978 --- /dev/null +++ b/Sandbox/meson.build @@ -0,0 +1,12 @@ +# Point to the public headers of FluxEngine +sandbox_inc = include_directories( + '../FluxEngine/src/public' +) + +executable( + 'sandbox', + 'src/private/SandboxApp.cpp', + include_directories: sandbox_inc, + dependencies : flux_dep, + install : true, +) diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/private/SandboxApp.cpp similarity index 100% rename from Sandbox/src/SandboxApp.cpp rename to Sandbox/src/private/SandboxApp.cpp diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..facaa72 --- /dev/null +++ b/meson.build @@ -0,0 +1,54 @@ +project( + 'FluxEngine', + 'cpp', + version : '0.1.0', + meson_version : '>=0.60.0', + default_options : [ + 'cpp_std=c++20', + 'warning_level=3', + 'buildtype=debugoptimized', + ] +) + +# 1) Grab the active C++ compiler +cpp = meson.get_compiler('cpp') +ccid = cpp.get_id() # e.g. 'msvc', 'gcc', 'clang', 'intel', ... + +# 2) Decide your D-flag prefix +if ccid == 'msvc' + dflag = '/D' +else + dflag = '-D' +endif + +# 3) Platform macro (all OSes) +sys = host_machine.system() +if sys == 'windows' + plat = 'FLUX_PLATFORM_WINDOWS' +elif sys == 'linux' + plat = 'FLUX_PLATFORM_LINUX' +elif sys == 'darwin' + plat = 'FLUX_PLATFORM_MACOS' +elif sys == 'freebsd' + plat = 'FLUX_PLATFORM_FREEBSD' +else + plat = 'FLUX_PLATFORM_UNKNOWN' +endif + +add_global_arguments(dflag + plat, language : 'cpp') + +# 4) Build-type macros +bt = get_option('buildtype') +if bt == 'debug' + add_project_arguments(dflag + 'FLUX_DEBUG', language : 'cpp') +elif bt == 'release' + add_project_arguments(dflag + 'FLUX_RELEASE', language : 'cpp') +elif bt == 'debugoptimized' + add_project_arguments(dflag + 'FLUX_DIST', language : 'cpp') +else + warning('Unrecognized buildtype: ' + bt) +endif + +# Tell Meson to descend into these directories +subdir('FluxEngine') +subdir('Sandbox') diff --git a/premake5.lua b/premake5.lua deleted file mode 100644 index 079eeda..0000000 --- a/premake5.lua +++ /dev/null @@ -1,98 +0,0 @@ -workspace "FluxEngine" - architecture "x64" - startproject "Sandbox" - - configurations { "Debug", "Release", "Dist" } - -outputdir = "%{cfg.buildcfg}-%{cfg.system}" - -project "FluxEngine" - location "FluxEngine" - kind "SharedLib" - language "C++" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - files - { - "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp", - } - - includedirs - { - "%{prj.name}/vendor/spdlog/include", - } - - filter "system:windows" - cppdialect "C++20" - staticruntime "on" - systemversion "latest" - defines - { - "FLUX_PLATFORM_WINDOWS", - "FLUX_BUILD_DLL" - } - - postbuildcommands - { - ("{COPY} %{cfg.buildtarget.relpath} ../bin/".. outputdir .. "/Sandbox") - } - filter "configurations:Debug" - defines "FLUX_DEBUG" - symbols "On" - - filter "configurations:Release" - defines "FLUX_RELEASE" - optimize "On" - - filter "configurations:Dist" - defines "FLUX_DIST" - optimize "On" - -project "Sandbox" - location "Sandbox" - kind "ConsoleApp" - language "C++" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - files - { - "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp", - } - - includedirs - { - "FluxEngine/vendor/spdlog/include", - "FluxEngine/src" - } - - links - { - "FluxEngine" - } - - filter "system:windows" - cppdialect "C++20" - staticruntime "on" - systemversion "latest" - defines - { - "FLUX_PLATFORM_WINDOWS" - } - - filter "configurations:Debug" - defines "FLUX_DEBUG" - symbols "On" - - filter "configurations:Release" - defines "FLUX_RELEASE" - optimize "On" - - filter "configurations:Dist" - defines "FLUX_DIST" - optimize "On" \ No newline at end of file diff --git a/subprojects/spdlog.wrap b/subprojects/spdlog.wrap new file mode 100644 index 0000000..1e8bb55 --- /dev/null +++ b/subprojects/spdlog.wrap @@ -0,0 +1,5 @@ +[wrap-git] +url = https://github.com/gabime/spdlog.git +revision = v1.15.2 +depth = 1 +method = cmake \ No newline at end of file diff --git a/vendor/bin/premake/LICENSE.txt b/vendor/bin/premake/LICENSE.txt deleted file mode 100644 index 63962d7..0000000 --- a/vendor/bin/premake/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2003-2022 Jason Perkins and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of Premake nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/bin/premake/premake5.exe b/vendor/bin/premake/premake5.exe deleted file mode 100644 index 1a637aa..0000000 Binary files a/vendor/bin/premake/premake5.exe and /dev/null differ