-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
208 lines (172 loc) · 6.69 KB
/
premake5.lua
File metadata and controls
208 lines (172 loc) · 6.69 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
--[[ TODO:
link these:
- curl
- mbedtls
- zlib
- ffmpeg
]]
local function addImGUI()
includedirs {
"extlib/imgui",
"extlib/rlimgui",
}
files {
"extlib/imgui/imgui.cpp",
"extlib/imgui/imgui_draw.cpp",
"extlib/imgui/imgui_widgets.cpp",
"extlib/imgui/imgui_tables.cpp",
"extlib/imgui/imgui_demo.cpp",
"extlib/imgui/misc/cpp/imgui_stdlib.cpp",
"extlib/rlimgui/rlImGui.cpp",
}
end
local function addRaylib()
includedirs { "extlib/raylib/src" }
libdirs { "extlib/raylib/src" }
links { "raylib" }
dependson { "extlib_raylib" }
filter "system:macosx"
linkoptions { "-framework CoreVideo", "-framework IOKit", "-framework Cocoa", "-framework GLUT", "-framework OpenGL" }
filter {}
end
local function addTinydir()
includedirs { "extlib/tinydir" }
end
local function addFmt()
includedirs { "extlib/fmt/include" }
libdirs { "extlib/fmt/build" }
links { "fmt" }
dependson { "extlib_fmt" }
end
local function addJSON()
includedirs { "extlib/nlohmann-json/single_include" }
end
local function applyOSAndArchDefines()
filter "system:windows"
defines { "PLATFORM_WINDOWS" }
removefiles { "src/**.c" }
links { "ws2_32", "winmm" }
removebuildoptions { "-Wno-deprecated-declarations", "-Wno-c++11-narrowing" }
buildoptions { "/W3" }
filter "system:macosx"
links { "m", "dl", "pthread" }
defines { "PLATFORM_MACOS" }
filter "system:linux"
links { "m", "dl", "pthread" }
defines { "PLATFORM_LINUX" }
filter "architecture:x64"
defines { "ARCH_X64" }
filter "system:windows"
defines { "USE_X86_SSE" }
filter "system:macosx"
defines { "USE_X86_SSE" }
filter "system:linux"
defines { "USE_X86_SSE" }
filter "architecture:ARM64"
defines { "ARCH_ARM64" }
filter "system:macosx"
defines { "__ARM_NEON" }
filter "system:linux"
defines { "__ARM_NEON" }
filter {}
end
local function applyOutDir(build)
targetdir ("build/bin/" .. build)
objdir ("build/obj/" .. build)
end
local function applyBaseConfig()
kind "ConsoleApp"
language "C++"
buildoptions {
"-std=c++20",
"-Wno-deprecated-declarations",
"-Wno-c++11-narrowing",
}
end
local function projectBase()
applyBaseConfig()
files {
"src/**.h", "src/**.c",
"src/**.hpp", "src/**.cpp",
}
includedirs {
"src",
"extlib/imgui",
"extlib/rlimgui",
"extlib/raylib/src",
"extlib/tinydir",
"extlib/fmt/include",
"extlib/nlohmann-json/single_include"
}
applyOSAndArchDefines()
end
local function unitTest(name, extraIncludes, extraFiles)
project(name)
applyBaseConfig()
files {
"extlib/catch2/extras/catch_amalgamated.cpp",
"tests/"..name..".cpp"
}
includedirs {
"src",
"extlib/catch2/extras"
}
if extraFiles then
for _, file in ipairs(extraFiles) do
files { file }
end
end
if extraIncludes then
for _, include in ipairs(extraIncludes) do
includedirs { include }
end
end
applyOSAndArchDefines()
defines { "DEBUG" }
symbols "On"
applyOutDir("debug")
end
local maxosx_deployment_target = "export MACOSX_DEPLOYMENT_TARGET=10.15; "
workspace "particles"
location "build"
configurations { "Debug", "Release" }
project "extlib_fmt"
kind "Makefile"
buildcommands {
"mkdir -p ../extlib/fmt/build",
maxosx_deployment_target .. "cd ../extlib/fmt/build && " .. "cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE",
maxosx_deployment_target .. "make -C ../extlib/fmt/build fmt -j4",
}
cleancommands { maxosx_deployment_target .. "make -C ../extlib/fmt/build clean" }
project "extlib_raylib"
kind "Makefile"
buildcommands { maxosx_deployment_target .. "make -C ../extlib/raylib/src -j4" }
cleancommands { maxosx_deployment_target .. "make -C ../extlib/raylib/src clean" }
project "particles"
projectBase()
addFmt()
addTinydir()
addRaylib()
addImGUI()
addJSON()
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
optimize "Off"
buildoptions { "-O1", "-fsanitize=address,undefined", "-fno-omit-frame-pointer"}
linkoptions { "-fsanitize=address,undefined" }
applyOutDir("debug")
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
buildoptions { "-O3", "-ffast-math", "-fno-math-errno", "-fno-trapping-math" }
applyOutDir("release")
unitTest("test_uniformgrid")
unitTest("test_world", { "extlib/raylib/src" }, { "src/simulation/world.cpp" })
unitTest("test_multicore", { "extlib/raylib/src" }, { "src/simulation/multicore.cpp" })
unitTest("test_mailboxes", { "extlib/raylib/src" }, { "src/mailbox/render/drawbuffer.cpp" })
unitTest("test_save_manager", { "extlib/raylib/src", "extlib/nlohmann-json/single_include" }, { "src/save_manager.cpp", "src/simulation/world.cpp" })
unitTest("test_simulation", { "extlib/raylib/src" }, { "src/simulation/simulation.cpp", "src/simulation/world.cpp", "src/simulation/multicore.cpp", "src/mailbox/render/drawbuffer.cpp" })
unitTest("test_undo_manager", { "extlib/imgui", "extlib/rlimgui", "extlib/raylib/src" }, { "src/undo/undo_manager.cpp", "src/undo/add_group_action.cpp", "src/undo/remove_group_action.cpp", "src/undo/resize_group_action.cpp", "src/undo/clear_all_groups_action.cpp" })
unitTest("test_file_dialog", { "extlib/imgui", "extlib/rlimgui", "extlib/raylib/src", "extlib/tinydir", "extlib/nlohmann-json/single_include" }, { "src/render/ui/file_dialog.cpp", "src/save_manager.cpp", "extlib/imgui/imgui.cpp", "extlib/imgui/imgui_draw.cpp", "extlib/imgui/imgui_widgets.cpp", "extlib/imgui/imgui_tables.cpp", "extlib/imgui/misc/cpp/imgui_stdlib.cpp" })
unitTest("test_version_tracking", { "extlib/imgui", "extlib/rlimgui", "extlib/raylib/src", "extlib/nlohmann-json/single_include", "extlib/tinydir" }, { "src/undo/undo_manager.cpp", "src/save_manager.cpp", "src/undo/add_group_action.cpp", "src/render/ui/menu_bar_ui.cpp", "src/render/ui/file_dialog.cpp", "src/simulation/simulation.cpp", "src/simulation/world.cpp", "src/simulation/multicore.cpp", "src/mailbox/render/drawbuffer.cpp", "extlib/imgui/imgui.cpp", "extlib/imgui/imgui_draw.cpp", "extlib/imgui/imgui_widgets.cpp", "extlib/imgui/imgui_tables.cpp", "extlib/imgui/misc/cpp/imgui_stdlib.cpp" })