1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
project(
'yasl',
'c',
meson_version: '>=1.6.0',
version: '0.1.0',
default_options: [
'c_std=c23',
'warning_level=2',
'b_lto=false',
],
)
cc = meson.get_compiler('c')
system = host_machine.system()
inc = include_directories('include', 'src')
deps = []
sources = []
has_wayland = false
has_x11 = false
has_dbus = false
has_cocoa = system == 'darwin'
if system == 'linux'
wl_client = dependency('wayland-client', required: get_option('wayland'))
wl_cursor = dependency('wayland-cursor', required: get_option('wayland'))
xkbcommon = dependency('xkbcommon', required: get_option('wayland'))
has_wayland = wl_client.found() and wl_cursor.found() and xkbcommon.found()
x11 = dependency('x11', required: get_option('x11'))
xi = dependency('xi', required: get_option('x11'))
x11_xkb = dependency('xkbcommon', required: get_option('x11'))
xext = dependency('xext', required: get_option('x11'))
xrandr = dependency('xrandr', required: false)
has_x11 = x11.found() and xi.found() and x11_xkb.found() and xext.found()
if has_x11
deps += [x11, xi, x11_xkb, xext]
if xrandr.found()
deps += [xrandr]
add_project_arguments('-DYASL_HAS_XRANDR=1', language: 'c')
endif
endif
dbus = dependency('dbus-1', required: get_option('dbus'))
has_dbus = dbus.found()
if has_dbus
deps += [dbus]
endif
m_dep = cc.find_library('m', required: false)
rt_dep = cc.find_library('rt', required: false)
deps += [m_dep, rt_dep]
if has_wayland
deps += [wl_client, wl_cursor, xkbcommon]
endif
elif system == 'darwin'
add_languages('objc', native: false)
if not cc.compiles('''
#if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000
#error YASL requires macOS 14 or newer
#endif
int main(void) { return 0; }
''', name: 'macOS deployment target is at least 14')
error('Cocoa requires macOS 14 or newer. Set MACOSX_DEPLOYMENT_TARGET=14.0 or a newer target before configuring.')
endif
deps += [
dependency('appleframeworks', modules: ['AppKit', 'Metal', 'QuartzCore', 'UserNotifications']),
]
else
error('YASL supports Linux and macOS.')
endif
if not has_wayland and not has_x11 and not has_cocoa
error('Enable at least one window backend.')
endif
add_project_arguments(
'-DYASL_HAS_WAYLAND=' + (has_wayland ? '1' : '0'),
'-DYASL_HAS_X11=' + (has_x11 ? '1' : '0'),
'-DYASL_HAS_COCOA=' + (has_cocoa ? '1' : '0'),
'-DYASL_HAS_DBUS=' + (has_dbus ? '1' : '0'),
language: has_cocoa ? ['c', 'objc'] : ['c'],
)
if has_cocoa
add_project_arguments('-fblocks', language: 'objc')
endif
subdir('src')
yasl_lib = both_libraries(
'yasl',
sources,
include_directories: inc,
dependencies: deps,
gnu_symbol_visibility: 'hidden',
install: true,
)
yasl_dep = declare_dependency(
link_with: yasl_lib.get_static_lib(),
include_directories: include_directories('include'),
dependencies: deps,
)
meson.override_dependency('yasl', yasl_dep)
hello_example = executable(
'yasl-hello',
'examples/hello.c',
include_directories: inc,
link_with: yasl_lib.get_shared_lib(),
)
interactive_example = executable(
'yasl-example',
'examples/simple_window.c',
include_directories: inc,
link_with: yasl_lib.get_shared_lib(),
dependencies: deps,
)
tablet_example = executable(
'yasl-tablet',
'examples/tablet.c',
dependencies: yasl_dep,
)
notepad_example = executable(
'yasl-notepad',
'examples/notepad.c',
dependencies: yasl_dep,
)
game_example = executable(
'yasl-game',
'examples/game.c',
dependencies: yasl_dep,
)
subdir('tests')
|