From 61722d1c9b9120bc1a46481f0dce62599f1f6c9f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 7 Jun 2022 20:52:46 +0200 Subject: [PATCH] Add support for options on task compile-shaders --- xmake/actions/compile_shaders.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xmake/actions/compile_shaders.lua b/xmake/actions/compile_shaders.lua index 3b179f69f..cc3bfa927 100644 --- a/xmake/actions/compile_shaders.lua +++ b/xmake/actions/compile_shaders.lua @@ -3,10 +3,15 @@ task("compile-shaders") set_menu({ -- Settings menu usage 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 () + import("core.base.option") import("core.project.project") local nzsl = path.join(project.required_package("nzsl"):installdir(), "bin", "nzslc") @@ -17,11 +22,17 @@ task("compile-shaders") envs = mingw:runenvs() end end - + print("Compiling shaders...") for _, filepath in pairs(os.files("src/Nazara/*/Resources/**.nzsl")) do print(" - Compiling " .. 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 }) end end)