Fixed it
This commit is contained in:
parent
0460ae1a50
commit
1dca4a91d9
19 changed files with 333 additions and 156 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,3 +4,6 @@ bin-int/
|
|||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
!/vendor/**
|
||||
|
||||
subprojects/
|
||||
!subprojects/*.wrap
|
||||
|
|
22
.vscode/launch.json
vendored
Normal file
22
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"name": "Debug Sandbox Shared",
|
||||
"program": "${workspaceFolder}/builddir/Sandbox/sandbox_shared.exe",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "build"
|
||||
},
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"name": "Debug Sandbox Static",
|
||||
"program": "${workspaceFolder}/builddir/Sandbox/sandbox_static.exe",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "build"
|
||||
},
|
||||
]
|
||||
}
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"C_Cpp.default.compileCommands": "d:\\FluxEngine\\builddir/compile_commands.json",
|
||||
"C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild",
|
||||
"cmake.ignoreCMakeListsMissing": true
|
||||
"cmake.ignoreCMakeListsMissing": true,
|
||||
"C_Cpp.errorSquiggles": "enabled"
|
||||
}
|
24
.vscode/tasks.json
vendored
Normal file
24
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "setup",
|
||||
"type": "shell",
|
||||
"command": "meson setup builddir",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
},
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "meson compile -C builddir",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"dependsOn": "setup",
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,23 +1,54 @@
|
|||
flux_inc = include_directories('src/public')
|
||||
|
||||
flux_sources = files(
|
||||
'src/private/Application.cpp',
|
||||
'src/private/Engine/Engine.cpp',
|
||||
'src/private/Log.cpp',
|
||||
)
|
||||
|
||||
spd = subproject('spdlog')
|
||||
spdlog_dep = spd.get_variable('spdlog')
|
||||
# 1) Grab the active C++ compiler
|
||||
cpp = meson.get_compiler('cpp')
|
||||
ccid = cpp.get_id() # e.g. 'msvc', 'gcc', 'clang', 'intel', ...
|
||||
|
||||
flux_lib = library(
|
||||
'fluxengine',
|
||||
# 2) Decide your D-flag prefix
|
||||
if ccid == 'msvc'
|
||||
dflag = '/D'
|
||||
else
|
||||
dflag = '-D'
|
||||
endif
|
||||
|
||||
if meson.get_compiler('cpp').get_id() == 'msvc'
|
||||
add_project_arguments('/utf-8', language: 'cpp')
|
||||
endif
|
||||
|
||||
spdlog_dep = dependency(
|
||||
'spdlog',
|
||||
required: true,
|
||||
fallback: ['spdlog', 'spdlog_dep'],
|
||||
version: '>=1.15.0',
|
||||
method: 'cmake',
|
||||
static: true,
|
||||
)
|
||||
|
||||
# 2A) Shared library (DLL + import lib)
|
||||
flux_shared = shared_library(
|
||||
'FluxEngine_shared',
|
||||
flux_sources,
|
||||
include_directories: flux_inc,
|
||||
link_with : spdlog_dep,
|
||||
version : meson.project_version(),
|
||||
install : true,
|
||||
dependencies: [spdlog_dep],
|
||||
cpp_args: [
|
||||
dflag + 'FLUX_BUILD_DLL'
|
||||
],
|
||||
install: true
|
||||
)
|
||||
|
||||
flux_dep = declare_dependency(
|
||||
# 2B) Static library
|
||||
flux_static = static_library(
|
||||
'FluxEngine_static',
|
||||
flux_sources,
|
||||
include_directories: flux_inc,
|
||||
link_with : [ flux_lib, spdlog_dep ],
|
||||
dependencies: [spdlog_dep],
|
||||
cpp_args: [
|
||||
dflag + 'FLUX_STATIC'
|
||||
],
|
||||
install: true
|
||||
)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#include "Application.h"
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
namespace Flux {
|
||||
|
||||
Application::Application()
|
||||
{
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
}
|
||||
void Application::Run()
|
||||
{
|
||||
FLUX_CORE_TRACE("FLUX Engine Running!");
|
||||
while (true);
|
||||
}
|
||||
}
|
58
FluxEngine/src/private/Engine/Engine.cpp
Normal file
58
FluxEngine/src/private/Engine/Engine.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "Engine/Engine.h"
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
bool FluxEngine::GIsRunning = false;
|
||||
FluxEngine* FluxEngine::GInstance = nullptr;
|
||||
|
||||
FluxEngine::FluxEngine() : _Logger(*new Logger())
|
||||
{
|
||||
if (GIsRunning)
|
||||
{
|
||||
GetLogger()->LogTrace("Engine already running!");
|
||||
bErrorState = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (GInstance != nullptr)
|
||||
{
|
||||
FluxEngine* Engine = GetInstance();
|
||||
|
||||
if (Engine)
|
||||
{
|
||||
Engine->GetLogger()->LogTrace("Engine already running!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GInstance = this;
|
||||
}
|
||||
|
||||
FluxEngine::~FluxEngine()
|
||||
{
|
||||
GetLogger()->LogTrace("Engine shutting down!");
|
||||
}
|
||||
|
||||
void FluxEngine::Start()
|
||||
{
|
||||
if (bErrorState)
|
||||
{
|
||||
GetLogger()->LogTrace("Engine failed to start!");
|
||||
return;
|
||||
}
|
||||
|
||||
GetLogger()->LogTrace("Engine started!");
|
||||
GIsRunning = true;
|
||||
EngineLoop();
|
||||
}
|
||||
|
||||
void Flux::FluxEngine::EngineLoop()
|
||||
{
|
||||
while (IsRunning())
|
||||
{
|
||||
GetLogger()->LogTrace("Loop running!");
|
||||
// Main engine loop
|
||||
// Update, render, etc.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#ifdef FLUX_PLATFORM_WINDOWS
|
||||
|
||||
extern Flux::Application* Flux::CreateApplication();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Flux::Log::Init();
|
||||
|
||||
FLUX_CORE_WARN("Logging Initialized!");
|
||||
int a = 5;
|
||||
FLUX_INFO("Hello! {0}", a);
|
||||
|
||||
auto app = Flux::CreateApplication();
|
||||
app->Run();
|
||||
delete app;
|
||||
}
|
||||
#endif
|
|
@ -1,19 +1,50 @@
|
|||
#include "Log.h"
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
|
||||
std::shared_ptr<spdlog::logger> Log::s_ClientLogger;
|
||||
|
||||
void Log::Init()
|
||||
struct LoggerImpl
|
||||
{
|
||||
spdlog::set_pattern("%^[%T] %n: %v%$");
|
||||
s_CoreLogger = spdlog::stdout_color_mt("FLUX");
|
||||
s_CoreLogger->set_level(spdlog::level::trace);
|
||||
LoggerImpl() = default;
|
||||
~LoggerImpl() = default;
|
||||
|
||||
s_ClientLogger = spdlog::stdout_color_mt("APP");
|
||||
s_ClientLogger->set_level(spdlog::level::trace);
|
||||
std::shared_ptr<spdlog::logger> _logger;
|
||||
};
|
||||
|
||||
Logger::~Logger() = default;
|
||||
|
||||
spdlog::logger *Logger::GetLogger() const
|
||||
{
|
||||
return _impl._logger.get();
|
||||
}
|
||||
|
||||
Logger::Logger() : _impl(* new LoggerImpl())
|
||||
{
|
||||
// Initialize the logger
|
||||
if (GetLogger()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new logger instance
|
||||
spdlog::set_pattern("%^[%T] %n: %v%$");
|
||||
|
||||
_impl._logger = spdlog::stdout_color_mt("FLUX");
|
||||
_impl._logger->set_level(spdlog::level::trace);
|
||||
|
||||
LogTrace("Logger initialized!");
|
||||
}
|
||||
|
||||
void Logger::LogTrace(const std::string &message)
|
||||
{
|
||||
spdlog::logger* logger = GetLogger();
|
||||
|
||||
if (!logger)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger->trace(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
namespace Flux {
|
||||
class FLUX_API Application
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
virtual ~Application();
|
||||
|
||||
void Run();
|
||||
};
|
||||
|
||||
Application* CreateApplication();
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef FLUX_PLATFORM_WINDOWS
|
||||
#ifdef FLUX_BUILD_DLL
|
||||
#define FLUX_API __declspec(dllexport)
|
||||
#else
|
||||
#define FLUX_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#error Flux only supports windows!
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define FLUX_PLATFORM_WINDOWS
|
||||
#elif defined(__linux__)
|
||||
#define FLUX_PLATFORM_LINUX
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#define FLUX_PLATFORM_MACOS
|
||||
#endif
|
||||
|
||||
#if defined(FLUX_PLATFORM_WINDOWS)
|
||||
#if defined(FLUX_BUILD_DLL)
|
||||
#define FLUX_API __declspec(dllexport)
|
||||
#elif defined(FLUX_STATIC)
|
||||
#define FLUX_API
|
||||
#else
|
||||
#define FLUX_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define FLUX_API
|
||||
#endif
|
56
FluxEngine/src/public/Engine/Engine.h
Normal file
56
FluxEngine/src/public/Engine/Engine.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "Core.h"
|
||||
#include "Log.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
class FLUX_API FluxEngine
|
||||
{
|
||||
public:
|
||||
FluxEngine();
|
||||
~FluxEngine();
|
||||
|
||||
void Start();
|
||||
|
||||
static FluxEngine* GetInstance()
|
||||
{
|
||||
return GInstance;
|
||||
}
|
||||
|
||||
static bool IsRunning()
|
||||
{
|
||||
return GIsRunning;
|
||||
}
|
||||
|
||||
static Logger* GetLogger()
|
||||
{
|
||||
if (GIsRunning || GInstance != nullptr)
|
||||
{
|
||||
FluxEngine* Engine = GetInstance();
|
||||
if (Engine)
|
||||
{
|
||||
return &Engine->_Logger;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RequestExit()
|
||||
{
|
||||
GIsRunning = false;
|
||||
}
|
||||
|
||||
void EngineLoop();
|
||||
|
||||
private:
|
||||
Flux::Logger& _Logger;
|
||||
|
||||
static bool GIsRunning;
|
||||
static FluxEngine* GInstance;
|
||||
|
||||
bool bErrorState = false;
|
||||
};
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "Flux/Application.h"
|
||||
#include "Flux/Log.h"
|
||||
|
||||
#include "Flux/EntryPoint.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Log.h"
|
|
@ -1,28 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Core.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace spdlog
|
||||
{
|
||||
class logger;
|
||||
}
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
class FLUX_API Log
|
||||
struct LoggerImpl;
|
||||
|
||||
class FLUX_API Logger
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
|
||||
inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
|
||||
private:
|
||||
static std::shared_ptr<spdlog::logger> s_CoreLogger;
|
||||
static std::shared_ptr<spdlog::logger> s_ClientLogger;
|
||||
};
|
||||
Logger();
|
||||
~Logger();
|
||||
|
||||
void LogTrace(const std::string& message);
|
||||
private:
|
||||
spdlog::logger* GetLogger() const;
|
||||
|
||||
Flux::LoggerImpl& _impl;
|
||||
};
|
||||
}
|
||||
|
||||
// Core log macros
|
||||
#define FLUX_CORE_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__)
|
||||
/*#define FLUX_CORE_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__)
|
||||
#define FLUX_CORE_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__)
|
||||
#define FLUX_CORE_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__)
|
||||
#define FLUX_CORE_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__)
|
||||
|
@ -33,4 +40,4 @@ namespace Flux
|
|||
#define FLUX_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__)
|
||||
#define FLUX_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__)
|
||||
#define FLUX_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__)
|
||||
#define FLUX_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__)
|
||||
#define FLUX_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__)*/
|
||||
|
|
|
@ -5,7 +5,7 @@ rem ─────────────────────────
|
|||
rem Defaults (override by passing [backend] [build])
|
||||
rem ──────────────────────────────────────────────────
|
||||
set BUILD_DIR=builddir
|
||||
set BACKEND=ninja
|
||||
set BACKEND=vs2022
|
||||
set BUILD=debug
|
||||
|
||||
rem ──────────────────────────────────────────────────
|
||||
|
@ -22,18 +22,6 @@ 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 ──────────────────────────────────────────────────
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
# 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
|
||||
|
||||
# Point to the public headers of FluxEngine
|
||||
sandbox_inc = include_directories(
|
||||
'../FluxEngine/src/public'
|
||||
)
|
||||
|
||||
executable(
|
||||
'sandbox',
|
||||
'sandbox_Shared',
|
||||
'src/private/SandboxApp.cpp',
|
||||
include_directories: sandbox_inc,
|
||||
dependencies : flux_dep,
|
||||
install : true,
|
||||
include_directories: [sandbox_inc, flux_inc],
|
||||
link_with: [ flux_shared ],
|
||||
)
|
||||
|
||||
executable(
|
||||
'sandbox_Static',
|
||||
'src/private/SandboxApp.cpp',
|
||||
include_directories: [sandbox_inc, flux_inc],
|
||||
link_with: [ flux_static ],
|
||||
cpp_args: [
|
||||
dflag + 'FLUX_STATIC'
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
#include <Flux.h>
|
||||
#include "Flux.h"
|
||||
|
||||
class Sandbox : public Flux::Application
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
public:
|
||||
Sandbox()
|
||||
{
|
||||
Flux::FluxEngine engine;
|
||||
engine.Start();
|
||||
|
||||
}
|
||||
~Sandbox()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Flux::Application* Flux::CreateApplication()
|
||||
{
|
||||
return new Sandbox();
|
||||
return 0;
|
||||
}
|
18
meson.build
18
meson.build
|
@ -2,7 +2,7 @@ project(
|
|||
'FluxEngine',
|
||||
'cpp',
|
||||
version : '0.1.0',
|
||||
meson_version : '>=0.60.0',
|
||||
meson_version : '>=0.63.0',
|
||||
default_options : [
|
||||
'cpp_std=c++20',
|
||||
'warning_level=3',
|
||||
|
@ -21,22 +21,10 @@ 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'
|
||||
if meson.get_compiler('cpp').get_id() == 'msvc'
|
||||
add_project_arguments('/utf-8', language: 'cpp')
|
||||
endif
|
||||
|
||||
add_global_arguments(dflag + plat, language : 'cpp')
|
||||
|
||||
# 4) Build-type macros
|
||||
bt = get_option('buildtype')
|
||||
if bt == 'debug'
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
[wrap-git]
|
||||
url = https://github.com/gabime/spdlog.git
|
||||
revision = v1.15.2
|
||||
depth = 1
|
||||
method = cmake
|
||||
[wrap-file]
|
||||
directory = spdlog-1.15.2
|
||||
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.15.2.tar.gz
|
||||
source_filename = spdlog-1.15.2.tar.gz
|
||||
source_hash = 7a80896357f3e8e920e85e92633b14ba0f229c506e6f978578bdc35ba09e9a5d
|
||||
patch_filename = spdlog_1.15.2-3_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.15.2-3/get_patch
|
||||
patch_hash = d5ab078661f571ef5113a8e4bc5c4121e16c044e7772a24b44b1ca8f3ee7c6cb
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.15.2-3/spdlog-1.15.2.tar.gz
|
||||
wrapdb_version = 1.15.2-3
|
||||
|
||||
[provide]
|
||||
spdlog = spdlog_dep
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue