-
Notifications
You must be signed in to change notification settings - Fork 1
/
premake4.lua
554 lines (512 loc) · 25.9 KB
/
premake4.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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
--[[
This premake4.lua _requires_ windirstat/premake-stable to work properly.
If you don't want to use the code-signed build that can be found in the
./common/ subfolder, you can build from the WDS-branch over at:
https://sourceforge.net/projects/windirstat/
Prebuilt, signed binaries are available from:
https://github.com/windirstat/premake-stable
https://sourceforge.net/projects/windirstat/files/premake-stable/
https://osdn.net/projects/windirstat/storage/historical/premake-stable/
// SPDX-License-Identifier: Unlicense
]]
local action = _ACTION or ""
local release = false
local tgtname = "ntobjx"
local cmdline = iif(action >= "vs2019", true, false) -- newer versions have solution filters to deal with the issue we're trying to address here
if _OPTIONS["cmdline"] then
cmdline = true
end
if _OPTIONS["release"] then
print "INFO: Creating release build solution."
release = true
end
local function legacy_names(input) -- transform the macro names for older Visual Studio versions
local new_map = { vs2002 = 0, vs2003 = 0, vs2005 = 0, vs2008 = 0 }
local replacements = { Platform = "PlatformName", Configuration = "ConfigurationName" }
if new_map[action] ~= nil then
for k,v in pairs(replacements) do
print("Finding: " .. k)
if input:find(k, 1, true) then
print("Found: " .. k)
k = "%$%(" .. k .. "%)"
v = "%$%(" .. v .. "%)"
input = input:gsub(k, v)
end
end
end
return input
end
newoption { trigger = "release", description = "Creates a solution suitable for a release build." }
newoption { trigger = "cmdline", description = "Also creates the project for the command line tool (default on >=VS2019)." }
solution (tgtname .. iif(release, "_release", ""))
configurations (iif(release, {"Release"}, {"Debug", "Release"}))
platforms {"x32", "x64"}
location (".")
project (tgtname .. iif(release, "_release", ""))
local int_dir = iif(release, "release_", "").."intermediate/" .. action .. "_$(Platform)_$(Configuration)\\$(ProjectName)"
int_dir = legacy_names(int_dir)
uuid ("DE5A7539-C36C-4F2E-9CE3-18087DC72346")
language ("C++")
kind ("WindowedApp")
targetname (tgtname)
flags {"StaticRuntime", "Unicode", "WinMain", "NoPCH", "NoMinimalRebuild", "Symbols",}
targetdir (iif(release, tgtname .. "_release", "build." .. action))
includedirs {"pugixml"}
objdir (int_dir)
links {"ntdll-delayed", "version"}
resoptions {"/nologo", "/l409"}
resincludedirs {".", "$(IntDir)"}
linkoptions {"/delay:nobind", "/delayload:ntdll.dld", "/delayload:version.dll"}
defines {"WIN32", "_WINDOWS", "STRICT", "WINVER=0x0600",}
excludes
{
"ntobjx_c.cpp",
"ntobjx.txt",
"hgid.h",
"Backup*.*",
}
files
{
"delayload-stubs/*.txt",
"pugixml/*.hpp",
"util/*.h", "util/*.hpp",
"res/*.ico",
"*.cpp",
"*.h",
"*.hpp",
"*.rc",
"*.manifest",
"*.cmd", "*.txt", "*.md", "*.rst", "premake4.lua",
"*.manifest", "*.props", "*.targets", "*.ruleset", ".editorconfig", ".clang-format",
".gitignore", ".hgignore",
}
vpaths
{
["Special Files/*"] = { "*.cmd", "premake4.lua", "*.manifest", ".gitignore", ".hgignore", "*.props", "*.targets", "*.ruleset", ".editorconfig", ".clang-format", },
["Special Files/Module Definition Files/*"] = { "delayload-stubs/*.txt", "delayload-stubs/*.c", },
["Header Files/WTL/*"] = { "wtl9/Include/*.h", "wtl10/Include/*.h" },
["Header Files/pugixml/*"] = { "pugixml/*.hpp" },
["Header Files/Utility classes/*"] = { "util/*.h", "util/*.hpp" },
["Header Files/*"] = { "*.h", "*.hpp", },
["Resource Files/*"] = { "**.rc", "res/*.ico" },
["Source Files/*"] = { "*.cpp" },
}
configuration {"*"}
prebuildcommands{"call \"$(ProjectDir)\\hgid.cmd\"",}
configuration {"x64"}
prebuildcommands{
"lib.exe /nologo /nodefaultlib \"/def:delayload-stubs\\ntdll-delayed.txt\" \"/out:$(IntDir)\\ntdll-delayed.lib\" /machine:x64",
}
configuration {"x32"}
prebuildcommands{
"cl.exe /nologo /c /TC /Ob0 /Gz delayload-stubs\\ntdll-delayed-stubs.c \"/Fo$(IntDir)\\ntdll-delayed-stubs.obj\"",
"lib.exe /nologo \"/def:delayload-stubs\\ntdll-delayed.txt\" \"/out:$(IntDir)\\ntdll-delayed.lib\" /machine:x86 \"$(IntDir)\\ntdll-delayed-stubs.obj\"",
}
configuration {"Debug"}
defines {"_DEBUG"}
configuration {"Release"}
defines {"NDEBUG"}
flags {"Optimize", "NoIncrementalLink", "NoEditAndContinue"}
configuration {"vs2015 or vs2017 or vs2019 or vs2022"}
flags {"NoMinimalRebuild"}
files
{
"delayload-stubs/*.c",
}
configuration {"vs2015 or vs2017 or vs2019 or vs2022"}
defines {"WTLVER=10"}
includedirs {"wtl10/Include"}
files
{
"wtl10/Include/*.h",
}
configuration {"vs2002 or vs2003 or vs2005 or vs2008 or vs2010"}
defines {"WTLVER=9"}
includedirs {"wtl9/Include"}
libdirs {"$(IntDir)"}
files
{
"wtl9/Include/*.h",
}
configuration {"x64", "vs2002 or vs2003 or vs2005 or vs2008 or vs2010"}
linkoptions {"/subsystem:windows,5.02"}
configuration {"x32", "vs2002 or vs2003 or vs2005 or vs2008 or vs2010"}
linkoptions {"/subsystem:windows,5.00"}
if cmdline then
-- ntobjx_c project
project (tgtname .. "_c" .. iif(release, "_release", ""))
local int_dir = iif(release, "release_", "").."intermediate/" .. action .. "_$(Platform)_$(Configuration)\\$(ProjectName)"
int_dir = legacy_names(int_dir)
uuid ("CA1F91D0-7D7E-4A9C-9DD1-6C65C2F37A59")
language ("C++")
kind ("ConsoleApp")
targetname (tgtname .. "_c")
flags {"StaticRuntime", "Unicode", "WinMain", "NoPCH", "NoMinimalRebuild", "Symbols",}
targetdir (iif(release, tgtname .. "_release", "build." .. action))
objdir (int_dir)
links {"ntdll-delayed"}
resoptions {"/nologo", "/l409"}
resincludedirs {".", "$(IntDir)"}
linkoptions {"\"/libpath:$(IntDir)\"", "/delay:nobind","/delayload:ntdll.dld"}
defines {"WIN32", "_WINDOWS", "STRICT", "_CONSOLE", "WINVER=0x0600",}
files
{
"delayload-stubs/*.txt",
"ntnative.h",
"*.cpp",
"*.hpp",
"*.cmd", "*.txt", "*.md", "*.rst", "premake4.lua",
}
excludes
{
"ntobjx.cpp",
"hgid.h",
"fake_commodule.hpp",
"stdafx.*", "ntobjx.txt",
"reslang.*", "resource.h",
}
vpaths
{
["Header Files/*"] = { "*.h" },
["Source Files/*"] = { "*.cpp" },
["Special Files/*"] = { "**.cmd", "premake4.lua", "**.manifest", },
["Special Files/Module Definition Files/*"] = { "delayload-stubs/*.txt", },
}
configuration {"Debug"}
defines {"_DEBUG"}
configuration {"x64"}
prebuildcommands{"lib.exe /nologo /nodefaultlib \"/def:delayload-stubs\\ntdll-delayed.txt\" \"/out:$(IntDir)\\ntdll-delayed.lib\" /machine:x64", "\"$(ProjectDir)\\hgid.cmd\""}
configuration {"x32"}
prebuildcommands{"cl.exe /nologo /c /TC /Ob0 /Gz delayload-stubs\\ntdll-delayed-stubs.c \"/Fo$(IntDir)\\ntdll-delayed-stubs.obj\"", "lib.exe /nologo \"/def:delayload-stubs\\ntdll-delayed.txt\" \"/out:$(IntDir)\\ntdll-delayed.lib\" /machine:x86 \"$(IntDir)\\ntdll-delayed-stubs.obj\"", "\"$(ProjectDir)\\hgid.cmd\""}
configuration {"Release"}
defines {"NDEBUG"}
flags {"Optimize", "NoIncrementalLink", "NoEditAndContinue"}
end
do
-- Some tags we suppress as we override those from the project.props file
local suppress_tags2 = {
['<OutDir>%s\\</OutDir>'] = 0,
['<IntDir>%s\\</IntDir>'] = 0,
['<TargetName>%s</TargetName>'] = 0,
['<TargetExt>%s</TargetExt>'] = 0,
['<PrecompiledHeader></PrecompiledHeader>'] = 0,
}
local suppress_tags3 = {
['<PrecompiledHeader></PrecompiledHeader>'] = 0,
['<MinimalRebuild>false</MinimalRebuild>'] = 0,
['<MinimalRebuild>true</MinimalRebuild>'] = 0,
['<Optimization>%s</Optimization>'] = 0,
['<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>'] = 0,
['<RuntimeLibrary>%s</RuntimeLibrary>'] = 0,
['<FunctionLevelLinking>true</FunctionLevelLinking>'] = 0,
['<DebugInformationFormat>%s</DebugInformationFormat>'] = 0,
['<StringPooling>true</StringPooling>'] = 0,
['<OptimizeReferences>true</OptimizeReferences>'] = 0,
['<TargetMachine>%s</TargetMachine>'] = 0,
['<EnableCOMDATFolding>true</EnableCOMDATFolding>'] = 0,
['<OutputFile>$(OutDir)%s</OutputFile>'] = 0,
['<AdditionalLibraryDirectories>%s;%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>'] = 0,
['<WarningLevel>Level3</WarningLevel>'] = 0,
}
-- Embed the property sheet
_G.override_vcxproj = function(prj, orig_p, indent, msg, first, ...)
if indent == 1 then
if msg == [[<ImportGroup Label="ExtensionSettings">]] then
orig_p(indent, msg, first, ...) -- pass through original line
orig_p(indent, [[</ImportGroup>]])
orig_p(indent, [[<ImportGroup Label="PropertySheets">]])
orig_p(indent+1, [[<Import Project="$(SolutionDir)project.props" Condition="exists('$(SolutionDir)project.props')" Label="ProjectSpecific (solution)" />]])
orig_p(indent+1, [[<Import Project="$(ProjectDir)project.props" Condition="exists('$(ProjectDir)project.props') AND '$(SolutionDir)' != '$(ProjectDir)'" Label="Project-specific (local)" />]])
return true
end
end
if (indent == 2) and (msg == '<Keyword>Win32Proj</Keyword>') then
orig_p(indent, msg, first, ...) -- pass through original line
orig_p(indent, '<ProjectName>%s</ProjectName>', prj.name)
return true
end
if (indent == 2) and (msg == '<ClCompile Include=\"%s\">') and (first == "delayload-stubs\\ntdll-delayed-stubs.c") then
orig_p(indent, msg, first, ...) -- what was originally supposed to be output
orig_p(indent+1, "<ExcludedFromBuild>true</ExcludedFromBuild>")
return true
end
if (indent == 2) and (suppress_tags2[msg] ~= nil) then -- Suppress these, our property sheet takes care of those
return true
end
if (indent == 3) and (suppress_tags3[msg] ~= nil) then -- Suppress these, our property sheet takes care of those
return true
end
end
end
--[[
This part of the premake4.lua modifies the core premake4 behavior a little.
It does the following (in order of appearence below):
- New option --sdkver to override <WindowsTargetPlatformVersion> on modern VS
- New option --clang to request ClangCL toolset on modern VS
- New option --xp to request XP-compatible toolset on modern VS
- On older premake4 versions it will provide a premake.project.getbasename
function, furthermore two other functions get patched to make use of it
- premake.project.getbasename() gets overridden to insert a marker into the
created file name, based on the chosen action
Example: foobar.vcxproj becomes foobar.vs2022.vcxproj etc ...
The purpose of this exercise is to allow for projects/solutions of several
Visual Studio versions to reside in the same folder
- Options "dotnet" gets removed
- The "platform" option has some allowed values removed
- The "os" option has some allowed values removed
- The actions are trimmed to what we know can work
]]
newoption { trigger = "sdkver", value = "SDKVER", description = "Allows to override SDK version (VS2015 through VS2022)" }
newoption { trigger = "clang", description = "Allows to use clang-cl as compiler and lld-link as linker (VS2019 and VS2022)" }
newoption { trigger = "xp", description = "Allows to use a supported XP toolset for some VS versions" }
do
-- This is mainly to support older premake4 builds
if not premake.project.getbasename then
print "Magic happens for old premake4 versions without premake.project.getbasename() ..."
-- override the function to establish the behavior we'd get after patching Premake to have premake.project.getbasename
premake.project.getbasename = function(prjname, pattern)
return pattern:gsub("%%%%", prjname)
end
-- obviously we also need to overwrite the following to generate functioning VS solution files
premake.vstudio.projectfile = function(prj)
local pattern
if prj.language == "C#" then
pattern = "%%.csproj"
else
pattern = iif(_ACTION > "vs2008", "%%.vcxproj", "%%.vcproj")
end
local fname = premake.project.getbasename(prj.name, pattern)
fname = path.join(prj.location, fname)
return fname
end
-- we simply overwrite the original function on older Premake versions
premake.project.getfilename = function(prj, pattern)
local fname = premake.project.getbasename(prj.name, pattern)
fname = path.join(prj.location, fname)
return path.getrelative(os.getcwd(), fname)
end
end
-- Make UUID generation for filters deterministic
if os.str2uuid ~= nil then
local vc2010 = premake.vstudio.vc2010
vc2010.filteridgroup = function(prj)
local filters = { }
local filterfound = false
for file in premake.project.eachfile(prj) do
-- split the path into its component parts
local folders = string.explode(file.vpath, "/", true)
local path = ""
for i = 1, #folders - 1 do
-- element is only written if there *are* filters
if not filterfound then
filterfound = true
_p(1,"<ItemGroup>")
end
path = path .. folders[i]
-- have I seen this path before?
if not filters[path] then
local seed = path .. (prj.uuid or "")
local deterministic_uuid = os.str2uuid(seed)
filters[path] = true
_p(2, '<Filter Include="%s">', path)
_p(3, "<UniqueIdentifier>{%s}</UniqueIdentifier>", deterministic_uuid)
_p(2, "</Filter>")
end
-- prepare for the next subfolder
path = path .. "\\"
end
end
if filterfound then
_p(1,"</ItemGroup>")
end
end
end
do -- there is a glitch in Premake4 which prevents "patterns" in vpaths, which are identical to the file name to be matched, to match ...
local orig_getvpath = premake.project.getvpath
premake.project.getvpath = function(prj, abspath)
for replacement, patterns in pairs(prj.vpaths or {}) do
for _, pattern in ipairs(patterns) do
if abspath == pattern then -- only do this when file path and pattern are identical (which precludes wildcard patterns)
local stem, _ = replacement:gsub("%*", "")
return path.join(stem, abspath)
end
end
end
return orig_getvpath(prj, abspath)
end
end
-- Name the project files after their VS version
local orig_getbasename = premake.project.getbasename
premake.project.getbasename = function(prjname, pattern)
-- The below is used to insert the .vs(8|9|10|11|12|14|15|16|17) into the file names for projects and solutions
if _ACTION then
name_map = {vs2005 = "vs8", vs2008 = "vs9", vs2010 = "vs10", vs2012 = "vs11", vs2013 = "vs12", vs2015 = "vs14", vs2017 = "vs15", vs2019 = "vs16", vs2022 = "vs17"}
if name_map[_ACTION] then
pattern = pattern:gsub("%%%%", "%%%%." .. name_map[_ACTION])
else
pattern = pattern:gsub("%%%%", "%%%%." .. _ACTION)
end
end
return orig_getbasename(prjname, pattern)
end
-- Premake4 sets the PDB file name for the compiler's PDB to the default
-- value used by the linker's PDB. This causes error C1052 on VS2017. Fix it.
-- But this also fixes up certain other areas of the generated project. The idea
-- here is to catch the original _p() invocations, evaluate the arguments and
-- then act based on those, using orig_p() as a standin during a call to the
-- underlying premake.vs2010_vcxproj() function ;-)
local orig_premake_vs2010_vcxproj = premake.vs2010_vcxproj
premake.vs2010_vcxproj = function(prj)
-- The whole stunt below is necessary in order to modify the resource_compile()
-- output. Given it's a local function we have to go through hoops.
local orig_p = _G._p
local besilent = false
-- We patch the global _p() function
_G._p = function(indent, msg, first, ...)
-- Look for non-empty messages and narrow it down by the indent values
if msg ~= nil then
-- Allow this logic to be hooked and the hook to preempt any action hardcoded below
if (_G.override_vcxproj ~= nil) and (type(_G.override_vcxproj) == 'function') then
if _G.override_vcxproj(prj, orig_p, indent, msg, first, ...) then
return -- suppress further output
end
end
if msg:match("<ProgramDataBaseFileName>[^<]+</ProgramDataBaseFileName>") then
return -- we want to suppress these
end
if indent == 2 then
if msg == "<RootNamespace>%s</RootNamespace>" then
local sdkmap = {vs2015 = "8.1", vs2017 = "10.0.17763.0", vs2019 = "10.0", vs2022 = "10.0"}
if (not _ACTION) or (not sdkmap[_ACTION]) then -- should not happen, but tread carefully anyway
orig_p(indent, msg, first, ...) -- what was originally supposed to be output
return
end
local sdkver = _OPTIONS["sdkver"] or sdkmap[_ACTION]
orig_p(indent, msg, first, ...) -- what was originally supposed to be output
orig_p(indent, "<WindowsTargetPlatformVersion>%s</WindowsTargetPlatformVersion>", sdkver)
return
end
if msg == "<PlatformToolset>%s</PlatformToolset>" then
if (_OPTIONS["clang"] ~= nil) and (_ACTION == "vs2017") then
if _OPTIONS["xp"] ~= nil then
print "WARNING: The --clang option takes precedence over --xp, therefore picking v141_clang_c2 toolset."
end
print "WARNING: If you are used to Clang support from VS2019 and newer, be sure to review your choice. It's not the same on older VS versions."
orig_p(indent, msg, "v141_clang_c2")
return
elseif (_OPTIONS["clang"] ~= nil) and (_ACTION >= "vs2019") then
if _OPTIONS["xp"] ~= nil then
print "WARNING: The --clang option takes precedence over --xp, therefore picking ClangCL toolset."
end
orig_p(indent, msg, "ClangCL")
return
elseif _OPTIONS["xp"] ~= nil then
local toolsets = { vs2012 = "v110", vs2013 = "v120", vs2015 = "v140", vs2017 = "v141", vs2019 = "v142", vs2022 = "v143" }
local toolset = toolsets[_ACTION]
if toolset then
if _OPTIONS["xp"] and toolset >= "v141" then
toolset = "v141" -- everything falls back to the VS2017 XP toolset for more recent VS
end
orig_p(indent,"<PlatformToolset>%s_xp</PlatformToolset>", toolset)
return
end
end
end
elseif indent == 3 then
-- This is what vanilla VS would output it as, so let's try to align with that
if msg == "<PrecompiledHeader></PrecompiledHeader>" then
orig_p(indent, "<PrecompiledHeader>")
orig_p(indent, "</PrecompiledHeader>")
return
end
end
end
if not besilent then -- should we be silent (i.e. suppress default output)?
orig_p(indent, msg, first, ...)
end
end
orig_premake_vs2010_vcxproj(prj)
_G._p = orig_p -- restore in any case
end
-- ... same as above but for VS200x this time
local function wrap_remove_pdb_attribute(origfunc)
local fct = function(cfg)
local old_captured = io.captured -- save io.captured state
io.capture() -- this sets io.captured = ""
origfunc(cfg)
local captured = io.endcapture()
assert(captured ~= nil)
captured = captured:gsub('%s+ProgramDataBaseFileName=\"[^"]+\"', "")
if old_captured ~= nil then
io.captured = old_captured .. captured -- restore outer captured state, if any
else
io.write(captured)
end
end
return fct
end
premake.vstudio.vc200x.VCLinkerTool = wrap_remove_pdb_attribute(premake.vstudio.vc200x.VCLinkerTool)
premake.vstudio.vc200x.toolmap.VCLinkerTool = premake.vstudio.vc200x.VCLinkerTool -- this is important as well
premake.vstudio.vc200x.VCCLCompilerTool = wrap_remove_pdb_attribute(premake.vstudio.vc200x.VCCLCompilerTool)
premake.vstudio.vc200x.toolmap.VCCLCompilerTool = premake.vstudio.vc200x.VCCLCompilerTool -- this is important as well
-- Override the object directory paths ... don't make them "unique" inside premake4
local orig_gettarget = premake.gettarget
premake.gettarget = function(cfg, direction, pathstyle, namestyle, system)
local r = orig_gettarget(cfg, direction, pathstyle, namestyle, system)
if (cfg.objectsdir) and (cfg.objdir) then
cfg.objectsdir = cfg.objdir
end
return r
end
-- Silently suppress generation of the .user files ...
local orig_generate = premake.generate
premake.generate = function(obj, filename, callback)
if filename:find(".vcproj.user") or filename:find(".vcxproj.user") then
return
end
orig_generate(obj, filename, callback)
end
-- Fix up premake.getlinks() to not do stupid stuff with object files we pass
local orig_premake_getlinks = premake.getlinks
premake.getlinks = function(cfg, kind, part)
local origret = orig_premake_getlinks(cfg, kind, part)
local ret = {}
for k,v in ipairs(origret) do
local dep = v:gsub(".obj.lib", ".obj")
dep = dep:gsub(".lib.lib", ".lib")
table.insert(ret, dep)
end
return ret
end
-- Remove an option altogether or some otherwise accepted values for that option
local function remove_allowed_optionvalues(option, values_toremove)
if premake.option.list[option] ~= nil then
if values_toremove == nil then
premake.option.list[option] = nil
return
end
if premake.option.list.platform["allowed"] ~= nil then
local allowed = premake.option.list[option].allowed
for i = #allowed, 1, -1 do
if values_toremove[allowed[i][1]] then
table.remove(allowed, i)
end
end
end
end
end
local function remove_action(action)
if premake.action.list[action] ~= nil then
premake.action.list[action] = nil
end
end
-- Remove some unwanted/outdated options
remove_allowed_optionvalues("dotnet")
remove_allowed_optionvalues("platform", { universal = 0, universal32 = 0, universal64 = 0, ps3 = 0, xbox360 = 0, })
remove_allowed_optionvalues("os") -- ... , { bsd = 0, haiku = 0, linux = 0, macosx = 0, solaris = 0, }
remove_allowed_optionvalues("cc")
-- ... and actions (mainly because they are untested)
for k,v in pairs({codeblocks = 0, codelite = 0, gmake = 0, xcode3 = 0, xcode4 = 0, vs2002 = 0, vs2003 = 0, vs2008 = 0, vs2010 = 0, vs2012 = 0, vs2013 = 0}) do
remove_action(k)
end
end