Add support for options on task compile-shaders
This commit is contained in:
parent
16922a9519
commit
61722d1c9b
|
|
@ -3,10 +3,15 @@ task("compile-shaders")
|
||||||
set_menu({
|
set_menu({
|
||||||
-- Settings menu usage
|
-- Settings menu usage
|
||||||
usage = "xmake compile-shaders [options]",
|
usage = "xmake compile-shaders [options]",
|
||||||
description = "Compile engine shaders"
|
description = "Compile engine shaders",
|
||||||
|
options = {
|
||||||
|
{nil, "measure", "k", nil, "Measure time taken for every step of the shader compilation." },
|
||||||
|
{nil, "benchmark-iteration", "kv", nil, "Benchmark using a number of iterations." },
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
on_run(function ()
|
on_run(function ()
|
||||||
|
import("core.base.option")
|
||||||
import("core.project.project")
|
import("core.project.project")
|
||||||
local nzsl = path.join(project.required_package("nzsl"):installdir(), "bin", "nzslc")
|
local nzsl = path.join(project.required_package("nzsl"):installdir(), "bin", "nzslc")
|
||||||
|
|
||||||
|
|
@ -22,6 +27,12 @@ task("compile-shaders")
|
||||||
for _, filepath in pairs(os.files("src/Nazara/*/Resources/**.nzsl")) do
|
for _, filepath in pairs(os.files("src/Nazara/*/Resources/**.nzsl")) do
|
||||||
print(" - Compiling " .. filepath)
|
print(" - Compiling " .. filepath)
|
||||||
local argv = {"--compile=nzslb", "--partial", "--header-file", filepath }
|
local argv = {"--compile=nzslb", "--partial", "--header-file", filepath }
|
||||||
|
if option.get("measure") then
|
||||||
|
table.insert(argv, "--measure")
|
||||||
|
end
|
||||||
|
if option.get("benchmark-iteration") then
|
||||||
|
table.insert(argv, "--benchmark-iteration=" .. option.get("benchmark-iteration"))
|
||||||
|
end
|
||||||
os.execv(nzsl, argv, { envs = envs })
|
os.execv(nzsl, argv, { envs = envs })
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue