-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
327 lines (270 loc) · 6.33 KB
/
Copy pathpremake5.lua
File metadata and controls
327 lines (270 loc) · 6.33 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
local function is_linux()
return os.target() == "linux"
end
local function is_windows()
return os.target() == "windows"
end
local function is_macos()
return os.target() == "macosx"
end
local function is_clang()
return _OPTIONS["cc"] == "clang" or _OPTIONS["cc"] == "clangcl"
end
local function workspace_location()
if is_windows() then
return "build/windows"
elseif is_linux() then
if is_clang() then
return "build/linux-clang"
else
return "build/linux-gcc"
end
elseif is_macos() then
if is_clang() then
return "build/macos-clang"
else
return "build/macos"
end
end
return "build"
end
local vulkanSDK = os.getenv("VULKAN_SDK") or os.getenv("VK_SDK_PATH")
workspace("AppLib")
location(workspace_location())
architecture("x64")
configurations({ "Debug", "Release", "Dist" })
warnings("Extra")
filter("system:windows")
defines({ "AE_WINDOWS" })
filter("system:macosx")
defines({ "AE_MACOS" })
filter("system:linux")
defines({ "AE_LINUX" })
filter({})
filter("configurations:Debug")
defines({ "AE_DEBUG" })
symbols("On")
filter("configurations:Release")
defines({ "AE_RELEASE", "NDEBUG" })
optimize("Speed")
filter("configurations:Dist")
defines({ "AE_DIST", "NDEBUG" })
optimize("Speed")
symbols("Off")
filter({})
filter({ "action:vs*", "configurations:Debug" })
runtime("Debug")
filter({ "action:vs*", "configurations:Release or configurations:Dist" })
runtime("Release")
filter("action:vs*")
startproject("Sandbox")
filter({})
filter({ "system:linux or system:macosx" })
if is_clang() then
print(">> Using Clang toolchain")
buildoptions({
"-Wall",
"-Wextra",
"-Wpedantic",
"-fcolor-diagnostics",
})
else
print(">> Using GCC toolchain")
buildoptions({
"-Wall",
"-Wextra",
"-Wpedantic",
"-fdiagnostics-color=always",
})
end
filter({})
include("app-project.lua")
project("Sandbox")
kind("ConsoleApp")
language("C++")
cppdialect("C++23")
objdir("obj/%{prj.name}/%{cfg.buildcfg}")
targetdir("bin/%{prj.name}/%{cfg.buildcfg}")
files({ "sandbox/src/**.cpp", "sandbox/src/**.h" })
includedirs({
"vendor/glad/include",
"dep/OpenALSoft/include",
"dep/log-lib/log-lib/include",
"dep/event-lib/event-lib/include",
"app-lib/include",
"sandbox/src",
"vendor/glm",
"vendor/imgui",
"vendor/nlohmann",
"vendor/lua",
"vendor/sol",
"vendor/toml++",
"vendor/vma",
})
filter("system:windows")
includedirs({ "dep/GLFW/include" })
filter({})
dependson({ "GLM", "Nlohmann", "Sol" })
filter("system:windows")
links({
"dep/GLFW/lib/glfw3.lib",
"opengl32.lib",
"Log",
"Event",
"Lua",
"STB",
"ImGui",
"GLAD",
"App",
})
filter({ "system:windows", "configurations:Debug" })
links({ "dep/OpenALSoft/lib/Debug/OpenAL32" })
postbuildcommands({
'{COPY} "%{wks.location}/../../dep/OpenALSoft/lib/Debug/OpenAL32.dll" "%{cfg.targetdir}"',
})
filter({ "system:windows", "configurations:Release or configurations:Dist" })
links({ "dep/OpenALSoft/lib/Release/OpenAL32" })
postbuildcommands({
'{COPY} "%{wks.location}/../../dep/OpenALSoft/lib/Release/OpenAL32.dll" "%{cfg.targetdir}"',
})
filter("system:linux")
links({
"App",
"Lua",
"ImGui",
"STB",
"GLAD",
"Event",
"Log",
"glfw",
"GL",
"openal",
})
filter("system:macosx")
links({
"App",
"Lua",
"ImGui",
"STB",
"GLAD",
"Event",
"Log",
"glfw",
"OpenGL.framework",
"openal",
})
filter({})
-- Use the global AE_VULKAN_AVAILABLE set by app-project.lua
if AE_VULKAN_AVAILABLE then
defines({ "AE_VULKAN" })
if vulkanSDK then
includedirs({ vulkanSDK .. "/Include" })
filter("system:windows")
links({ vulkanSDK .. "/Lib/vulkan-1.lib" })
filter({})
end
filter("system:linux or system:macosx")
links({ "vulkan" })
filter({})
end
pchheader(path.getabsolute("sandbox/src/general/pch.h"))
pchsource("sandbox/src/general/pch.cpp")
local function own_source_files()
local files = {}
local function add(glob)
for _, f in ipairs(os.matchfiles(glob)) do
table.insert(files, f)
end
end
add("app-lib/src/**.cpp")
add("app-lib/src/**.c")
add("app-lib/include/**.h")
add("app-lib/include/**.hpp")
add("sandbox/src/**.cpp")
add("sandbox/src/**.c")
add("sandbox/src/**.h")
add("sandbox/src/**.hpp")
return files
end
newaction({
trigger = "format",
description = "Run clang-format on all non-vendor C/C++ files",
execute = function()
local files = own_source_files()
if #files == 0 then
print("No source files found to format.")
return
end
local cmd = "clang-format -i"
for _, f in ipairs(files) do
cmd = cmd .. " " .. f
end
print("Running:", cmd)
os.execute(cmd)
end,
})
local function run_clang_tidy(fix_mode)
local all_files = own_source_files()
local cpp_files = {}
for _, f in ipairs(all_files) do
local ext = path.getextension(f)
if ext == ".cpp" or ext == ".cc" or ext == ".cxx" then
table.insert(cpp_files, f)
end
end
if #cpp_files == 0 then
print("No C++ source files found to lint.")
return
end
local build_dir = "."
local mode_label = fix_mode and "lint + fix" or "lint"
print(string.format("Running clang-tidy (%s) on %d files...", mode_label, #cpp_files))
for _, f in ipairs(cpp_files) do
local extra = fix_mode and "-fix -fix-errors" or ""
local cmd = string.format('clang-tidy -quiet %s -p "%s" "%s"', extra, build_dir, f)
local result = os.execute(cmd)
if result ~= 0 then
print("")
if fix_mode then
print("clang-tidy reported issues (and may have applied fixes) in " .. f .. ".")
else
print("Issues found in " .. f .. " (see diagnostics above).")
end
print("")
end
end
if fix_mode then
print("clang-tidy auto-fix pass completed. Review changes with git diff.")
else
print("clang-tidy lint completed.")
end
end
newaction({
trigger = "lint",
description = "Run clang-tidy on all non-vendor C++ source files",
execute = function()
run_clang_tidy(false)
end,
})
newaction({
trigger = "lint-fix",
description = "Run clang-tidy with automatic fixes on all non-vendor C++ source files",
execute = function()
print("NOTE: This will modify your source files in-place. Make sure your tree is clean (git status).")
run_clang_tidy(true)
end,
})
newaction({
trigger = "gmake-gcc",
description = "Generate GNU Makefiles (gmake) using GCC on *nix",
execute = function()
os.execute("premake5 gmake --cc=gcc")
end,
})
newaction({
trigger = "gmake-clang",
description = "Generate GNU Makefiles (gmake) using Clang on *nix",
execute = function()
os.execute("premake5 gmake --cc=clang")
end,
})