-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathpremake5.lua
270 lines (210 loc) · 7.4 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
newoption { trigger = "use-frameworks", description = "In macOS it will try to link the external libraries from its frameworks. For example, instead of linking against SDL2 it will link against SDL2.framework." }
newoption { trigger = "windows-vc-build", description = "This is used to build the framework in Visual Studio downloading its external dependencies and making them available to the VS project without having to install them manually." }
function string.starts(String,Start)
if ( _ACTION ) then
return string.sub(String,1,string.len(Start))==Start
end
return false
end
function is_xcode()
return ( string.starts(_ACTION,"xcode") )
end
function incdirs( dirs )
if is_xcode() then
externalincludedirs { dirs }
end
includedirs { dirs }
end
function os_findlib( name )
if os.istarget("macosx") and ( is_xcode() or _OPTIONS["use-frameworks"] ) then
local path = "/Library/Frameworks/" .. name .. ".framework"
if os.isdir( path ) then
return path
end
end
return os.findlib( name )
end
function get_backend_link_name( name )
if os.istarget("macosx") and ( is_xcode() or _OPTIONS["use-frameworks"] ) then
local fname = name .. ".framework"
if os_findlib( name ) then -- Search for the framework
return fname
end
end
return name
end
remote_sdl2_version = "SDL2-2.30.8"
remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.30.8-VC.zip"
function download_and_extract_dependencies()
if _OPTIONS["windows-vc-build"] and not os.isdir("./" .. remote_sdl2_version) then
print("Downloading: " .. remote_sdl2_devel_vc_url)
local dest_dir = "./"
local local_file = dest_dir .. remote_sdl2_version .. ".zip"
local result_str, response_code = http.download(remote_sdl2_devel_vc_url, local_file)
if response_code == 200 then
print("Downloaded successfully to: " .. local_file)
zip.extract(local_file, dest_dir)
print("Extracted " .. local_file .. " into " .. dest_dir)
ok = os.copyfile(dest_dir .. remote_sdl2_version .. "/lib/x64/SDL2.dll", "./bin/SDL2.dll")
if not ok then
print("Failed to copy SDL2.dll.")
end
else
print("Failed to download: " .. remote_sdl2_rul)
exit(1)
end
end
end
workspace "SOIL2"
location("./make/" .. os.target() .. "/")
targetdir("./bin")
configurations { "debug", "release" }
platforms { "x86_64", "x86" }
download_and_extract_dependencies()
objdir("obj/" .. os.target() .. "/")
filter { "system:macosx", "not action:xcode*", "not options:use-frameworks" }
libdirs { "/opt/homebrew/lib" }
incdirs { "/opt/homebrew/include" }
filter "platforms:x86"
architecture "x86"
filter "platforms:x86_64"
architecture "x86_64"
project "soil2-static-lib"
kind "StaticLib"
targetdir("lib/" .. os.target() .. "/")
files { "src/SOIL2/*.c" }
filter "action:vs*"
buildoptions { "/TP" }
defines { "_CRT_SECURE_NO_WARNINGS" }
filter "action:not vs*"
language "C"
buildoptions { "-Wall" }
filter "configurations:debug"
defines { "DEBUG" }
symbols "On"
targetname "soil2-debug"
filter "configurations:release"
defines { "NDEBUG" }
optimize "On"
targetname "soil2"
filter "system:macosx"
defines { "GL_SILENCE_DEPRECATION" }
project "soil2-shared-lib"
kind "SharedLib"
targetdir("lib/" .. os.target() .. "/")
files { "src/SOIL2/*.c" }
filter "action:vs*"
buildoptions { "/TP" }
defines { "_CRT_SECURE_NO_WARNINGS" }
filter { "system:windows", "action:not vs*" }
links { "mingw32" }
vectorextensions "SSE2"
defines { "STBI_MINGW_ENABLE_SSE2" }
filter "system:windows"
links {"opengl32"}
filter "system:linux"
links {"GL"}
filter "system:macosx"
links { "OpenGL.framework", "CoreFoundation.framework" }
buildoptions {"-F /Library/Frameworks"}
linkoptions {"-F /Library/Frameworks"}
defines { "GL_SILENCE_DEPRECATION" }
filter "system:haiku"
links {"GL"}
filter "system:bsd"
links {"GL"}
filter "action:not vs*"
language "C"
buildoptions { "-Wall" }
filter "configurations:debug"
defines { "DEBUG" }
symbols "On"
targetname "soil2-debug"
filter "configurations:release"
defines { "NDEBUG" }
optimize "On"
targetname "soil2"
project "soil2-test"
kind "ConsoleApp"
language "C++"
links { "soil2-static-lib" }
files { "src/test/*.cpp", "src/common/*.cpp" }
filter { "system:windows", "action:not vs*" }
links { "mingw32" }
filter "system:windows"
links {"opengl32","SDL2main","SDL2"}
filter "system:linux"
links {"GL","SDL2"}
filter "system:macosx"
links { "OpenGL.framework", "CoreFoundation.framework", get_backend_link_name("SDL2") }
buildoptions {"-F /Library/Frameworks"}
linkoptions {"-F /Library/Frameworks"}
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
defines { "GL_SILENCE_DEPRECATION" }
if not _OPTIONS["use-frameworks"] then
defines { "SOIL2_NO_FRAMEWORKS" }
end
filter "system:haiku"
links {"GL","SDL2"}
filter "system:bsd"
links {"GL","SDL2"}
filter "action:not vs*"
buildoptions { "-Wall" }
vectorextensions "SSE2"
defines { "STBI_MINGW_ENABLE_SSE2" }
filter "configurations:debug"
defines { "DEBUG" }
symbols "On"
targetname "soil2-test-debug"
filter "configurations:release"
defines { "NDEBUG" }
optimize "On"
targetname "soil2-test-release"
filter { "options:windows-vc-build", "system:windows", "platforms:x86" }
syslibdirs { "./" .. remote_sdl2_version .."/lib/x86" }
filter { "options:windows-vc-build", "system:windows", "platforms:x86_64" }
syslibdirs { "./" .. remote_sdl2_version .."/lib/x64" }
filter { "options:windows-vc-build", "system:windows" }
incdirs { "./" .. remote_sdl2_version .. "/include" }
project "soil2-perf-test"
kind "ConsoleApp"
language "C++"
links { "soil2-static-lib" }
files { "src/perf_test/*.cpp", "src/common/*.cpp" }
filter { "system:windows", "action:not vs*" }
links { "mingw32" }
vectorextensions "SSE2"
defines { "STBI_MINGW_ENABLE_SSE2" }
filter "system:windows"
links {"opengl32","SDL2main","SDL2"}
filter "system:linux"
links {"GL","SDL2"}
filter "system:macosx"
links { "OpenGL.framework", "CoreFoundation.framework", get_backend_link_name("SDL2") }
buildoptions {"-F /Library/Frameworks"}
linkoptions {"-F /Library/Frameworks"}
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
defines { "GL_SILENCE_DEPRECATION" }
if not _OPTIONS["use-frameworks"] then
defines { "SOIL2_NO_FRAMEWORKS" }
end
filter "system:haiku"
links {"GL","SDL2"}
filter "system:bsd"
links {"GL","SDL2"}
filter "action:not vs*"
buildoptions { "-Wall" }
filter "configurations:debug"
defines { "DEBUG" }
symbols "On"
targetname "soil2-perf-test-debug"
filter "configurations:release"
defines { "NDEBUG" }
optimize "On"
targetname "soil2-perf-test-release"
filter { "options:windows-vc-build", "system:windows", "platforms:x86" }
syslibdirs { "./" .. remote_sdl2_version .."/lib/x86" }
filter { "options:windows-vc-build", "system:windows", "platforms:x86_64" }
syslibdirs { "./" .. remote_sdl2_version .."/lib/x64" }
filter { "options:windows-vc-build", "system:windows" }
incdirs { "./" .. remote_sdl2_version .. "/include" }