glfw: add version with wayland support (#129367)

This commit is contained in:
Lucas Ransan 2021-07-14 12:45:21 +02:00 committed by GitHub
parent ae7c092d88
commit 86bb129011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View File

@ -1,6 +1,8 @@
{ stdenv, lib, fetchFromGitHub, cmake
, libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext
, Cocoa, Kernel, fixDarwinDylibNames
, waylandSupport ? false, extra-cmake-modules, wayland
, wayland-protocols, libxkbcommon
}:
stdenv.mkDerivation rec {
@ -14,20 +16,34 @@ stdenv.mkDerivation rec {
sha256 = "sha256-BP4wxjgm0x0E68tNz5eudkVUyBnXkQlP7LY3ppZunhw=";
};
patches = lib.optional waylandSupport ./wayland.patch;
propagatedBuildInputs = [ libGL ];
nativeBuildInputs = [ cmake ]
++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.isDarwin fixDarwinDylibNames
++ lib.optional waylandSupport extra-cmake-modules;
buildInputs = [ libX11 libXrandr libXinerama libXcursor libXi libXext ]
++ lib.optionals stdenv.isDarwin [ Cocoa Kernel ];
buildInputs =
if waylandSupport
then [ wayland wayland-protocols libxkbcommon ]
else [ libX11 libXrandr libXinerama libXcursor libXi libXext ]
++ lib.optionals stdenv.isDarwin [ Cocoa Kernel ];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
] ++ lib.optional (!stdenv.isDarwin) [
] ++ lib.optionals (!stdenv.isDarwin) [
"-DCMAKE_C_FLAGS=-D_GLFW_GLX_LIBRARY='\"${lib.getLib libGL}/lib/libGL.so.1\"'"
] ++ lib.optionals waylandSupport [
"-DGLFW_USE_WAYLAND=ON"
"-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'"
];
postPatch = lib.optionalString waylandSupport ''
substituteInPlace src/wl_init.c \
--replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0"
'';
meta = with lib; {
description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
homepage = "https://www.glfw.org/";

View File

@ -0,0 +1,25 @@
From 46fb81c69e8acdb70907409f98dd01e387408414 Mon Sep 17 00:00:00 2001
From: Stone Tickle <lattis@mochiro.moe>
Date: Fri, 5 Jun 2020 12:51:25 +0900
Subject: [PATCH] set O_NONBLOCK on repeat timerfd
---
src/wl_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wl_init.c b/src/wl_init.c
index 49e7cc52..43569bef 100644
--- a/src/wl_init.c
+++ b/src/wl_init.c
@@ -1166,7 +1166,7 @@ int _glfwPlatformInit(void)
_glfw.wl.timerfd = -1;
if (_glfw.wl.seatVersion >= 4)
- _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
+ _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
if (_glfw.wl.pointer && _glfw.wl.shm)
{
--
2.31.1

View File

@ -15310,6 +15310,9 @@ in
});
glfw = glfw3;
glfw-wayland = glfw.override {
waylandSupport = true;
};
glfw2 = callPackage ../development/libraries/glfw/2.x.nix { };
glfw3 = callPackage ../development/libraries/glfw/3.x.nix {
inherit (darwin.apple_sdk.frameworks) Cocoa Kernel;