From feeb6e59751d1ef071f7393a09b8c47a160df15f Mon Sep 17 00:00:00 2001 From: staruwos Date: Thu, 20 Nov 2025 20:27:59 -0300 Subject: [PATCH 1/2] Split X11 and Wayland compiler flags --- build/premake5.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/build/premake5.lua b/build/premake5.lua index 6b777ec..a82fbe3 100644 --- a/build/premake5.lua +++ b/build/premake5.lua @@ -103,19 +103,13 @@ function platform_defines() filter {"system:macosx"} disablewarnings {"deprecated-declarations"} - filter {"system:linux"} + filter {"system:linux", "options:wayland=off"} defines {"_GLFW_X11"} - defines {"_GNU_SOURCE"} --- This is necessary, otherwise compilation will fail since --- there is no CLOCK_MONOTOMIC. raylib claims to have a workaround --- to compile under c99 without -D_GNU_SOURCE, but it didn't seem --- to work. raylib's Makefile also adds this flag, probably why it went --- unnoticed for so long. --- It compiles under c11 without -D_GNU_SOURCE, because c11 requires --- to have CLOCK_MONOTOMIC --- See: https://github.com/raysan5/raylib/issues/2729 - filter{} + filter {"system:linux", "options:wayland=on"} + defines {"_GLFW_WAYLAND"} + + filter {} end -- if you don't want to download raylib, then set this to false, and set the raylib dir to where you want raylib to be pulled from, must be full sources. @@ -231,7 +225,13 @@ if (downloadRaylib) then libdirs {"../bin/%{cfg.buildcfg}"} filter "system:linux" - links {"pthread", "m", "dl", "rt", "X11"} + links {"pthread", "m", "dl", "rt"} + + filter {"system:linux", "options:wayland=off"} + links {"X11"} + + filter {"system:linux", "options:wayland=on"} + links {"wayland-client", "wayland-cursor", "wayland-egl", "xkbcommon"} filter "system:macosx" links {"OpenGL.framework", "Cocoa.framework", "IOKit.framework", "CoreFoundation.framework", "CoreAudio.framework", "CoreVideo.framework", "AudioToolbox.framework"} @@ -249,6 +249,7 @@ if (downloadRaylib) then language "C" targetdir "../bin/%{cfg.buildcfg}" + filter {"options:wayland=on"} defines {"GLFW_LINUX_ENABLE_WAYLAND=TRUE" } From 371927cb86c7861ba268a9748f3256adb8af2dff Mon Sep 17 00:00:00 2001 From: staruwos Date: Thu, 20 Nov 2025 20:28:53 -0300 Subject: [PATCH 2/2] Add generate step for Wayland protocols --- build/premake5.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build/premake5.lua b/build/premake5.lua index a82fbe3..b49f0f2 100644 --- a/build/premake5.lua +++ b/build/premake5.lua @@ -253,6 +253,32 @@ if (downloadRaylib) then filter {"options:wayland=on"} defines {"GLFW_LINUX_ENABLE_WAYLAND=TRUE" } + filter {"options:wayland=on", "system:linux"} + prebuildcommands { + "@echo Generating Wayland protocols...", + -- Core Wayland & Shell + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/wayland.xml ../" .. raylib_dir .. "/src/wayland-client-protocol.h", + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/xdg-shell.xml ../" .. raylib_dir .. "/src/xdg-shell-client-protocol.h", + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml ../" .. raylib_dir .. "/src/xdg-decoration-unstable-v1-client-protocol.h", + + -- Viewporter + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/viewporter.xml ../" .. raylib_dir .. "/src/viewporter-client-protocol.h", + + -- Relative Pointer + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml ../" .. raylib_dir .. "/src/relative-pointer-unstable-v1-client-protocol.h", + -- Pointer Constraints + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml ../" .. raylib_dir .. "/src/pointer-constraints-unstable-v1-client-protocol.h", + + -- Fractional Scale + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/fractional-scale-v1.xml ../" .. raylib_dir .. "/src/fractional-scale-v1-client-protocol.h", + + -- XDG Activation + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/xdg-activation-v1.xml ../" .. raylib_dir .. "/src/xdg-activation-v1-client-protocol.h", + -- Idle Inhibit + "@wayland-scanner client-header ../" .. raylib_dir .. "/src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml ../" .. raylib_dir .. "/src/idle-inhibit-unstable-v1-client-protocol.h", + } + filter {} + filter "action:vs*" defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"} characterset ("Unicode")