Conditionally compile different drivers

This commit is contained in:
2025-03-28 18:13:19 +10:00
parent 211eb9a1d6
commit 40cfa9901e
7 changed files with 117 additions and 37 deletions

View File

@@ -4,12 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifdef NOVA_WINDOWS
#include "drivers/windows/system_driver.h"
#endif
#ifdef NOVA_LINUX
#include "drivers/linux/system_driver.h"
#endif
#include <nova/core/debug.h>
#include <nova/platform/system.h>
#include "drivers/linux/wayland/system_driver.h"
#include "drivers/linux/x11/system_driver.h"
#include "drivers/windows/system_driver.h"
#include <memory>
using namespace Nova;
@@ -19,17 +24,12 @@ void System::init() {
NOVA_AUTO_TRACE();
NOVA_ASSERT(!s_driver);
#ifdef WIN32
#ifdef NOVA_WINDOWS
s_driver = std::make_unique<WindowsSystemDriver>();
#elif NOVA_LINUX
s_driver = LinuxSystemDriver::get_default_driver();
#else
if (std::getenv("WAYLAND_DISPLAY")) {
s_driver = std::make_unique<WaylandSystemDriver>();
} else if (std::getenv("DISPLAY")) {
s_driver = std::make_unique<X11SystemDriver>();
} else {
NOVA_ERROR("Unsupported windowing system");
s_driver = std::make_unique<LinuxSystemDriver>();
}
throw std::runtime_error("Unsupported platform");
#endif
}