-
Notifications
You must be signed in to change notification settings - Fork 5
/
premake5.lua
321 lines (256 loc) · 9.06 KB
/
premake5.lua
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
newoption {
trigger = "to",
value = "path",
description = "Set the output location for the generated files",
default = "solution/%{_ACTION}/maxr"
}
newoption {
trigger = "crashRpt_root",
value = "path",
description = "Set the location of crashRpt_root",
}
if (_ACTION == nil) then
return
end
local locationDir = _OPTIONS["to"]
local nugetPackages = {
"sdl2.nuget:2.28.0", "sdl2.nuget.redist:2.28.0",
"sdl2_mixer.nuget:2.8.0", "sdl2_mixer.nuget.redist:2.8.0",
"sdl2_net.nuget:2.2.0", "sdl2_net.nuget.redist:2.2.0",
-- "CrashRpt2.CPP:1.5.3", "CrashRpt2.CPP.redist:1.5.3",
"vorbis-msvc14-x86:1.3.5.7785", "ogg-msvc-x86:1.3.2.8787", -- x86
-- "vorbis-msvc14-x64:1.3.5.7785", "ogg-msvc-x64:1.3.2.8787", -- x64
}
local SDL2_DIR = os.getenv("SDL2_DIR")
local SDL2_headerPath = os.findheader("SDL2/SDL.h", SDL2_DIR)
local SDL2_libraryPath = os.findlib("SDL2", SDL2_DIR)
local vorbis_headerPath = os.findheader("vorbis/vorbisenc.h")
local ogg_headerPath = os.findheader("ogg/ogg.h")
print("premake:", _PREMAKE_VERSION)
print("SDL2_DIR: ", SDL2_DIR)
print("SDL2 header path: ", SDL2_headerPath)
print("SDL2 library path: ", SDL2_libraryPath)
print("vorbis header path: ", vorbis_headerPath)
print("ogg header path: ", ogg_headerPath)
local function autoversion_h()
local git_tag, errorCode = os.outputof("git describe --tag --always")
if errorCode == 0 then
print("git description: ", git_tag)
local content = io.readfile("src/autoversion.h.in")
content = content:gsub("${GIT_DESC}", git_tag)
os.mkdir(locationDir)
local f, err = os.writefile_ifnotequal(content, path.join(locationDir, "autoversion.h"))
if (f == 0) then
-- file not modified
elseif (f < 0) then
error(err, 0)
return false
elseif (f > 0) then
print("Generated autoversion.h...")
end
return true
else
print("`git describe --tag` failed with error code", errorCode, git_tag)
return false
end
end
local have_autoversion_h = autoversion_h()
local function linksToCrashRpt()
if _OPTIONS["crashRpt_root"] ~= nil then
files {
path.join(_OPTIONS["crashRpt_root"], "bin/CrashRpt1403.dll"),
path.join(_OPTIONS["crashRpt_root"], "bin/CrashSender1403.exe"),
path.join(_OPTIONS["crashRpt_root"], "bin/crashrpt_lang.ini"),
}
libdirs { path.join(_OPTIONS["crashRpt_root"], "lib") }
links { "CrashRpt1403" }
filter { "files:" .. path.join(_OPTIONS["crashRpt_root"], "bin/*.*") }
buildaction "Copy"
filter {}
end
end
workspace "Maxr"
location(locationDir)
configurations {"Debug", "Release"}
language "C++"
cppdialect "C++17"
objdir(path.join(locationDir, "obj")) -- premake adds $(configName)/$(AppName)
startproject "maxr"
externalwarnings "Off"
if _OPTIONS["crashRpt_root"] ~= nil then
defines { "USE_CRASH_RPT" }
end
filter { "action:vs*" }
nuget(nugetPackages)
filter { "toolset:msc*" }
defines { "_CRT_SECURE_NO_WARNINGS" } -- 4996: '$func': This function or variable may be unsafe. Consider using $func2 instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
defines { "_USE_MATH_DEFINES" } -- for M_PI
buildoptions { "/Zc:__cplusplus" } -- else __cplusplus would be 199711L
disablewarnings {
"4458", -- declaration of '$var' hides class member
}
filter { "configurations:Debug" }
symbols "On"
defines { "DEBUG" }
optimize "Off"
filter { "configurations:Release" }
symbols "Off"
defines { "NDEBUG" }
optimize "On"
filter { "toolset:msc*" }
symbols "On" -- pdb even on release
filter "system:windows"
defines { "WIN32" }
project "resinstaller"
kind "ConsoleApp"
uuid "9DEEC088-8951-502D-32D7-88E31E191CB0"
targetdir "data"
debugdir "data"
filter { "configurations:Release" }
targetname "resinstaller"
filter { "configurations:Debug" }
targetname "resinstaller_%{_ACTION}_%{cfg.buildcfg}"
filter {}
warnings "Extra"
-- flags { "FatalWarnings"} -- We still have warnings :-(
files { "resinstaller/src/**.cpp", "resinstaller/src/**.c", "resinstaller/src/**.h" } -- source files
files { "resinstaller/.clang-format", "resinstaller/ABOUT", "resinstaller/AUTHORS", "resinstaller/Readme.md" } -- extra files
includedirs { "src", "resinstaller/src" }
links "SDL_flic"
filter { "toolset:msc*" }
disablewarnings {
"4244", -- '=': conversion from '$type1' to '$type2', possible loss of data
"4456", -- declaration of '$var' hides previous local declaration
"4701", -- potentially uninitialized local variable '$var' used
"4703", -- potentially uninitialized local pointer variable '$var' used
"4996", -- '$func': The POSIX name of this item is deprecated. Instead, use the ISO C and C++ conformant name: $func2. See online help for details.
}
filter "action:not vs*"
if vorbis_headerPath then
includedirsafter { vorbis_headerPath }
end
if ogg_headerPath then
includedirsafter { ogg_headerPath }
end
if SDL2_headerPath then
externalincludedirs { path.join(SDL2_headerPath, "SDL2") }
end
if SDL2_libraryPath then
libdirs { SDL2_libraryPath }
end
links { "SDL2", "ogg", "vorbis", "vorbisfile", "vorbisenc" }
filter {}
project "maxr"
kind "WindowedApp"
targetdir "data"
filter { "configurations:Release" }
targetname "maxr"
filter { "configurations:Debug" }
targetname "maxr_%{_ACTION}_%{cfg.buildcfg}"
filter {}
warnings "Extra"
flags { "FatalWarnings"}
if have_autoversion_h then
includedirs { locationDir } -- for generated file (autoversion.h)
end
files { "src/ui/**.cpp", "src/ui/**.h", "src/maxr.rc" }
includedirs { "src", "src/lib" }
externalincludedirs { "submodules/nlohmann/single_include" }
links { "maxr_lib", "SDL_flic", "mveplayer" }
linksToCrashRpt()
debugdir "data"
project "dedicated_server"
kind "ConsoleApp"
targetdir "data"
filter { "configurations:Release" }
targetname "dedicatedserver"
filter { "configurations:Debug" }
targetname "dedicatedserver_%{_ACTION}_%{cfg.buildcfg}"
filter {}
warnings "Extra"
flags { "FatalWarnings"}
if have_autoversion_h then
includedirs { locationDir } -- for generated file (autoversion.h)
end
files { "src/dedicatedserver/**.cpp", "src/dedicated_server/**.h", "src/maxr.rc" }
includedirs { "src", "src/lib" }
externalincludedirs { "submodules/nlohmann/single_include" }
links { "maxr_lib", "SDL_flic", "mveplayer" }
linksToCrashRpt()
debugdir "data"
project "tests"
kind "ConsoleApp"
targetdir(path.join(locationDir, "bin/%{cfg.buildcfg}"))
targetname "maxr_tests"
warnings "Extra"
flags { "FatalWarnings"}
files { "tests/**.cpp", "tests/**.h" }
vpaths { ["tests/*"] = "tests" }
includedirs { "src/lib" }
includedirs { "tests" }
externalincludedirs { "submodules/doctest/doctest", "submodules/nlohmann/single_include" }
links { "maxr_lib" }
linksToCrashRpt()
filter { "toolset:msc*" }
disablewarnings {
"4459", -- declaration of '$var' hides global declaration
}
filter {}
project "maxr_lib"
kind "StaticLib"
targetdir(path.join(locationDir, "obj/%{cfg.buildcfg}"))
targetname "maxr_lib"
warnings "Extra"
flags { "FatalWarnings"}
if have_autoversion_h then
files { path.join(locationDir, "autoversion.h") } -- generated file
includedirs { locationDir } -- for generated file (autoversion.h)
end
files { "src/lib/**.cpp", "src/lib/**.h" } -- Source
files { "src/autoversion.h.in"} -- template to generate autoversion.h
files { "src/.clang-format" }
files { "CMakeLists.txt", "mk/cmake/**.*" } --CMake stuff
files { "premake5.lua" }
includedirs { "src", "src/lib" }
externalincludedirs { "submodules/nlohmann/single_include", "submodules/spiritless_po/include" }
if _OPTIONS["crashRpt_root"] ~= nil then
externalincludedirs { path.join(_OPTIONS["crashRpt_root"], "include") }
end
group "3rd"
project "mveplayer"
kind "StaticLib"
targetdir(path.join(locationDir, "obj/%{cfg.buildcfg}"))
targetname "mveplayer"
files { "src/3rd/mveplayer/**.cpp", "src/3rd/mveplayer/**.h" }
vpaths { ["mveplayer/*"] = "src/3rd/mveplayer" }
project "SDL_flic"
kind "StaticLib"
targetdir(path.join(locationDir, "obj/%{cfg.buildcfg}"))
targetname "SDL_flic"
files { "src/3rd/SDL_flic/**.c", "src/3rd/SDL_flic/**.h" }
vpaths { ["SDL_flic/*"] = "src/3rd/SDL_flic" }
filter { "toolset:msc*" }
disablewarnings {
"4244", -- '=': conversion from '$type1' to '$type2', possible loss of data
}
filter {}
if premake.action.supports("None") then
project "doctest" -- header only
kind "None"
files { "submodules/doctest/**.*" }
vpaths { ["doctest/*"] = "submodules/doctest" }
project "nlohmann" -- header only
kind "None"
files { "submodules/nlohmann/**.*" }
vpaths { ["nlohmann/*"] = "submodules/nlohmann" }
project "spiritless_po" -- header only
kind "None"
files { "submodules/spiritless_po/**.*" }
vpaths { ["spiritless_po/*"] = "submodules/spiritless_po" }
group ""
project "data" -- data
kind "None"
files { "data/**.*" }
vpaths { ["data/*"] = "data" }
removefiles { "data/**.dll", "data/**.exe" }
end