Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@
"glfw3"
],
"versions": [
"3.4-2",
"3.4-1",
"3.3.10-1",
"3.3.9-1",
Expand Down
162 changes: 96 additions & 66 deletions subprojects/packagefiles/glfw/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version: '3.4',
license: 'Zlib',
default_options: ['b_ndebug=if-release', 'c_std=c99', 'warning_level=0'],
meson_version: '>=0.58.0',

Check warning on line 9 in subprojects/packagefiles/glfw/meson.build

View workflow job for this annotation

GitHub Actions / Ubuntu (x86_64)

Minimum Meson version is 0.63.0

0.56.0: oldest version supported by WrapDB 0.63.0: c_std in subproject default_options
)
#@ Project variables
sys_os = host_machine.system()
Expand All @@ -27,32 +27,41 @@
language: 'c',
)

if opt_display == 'auto'
if opt_display == ['auto']
if sys_os == 'windows'
opt_display = 'win32'
opt_display = ['win32']
elif sys_os == 'darwin'
opt_display = 'cocoa'
opt_display = ['cocoa']
else
opt_display = 'x11'
opt_display = ['x11']
endif
endif

### Dependencies ###
deps = []
#@ Backend API
# OSMesa
if opt_display == 'osmesa'
if opt_display.contains('osmesa')
deps += dependency('osmesa')
# X11
elif opt_display == 'x11'
endif

# X11
if opt_display.contains('x11')
foreach x : ['x11', 'xrandr', 'xinerama', 'xcursor', 'xi']
deps += dependency(
x,
required: true,
)
endforeach
# Wayland
elif opt_display == 'wayland'

add_project_arguments(
'-D_GLFW_X11',
language: 'c',
)
endif

# Wayland
if opt_display.contains('wayland')
warning('Wayland support is experimental & incomplete.')
warning(
'GLFW < 3.4 cannot detect Wayland if both x11 and Wayland exist on-system!',
Expand Down Expand Up @@ -90,58 +99,73 @@
)
endif
s_wayland = []
protocols = {
'idle-inhibit': 'unstable',
'pointer-constraints': 'unstable',
'relative-pointer': 'unstable',
'viewporter': 'stable',
'xdg-decoration': 'unstable',
'xdg-shell': 'stable',
}
foreach p, s : protocols
x_path = join_paths(wl_dir, s, p, p)
if s == 'stable'
x_name = p
xml = files(x_path + '.xml')
else
x_name = p + '-unstable-v1'
xml = files(x_path + '-unstable-v1.xml')
endif
foreach f : ['client-header', 'server-header', 'private-code']
if (f == 'client-header' and p == 'xdg-decoration')
outfile = 'wayland-' + p + '-client-protocol.h'
elif f == 'client-header'
outfile = 'wayland-' + x_name + '-client-protocol.h'
elif f == 'server-header'
outfile = 'wayland-' + p + '-server-protocol.h'
elif (f == 'private-code' and p == 'xdg-decoration')
outfile = 'wayland-' + p + '-protocol.c'
else
outfile = 'wayland-' + x_name + '-protocol.c'
endif
s_wayland += custom_target(
'@0@ @1@'.format(p, f),
command: ['wayland-scanner', f, '@INPUT@', '@OUTPUT@'],
input: xml,
output: outfile,
)
endforeach

protocols = [
'fractional-scale-v1',
'idle-inhibit-unstable-v1',
'pointer-constraints-unstable-v1',
'relative-pointer-unstable-v1',
'viewporter',
'wayland',
'xdg-activation-v1',
'xdg-decoration-unstable-v1',
'xdg-shell',
]

foreach proto : protocols
xml_file = files('deps' / 'wayland' / (proto + '.xml'))
header_file = proto + '-client-protocol.h'
code_file = proto + '-client-protocol-code.h'

s_wayland += custom_target(
'@0@ client-header'.format(proto),
command: ['wayland-scanner', 'client-header', '@INPUT@', '@OUTPUT@'],
input: xml_file,
output: header_file,
)

s_wayland += custom_target(
'@0@ private-code'.format(proto),
command: ['wayland-scanner', 'private-code', '@INPUT@', '@OUTPUT@'],
input: xml_file,
output: code_file,
)
endforeach
# Win32
elif opt_display == 'win32'

add_project_arguments(
'-D_GLFW_WAYLAND',
language: 'c',
)
endif

# Win32
if opt_display.contains('win32')
if sys_os != 'windows'
error('Non Windows is unsupported')
endif
# Cocoa
elif opt_display == 'cocoa'

add_project_arguments(
'-D_GLFW_WIN32',
language: 'c',
)
endif

# Cocoa
if opt_display.contains('cocoa')
if sys_os != 'darwin'
error('Non macOS is unsupported')
endif
deps += dependency(
'appleframeworks',
modules: ['Cocoa', 'CoreFoundation', 'IOKit'],
)

add_project_arguments(
'-D_GLFW_COCOA',
language: 'c',
)
endif

#@ System Dependencies
foreach l : ['m', 'rt']
deps += sys_cc.find_library(
Expand All @@ -162,12 +186,6 @@
endif
deps += dependency('threads')

### Configuration ###
add_project_arguments(
'-D_GLFW_' + opt_display.to_upper(),
language: 'c',
)

### Targets ###
#@ Primary target:
## GLFW library
Expand Down Expand Up @@ -195,9 +213,12 @@
else
s_os = files('src/posix_module.c', 'src/posix_thread.c', 'src/posix_time.c')
endif

# Backend files
if opt_display == 'osmesa'
s_display = files(
s_display = []

if opt_display.contains('osmesa')
s_display += files(
'src/null_init.c',
'src/null_joystick.c',
'src/null_monitor.c',
Expand All @@ -206,8 +227,10 @@
'src/posix_thread.c',
'src/posix_time.c',
)
elif opt_display == 'x11'
s_display = files(
endif

if opt_display.contains('x11')
s_display += files(
'src/glx_context.c',
'src/linux_joystick.c',
'src/posix_poll.c',
Expand All @@ -216,29 +239,35 @@
'src/x11_window.c',
'src/xkb_unicode.c',
)
elif opt_display == 'wayland'
s_display = files(
endif

if opt_display.contains('wayland')
s_display += files(
'src/linux_joystick.c',
'src/posix_poll.c',
'src/wl_init.c',
'src/wl_monitor.c',
'src/wl_window.c',
'src/xkb_unicode.c',
)
elif opt_display == 'win32'
s_display = files(
endif

if opt_display.contains('win32')
s_display += files(
'src/wgl_context.c',
'src/win32_init.c',
'src/win32_joystick.c',
'src/win32_monitor.c',
'src/win32_window.c',
)
elif opt_display == 'cocoa'
endif

if opt_display.contains('cocoa')
add_languages(
'objc',
native: false,
)
s_display = files(
s_display += files(
'src/cocoa_init.m',
'src/cocoa_joystick.m',
'src/cocoa_monitor.m',
Expand All @@ -253,8 +282,9 @@
)
endif
endif

srcfiles = [s_common, s_os, s_display]
if opt_display == 'wayland'
if opt_display.contains('wayland')
srcfiles += s_wayland
endif
incdirs = include_directories('include', 'src')
Expand Down
4 changes: 2 additions & 2 deletions subprojects/packagefiles/glfw/meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ option(
#@ Configuration options
option(
'display-api',
type: 'combo',
type: 'array',
choices: ['auto', 'osmesa', 'x11', 'wayland', 'win32', 'cocoa'],
value: 'auto',
value: ['auto'],
description: 'Choose backend display API.',
)
Loading