-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathpremake5.lua
More file actions
172 lines (148 loc) · 5.36 KB
/
premake5.lua
File metadata and controls
172 lines (148 loc) · 5.36 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
location ("build")
workspace "RGFW"
configurations { "Debug", "Release" }
startproject "examples"
-- cross compiling windows
if _ACTION and _ACTION:find("xcode") then
platforms({ "Native" })
else
platforms({
"Native",
"Win32",
"Win64"
})
end
defaultplatform("Native")
filter("platforms:Win32")
system("windows")
architecture("x86")
gccprefix("i686-w64-mingw32-")
filter("platforms:Win64")
system("windows")
architecture("x86_64")
gccprefix("x86_64-w64-mingw32-")
filter({})
-- clean command
newaction({
trigger = "clean",
description = "Clean the files",
execute = function()
os.rmdir("bin")
os.rmdir("bin-int")
os.rmdir("build")
end
})
-- Custom Options
newoption {
trigger = "wayland",
description = "Enable Wayland support"
}
newoption {
trigger = "no-vulkan",
description = "Disable Vulkan example"
}
newoption {
trigger = "no-gles",
description = "Disable GLES example"
}
newoption {
trigger = "no-osmesa",
description = "Disable OSMesa example"
}
-- Variables
local isWindows = os.host() == "windows"
local isLinux = os.host() == "linux"
local isMac = os.host() == "macosx"
local no_vulkan = _OPTIONS["no-vulkan"]
local no_gles = _OPTIONS["no-gles"] or not isLinux
local no_osmesa = _OPTIONS["no-osmesa"] or not isLinux
local use_wayland = _OPTIONS["wayland"]
group "examples"
-- List of simple examples
local exampleOutputs = {
"basic",
"buffer",
"events",
"callbacks",
"flags",
"monitor",
"gl33_ctx",
"smooth-resize",
"multi-window"
}
for _, example in ipairs(exampleOutputs) do
project(example)
kind "ConsoleApp"
language "C"
targetdir "bin/%{cfg.buildcfg}"
objdir "bin-int/%{cfg.buildcfg}"
files { "examples/" .. example .. "/" .. example .. ".c", "RGFW.h" }
includedirs { "." }
filter "system:windows"
links { "gdi32", "opengl32" }
filter "system:linux"
if use_wayland then
links { "EGL", "GL" }
else
links { "GL", "X11", "Xrandr", "dl", "pthread" }
end
filter "system:macosx"
links { "Cocoa.framework", "OpenGL.framework", "IOKit.framework", "CoreVideo.framework" }
end
-- List of special examples (conditionally compiled)
local exampleCustomOutputs = {
{ name = "icons/icons" },
{ name = "gamepad/gamepad" },
{ name = "silk/silk" },
{ name = "first-person-camera/camera", projectname = "camera" },
{ name = "microui_demo/microui_demo" },
{ name = "gl33/gl33" },
{ name = "portableGL/pgl", condition = not (os.target() == "emscripten") },
{ name = "gles2/gles2", condition = not no_gles },
{ name = "dx11/dx11", system = "windows", condition = isWindows },
{ name = "metal/metal", system = "macosx", condition = isMac },
{ name = "webgpu/webgpu", system = "emscripten", condition = (os.target() == "emscripten") },
{ name = "minimal_links/minimal_links" },
{ name = "osmesa_demo/osmesa_demo", condition = not no_osmesa },
{ name = "vk10/vk10", condition = not no_vulkan },
}
for _, e in ipairs(exampleCustomOutputs) do
if e.condition == nil or e.condition then
project(e.projectname or path.getname(e.name))
kind "ConsoleApp"
language "C"
targetdir "bin/%{cfg.buildcfg}"
objdir "bin-int/%{cfg.buildcfg}"
files { "examples/" .. e.name .. ".c", "RGFW.h" }
includedirs { "." }
if e.name == "gles2/gles2" then
links {"EGL"}
end
if e.name == "osmesa_demo/osmesa_demo" then
links { "OSMesa" }
end
if e.name == "microui_demo/microui_demo" then
files { "examples/microui_demo/microui.c" }
end
filter "system:windows"
if e.name == "dx11/dx11" then
links { "d3d11", "dxgi", "d3dcompiler", "uuid", "gdi32" }
else
links { "gdi32", "opengl32" }
end
filter "system:linux"
if use_wayland then
links { "EGL", "GL" }
else
links { "GL", "X11", "Xrandr", "dl", "pthread", "m" }
end
filter "system:macosx"
if e.name == "metal/metal" then
files { "RGFW.c" }
buildoptions { "-x objective-c" }
links { "Metal.framework", "QuartzCore.framework", "Cocoa.framework", "IOKit.framework", "CoreVideo.framework" }
else
links { "Cocoa.framework", "OpenGL.framework", "IOKit.framework", "CoreVideo.framework" }
end
end
end