-
Notifications
You must be signed in to change notification settings - Fork 75
/
premake5.lua
340 lines (289 loc) · 9.57 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
newoption {
trigger = "no-direct3d",
description = "Disable DirectX options in irrlicht if the DirectX SDK isn't installed"
}
newoption {
trigger = "oldwindows",
description = "Use some tricks to support up to windows XP sp3"
}
newoption {
trigger = "sound",
value = "backend",
description = "Choose sound backend",
allowed = {
{ "irrklang", "irrklang" },
{ "sdl-mixer", "SDL2-mixer" },
{ "sfml", "SFML" }
}
}
newoption {
trigger = "use-mpg123",
description = "Use mpg123 mp3 backend instead of minimp3 (Available only when using SFML audio backend)"
}
newoption {
trigger = "no-joystick",
default = "true",
description = "Add base joystick compatibility (Requires SDL2)"
}
newoption {
trigger = "pics",
value = "url_template",
description = "Default URL for card images"
}
newoption {
trigger = "fields",
value = "url_template",
description = "Default URL for Field Spell backgrounds"
}
newoption {
trigger = "covers",
value = "url_template",
description = "Default URL for cover images"
}
newoption {
trigger = "prebuilt-core",
value = "path",
description = "Path to library folder containing libocgcore"
}
newoption {
trigger = "vcpkg-root",
value = "path",
description = "Path to vcpkg installation"
}
newoption {
trigger = "discord",
value = "app_id_token",
description = "Discord App ID for rich presence"
}
newoption {
trigger = "update-url",
value = "url",
description = "API endpoint to check for updates from"
}
newoption {
trigger = "no-core",
description = "Ignore the ocgcore subproject and only generate the solution for ygoprodll"
}
newoption {
trigger = "architecture",
value = "arch",
description = "Architecture for the solution, allowed values are x86, x64, arm64, armv7, comma separated"
}
newoption {
trigger = "bundled-font",
value = "font",
description = "Path to a font file that will be bundled in the client and used as fallback font for missing glyphs"
}
newoption {
trigger = "lua-path",
description = "Path where the lua library has been installed"
}
local function default_arch()
if os.istarget("linux") or os.istarget("macosx") then return "x64" end
if os.istarget("windows") then return "x86" end
if os.istarget("ios") then return "arm64" end
end
local function valid_arch(arch)
return arch == "x86" or arch == "x64" or arch == "arm64" or arch == "armv7"
or arch == "x86-iossim" or arch == "x64-iossim" or arch == "arm64-iossim"
end
local absolute_vcpkg_path =(function()
if _OPTIONS["vcpkg-root"] then
return path.getabsolute(_OPTIONS["vcpkg-root"])
end
end)()
local function ends_with(str, ending)
return str:sub(-#ending) == ending
end
function get_vcpkg_root_path(arch)
local function vcpkg_triplet_path()
if os.istarget("linux") then
return "-linux"
elseif os.istarget("macosx") then
return "-osx"
elseif os.istarget("windows") then
return "-mingw-static"
elseif os.istarget("ios") then
if ends_with(arch, "iossim") then
return ""
else
return "-ios"
end
end
end
return absolute_vcpkg_path .. "/installed/" .. ((arch == "armv7" and "arm") or arch) .. vcpkg_triplet_path()
end
archs={}
if _OPTIONS["architecture"] then
for arch in string.gmatch(_OPTIONS["architecture"], "([^,]+)") do
if valid_arch(arch) then
table.insert(archs,arch)
end
end
end
if #archs == 0 then archs = { default_arch() } end
local _includedirs=includedirs
if _ACTION=="xcode4" then
_includedirs=sysincludedirs
end
workspace "ygo"
location "build"
language "C++"
objdir "obj"
if not _OPTIONS["no-core"] then
startproject "ygopro"
else
startproject "ygoprodll"
end
staticruntime "on"
warnings "Extra"
filter { "action:vs*" }
disablewarnings "4100" --'identifier' : unreferenced formal parameter
filter { "action:not vs*" }
disablewarnings { "unknown-warning-option", "unused-parameter", "unknown-pragmas", "ignored-qualifiers", "missing-field-initializers", "implicit-const-int-float-conversion", "missing-braces", "invalid-utf8" }
filter { "action:not vs*", "files:**.cpp" }
disablewarnings { "deprecated-copy", "unused-lambda-capture" }
filter{}
configurations { "Debug", "Release" }
filter "system:windows"
systemversion "latest"
defines { "WIN32", "_WIN32", "NOMINMAX" }
for _,arch in ipairs(archs) do
if arch=="x86" then platforms "Win32" end
if arch=="x64" then platforms "x64" end
end
filter "system:not windows"
platforms(archs)
filter "platforms:Win32"
architecture "x86"
filter "platforms:x86*"
architecture "x86"
filter "platforms:x64*"
architecture "x64"
filter "platforms:arm64*"
architecture "ARM64"
filter "platforms:armv7"
architecture "ARM"
if os.istarget("ios") and _ACTION~="xcode4" then
premake.tools.clang.ldflags.architecture.x86 = "-arch i386"
premake.tools.clang.ldflags.architecture.x86_64 = "-arch x86_64"
premake.tools.clang.ldflags.architecture.ARM = "-arch armv7"
premake.tools.clang.ldflags.architecture.ARM64 = "-arch arm64"
premake.tools.clang.shared.architecture = premake.tools.clang.ldflags.architecture
premake.tools.gcc.ldflags.architecture = premake.tools.clang.ldflags.architecture
premake.tools.gcc.shared.architecture = premake.tools.clang.ldflags.architecture
end
if _OPTIONS["oldwindows"] then
filter { "action:vs*" }
toolset "v141_xp"
filter {}
else
filter { "action:vs*" }
systemversion "latest"
end
if _OPTIONS["vcpkg-root"] then
for _,arch in ipairs(archs) do
local full_vcpkg_root_path=get_vcpkg_root_path(arch)
print(full_vcpkg_root_path)
local platform="platforms:" .. (arch=="x86" and os.istarget("windows") and "Win32" or arch)
filter { "action:not vs*", platform }
_includedirs { full_vcpkg_root_path .. "/include" }
filter { "action:not vs*", "configurations:Debug", platform }
libdirs { full_vcpkg_root_path .. "/debug/lib" }
filter { "action:not vs*", "configurations:Release", platform }
libdirs { full_vcpkg_root_path .. "/lib" }
end
end
filter "system:macosx"
_includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
--systemversion "10.10"
filter { "system:ios", "platforms:*-iossim"}
buildoptions { "-mios-simulator-version-min=9.0" }
linkoptions { "-mios-simulator-version-min=9.0" }
filter { "system:ios", "platforms:arm64 or armv7"}
buildoptions { "-miphoneos-version-min=9.0" }
linkoptions { "-miphoneos-version-min=9.0" }
filter "action:vs*"
vectorextensions "SSE2"
buildoptions "-wd4996"
defines "_CRT_SECURE_NO_WARNINGS"
filter "action:not vs*"
buildoptions { "-fno-strict-aliasing", "-Wno-multichar" }
filter { "action:not vs*", "system:windows" }
buildoptions { "-static-libgcc", "-static-libstdc++", "-static", "-lpthread" }
linkoptions { "-mthreads", "-municode", "-static-libgcc", "-static-libstdc++", "-static", "-lpthread" }
defines { "UNICODE", "_UNICODE" }
filter { "action:not vs*", "system:windows", "configurations:Release" }
buildoptions { "-s" }
linkoptions { "-s" }
filter "configurations:Debug"
symbols "On"
defines "_DEBUG"
targetdir "bin/debug"
runtime "Debug"
filter { "configurations:Debug", "architecture:x64" }
targetdir "bin/x64/debug"
filter { "configurations:Debug", "platforms:x64-iossim" }
targetdir "bin/x64-iossim/debug"
filter { "configurations:Debug", "architecture:ARM64" }
targetdir "bin/arm64/debug"
filter { "configurations:Debug", "platforms:arm64-iossim" }
targetdir "bin/arm64-iossim/debug"
filter { "configurations:Debug", "architecture:ARM" }
targetdir "bin/armv7/debug"
filter { "configurations:Release*" , "action:not vs*" }
symbols "On"
filter "configurations:Release"
optimize "Size"
targetdir "bin/release"
defines "NDEBUG"
filter { "configurations:Release", "action:vs* or system:not windows" }
flags "LinkTimeOptimization"
filter { "configurations:Release", "architecture:x64" }
targetdir "bin/x64/release"
filter { "configurations:Release", "platforms:x64-iossim" }
targetdir "bin/x64-iossim/release"
filter { "configurations:Release", "architecture:ARM64" }
targetdir "bin/arm64/release"
filter { "configurations:Release", "platforms:arm64-iossim" }
targetdir "bin/arm64-iossim/release"
filter { "configurations:Release", "architecture:ARM" }
targetdir "bin/armv7/release"
filter { "system:linux", "configurations:Release" }
linkoptions { "-static-libgcc", "-static-libstdc++" }
subproject = true
if not _OPTIONS["prebuilt-core"] and not _OPTIONS["no-core"] then
include "ocgcore"
end
if _OPTIONS["bundled-font"] then
local bin2c=require("tools.bin2c")
bin2c(_OPTIONS["bundled-font"], "gframe/CGUITTFont/bundled_font.cpp")
end
include "gframe"
if os.istarget("windows") then
include "irrlicht"
end
if os.istarget("macosx") and _OPTIONS["discord"] then
include "discord-launcher"
end
local function vcpkgStaticTriplet(prj)
premake.w('<VcpkgTriplet Condition="\'$(Platform)\'==\'Win32\'">x86-windows-static</VcpkgTriplet>')
premake.w('<VcpkgTriplet Condition="\'$(Platform)\'==\'x64\'">x64-windows-static</VcpkgTriplet>')
end
local function disableWinXPWarnings(prj)
premake.w('<XPDeprecationWarning>false</XPDeprecationWarning>')
end
local function vcpkgStaticTriplet202006(prj)
premake.w('<VcpkgEnabled>true</VcpkgEnabled>')
premake.w('<VcpkgUseStatic>true</VcpkgUseStatic>')
premake.w('<VcpkgAutoLink>true</VcpkgAutoLink>')
end
require('vstudio')
premake.override(premake.vstudio.vc2010.elements, "globals", function(base, prj)
local calls = base(prj)
table.insertafter(calls, premake.vstudio.vc2010.targetPlatformVersionGlobal, vcpkgStaticTriplet)
table.insertafter(calls, premake.vstudio.vc2010.targetPlatformVersionGlobal, disableWinXPWarnings)
table.insertafter(calls, premake.vstudio.vc2010.globals, vcpkgStaticTriplet202006)
return calls
end)