-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpal.lua
More file actions
271 lines (232 loc) · 8.45 KB
/
Copy pathpal.lua
File metadata and controls
271 lines (232 loc) · 8.45 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
dofile("pal_config.lua")
project "PAL2"
if PAL_BUILD_STATIC_LIBRARY then
kind "StaticLib"
else
kind "SharedLib"
defines {
"_PAL_EXPORT",
"_PAL_BUILD_DLL"
}
end
targetdir(targetDir)
objdir(objDir)
includedirs {
"include",
"src"
}
files {
-- core
"src/core/pal_version.c",
-- event
"src/event/pal_default_queue.c",
"src/event/pal_event.c"
}
filter {"system:windows", "configurations:*"}
files {
"src/core/win32/pal_log_win32.c",
"src/core/win32/pal_memory_win32.c",
"src/core/win32/pal_result_win32.c",
"src/core/win32/pal_time_win32.c"
}
filter {"system:linux", "configurations:*"}
files {
"src/core/posix/pal_log_posix.c",
"src/core/posix/pal_memory_posix.c",
"src/core/posix/pal_result_posix.c",
"src/core/posix/pal_time_posix.c"
}
filter {}
if (PAL_BUILD_SYSTEM_MODULE) then
filter {"system:windows", "configurations:*"}
files {
"src/system/win32/pal_cpu_win32.c",
"src/system/win32/pal_platform_win32.c"
}
filter {"system:linux", "configurations:*"}
files {
"src/system/linux/pal_cpu_linux.c",
"src/system/linux/pal_platform_linux.c"
}
filter {}
end
if (PAL_BUILD_THREAD_MODULE) then
filter {"system:windows", "configurations:*"}
files {
"src/thread/win32/pal_condvar_win32.c",
"src/thread/win32/pal_mutex_win32.c",
"src/thread/win32/pal_tls_win32.c",
"src/thread/win32/pal_thread_win32.c"
}
filter {"system:linux", "configurations:*"}
files {
"src/thread/posix/pal_condvar_posix.c",
"src/thread/posix/pal_mutex_posix.c",
"src/thread/posix/pal_tls_posix.c",
"src/thread/posix/pal_thread_posix.c"
}
filter {}
end
if (PAL_BUILD_VIDEO_MODULE) then
files { "src/video/pal_video.c" }
if (os.target() == "linux") then
-- check for wayland support. This is cross compiler
local waylandPaths = {
"/usr/include/wayland-client.h",
"/usr/include/x86_64-linux-gnu/wayland-client.h"
}
local found = false
for _, path in ipairs(waylandPaths) do
local file = io.open(path, "r")
if file then
file:close()
found = true
break
end
end
if found then
defines { "PAL_HAS_WAYLAND_BACKEND=1" }
else
defines { "PAL_HAS_WAYLAND_BACKEND=0" }
end
-- check for X11 support. This is cross compiler
local XPaths = {
"/usr/include/X11/Xlib.h",
"/usr/include/x86_64-linux-gnu/X11/Xlib.h"
}
found = false
for _, path in ipairs(XPaths) do
local file = io.open(path, "r")
if file then
file:close()
found = true
break
end
end
if found then
defines { "PAL_HAS_X11_BACKEND=1" }
else
defines { "PAL_HAS_X11_BACKEND=0" }
end
end
filter {"system:windows", "configurations:*"}
files {
"src/video/win32/pal_cursor_win32.c",
"src/video/win32/pal_icon_win32.c",
"src/video/win32/pal_monitor_win32.c",
"src/video/win32/pal_window_win32.c",
"src/video/win32/pal_video_win32.c"
}
filter {"system:linux", "configurations:*"}
files {
-- X11
"src/video/x11/pal_cursor_x11.c",
"src/video/x11/pal_icon_x11.c",
"src/video/x11/pal_monitor_x11.c",
"src/video/x11/pal_window_x11.c",
"src/video/x11/pal_video_x11.c",
-- Wayland
"src/video/wayland/pal_cursor_wayland.c",
"src/video/wayland/pal_icon_wayland.c",
"src/video/wayland/pal_monitor_wayland.c",
"src/video/wayland/pal_window_wayland.c",
"src/video/wayland/pal_wayland_protocols.c",
"src/video/wayland/pal_video_wayland.c"
}
filter {}
end
if (PAL_BUILD_OPENGL_MODULE) then
files { "src/opengl/pal_opengl.c" }
filter {"system:windows", "configurations:*"}
files {
"src/opengl/wgl/pal_context_wgl.c",
"src/opengl/wgl/pal_wgl.c"
}
filter {"system:linux", "configurations:*"}
files {
"src/opengl/egl/pal_context_egl.c",
"src/opengl/egl/pal_egl.c"
}
filter {}
end
if (PAL_BUILD_GRAPHICS_MODULE) then
-- check for vulkan support. This is cross compiler
local vulkanSdk = os.getenv("VULKAN_SDK")
local hasVulkan = false
if (vulkanSdk) then
hasVulkan = true
-- add to include path if compiler does not see it
includedirs {
path.join(vulkanSdk, "include")
}
defines { "PAL_HAS_VULKAN_BACKEND=1" }
else
defines { "PAL_HAS_VULKAN_BACKEND=0" }
end
-- check for d3d12 support. This is cross compiler
local hasD3D12 = false
local d3d12Include = ""
if (_ACTION == "vs2022") or (_ACTION == "vs2026") then
local base = "C:/Program Files (x86)/Windows Kits/10/Include"
local versions = os.matchdirs(base .. "/*")
table.sort(versions)
for i = #versions, 1, -1 do
local v = versions[i]
d3d12Include = path.join(v, "um")
if (os.isdir(d3d12Include)) then
break
end
end
else
-- gccBasePath will be set if we are on gcc
d3d12Include = path.join(gccBasePath, "include")
end
if (os.isfile(path.join(d3d12Include, "d3d12.h"))) then
hasD3D12 = true
end
if (hasD3D12) then
-- add to include path if compiler does not see it
includedirs {
d3d12Include
}
defines { "PAL_HAS_D3D12_BACKEND=1" }
else
defines { "PAL_HAS_D3D12_BACKEND=0" }
end
-- base graphics file
files { "src/graphics/pal_graphics.c" }
if (hasVulkan) then
files {
"src/graphics/vulkan/pal_adapter_vulkan.c",
"src/graphics/vulkan/pal_as_vulkan.c",
"src/graphics/vulkan/pal_buffer_vulkan.c",
"src/graphics/vulkan/pal_command_pool_vulkan.c",
"src/graphics/vulkan/pal_commands_vulkan.c",
"src/graphics/vulkan/pal_descriptors_vulkan.c",
"src/graphics/vulkan/pal_device_vulkan.c",
"src/graphics/vulkan/pal_image_vulkan.c",
"src/graphics/vulkan/pal_pipeline_vulkan.c",
"src/graphics/vulkan/pal_sbt_vulkan.c",
"src/graphics/vulkan/pal_swapchain_vulkan.c",
"src/graphics/vulkan/pal_sync_vulkan.c",
"src/graphics/vulkan/pal_vulkan.c"
}
end
if (hasD3D12) then
files {
"src/graphics/d3d12/pal_adapter_d3d12.c",
"src/graphics/d3d12/pal_as_d3d12.c",
"src/graphics/d3d12/pal_buffer_d3d12.c",
"src/graphics/d3d12/pal_command_pool_d3d12.c",
"src/graphics/d3d12/pal_commands_d3d12.c",
"src/graphics/d3d12/pal_descriptors_d3d12.c",
"src/graphics/d3d12/pal_device_d3d12.c",
"src/graphics/d3d12/pal_image_d3d12.c",
"src/graphics/d3d12/pal_pipeline_d3d12.c",
"src/graphics/d3d12/pal_sbt_d3d12.c",
"src/graphics/d3d12/pal_swapchain_d3d12.c",
"src/graphics/d3d12/pal_sync_d3d12.c",
"src/graphics/d3d12/pal_d3d12.c"
}
end
end