forked from HeliumProject/Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helium.lua
480 lines (405 loc) · 12.3 KB
/
Helium.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
Helium = {}
Helium.RequiredPremakeVersion = '4.4-beta1'
Helium.RequiredCLVersion = 150030729
Helium.RequiredFBXVersion = '2012.2'
os.capture = function( cmd, raw )
local f = assert( io.popen( cmd, 'r' ) )
local s = assert( f:read( '*a' ) )
f:close()
if raw then
return s
end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
Helium.GetSystemVersion = function()
local version = 'Unknown'
if os.get() == "windows" then
version = os.capture( "cmd /c ver" )
else
version = os.capture( "uname -r" )
end
return version
end
Helium.Build32Bit = function()
if ( _OPTIONS[ "build32and64" ] ) then
return true
else
return not os.is64bit()
end
end
Helium.Build64Bit = function()
if ( _OPTIONS[ "build32and64" ] ) then
return true
else
return os.is64bit()
end
end
Helium.GetFbxSdkLocation = function()
local fbxLocation = os.getenv( 'FBX_SDK' )
if not fbxLocation then
if os.get() == "windows" then
fbxLocation = "C:\\Program Files\\Autodesk\\FBX\\FbxSdk\\" .. Helium.RequiredFBXVersion
elseif os.get() == "macosx" then
fbxLocation = "/Applications/Autodesk/FBXSDK" .. string.gsub(Helium.RequiredFBXVersion, "%.", "")
else
print("Implement support for " .. os.get() .. " to Helium.GetFbxSdkLocation()")
os.exit(1)
end
if not os.isdir( fbxLocation ) then
print("FBX SDK not found at: " .. fbxLocation)
os.exit(1)
end
end
return fbxLocation
end
Helium.Sleep = function( seconds )
if os.get() == "windows" then
os.execute("ping 127.0.0.1 -n " .. seconds + 1 .. " -w 1000 >:nul 2>&1")
else
os.execute("sleep " .. seconds)
end
end
Helium.CheckEnvironment = function()
print("\nChecking Environment...\n")
if _PREMAKE_VERSION < Helium.RequiredPremakeVersion then
print( "You must be running at least Premake " .. Helium.RequiredPremakeVersion .. "." )
os.exit( 1 )
end
if os.get() == "windows" then
local failed = 0
if os.pathsearch( 'Python.exe', os.getenv( 'PATH' ) ) == nil then
print( " -> Python was not found in your path. Python is required for the 'prebuild' phase." )
print( " -> Make sure to download python (http://www.python.org/download/) and add it to your path." )
print( " -> eg: Add c:\\Python\\Python31 to your path." )
failed = 1
end
if os.getenv( "VCINSTALLDIR" ) == nil then
print( " -> You must be running in a Visual Studio Command Prompt.")
failed = 1
end
if not failed then
if os.pathsearch( 'cl.exe', os.getenv( 'PATH' ) ) == nil then
print( " -> cl.exe was not found in your path. Make sure you are using a Visual Studio 2008 SP1 Command Prompt." )
failed = 1
else
compilerPath = "cl.exe"
end
local compilerVersion = ''
local compilerVersionOutput = os.capture( "\"cl.exe\" 2>&1" )
for major, minor, build in string.gmatch( compilerVersionOutput, "Version (%d+)\.(%d+)\.(%d+)" ) do
compilerVersion = major .. minor .. build
end
if tonumber( compilerVersion ) < Helium.RequiredCLVersion then
print( " -> You must have Visual Studio 2008 with SP1 applied to compile Helium. Please update your compiler and tools." )
failed = 1
end
end
if os.getenv( "DXSDK_DIR" ) == nil then
print( " -> You must have the DirectX SDK installed (DXSDK_DIR is not defined in your environment)." )
failed = 1
end
local fbxDir = Helium.GetFbxSdkLocation()
if not fbxDir or not os.isdir( fbxDir ) then
print( " -> You must have the FBX SDK installed and the FBX_SDK environment variable set." )
print( " -> Make sure to point the FBX_SDK environment variable at the FBX install location, eg: C:\\Program Files\\Autodesk\\FBX\\FbxSdk\\" .. Helium.RequiredFBXVersion )
failed = 1
end
if failed == 1 then
print( "\nCannot proceed until your environment is valid." )
os.exit( 1 )
end
end
end
Helium.Publish = function( files )
for i,v in pairs(files) do
-- mkpath the target folder
os.mkdir( v.target )
local path = v.source .. "/" .. v.file
local exists = os.isfile( path )
local destination = v.target .. "/" .. v.file
print( path )
-- do the hard link
local linkCommand = ''
if ( os.get() == "windows" ) then
-- delete target
if os.isfile( destination ) then
local delCommand = "del /q \"" .. string.gsub( destination, "/", "\\" ) .. "\""
-- if deleting the target failed, bail
if os.execute( delCommand ) ~= 0 then
print( "Deleting destination file: " .. destination .. " failed." )
os.exit( 1 )
end
end
-- check system version, do appropriate command line
local versionString = Helium.GetSystemVersion()
if ( string.find( versionString, "6\.%d+\.%d+" ) ) then -- vista/windows 7
linkCommand = "mklink /H \"" .. destination .. "\" \"" .. path .. "\""
else
linkCommand = "fsutil hardlink create \"" .. destination .. "\" \"" .. path .. "\""
end
else
-- hooray simplicity in *nix
linkCommand = "ln -f \"" .. path .. "\" \"" .. destination .. "\""
end
-- if creating a hardlink failed, bail
if os.execute( linkCommand ) ~= 0 then
print( "Creating hardlink: " .. destination .. " failed." )
os.exit( 1 )
end
-- the files were copied, complete this entry
files[ i ] = nil
end
end
Helium.PublishIcons = function( bin )
if os.get() == "windows" then
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x32\\Debug\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x32\\Intermediate\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x32\\Profile\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x32\\Release\\Icons\" *.png")
if Helium.Build64Bit() then
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x64\\Debug\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x64\\Intermediate\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x64\\Profile\\Icons\" *.png")
os.execute("robocopy /njs /nfl /ndl /nc /ns /np /MIR \"Editor\\Icons\\Helium\" \"" .. bin .. "\\x64\\Release\\Icons\" *.png")
end
else
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x32/Debug/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x32/Intermediate/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x32/Profile/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x32/Release/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
if Helium.Build64Bit() then
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x64/Debug/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x64/Intermediate/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x64/Profile/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
os.execute("rsync -a --delete Editor/Icons/Helium/ " .. bin .. "/x64/Release/Icons/ --filter='+ */' --filter '+ *.png' --filter='- *'")
end
end
end
Helium.DoDefaultSolutionSettings = function()
location "Premake"
if _OPTIONS[ "build32and64" ] then
platforms
{
"x32",
"x64",
}
elseif Helium.Build32Bit() then
platforms
{
"x32",
}
elseif Helium.Build64Bit() then
platforms
{
"x64",
}
end
configurations
{
"Debug",
"Intermediate",
"Profile",
"Release",
}
defines
{
"UNICODE=1",
"FBXSDK_SHARED=1",
"LITESQL_UNICODE=1",
"XML_STATIC=1",
"HELIUM_UNICODE=1",
}
flags
{
"Unicode",
"EnableSSE2",
"NoMinimalRebuild",
}
configuration "x64"
defines
{
-- Explicitly define "__SSE__" and "__SSE2__" on x86-64 platforms, as Visual C++ does not define them automatically.
"__SSE__",
"__SSE2__",
}
for i, platform in ipairs( platforms() ) do
for j, config in ipairs( configurations() ) do
configuration( { config, platform } )
objdir( "Build" ) -- premake seems to automatically add the platform and config name
configuration( { config, platform } )
targetdir( "Bin/" .. platform .. "/" .. config )
end
end
configuration "windows"
defines
{
"WIN32",
"_WIN32",
"_CRT_SECURE_NO_DEPRECATE",
"_CRT_NON_CONFORMING_SWPRINTFS",
"XML_UNICODE_WCHAR_T=1",
}
configuration "Debug"
defines
{
"_DEBUG",
"TBB_USE_DEBUG=1",
"HELIUM_DEBUG=1",
"HELIUM_SHARED=1",
}
flags
{
"Symbols",
}
configuration "Intermediate"
defines
{
"HELIUM_INTERMEDIATE=1",
"HELIUM_STATIC=1",
}
flags
{
"Symbols",
"OptimizeSpeed",
"NoEditAndContinue",
}
configuration "Profile"
defines
{
"NDEBUG",
"HELIUM_PROFILE=1",
"HELIUM_STATIC=1",
}
flags
{
"Symbols",
"NoFramePointer",
"OptimizeSpeed",
"NoEditAndContinue",
}
configuration "Release"
defines
{
"NDEBUG",
"HELIUM_RELEASE=1",
"HELIUM_STATIC=1",
}
flags
{
"Symbols",
"NoFramePointer",
"OptimizeSpeed",
"NoEditAndContinue",
}
configuration "windows"
buildoptions
{
"/MP",
"/Zm256"
}
configuration { "windows", "Debug" }
buildoptions
{
"/Ob0",
}
configuration { "windows", "not Debug" }
buildoptions
{
"/Ob2",
"/Oi",
}
configuration {}
end
-- Common settings for projects linking with libraries.
Helium.DoDefaultProjectSettings = function()
language "C++"
location( "Premake/" .. solution().name )
targetname( "Helium." .. project().name )
configuration {}
flags
{
--"FatalWarnings",
--"ExtraWarnings",
"FloatFast", -- Should be used in all configurations to ensure data consistency.
}
configuration "SharedLib or *App"
links
{
"Expat",
"freetype",
"nvtt",
"png",
"zlib",
}
configuration { "windows", "SharedLib or *App" }
links
{
"ws2_32",
"d3d9",
"d3dx9",
"d3d11",
"dxguid",
"d3dcompiler",
"wininet",
}
configuration { "windows", "SharedLib or *App" }
links
{
"dbghelp",
}
configuration { "windows", "Debug", "SharedLib or *App" }
links
{
"fbxsdk-2012.2d",
}
configuration { "windows", "not Debug", "SharedLib or *App" }
links
{
"fbxsdk-2012.2",
}
if haveGranny then
configuration { "x32", "SharedLib or *App" }
links
{
"granny2",
}
configuration { "x64", "SharedLib or *App" }
links
{
"granny2_x64",
}
end
configuration {}
end
-- Common settings for modules.
Helium.DoModuleProjectSettings = function( baseDirectory, tokenPrefix, moduleName, moduleNameUpper )
configuration {}
defines
{
"HELIUM_MODULE_HEAP_FUNCTION=Get" .. moduleName .. "DefaultHeap"
}
pchheader( moduleName .. "Pch.h" )
pchsource( baseDirectory .. "/" .. moduleName .. "/" .. moduleName .. "Pch.cpp" )
Helium.DoDefaultProjectSettings()
--[[--This is off until we get rid of a couple dynamic_cast<>'s -Geoff
configuration "not Debug"
flags
{
"NoRTTI",
}
--]]
configuration "not windows"
kind "StaticLib"
configuration { "windows", "Debug" }
kind "SharedLib"
defines
{
tokenPrefix .. "_" .. moduleNameUpper .. "_EXPORTS",
}
configuration { "windows", "not Debug" }
kind "StaticLib"
configuration {}
end