Add shader compiler (nzslc) and use it

This commit is contained in:
SirLynix
2022-04-06 09:04:09 +02:00
parent 262c82b9e1
commit 8784ec9b47
9 changed files with 331 additions and 21 deletions

View File

@@ -0,0 +1,22 @@
-- Turns resources into includables headers
rule("compile_shaders")
on_load(function (target)
target:add("deps", "NazaraShaderCompiler")
target:set("policy", "build.across_targets_in_parallel", false)
end)
before_buildcmd_file(function (target, batchcmds, shaderfile, opt)
local nzslc = target:dep("NazaraShaderCompiler")
-- add commands
batchcmds:show_progress(opt.progress, "${color.build.object}compiling shader %s", shaderfile)
local argv = {"--compile", "--partial", "--header-file", shaderfile}
batchcmds:vrunv(nzslc:targetfile(), argv, { curdir = "." })
local outputFile = path.join(path.directory(shaderfile), path.basename(shaderfile) .. ".nzslb.h")
-- add deps
batchcmds:add_depfiles(shaderfile)
batchcmds:set_depmtime(os.mtime(outputFile))
batchcmds:set_depcache(target:dependfile(outputFile))
end)