-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpal.lua
More file actions
144 lines (115 loc) · 3.59 KB
/
pal.lua
File metadata and controls
144 lines (115 loc) · 3.59 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
dofile("pal_config.lua")
function writeConfig(path)
local file = io.open(path, "w")
file:write("\n// Auto Generated Config Header From pal_config.lua\n")
file:write("// Must not be edited manually\n\n")
if (PAL_BUILD_SYSTEM) then
file:write("#define PAL_HAS_SYSTEM 1\n")
else
file:write("#define PAL_HAS_SYSTEM 0\n")
end
if (PAL_BUILD_THREAD) then
file:write("#define PAL_HAS_THREAD 1\n")
else
file:write("#define PAL_HAS_THREAD 0\n")
end
if (PAL_BUILD_VIDEO) then
file:write("#define PAL_HAS_VIDEO 1\n")
else
file:write("#define PAL_HAS_VIDEO 0\n")
end
if (PAL_BUILD_OPENGL) then
file:write("#define PAL_HAS_OPENGL 1\n")
else
file:write("#define PAL_HAS_OPENGL 0\n")
end
file:close()
end
project "PAL"
language "C"
if PAL_BUILD_STATIC then
kind "StaticLib"
else
kind "SharedLib"
defines {
"_PAL_EXPORT",
"_PAL_BUILD_DLL"
}
end
targetdir(target_dir)
objdir(obj_dir)
includedirs {
"include",
"src"
}
files {
"src/pal_core.c",
"src/pal_event.c"
}
if (PAL_BUILD_SYSTEM) then
filter {"system:windows", "configurations:*"}
files { "src/system/pal_system_win32.c" }
filter {"system:linux", "configurations:*"}
files { "src/system/pal_system_linux.c" }
filter {}
end
if (PAL_BUILD_THREAD) then
filter {"system:windows", "configurations:*"}
files { "src/thread/pal_thread_win32.c" }
filter {"system:linux", "configurations:*"}
files { "src/thread/pal_thread_linux.c" }
filter {}
end
if (PAL_BUILD_VIDEO) then
filter {"system:windows", "configurations:*"}
files { "src/video/pal_video_win32.c" }
filter {"system:linux", "configurations:*"}
files { "src/video/pal_video_linux.c" }
-- 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=1" }
else
defines { "PAL_HAS_WAYLAND=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=1" }
else
defines { "PAL_HAS_X11=0" }
end
filter {}
end
if (PAL_BUILD_OPENGL) then
filter {"system:windows", "configurations:*"}
files { "src/opengl/pal_opengl_win32.c" }
filter {"system:linux", "configurations:*"}
files { "src/opengl/pal_opengl_linux.c" }
filter {}
end
writeConfig("include/pal/pal_config.h")