From 84f73f2b6af7ed5da54b15b16479575f5b1592c5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 11 Nov 2012 17:57:43 +0100 Subject: [PATCH] Updated global header generator Now adds include guards Former-commit-id: bbc67864703910cf21946fd22302efe6a52d8495 --- build/scripts/actions/examples.lua | 2 +- .../{headergenerator.lua => generateheaders.lua} | 16 +++++++++++----- build/scripts/actions/unicode.lua | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) rename build/scripts/actions/{headergenerator.lua => generateheaders.lua} (80%) diff --git a/build/scripts/actions/examples.lua b/build/scripts/actions/examples.lua index 0cb6d9ef7..5826a6ba4 100644 --- a/build/scripts/actions/examples.lua +++ b/build/scripts/actions/examples.lua @@ -7,4 +7,4 @@ newaction trigger = "examples", description = "Generate examples", execute = examples -} \ No newline at end of file +} diff --git a/build/scripts/actions/headergenerator.lua b/build/scripts/actions/generateheaders.lua similarity index 80% rename from build/scripts/actions/headergenerator.lua rename to build/scripts/actions/generateheaders.lua index 0553807f4..65862d5bd 100644 --- a/build/scripts/actions/headergenerator.lua +++ b/build/scripts/actions/generateheaders.lua @@ -16,7 +16,7 @@ function generateHeaders() break end end - + config:close() local header, err = io.open(modulePath .. ".hpp", "w+") @@ -27,11 +27,16 @@ function generateHeaders() header:write("// This file was automatically generated by Nazara\n\n") header:write(head .. "\n") + -- Protection du multi-including + local preprocessorName = "NAZARA_GLOBAL_" .. string.upper(moduleName) .. "_HPP" + header:write("#ifndef " .. preprocessorName .. "\n") + header:write("#define " .. preprocessorName .. "\n\n") + local files = os.matchfiles(modulePath .. "/*.hpp") local count = 0 for k, filePath in pairs(files) do local include, fileName = filePath:match(".*(Nazara/.*/(.*))") - if (fileName ~= "Debug.hpp" and + if (fileName ~= "Debug.hpp" and fileName ~= "DebugOff.hpp" and fileName ~= "ThreadSafety.hpp" and fileName ~= "ThreadSafetyOff.hpp") then @@ -40,9 +45,10 @@ function generateHeaders() end end - print(string.format("-# of includes: %d", count)) - + header:write("\n#endif // " .. preprocessorName .. "\n") header:close() + + print(string.format("-# of includes: %d", count)) end end @@ -51,4 +57,4 @@ newaction trigger = "generateheaders", description = "Generate a global header for each module", execute = generateHeaders -} \ No newline at end of file +} diff --git a/build/scripts/actions/unicode.lua b/build/scripts/actions/unicode.lua index 911a338dd..4db23db8a 100644 --- a/build/scripts/actions/unicode.lua +++ b/build/scripts/actions/unicode.lua @@ -194,4 +194,4 @@ newaction trigger = "unicode", description = "Parse the Unicode Character Data and put the useful informations into a header", execute = parseUnicodeData -} \ No newline at end of file +}