forked from NVIDIAGameWorks/Streamline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake.lua
430 lines (346 loc) · 15.1 KB
/
premake.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
require("vstudio")
local ROOT = "./"
function os.winSdkVersion()
local reg_arch = iif( os.is64bit(), "\\Wow6432Node\\", "\\" )
local sdk_version = os.getWindowsRegistry( "HKLM:SOFTWARE" .. reg_arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" )
if sdk_version ~= nil then return sdk_version end
end
workspace "streamline"
-- _ACTION is the argument you passed into premake5 when you ran it.
local project_action = "UNDEFINED"
if _ACTION ~= nill then project_action = _ACTION end
-- Where the project files (vs project, solution, etc) go
location( ROOT .. "_project/" .. project_action)
configurations { "Debug", "Release", "Production", "Profiling", "RelExtDev" }
platforms { "x64"}
architecture "x64"
language "c++"
preferredtoolarchitecture "x86_64"
local externaldir = (ROOT .."external/")
includedirs
{
".", ROOT
}
if os.host() == "windows" then
local winSDK = os.winSdkVersion() .. ".0"
print("WinSDK", winSDK)
systemversion(winSDK)
defines { "SL_SDK", "SL_WINDOWS", "WIN32" , "WIN64" , "_CONSOLE", "NOMINMAX"}
else
defines { "SL_SDK", "SL_LINUX" }
-- stop on first error and also downgrade checks for casting due to ReShade
buildoptions {"-std=c++17", "-Wfatal-errors", "-fpermissive"}
end
-- when building any visual studio project
filter {"system:windows", "action:vs*"}
flags { "MultiProcessorCompile", "NoMinimalRebuild"}
-- building makefiles
cppdialect "C++20"
filter "configurations:Debug"
defines { "DEBUG", "_DEBUG", "SL_ENABLE_TIMING=1", "SL_DEBUG" }
symbols "Full"
filter "configurations:Release"
defines { "NDEBUG","SL_ENABLE_TIMING=1", "SL_RELEASE" }
optimize "On"
flags { "LinkTimeOptimization" }
filter "configurations:Profiling"
defines { "NDEBUG","SL_ENABLE_TIMING=0","SL_ENABLE_PROFILING=1", "SL_PROFILING" }
optimize "On"
flags { "LinkTimeOptimization" }
filter "configurations:Production"
defines { "NDEBUG","SL_ENABLE_TIMING=0","SL_ENABLE_PROFILING=0","SL_PRODUCTION" }
optimize "On"
flags { "LinkTimeOptimization" }
filter "configurations:RelExtDev"
defines { "NDEBUG","SL_ENABLE_TIMING=0","SL_ENABLE_PROFILING=0", "SL_REL_EXT_DEV" }
optimize "On"
flags { "LinkTimeOptimization" }
filter { "files:**.hlsl" }
buildmessage 'Compiling shader %{file.relpath} to DXBC/SPIRV with slang'
buildcommands {
path.translate("../../external/slang_internal/bin/windows-x64/release/")..'slangc "%{file.relpath}" -entry main -target spirv -o "../../_artifacts/shaders/%{file.basename}.spv"',
path.translate("../../external/slang_internal/bin/windows-x64/release/")..'slangc "%{file.relpath}" -profile sm_5_0 -entry main -target dxbc -o "../../_artifacts/shaders/%{file.basename}.cs"',
'pushd '..path.translate("../../_artifacts/shaders"),
path.translate("../../tools/")..'xxd --include "%{file.basename}.spv" > "%{file.basename}_spv.h"',
path.translate("../../tools/")..'xxd --include "%{file.basename}.cs" > "%{file.basename}_cs.h"',
'popd'
}
-- One or more outputs resulting from the build (required)
buildoutputs { ROOT .. "_artifacts/shaders/%{file.basename}.spv", ROOT .. "_artifacts/shaders/%{file.basename}.cs" }
-- One or more additional dependencies for this build command (optional)
--buildinputs { 'path/to/file1.ext', 'path/to/file2.ext' }
filter {}
filter {} -- clear filter when you know you no longer need it!
vpaths { ["shaders"] = {"**.hlsl" } }
group "core"
project "sl.interposer"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
staticruntime "off"
if os.host() == "windows" then
prebuildcommands { 'pushd '..path.translate("../../_artifacts"), path.translate("../tools/").."gitVersion.bat", 'popd' }
else
prebuildcommands { 'pushd '..path.translate("../../_artifacts"), path.translate("../tools/").."gitVersion.sh", 'popd' }
end
files {
"./include/**.h",
"./source/core/sl.interposer/**.h",
"./source/core/sl.interposer/**.cpp",
"./source/core/sl.interposer/**.rc",
"./source/core/sl.api/**.h",
"./source/core/sl.api/**.cpp",
"./source/core/sl.param/**.h",
"./source/core/sl.param/**.cpp",
"./source/core/sl.log/**.h",
"./source/core/sl.log/**.cpp",
"./source/core/sl.exception/**.h",
"./source/core/sl.exception/**.cpp",
"./source/core/sl.security/**.h",
"./source/core/sl.security/**.cpp",
"./source/core/sl.plugin-manager/**.h",
"./source/core/sl.plugin-manager/**.cpp",
}
if os.host() == "windows" then
defines {"VK_USE_PLATFORM_WIN32_KHR", "SL_ENABLE_EXCEPTION_HANDLING"}
vpaths { ["proxies/d3d12"] = {"./source/core/sl.interposer/d3d12/**.h", "./source/core/sl.interposer/d3d12/**.cpp" }}
vpaths { ["proxies/d3d11"] = {"./source/core/sl.interposer/d3d11/**.h", "./source/core/sl.interposer/d3d11/**.cpp" }}
vpaths { ["proxies/dxgi"] = {"./source/core/sl.interposer/dxgi/**.h", "./source/core/sl.interposer/dxgi/**.cpp" }}
vpaths { ["security"] = {"./source/security/**.h","./source/security/**.cpp"}}
links {"dbghelp.lib"}
linkoptions { "/DEF:../../source/core/sl.interposer/exports.def" }
else
-- remove on Linux all DX related stuff
removefiles
{
"./source/core/sl.interposer/d3d**",
"./source/core/sl.interposer/dxgi**",
"./source/core/sl.interposer/resource.h",
"./source/core/sl.interposer/**.rc"
}
end
vpaths { ["hook"] = {"./source/core/sl.interposer/hook**"}}
vpaths { ["proxies/vulkan"] = {"./source/core/sl.interposer/vulkan/**.h", "./source/core/sl.interposer/vulkan/**.cpp" }}
vpaths { ["manager"] = {"./source/core/sl.plugin-manager/**.h", "./source/core/sl.plugin-manager/**.cpp" }}
vpaths { ["api"] = {"./source/core/sl.api/**.h","./source/core/sl.api/**.cpp"}}
vpaths { ["include"] = {"./include/**.h"}}
vpaths { ["log"] = {"./source/core/sl.log/**.h","./source/core/sl.log/**.cpp"}}
vpaths { ["exception"] = {"./source/core/sl.exception/**.h","./source/core/sl.exception/**.cpp"}}
vpaths { ["params"] = {"./source/core/sl.param/**.h","./source/core/sl.param/**.cpp"}}
vpaths { ["security"] = {"./source/core/sl.security/**.h","./source/core/sl.security/**.cpp"}}
vpaths { ["version"] = {"./source/core/sl.interposer/versions.h","./source/core/sl.interposer/resource.h","./source/core/sl.interposer/**.rc"}}
removefiles
{
"./source/core/sl.plugin-manager/pluginManagerEntry.cpp","./source/core/sl.api/plugin-manager.h"
}
group ""
group "platforms"
project "sl.compute"
kind "StaticLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
staticruntime "off"
dependson { "sl.interposer"}
if os.host() == "windows" then
if (os.isfile("./external/slang_internal/bin/windows-x64/release/slangc.exe")) then
files {
"./shaders/**.hlsl"
}
end
files {
"./source/platforms/sl.chi/capture.h",
"./source/platforms/sl.chi/capture.cpp",
"./source/platforms/sl.chi/compute.h",
"./source/platforms/sl.chi/generic.h",
"./source/platforms/sl.chi/d3d12.cpp",
"./source/platforms/sl.chi/d3d12.h",
"./source/platforms/sl.chi/d3d11.cpp",
"./source/platforms/sl.chi/d3d11.h",
"./source/platforms/sl.chi/vulkan.cpp",
"./source/platforms/sl.chi/vulkan.h",
"./source/platforms/sl.chi/generic.cpp",
"./source/core/sl.security/**.h",
"./source/core/sl.security/**.cpp"
}
else
files {
"./shaders/**.hlsl",
"./source/platforms/sl.chi/capture.h",
"./source/platforms/sl.chi/capture.cpp",
"./source/platforms/sl.chi/compute.h",
"./source/platforms/sl.chi/generic.h",
"./source/platforms/sl.chi/vulkan.cpp",
"./source/platforms/sl.chi/vulkan.h",
"./source/platforms/sl.chi/generic.cpp"
}
end
vpaths { ["chi"] = {"./source/platforms/sl.chi/**.h","./source/platforms/sl.chi/**.cpp"}}
vpaths { ["security"] = {"./source/core/sl.security/**.h","./source/core/sl.security/**.cpp"}}
group ""
group "plugins"
function pluginBasicSetup(name)
files {
"./source/core/sl.api/**.h",
"./source/core/sl.log/**.h",
"./source/core/sl.ota/**.h",
"./source/core/sl.security/**.h",
"./source/core/sl.security/**.cpp",
"./source/core/sl.file/**.h",
"./source/core/sl.file/**.cpp",
"./source/core/sl.extra/**.h",
"./source/core/sl.plugin/**.h",
"./source/core/sl.plugin/**.cpp",
"./source/plugins/sl."..name.."/versions.h",
"./source/plugins/sl."..name.."/resource.h",
"./source/plugins/sl."..name.."/**.rc"
}
removefiles {"./source/core/sl.api/plugin-manager.h"}
vpaths { ["api"] = {"./source/core/sl.api/**.h"}}
vpaths { ["log"] = {"./source/core/sl.log/**.h","./source/core/sl.log/**.cpp"}}
vpaths { ["ota"] = {"./source/core/sl.ota/**.h", "./source/core/sl.ota/**.cpp"}}
vpaths { ["file"] = {"./source/core/sl.file/**.h", "./source/core/sl.file/**.cpp"}}
vpaths { ["extra"] = {"./source/core/sl.extra/**.h", "./source/core/sl.extra/**.cpp"}}
vpaths { ["plugin"] = {"./source/core/sl.plugin/**.h","./source/core/sl.plugin/**.cpp"}}
vpaths { ["security"] = {"./source/core/sl.security/**.h","./source/core/sl.security/**.cpp"}}
vpaths { ["version"] = {"./source/plugins/sl."..name.."/resource.h","./source/plugins/sl."..name.."/versions.h","./source/plugins/sl."..name.."/**.rc"}}
end
project "sl.common"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.compute"}
pluginBasicSetup("common")
defines {"SL_COMMON_PLUGIN"}
files {
"./source/core/sl.extra/**.cpp",
"./source/plugins/sl.common/**.h",
"./source/plugins/sl.common/**.cpp",
"./source/core/ngx/**.h",
"./source/core/ngx/**.cpp",
"./source/core/sl.ota/**.cpp",
}
vpaths { ["imgui"] = {"./external/imgui/**.cpp" }}
vpaths { ["impl"] = {"./source/plugins/sl.common/**.h", "./source/plugins/sl.common/**.cpp" }}
--vpaths { ["ngx"] = {"./source/core/ngx/**.h", "./source/core/ngx/**.cpp"}}
libdirs {externaldir .."nvapi/amd64",externaldir .."ngx/Lib/Windows_x86_64/x86_64", externaldir .."pix/bin", externaldir .."reflex-sdk-vk/lib"}
links
{
"delayimp.lib", "d3d12.lib", "nvapi64.lib", "dxgi.lib", "dxguid.lib", (ROOT .. "_artifacts/sl.compute/%{cfg.buildcfg}_%{cfg.platform}/sl.compute.lib"),
"NvLowLatencyVk.lib", "Version.lib"
}
filter "configurations:Debug"
links { "nvsdk_ngx_d_dbg.lib" }
filter "configurations:Release or Production or Profiling or RelExtDev"
links { "nvsdk_ngx_d.lib"}
filter {}
linkoptions { "/DELAYLOAD:NvLowLatencyVk.dll" }
if (os.isdir("./source/plugins/sl.dlss_g")) then
project "sl.dlss_g"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.common"}
pluginBasicSetup("dlss_g")
files {
"./source/plugins/sl.dlss_g/**.h",
"./source/plugins/sl.dlss_g/**.cpp",
}
links {"external/nvapi/amd64/nvapi64.lib"}
vpaths {["impl"] = { "./source/plugins/sl.dlss_g/**.h", "./source/plugins/sl.dlss_g/**.cpp" }}
removefiles {"./source/core/sl.extra/extra.cpp"}
end
project "sl.dlss"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.common"}
pluginBasicSetup("dlss")
files {
"./source/core/ngx/**.h",
"./source/core/ngx/**.cpp",
"./source/plugins/sl.dlss/**.h",
"./source/plugins/sl.dlss/**.cpp"
}
vpaths { ["impl"] = {"./source/plugins/sl.dlss/**.h", "./source/plugins/sl.dlss/**.cpp" }}
vpaths { ["ngx"] = {"./source/core/ngx/**.h", "./source/core/ngx/**.cpp"}}
removefiles {"./source/core/sl.extra/extra.cpp"}
project "sl.nrd"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.compute"}
dependson { "sl.common"}
pluginBasicSetup("nrd")
files {
"./source/plugins/sl.nrd/**.h",
"./source/plugins/sl.nrd/**.cpp"
}
vpaths { ["impl"] = {"./source/plugins/sl.nrd/**.h", "./source/plugins/sl.nrd/**.cpp" }}
removefiles {"./source/core/sl.extra/extra.cpp"}
project "sl.reflex"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
pluginBasicSetup("reflex")
files {
"./source/plugins/sl.reflex/**.h",
"./source/plugins/sl.reflex/**.cpp"
}
vpaths { ["impl"] = {"./source/plugins/sl.reflex/**.h", "./source/plugins/sl.reflex/**.cpp" }}
removefiles {"./source/core/sl.extra/extra.cpp"}
project "sl.template"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
pluginBasicSetup("template")
files {
"./source/plugins/sl.template/**.h",
"./source/plugins/sl.template/**.cpp"
}
vpaths { ["impl"] = {"./source/plugins/sl.template/**.h", "./source/plugins/sl.template/**.cpp" }}
removefiles {"./source/core/sl.extra/extra.cpp"}
project "sl.nis"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.compute"}
dependson { "sl.common"}
pluginBasicSetup("nis")
files {
"./source/plugins/sl.nis/**.h",
"./source/plugins/sl.nis/**.cpp"
}
vpaths { ["impl"] = {"./source/plugins/sl.nis/**.h", "./source/plugins/sl.nis/**.cpp" }}
removefiles {"./source/core/sl.extra/extra.cpp"}
project "sl.imgui"
kind "SharedLib"
targetdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
objdir (ROOT .. "_artifacts/%{prj.name}/%{cfg.buildcfg}_%{cfg.platform}")
characterset ("MBCS")
dependson { "sl.compute"}
pluginBasicSetup("nis")
files {
"./source/plugins/sl.imgui/**.h",
"./source/plugins/sl.imgui/**.cpp",
"./external/imgui/imgui*.cpp",
"./external/implot/*.h",
"./external/implot/*.cpp"
}
vpaths { ["helpers"] = {"./source/plugins/sl.imgui/imgui_impl**"}}
vpaths { ["impl"] = {"./source/plugins/sl.imgui/**.h", "./source/plugins/sl.imgui/**.cpp" }}
vpaths { ["implot"] = {"./external/implot/*.h", "./external/implot/*.cpp"}}
vpaths { ["imgui"] = {"./external/imgui/**.cpp" }}
defines {"ImDrawIdx=unsigned int"}
removefiles {"./source/core/sl.extra/extra.cpp"}
libdirs {externaldir .."vulkan/Lib"}
links { "d3d12.lib", "vulkan-1.lib"}
group ""