@@ -2,7 +2,7 @@ package = {
22 spec = " 1" ,
33 namespace = " compat" ,
44 name = " compat.glfw" ,
5- description = " GLFW windowing and input library built from source with the null platform backend " ,
5+ description = " GLFW windowing and input library built from upstream sources " ,
66 licenses = {" Zlib" },
77 repo = " https://github.com/glfw/glfw" ,
88 type = " package" ,
@@ -14,35 +14,134 @@ package = {
1414 sha256 = " c038d34200234d071fae9345bc455e4a8f2f544ab60150765d7704e08f3dac01" ,
1515 },
1616 },
17+ macosx = {
18+ [" 3.4" ] = {
19+ url = " https://github.com/glfw/glfw/archive/refs/tags/3.4.tar.gz" ,
20+ sha256 = " c038d34200234d071fae9345bc455e4a8f2f544ab60150765d7704e08f3dac01" ,
21+ },
22+ },
23+ windows = {
24+ [" 3.4" ] = {
25+ url = " https://github.com/glfw/glfw/archive/refs/tags/3.4.tar.gz" ,
26+ sha256 = " c038d34200234d071fae9345bc455e4a8f2f544ab60150765d7704e08f3dac01" ,
27+ },
28+ },
1729 },
1830
1931 mcpp = {
2032 language = " c++23" ,
2133 import_std = false ,
2234 c_standard = " c11" ,
23- cflags = { " -D_DEFAULT_SOURCE" },
24- include_dirs = {" */include" , " */src" },
35+ include_dirs = {" include" , " src" },
2536 sources = {
26- " */src/context.c" ,
27- " */src/init.c" ,
28- " */src/input.c" ,
29- " */src/monitor.c" ,
30- " */src/platform.c" ,
31- " */src/vulkan.c" ,
32- " */src/window.c" ,
33- " */src/egl_context.c" ,
34- " */src/osmesa_context.c" ,
35- " */src/null_init.c" ,
36- " */src/null_monitor.c" ,
37- " */src/null_window.c" ,
38- " */src/null_joystick.c" ,
39- " */src/posix_time.c" ,
40- " */src/posix_thread.c" ,
41- " */src/posix_module.c" ,
37+ " src/context.c" ,
38+ " src/init.c" ,
39+ " src/input.c" ,
40+ " src/monitor.c" ,
41+ " src/platform.c" ,
42+ " src/vulkan.c" ,
43+ " src/window.c" ,
44+ " src/egl_context.c" ,
45+ " src/osmesa_context.c" ,
46+ " src/null_init.c" ,
47+ " src/null_monitor.c" ,
48+ " src/null_window.c" ,
49+ " src/null_joystick.c" ,
4250 },
4351 targets = { [" glfw" ] = { kind = " lib" } },
4452 deps = {
4553 [" compat.opengl" ] = " 2026.05.31" ,
4654 },
55+ linux = {
56+ cflags = { " -D_DEFAULT_SOURCE" , " -D_GLFW_X11" },
57+ sources = {
58+ " src/x11_init.c" ,
59+ " src/x11_monitor.c" ,
60+ " src/x11_window.c" ,
61+ " src/xkb_unicode.c" ,
62+ " src/glx_context.c" ,
63+ " src/linux_joystick.c" ,
64+ " src/posix_poll.c" ,
65+ " src/posix_time.c" ,
66+ " src/posix_thread.c" ,
67+ " src/posix_module.c" ,
68+ },
69+ deps = {
70+ [" compat.x11" ] = " 1.8.13" ,
71+ [" compat.xcursor" ] = " 1.2.3" ,
72+ [" compat.xext" ] = " 1.3.7" ,
73+ [" compat.xfixes" ] = " 6.0.2" ,
74+ [" compat.xi" ] = " 1.8.3" ,
75+ [" compat.xinerama" ] = " 1.1.6" ,
76+ [" compat.xorgproto" ] = " 2025.1" ,
77+ [" compat.xrandr" ] = " 1.5.5" ,
78+ [" compat.xrender" ] = " 0.9.12" ,
79+ },
80+ },
81+ macosx = {
82+ cflags = { " -D_GLFW_COCOA" },
83+ sources = {
84+ " src/cocoa_time.c" ,
85+ " src/posix_thread.c" ,
86+ " src/posix_module.c" ,
87+ " src/cocoa_init.m" ,
88+ " src/cocoa_joystick.m" ,
89+ " src/cocoa_monitor.m" ,
90+ " src/cocoa_window.m" ,
91+ " src/nsgl_context.m" ,
92+ },
93+ ldflags = {
94+ " -framework" , " Cocoa" ,
95+ " -framework" , " IOKit" ,
96+ " -framework" , " CoreFoundation" ,
97+ },
98+ },
99+ windows = {
100+ cflags = { " -D_GLFW_WIN32" , " -DUNICODE" , " -D_UNICODE" },
101+ sources = {
102+ " src/win32_time.c" ,
103+ " src/win32_thread.c" ,
104+ " src/win32_module.c" ,
105+ " src/win32_init.c" ,
106+ " src/win32_joystick.c" ,
107+ " src/win32_monitor.c" ,
108+ " src/win32_window.c" ,
109+ " src/wgl_context.c" ,
110+ },
111+ ldflags = { " -lgdi32" },
112+ },
47113 },
48114}
115+
116+ import (" xim.libxpkg.pkginfo" )
117+
118+ local function patch_x11_loader_names (root )
119+ local file = path .join (root , " src" , " x11_init.c" )
120+ local data = io .readfile (file )
121+ local replacements = {
122+ [' "libX11.so.6"' ] = ' "libX11.so"' ,
123+ [' "libXi.so.6"' ] = ' "libXi.so"' ,
124+ [' "libXrandr.so.2"' ] = ' "libXrandr.so"' ,
125+ [' "libXcursor.so.1"' ] = ' "libXcursor.so"' ,
126+ [' "libXinerama.so.1"' ] = ' "libXinerama.so"' ,
127+ [' "libX11-xcb.so.1"' ] = ' "libX11-xcb.so"' ,
128+ [' "libXrender.so.1"' ] = ' "libXrender.so"' ,
129+ [' "libXext.so.6"' ] = ' "libXext.so"' ,
130+ }
131+ for from , to in pairs (replacements ) do
132+ data = data :gsub (from , to )
133+ end
134+ io .writefile (file , data )
135+ end
136+
137+ function install ()
138+ local srcdir = pkginfo .install_file ():replace (" .tar.gz" , " " )
139+ if not os .isdir (srcdir ) then
140+ srcdir = " glfw-" .. pkginfo .version ()
141+ end
142+
143+ os .tryrm (pkginfo .install_dir ())
144+ os .mv (srcdir , pkginfo .install_dir ())
145+ patch_x11_loader_names (pkginfo .install_dir ())
146+ return true
147+ end
0 commit comments