Split engine to packages NazaraUtils and NZSL (#375)

* Move code to NazaraUtils and NZSL packages

* Reorder includes

* Tests: Remove glslang and spirv-tools deps

* Tests: Remove glslang init

* Remove NazaraUtils tests and fix Vector4Test

* Fix Linux compilation

* Update msys2-build.yml

* Fix assimp package

* Update xmake.lua

* Update xmake.lua

* Fix shader compilation on MinGW

* Final fixes

* The final fix 2: the fix strikes back!

* Disable cache on CI

* The return of the fix™️
This commit is contained in:
Jérôme Leclercq
2022-05-25 19:36:10 +02:00
committed by GitHub
parent 3f8f1c4653
commit 03e2801dbe
483 changed files with 1139 additions and 59112 deletions

View File

@@ -486,6 +486,8 @@ on_run(function ()
order = 1 -- top engine includes
elseif inclusions[i].path == "Nazara/" .. debugIncludeModule .. "/Debug.hpp" then
order = 6 -- debug include
elseif inclusions[i].path:match("^Nazara/Utils/") then
order = 2.1 -- NazaraUtils
elseif inclusions[i].path:match("^Nazara/") then
order = 2 -- engine includes
elseif IsSystemHeader(inclusions[i].path) then

View File

@@ -0,0 +1,27 @@
task("compile-shaders")
set_menu({
-- Settings menu usage
usage = "xmake compile-shaders [options]",
description = "Compile engine shaders"
})
on_run(function ()
import("core.project.project")
local nzsl = path.join(project.required_package("nzsl"):installdir(), "bin", "nzslc")
local envs
if is_plat("mingw") then
local mingw = toolchain.load("mingw")
if mingw and mingw:check() then
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 }
os.execv(nzsl, argv, { envs = envs })
end
end)

View File

@@ -1,21 +0,0 @@
task("compile-shaders")
set_menu({
-- Settings menu usage
usage = "xmake compile-shaders [options]",
description = "Compile engine shaders"
})
on_run(function ()
import("core.project.task")
print("Compiling NZSLC...")
task.run("build", {target = "NazaraShaderCompiler"})
print("Compiling shaders...")
for _, filepath in pairs(os.files("src/Nazara/*/Resources/**.nzsl")) do
print(" - Compiling " .. filepath)
local argv = {"--compile", "--partial", "--header-file", path.join("..", "..", filepath) }
task.run("run", {target = "NazaraShaderCompiler", arguments = argv})
end
end)

View File

@@ -74,8 +74,6 @@ on_run(function ()
paths["Core"].Excludes["ECS.hpp"] = true
paths["OpenGLRenderer"].Excludes["Wrapper.hpp"] = true
paths["Shader"].Excludes["ShaderLangErrorList.hpp"] = true
paths["Shader"].Excludes["ShaderLangTokenList.hpp"] = true
paths["VulkanRenderer"].Excludes["Wrapper.hpp"] = true
-- OpenGL renderer wrapper

View File

@@ -84,8 +84,8 @@ on_run(function()
#define NAZARA_SHADER_SPIRVDATA_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Flags.hpp>
#include <Nazara/Shader/Config.hpp>
#include <Nazara/Utils/Bitset.hpp>
#include <NZSL/Config.hpp>
namespace Nz
{
@@ -226,11 +226,11 @@ headerFile:write([[
// this file was automatically generated and should not be edited
#include <Nazara/Shader/SpirvData.hpp>
#include <NZSL/SpirvData.hpp>
#include <algorithm>
#include <array>
#include <cassert>
#include <Nazara/Shader/Debug.hpp>
#include <NZSL/Debug.hpp>
namespace Nz
{

View File

@@ -1,28 +1,17 @@
-- Compile shaders to includables headers
rule("compile_shaders")
on_load(function (target)
target:add("deps", "NazaraShaderCompiler")
target:set("policy", "build.across_targets_in_parallel", false)
target:add("packages", "nzsl")
end)
-- temporary fix
before_build("mingw", function (target)
local mingw = target:toolchain("mingw")
local bindir = mingw:bindir()
local targetdir = target:targetdir()
if bindir then
os.trycp(path.join(bindir, "libgcc_s_seh-1.dll"), targetdir)
os.trycp(path.join(bindir, "libstdc++-6.dll"), targetdir)
os.trycp(path.join(bindir, "libwinpthread-1.dll"), targetdir)
end
end)
before_buildcmd_file(function (target, batchcmds, shaderfile, opt)
local nzslc = target:dep("NazaraShaderCompiler")
import("core.tool.toolchain")
local nzsl = path.join(target:pkg("nzsl"):installdir(), "bin", "nzslc")
-- add commands
batchcmds:show_progress(opt.progress, "${color.build.object}compiling shader %s", shaderfile)
local argv = {"--compile", "--partial", "--header-file"}
local argv = {"--compile=nzslb", "--partial", "--header-file"}
-- handle --log-format
local kind = target:data("plugin.project.kind") or ""
@@ -32,7 +21,15 @@ rule("compile_shaders")
table.insert(argv, shaderfile)
batchcmds:vrunv(nzslc:targetfile(), argv, { curdir = "." })
local envs
if is_plat("mingw") then
local mingw = toolchain.load("mingw")
if mingw and mingw:check() then
envs = mingw:runenvs()
end
end
batchcmds:vrunv(nzsl, argv, { curdir = ".", envs = envs })
local outputFile = path.join(path.directory(shaderfile), path.basename(shaderfile) .. ".nzslb.h")