From 0eda2d0721e27f4c9f9543ebef4bcee1b1a6f29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 20 Jun 2021 13:34:11 +0200 Subject: [PATCH] Improve global header generation to take ECS into account --- include/Nazara/Graphics.hpp | 1 + include/Nazara/Graphics/Components.hpp | 34 +++++++++++++ include/Nazara/OpenGLRenderer/Wrapper.hpp | 24 +++++++++ include/Nazara/Physics3D/Components.hpp | 34 +++++++++++++ include/Nazara/Physics3D/Systems.hpp | 34 +++++++++++++ include/Nazara/Utility/Components.hpp | 34 +++++++++++++ include/Nazara/VulkanRenderer.hpp | 1 - include/Nazara/VulkanRenderer/Wrapper.hpp | 24 +++++++++ xmake/actions/generateheaders.lua | 59 +++++++++++++++++++---- 9 files changed, 234 insertions(+), 11 deletions(-) create mode 100644 include/Nazara/Graphics/Components.hpp create mode 100644 include/Nazara/Physics3D/Components.hpp create mode 100644 include/Nazara/Physics3D/Systems.hpp create mode 100644 include/Nazara/Utility/Components.hpp diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 4edae9e1c..70de1f7bd 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Graphics/Components.hpp b/include/Nazara/Graphics/Components.hpp new file mode 100644 index 000000000..b92d44c24 --- /dev/null +++ b/include/Nazara/Graphics/Components.hpp @@ -0,0 +1,34 @@ +// This file was automatically generated + +/* + Nazara Engine - Graphics module + + Copyright (C) 2020 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_GLOBAL_GRAPHICS_COMPONENTS_HPP +#define NAZARA_GLOBAL_GRAPHICS_COMPONENTS_HPP + +#include + +#endif // NAZARA_GLOBAL_GRAPHICS_COMPONENTS_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper.hpp b/include/Nazara/OpenGLRenderer/Wrapper.hpp index dd2753244..77133a5e4 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper.hpp @@ -1,5 +1,29 @@ // This file was automatically generated +/* + Nazara Engine - OpenGL + + Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + #pragma once #ifndef NAZARA_GLOBAL_OPENGLRENDERER_WRAPPER_HPP diff --git a/include/Nazara/Physics3D/Components.hpp b/include/Nazara/Physics3D/Components.hpp new file mode 100644 index 000000000..73936ed86 --- /dev/null +++ b/include/Nazara/Physics3D/Components.hpp @@ -0,0 +1,34 @@ +// This file was automatically generated + +/* + Nazara Engine - Physics 3D module + + Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_GLOBAL_PHYSICS3D_COMPONENTS_HPP +#define NAZARA_GLOBAL_PHYSICS3D_COMPONENTS_HPP + +#include + +#endif // NAZARA_GLOBAL_PHYSICS3D_COMPONENTS_HPP diff --git a/include/Nazara/Physics3D/Systems.hpp b/include/Nazara/Physics3D/Systems.hpp new file mode 100644 index 000000000..cf1e7745a --- /dev/null +++ b/include/Nazara/Physics3D/Systems.hpp @@ -0,0 +1,34 @@ +// This file was automatically generated + +/* + Nazara Engine - Physics 3D module + + Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_GLOBAL_PHYSICS3D_SYSTEMS_HPP +#define NAZARA_GLOBAL_PHYSICS3D_SYSTEMS_HPP + +#include + +#endif // NAZARA_GLOBAL_PHYSICS3D_SYSTEMS_HPP diff --git a/include/Nazara/Utility/Components.hpp b/include/Nazara/Utility/Components.hpp new file mode 100644 index 000000000..a7ef8eaa4 --- /dev/null +++ b/include/Nazara/Utility/Components.hpp @@ -0,0 +1,34 @@ +// This file was automatically generated + +/* + Nazara Engine - Utility module + + Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +#pragma once + +#ifndef NAZARA_GLOBAL_UTILITY_COMPONENTS_HPP +#define NAZARA_GLOBAL_UTILITY_COMPONENTS_HPP + +#include + +#endif // NAZARA_GLOBAL_UTILITY_COMPONENTS_HPP diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index f5ce90f75..bc1bf2c0e 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -54,6 +54,5 @@ #include #include #include -#include #endif // NAZARA_GLOBAL_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index df6896383..94c80b9c5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -1,5 +1,29 @@ // This file was automatically generated +/* + Nazara Engine - Vulkan + + Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + #pragma once #ifndef NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP diff --git a/xmake/actions/generateheaders.lua b/xmake/actions/generateheaders.lua index b23e88479..872ab4eda 100644 --- a/xmake/actions/generateheaders.lua +++ b/xmake/actions/generateheaders.lua @@ -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)