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,10 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "drivers/linux/system_driver.h"
#ifdef NOVA_WAYLAND
#include "drivers/linux/wayland/system_driver.h"
#endif
#ifdef NOVA_X11
#include "drivers/linux/x11/system_driver.h"
#endif
#include <nova/core/debug.h>
#include "drivers/linux/system_driver.h"
using namespace Nova;
LinuxSystemDriver::LinuxSystemDriver() {
@@ -17,3 +24,21 @@ LinuxSystemDriver::LinuxSystemDriver() {
LinuxSystemDriver::~LinuxSystemDriver() {
NOVA_AUTO_TRACE();
}
std::unique_ptr<SystemDriver> LinuxSystemDriver::get_default_driver() {
NOVA_AUTO_TRACE();
#ifdef NOVA_WAYLAND
if (std::getenv("WAYLAND_DISPLAY")) {
return std::make_unique<WaylandSystemDriver>();
}
#endif
#ifdef NOVA_X11
if (std::getenv("DISPLAY")) {
return std::make_unique<X11SystemDriver>();
}
#endif
NOVA_WARN("Unsupported display server");
return std::make_unique<LinuxSystemDriver>();
}

View File

@@ -8,10 +8,14 @@
#include <nova/platform/system_driver.h>
#include <memory>
namespace Nova {
class LinuxSystemDriver : public SystemDriver {
public:
LinuxSystemDriver();
~LinuxSystemDriver() override;
static std::unique_ptr<SystemDriver> get_default_driver();
};
} // namespace Nova