Improve global header generation to take ECS into account
This commit is contained in:
@@ -11,9 +11,11 @@ on_run(function ()
|
||||
local paths = {}
|
||||
|
||||
local excludedFiles = {
|
||||
["Components.hpp"] = true,
|
||||
["ConfigCheck.hpp"] = true,
|
||||
["Debug.hpp"] = true,
|
||||
["DebugOff.hpp"] = true,
|
||||
["Systems.hpp"] = true,
|
||||
["ThreadSafety.hpp"] = true,
|
||||
["ThreadSafetyOff.hpp"] = true
|
||||
}
|
||||
@@ -37,42 +39,80 @@ on_run(function ()
|
||||
|
||||
config:close()
|
||||
|
||||
table.insert(paths, {
|
||||
Excludes = excludedFiles,
|
||||
paths[moduleName] = {
|
||||
Excludes = table.copy(excludedFiles),
|
||||
Header = head,
|
||||
HeaderGuard = "NAZARA_GLOBAL_" .. moduleName:upper() .. "_HPP",
|
||||
Name = "Nazara" .. moduleName,
|
||||
SearchDir = modulePath,
|
||||
Target = modulePath .. ".hpp"
|
||||
})
|
||||
}
|
||||
|
||||
-- Handle components and systems
|
||||
if (os.isdir(modulePath .. "/Components")) then
|
||||
paths[moduleName .. "_Components"] = {
|
||||
Excludes = table.copy(excludedFiles),
|
||||
Header = head,
|
||||
HeaderGuard = "NAZARA_GLOBAL_" .. moduleName:upper() .. "_COMPONENTS_HPP",
|
||||
Name = "Nazara" .. moduleName .. " components",
|
||||
SearchDir = modulePath .. "/Components",
|
||||
Target = modulePath .. "/Components.hpp"
|
||||
}
|
||||
end
|
||||
|
||||
if (os.isdir(modulePath .. "/Systems")) then
|
||||
paths[moduleName .. "_Systems"] = {
|
||||
Excludes = table.copy(excludedFiles),
|
||||
Header = head,
|
||||
HeaderGuard = "NAZARA_GLOBAL_" .. moduleName:upper() .. "_SYSTEMS_HPP",
|
||||
Name = "Nazara" .. moduleName .. " systems",
|
||||
SearchDir = modulePath .. "/Systems",
|
||||
Target = modulePath .. "/Systems.hpp"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(paths, {
|
||||
paths["Core"].Excludes["ECS.hpp"] = true
|
||||
paths["OpenGLRenderer"].Excludes["Wrapper.hpp"] = true
|
||||
paths["Shader"].Excludes["ShaderLangTokenList.hpp"] = true
|
||||
paths["VulkanRenderer"].Excludes["Wrapper.hpp"] = true
|
||||
|
||||
-- OpenGL renderer wrapper
|
||||
paths["OpenGLWrapper"] = {
|
||||
Excludes = {
|
||||
["DeviceFunctions.hpp"] = true,
|
||||
["GlobalFunctions.hpp"] = true,
|
||||
["InstanceFunctions.hpp"] = true,
|
||||
},
|
||||
Header = paths["OpenGLRenderer"].Header,
|
||||
HeaderGuard = "NAZARA_GLOBAL_OPENGLRENDERER_WRAPPER_HPP",
|
||||
Name = "OpenGL wrapper",
|
||||
SearchDir = "include/Nazara/OpenGLRenderer/Wrapper",
|
||||
Target = "include/Nazara/OpenGLRenderer/Wrapper.hpp"
|
||||
})
|
||||
}
|
||||
|
||||
table.insert(paths, {
|
||||
-- Vulkan renderer wrapper
|
||||
paths["VulkanWrapper"] = {
|
||||
Excludes = {
|
||||
["DeviceFunctions.hpp"] = true,
|
||||
["GlobalFunctions.hpp"] = true,
|
||||
["InstanceFunctions.hpp"] = true,
|
||||
},
|
||||
Header = paths["VulkanRenderer"].Header,
|
||||
HeaderGuard = "NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP",
|
||||
Name = "Vulkan wrapper",
|
||||
SearchDir = "include/Nazara/VulkanRenderer/Wrapper",
|
||||
Target = "include/Nazara/VulkanRenderer/Wrapper.hpp"
|
||||
})
|
||||
}
|
||||
|
||||
for k,v in ipairs(paths) do
|
||||
for _,v in pairs(paths) do
|
||||
print(v.Name)
|
||||
local files = os.files(v.SearchDir .. "/*.hpp")
|
||||
if (#files == 0) then
|
||||
print("Skipped (no file matched)")
|
||||
goto continue
|
||||
end
|
||||
|
||||
local header, err = io.open(v.Target, "w+")
|
||||
if (not header) then
|
||||
error("Failed to create header file (" .. v.Target .. "): " .. err)
|
||||
@@ -87,7 +127,6 @@ on_run(function ()
|
||||
header:write("#ifndef " .. v.HeaderGuard .. "\n")
|
||||
header:write("#define " .. v.HeaderGuard .. "\n\n")
|
||||
|
||||
local files = os.files(v.SearchDir .. "/*.hpp")
|
||||
local count = 0
|
||||
for _, filePath in pairs(files) do
|
||||
local pathParts = path.split(filePath)
|
||||
@@ -96,7 +135,6 @@ on_run(function ()
|
||||
end
|
||||
|
||||
local include = table.concat(pathParts, "/")
|
||||
print(include)
|
||||
local fileName = path.filename(filePath)
|
||||
if (not v.Excludes[fileName]) then
|
||||
header:write("#include <" .. include .. ">\n")
|
||||
@@ -108,5 +146,6 @@ on_run(function ()
|
||||
header:close()
|
||||
|
||||
print(string.format("-#include count: %d", count))
|
||||
::continue::
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user