From 5df9325f630425b9d52ddabb86b8e08c2f7ea317 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Tue, 3 Dec 2024 08:00:59 +0100 Subject: [PATCH] Add wayland build tag, issue #404 --- README.md | 1 + raylib/cgo_linux.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 309ad7aa..a916b78e 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ It is also possible to build the DLL yourself. You can find more info at [raylib * `es2` - uses OpenGL ES 2.0 backend (can be used to link against [Google's ANGLE](https://github.com/google/angle)) * `es3` - experimental support for OpenGL ES 3.0 * `x11` - force X11 compatibility mode on Wayland (PLATFORM_DESKTOP/GLFW) +* `wayland` - force Wayland only mode (PLATFORM_DESKTOP/GLFW) ### Documentation diff --git a/raylib/cgo_linux.go b/raylib/cgo_linux.go index 07f98863..d6c3b81d 100644 --- a/raylib/cgo_linux.go +++ b/raylib/cgo_linux.go @@ -12,14 +12,18 @@ package rl #include "external/glfw/src/vulkan.c" #include "external/glfw/src/window.c" +#if defined _GLFW_WAYLAND #include "external/glfw/src/wl_init.c" #include "external/glfw/src/wl_monitor.c" #include "external/glfw/src/wl_window.c" +#endif +#if defined _GLFW_X11 #include "external/glfw/src/x11_init.c" #include "external/glfw/src/x11_monitor.c" #include "external/glfw/src/x11_window.c" #include "external/glfw/src/glx_context.c" +#endif #include "external/glfw/src/linux_joystick.c" #include "external/glfw/src/posix_module.c" @@ -35,12 +39,14 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) { } #cgo linux CFLAGS: -Iexternal/glfw/include -DPLATFORM_DESKTOP -Wno-stringop-overflow -#cgo linux LDFLAGS: -lm -pthread -ldl -lrt -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon +#cgo linux LDFLAGS: -lm -pthread -ldl -lrt -lxkbcommon +#cgo linux,!x11 LDFLAGS: -lwayland-client -lwayland-cursor -lwayland-egl #cgo linux,x11 CFLAGS: -D_GLFW_X11 -#cgo linux,!x11 CFLAGS: -D_GLFW_X11 -D_GLFW_WAYLAND +#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND +#cgo linux,!x11,!wayland CFLAGS: -D_GLFW_X11 -D_GLFW_WAYLAND -#cgo linux,!es2,!es3 LDFLAGS: -lGL +#cgo linux,!es2,!es3,!wayland LDFLAGS: -lGL #cgo linux,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11 #cgo linux,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21