SDK: Add global headers (improved global headers script)
Former-commit-id: f04a3526b185c6c5b8025168cd56829898082bc6
This commit is contained in:
parent
d6a436100c
commit
946d2cea7a
|
|
@ -0,0 +1,17 @@
|
|||
// This file was automatically generated on 03 Mar 2016 at 14:09:12
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_COMPONENTS_GLOBAL_HPP
|
||||
#define NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/ListenerComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
|
||||
#endif // NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// This file was automatically generated on 03 Mar 2016 at 14:09:12
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_GLOBAL_HPP
|
||||
#define NDK_SYSTEMS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
#endif // NDK_SYSTEMS_GLOBAL_HPP
|
||||
|
|
@ -1,11 +1,20 @@
|
|||
ACTION.Name = "GenerateHeaders"
|
||||
ACTION.Description = "Generate a global header for each module"
|
||||
|
||||
ACTION.ModuleExcludes = {}
|
||||
ACTION.ModuleExcludes["ConfigCheck.hpp"] = true
|
||||
ACTION.ModuleExcludes["Debug.hpp"] = true
|
||||
ACTION.ModuleExcludes["DebugOff.hpp"] = true
|
||||
ACTION.ModuleExcludes["ThreadSafety.hpp"] = true
|
||||
ACTION.ModuleExcludes["ThreadSafetyOff.hpp"] = true
|
||||
|
||||
local action = ACTION
|
||||
ACTION.Function = function ()
|
||||
local paths = {}
|
||||
|
||||
local modules = os.matchdirs("../include/Nazara/*")
|
||||
for k, modulePath in pairs(modules) do
|
||||
local moduleName = modulePath:match(".*/(.*)")
|
||||
print(moduleName)
|
||||
|
||||
local config, err = io.open(modulePath .. "/Config.hpp", "r")
|
||||
local head = ""
|
||||
|
|
@ -14,44 +23,72 @@ ACTION.Function = function ()
|
|||
end
|
||||
|
||||
for line in config:lines() do
|
||||
head = head .. line .. "\n"
|
||||
if (line == "#pragma once") then -- On s'arrête au #pragma once, qu'on inclut quand même
|
||||
if (line == "#pragma once") then -- Stop before including the #pragma once as it's already written automatically
|
||||
break
|
||||
end
|
||||
head = head .. line .. "\n"
|
||||
end
|
||||
|
||||
config:close()
|
||||
|
||||
local header, err = io.open(modulePath .. ".hpp", "w+")
|
||||
table.insert(paths, {
|
||||
Excludes = action.ModuleExcludes,
|
||||
Header = head,
|
||||
HeaderGuard = "NAZARA_GLOBAL_" .. moduleName:upper() .. "_HPP",
|
||||
Name = "Nazara" .. moduleName,
|
||||
SearchDir = modulePath,
|
||||
Target = modulePath .. ".hpp",
|
||||
TopDir = "Nazara"
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(paths, {
|
||||
Excludes = {},
|
||||
HeaderGuard = "NDK_COMPONENTS_GLOBAL_HPP",
|
||||
Name = "NDK Components",
|
||||
SearchDir = "../SDK/include/NDK/Components",
|
||||
TopDir = "NDK",
|
||||
Target = "../SDK/include/NDK/Components.hpp"
|
||||
})
|
||||
|
||||
table.insert(paths, {
|
||||
Excludes = {},
|
||||
HeaderGuard = "NDK_SYSTEMS_GLOBAL_HPP",
|
||||
Name = "NDK Systems",
|
||||
SearchDir = "../SDK/include/NDK/Systems",
|
||||
TopDir = "NDK",
|
||||
Target = "../SDK/include/NDK/Systems.hpp"
|
||||
})
|
||||
|
||||
for k,v in ipairs(paths) do
|
||||
print(v.Name)
|
||||
local header, err = io.open(v.Target, "w+")
|
||||
if (not header) then
|
||||
error("Failed to create header file: " .. err)
|
||||
error("Failed to create header file (" .. v.Target .. "): " .. err)
|
||||
end
|
||||
|
||||
header:write("// This file was automatically generated on " .. os.date("%d %b %Y at %X") .. "\n\n")
|
||||
header:write(head .. "\n")
|
||||
if (v.Header) then
|
||||
header:write(v.Header)
|
||||
end
|
||||
|
||||
-- Protection du multi-including
|
||||
local preprocessorName = "NAZARA_GLOBAL_" .. string.upper(moduleName) .. "_HPP"
|
||||
header:write("#ifndef " .. preprocessorName .. "\n")
|
||||
header:write("#define " .. preprocessorName .. "\n\n")
|
||||
header:write("#pragma once\n\n")
|
||||
header:write("#ifndef " .. v.HeaderGuard .. "\n")
|
||||
header:write("#define " .. v.HeaderGuard .. "\n\n")
|
||||
|
||||
local files = os.matchfiles(modulePath .. "/*.hpp")
|
||||
local files = os.matchfiles(v.SearchDir .. "/*.hpp")
|
||||
local count = 0
|
||||
for k, filePath in pairs(files) do
|
||||
local include, fileName = filePath:match(".*(Nazara/.*/(.*))")
|
||||
if (fileName ~= "ConfigCheck.hpp" and
|
||||
fileName ~= "Debug.hpp" and
|
||||
fileName ~= "DebugOff.hpp" and
|
||||
fileName ~= "ThreadSafety.hpp" and
|
||||
fileName ~= "ThreadSafetyOff.hpp") then
|
||||
local include, fileName = filePath:match(".*(" .. v.TopDir .. "/.*/(.*))")
|
||||
if (not v.Excludes[fileName]) then
|
||||
header:write("#include <" .. include .. ">\n")
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
header:write("\n#endif // " .. preprocessorName .. "\n")
|
||||
|
||||
header:write("\n#endif // " .. v.HeaderGuard .. "\n")
|
||||
header:close()
|
||||
|
||||
|
||||
print(string.format("-#include count: %d", count))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue