From debe39501ec96a8837e13ddec182cbf6c2aa7e65 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Jan 2015 23:37:49 +0100 Subject: [PATCH] Added experimental new build system Former-commit-id: ab7fb35db6be4b975d0558680c840d72e38562f9 --- build/scripts/actions/encodesresources.lua | 12 +- build/scripts/actions/examples.lua | 10 - build/scripts/actions/generateheaders.lua | 12 +- build/scripts/actions/unicode.lua | 13 +- build/scripts/common.lua | 713 +++++++++++++++++++-- build/scripts/common_examples.lua | 39 -- build/scripts/common_extlibs.lua | 31 - build/scripts/module/audio.lua | 47 +- build/scripts/module/core.lua | 21 +- build/scripts/module/graphics.lua | 44 +- build/scripts/module/lua.lua | 42 +- build/scripts/module/noise.lua | 34 +- build/scripts/module/physics.lua | 41 +- build/scripts/module/renderer.lua | 56 +- build/scripts/module/utility.lua | 52 +- examples/DopplerEffect/build.lua | 44 +- examples/FirstScene/build.lua | 49 +- examples/HardwareInfo/build.lua | 48 +- examples/MeshInfos/build.lua | 38 +- 19 files changed, 797 insertions(+), 549 deletions(-) delete mode 100644 build/scripts/actions/examples.lua delete mode 100644 build/scripts/common_examples.lua delete mode 100644 build/scripts/common_extlibs.lua diff --git a/build/scripts/actions/encodesresources.lua b/build/scripts/actions/encodesresources.lua index f098cd3fd..5e5376fee 100644 --- a/build/scripts/actions/encodesresources.lua +++ b/build/scripts/actions/encodesresources.lua @@ -1,4 +1,7 @@ -function encodeResources() +ACTION.Name = "EncodeResources" +ACTION.Description = "Generate a includable header version of resources" + +ACTION.Function = function () print("Encoding resources ...") local startClock = os.clock() local modules = os.matchdirs("../src/Nazara/*") @@ -38,10 +41,3 @@ function encodeResources() end print("Finished (took " .. os.clock() - startClock .. "s)") end - -newaction -{ - trigger = "encoderesources", - description = "Generate a includable header version of resources", - execute = encodeResources -} diff --git a/build/scripts/actions/examples.lua b/build/scripts/actions/examples.lua deleted file mode 100644 index 5826a6ba4..000000000 --- a/build/scripts/actions/examples.lua +++ /dev/null @@ -1,10 +0,0 @@ -function examples() - dofile("../examples/build/common.lua") -end - -newaction -{ - trigger = "examples", - description = "Generate examples", - execute = examples -} diff --git a/build/scripts/actions/generateheaders.lua b/build/scripts/actions/generateheaders.lua index 51cf910f8..01cea67e8 100644 --- a/build/scripts/actions/generateheaders.lua +++ b/build/scripts/actions/generateheaders.lua @@ -1,4 +1,7 @@ -function generateHeaders() +ACTION.Name = "GenerateHeaders" +ACTION.Description = "Generate a global header for each module" + +ACTION.Function = function () local modules = os.matchdirs("../include/Nazara/*") for k, modulePath in pairs(modules) do local moduleName = modulePath:match(".*/(.*)") @@ -52,10 +55,3 @@ function generateHeaders() print(string.format("-#include count: %d", count)) end end - -newaction -{ - trigger = "generateheaders", - description = "Generate a global header for each module", - execute = generateHeaders -} diff --git a/build/scripts/actions/unicode.lua b/build/scripts/actions/unicode.lua index 8105cb3a0..536fb44ec 100644 --- a/build/scripts/actions/unicode.lua +++ b/build/scripts/actions/unicode.lua @@ -1,3 +1,6 @@ +ACTION.Name = "ParseUnicode" +ACTION.Description = "Parse the Unicode Character Data and put the useful informations into a header" + local CategoryToString = {} CategoryToString["C"] = "Category_Other" CategoryToString["Cc"] = "Category_Other_Control" @@ -67,7 +70,7 @@ table.maxn = table.maxn or function (tab) -- Compatibilit end end -function getCharacter(tab, first, index) +local function getCharacter(tab, first, index) local character = {} character.Category = CategoryToString[tab[3]] or "Category_NoCategory" character.Direction = DirectionToString[tab[5]] or error("Direction not recognized") @@ -78,7 +81,7 @@ function getCharacter(tab, first, index) return character end -function parseUnicodeData() +ACTION.Function = function () local unicodeSet = {} file = io.open ("scripts/data/UnicodeData.txt", "r") @@ -189,9 +192,3 @@ function parseUnicodeData() end --print(string.match("", "<.+, (%w+)>")) -newaction -{ - trigger = "parseunicode", - description = "Parse the Unicode Character Data and put the useful informations into a header", - execute = parseUnicodeData -} diff --git a/build/scripts/common.lua b/build/scripts/common.lua index c0541e848..71af8332b 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -1,69 +1,680 @@ --- Configuration générale -configurations -{ --- "DebugStatic", --- "ReleaseStatic", - "DebugDLL", - "ReleaseDLL" -} +local PosixOSes = {"bsd", "linux", "macosx", "solaris"} -defines "NAZARA_BUILD" -language "C++" -location(_ACTION) +NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table -includedirs -{ - "../include", - "../src/", - "../extlibs/include" -} +function NazaraBuild:Execute() + if (_ACTION == nil) then -- Si aucune action n'est spécifiée + return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien + end -libdirs "../lib" + if (self.Actions[_ACTION] ~= nil) then + self.Actions[_ACTION].Function() + else + solution "NazaraEngine" -if (_OPTIONS["x64"]) then - defines "NAZARA_PLATFORM_x64" - libdirs "../extlibs/lib/x64" -else - libdirs "../extlibs/lib/x86" + -- Configuration générale + configurations + { + -- "DebugStatic", + -- "ReleaseStatic", + "DebugDynamic", + "ReleaseDynamic" + } + + defines "NAZARA_BUILD" + language "C++" + location(_ACTION) + + includedirs + { + "../include", + "../src/", + "../extlibs/include" + } + + libdirs "../lib" + + if (_OPTIONS["x64"]) then + defines "NAZARA_PLATFORM_x64" + libdirs "../extlibs/lib/x64" + else + libdirs "../extlibs/lib/x86" + end + + targetdir "../lib" + + configuration "Debug*" + defines "NAZARA_DEBUG" + flags "Symbols" + + configuration "Release*" + flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } + + configuration { "Release*", "codeblocks or codelite or gmake or xcode3 or xcode4" } + buildoptions "-mfpmath=sse" -- Utilisation du SSE pour les calculs flottants + buildoptions "-ftree-vectorize" -- Activation de la vectorisation du code + + configuration "*Static" + defines "NAZARA_STATIC" + kind "StaticLib" + + configuration "*Dynamic" + kind "SharedLib" + + configuration "DebugStatic" + targetsuffix "-s-d" + + configuration "ReleaseStatic" + targetsuffix "-s" + + configuration "DebugDynamic" + targetsuffix "-d" + + configuration "codeblocks or codelite or gmake or xcode3 or xcode4" + buildoptions "-std=c++11" + if (_OPTIONS["x64"]) then + buildoptions "-m64" + end + + configuration { "linux or bsd or macosx", "gmake" } + buildoptions "-fvisibility=hidden" + + configuration { "linux or bsd or macosx", "gmake" } + buildoptions "-fvisibility=hidden" + + configuration "vs*" + defines "_CRT_SECURE_NO_WARNINGS" + + -- Spécification des modules + if (_OPTIONS["united"]) then + project "NazaraEngine" + end + + for i=1, #self.Modules do + local moduleTable = self.Modules[i] + if (not _OPTIONS["united"]) then + project("Nazara" .. moduleTable.Name) + end + + configuration {} + + files(moduleTable.Files) + excludes(moduleTable.FilesExclusion) + + defines(moduleTable.Defines) + flags(moduleTable.Flags) + links(moduleTable.Libraries) + + for k,v in pairs(moduleTable.ConfigurationLibraries) do + configuration(k) + links(v) + end + end + end + + if (_OPTIONS["with-examples"]) then + solution "NazaraExamples" + -- Configuration générale + configurations + { + -- "DebugStatic", + -- "ReleaseStatic", + "DebugDynamic", + "ReleaseDynamic" + } + + language "C++" + location("../examples/build/" .. _ACTION) + + debugdir "../examples/bin" + includedirs "../include" + libdirs "../lib" + + if (_OPTIONS["x64"]) then + defines "NAZARA_PLATFORM_x64" + libdirs "../extlibs/lib/x64" + else + libdirs "../extlibs/lib/x86" + end + + targetdir "../examples/bin" + + configuration "Debug*" + defines "NAZARA_DEBUG" + flags "Symbols" + + configuration "Release*" + flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } + + configuration { "Release*", "codeblocks or codelite or gmake or xcode3 or xcode4" } + buildoptions "-mfpmath=sse" -- Utilisation du SSE pour les calculs flottants + buildoptions "-ftree-vectorize" -- Activation de la vectorisation du code + + configuration "*Static" + defines "NAZARA_STATIC" + + configuration "codeblocks or codelite or gmake or xcode3 or xcode4" + buildoptions "-std=c++11" + + for i=1, #self.Examples do + local exampleTable = self.Examples[i] + project("Demo" .. exampleTable.Name) + + if (exampleTable.Console) then + kind "ConsoleApp" + else + kind "Window" + end + + files(exampleTable.Files) + excludes(exampleTable.FilesExclusion) + + defines(exampleTable.Defines) + flags(exampleTable.Flags) + links(exampleTable.Libraries) + + for k,v in pairs(exampleTable.ConfigurationLibraries) do + configuration(k) + links(v) + end + end + end + + if (_OPTIONS["with-extlibs"]) then + solution "NazaraExtlibs" + -- Configuration générale + configurations + { + "DebugStatic", + "ReleaseStatic" + } + + location("../extlibs/build/" .. _ACTION) + includedirs "../extlibs/include" + kind "StaticLib" + + if (_OPTIONS["x64"]) then + libdirs "../extlibs/lib/x64" + targetdir "../extlibs/lib/x64" + else + libdirs "../extlibs/lib/x86" + targetdir "../extlibs/lib/x86" + end + + configuration "Debug*" + flags "Symbols" + + configuration "Release*" + flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } + + configuration { "Release*", "codeblocks or codelite or gmake or xcode3 or xcode4" } + buildoptions "-mfpmath=sse" -- Utilisation du SSE pour les calculs flottants + buildoptions "-ftree-vectorize" -- Activation de la vectorisation du code + + configuration "DebugStatic" + targetsuffix "-s-d" + + configuration "ReleaseStatic" + targetsuffix "-s" + + configuration "codeblocks or codelite or gmake or xcode3 or xcode4" + buildoptions "-std=c++11" + + for i=1, #self.ExtLibs do + local libTable = self.ExtLibs[i] + project(libTable.Name) + + language(libTable.Language) + + files(libTable.Files) + excludes(libTable.FilesExclusion) + + defines(libTable.Defines) + flags(libTable.Flags) + links(libTable.Libraries) + + for k,v in pairs(libTable.ConfigurationLibraries) do + configuration(k) + links(v) + end + end + end end -targetdir "../lib" +function NazaraBuild:Initialize() + -- Commençons par les options + newoption { + trigger = "x64", + description = "Setup build project for x64 arch" + } -configuration "Debug*" - defines "NAZARA_DEBUG" - flags "Symbols" + newoption { + trigger = "united", + description = "Builds all the modules as one united library" + } -configuration "Release*" - flags { "EnableSSE", "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } + newoption { + trigger = "with-extlibs", + description = "Builds the extern libraries" + } -configuration { "Release*", "codeblocks or codelite or gmake or xcode3*" } - buildoptions "-mfpmath=sse" -- Utilisation du SSE pour les calculs flottants - buildoptions "-ftree-vectorize" -- Activation de la vectorisation du code + newoption { + trigger = "with-examples", + description = "Builds the examples" + } -configuration "*Static" - defines "NAZARA_STATIC" - kind "StaticLib" + -- Puis par les bibliothèques externes + self.ExtLibs = {} + local extlibs = os.matchfiles("../extlibs/build/*.lua") + for k,v in pairs(extlibs) do + local f, err = loadfile(v) + if (f) then + LIBRARY = {} + LIBRARY.ConfigurationLibraries = {} + LIBRARY.ConfigurationLibraries.DebugStatic = {} + LIBRARY.ConfigurationLibraries.ReleaseStatic = {} + LIBRARY.ConfigurationLibraries.DebugDynamic = {} + LIBRARY.ConfigurationLibraries.ReleaseDynamic = {} + LIBRARY.Defines = {} + LIBRARY.Files = {} + LIBRARY.FilesExclusion = {} + LIBRARY.Flags = {} + LIBRARY.Libraries = {} + LIBRARY.OsFiles = {} + LIBRARY.OsLibraries = {} -configuration "*DLL" - kind "SharedLib" + f() -configuration "DebugStatic" - targetsuffix "-s-d" + local succeed, err = self:RegisterExternLibrary(LIBRARY) + if (not succeed) then + print("Unable to register extern library: " .. err) + end + else + print("Unable to load extern library file: " .. err) + end + end + LIBRARY = nil -configuration "ReleaseStatic" - targetsuffix "-s" + -- Ensuite nous allons parcourir tous les scripts de modules + self.Modules = {} + local modules = os.matchfiles("scripts/module/*.lua") + for k,v in pairs(modules) do + local moduleName = v:match(".*/(.*).lua"):lower() -configuration "DebugDLL" - targetsuffix "-d" + if (moduleName ~= "core") then -- exclure le noyau n'aurait aucun sens + newoption { + trigger = "exclude-" .. moduleName, + description = "Exclude the " .. moduleName .. " module from the build system" + } + end -configuration "codeblocks or codelite or gmake or xcode3*" - buildoptions "-std=c++11" -- On compile en C++11 -if (_OPTIONS["x64"]) then - buildoptions "-m64" + if (not _OPTIONS["exclude-" .. moduleName]) then + local f, err = loadfile(v) + if (f) then + MODULE = {} + MODULE.ConfigurationLibraries = {} + MODULE.ConfigurationLibraries.DebugStatic = {} + MODULE.ConfigurationLibraries.ReleaseStatic = {} + MODULE.ConfigurationLibraries.DebugDynamic = {} + MODULE.ConfigurationLibraries.ReleaseDynamic = {} + MODULE.Defines = {} + MODULE.ExtLibs = {} + MODULE.Files = {} + MODULE.FilesExclusion = {} + MODULE.Flags = {} + MODULE.Libraries = {} + MODULE.OsFiles = {} + MODULE.OsLibraries = {} + + f() + + local succeed, err = self:RegisterModule(MODULE) + if (not succeed) then + print("Unable to register module: " .. err) + end + else + print("Unable to load module file: " .. err) + end + end + end + MODULE = nil + table.sort(self.Modules, function (a, b) return a.Name < b.Name end) + + -- Et ensuite les scripts d'actions possibles + self.Actions = {} + modules = os.matchfiles("scripts/actions/*.lua") + for k,v in pairs(modules) do + local f, err = loadfile(v) + if (f) then + ACTION = {} + + f() + + local succeed, err = self:RegisterAction(ACTION) + if (not succeed) then + print("Unable to register action: " .. err) + end + else + print("Unable to load action file: " .. err) + end + end + ACTION = nil + + self.Examples = {} + local examples = os.matchdirs("../examples/*") + for k,v in pairs(examples) do + local dirName = v:match(".*/(.*)") + if (dirName ~= "bin" and dirName ~= "build") then + local f, err = loadfile(v .. "/build.lua") + if (f) then + EXAMPLE = {} + EXAMPLE.ConfigurationLibraries = {} + EXAMPLE.ConfigurationLibraries.DebugStatic = {} + EXAMPLE.ConfigurationLibraries.ReleaseStatic = {} + EXAMPLE.ConfigurationLibraries.DebugDynamic = {} + EXAMPLE.ConfigurationLibraries.ReleaseDynamic = {} + EXAMPLE.Defines = {} + EXAMPLE.Directory = dirName + EXAMPLE.Files = {} + EXAMPLE.FilesExclusion = {} + EXAMPLE.Flags = {} + EXAMPLE.Libraries = {} + EXAMPLE.OsFiles = {} + EXAMPLE.OsLibraries = {} + + f() + + local succeed, err = self:RegisterExample(EXAMPLE) + if (not succeed) then + print("Unable to register example: " .. err) + end + else + print("Unable to load example file: " .. err) + end + end + end + EXAMPLE = nil end -configuration { "linux or bsd or macosx", "gmake" } - buildoptions "-fvisibility=hidden" +function NazaraBuild:RegisterAction(actionTable) + if (actionTable.Name == nil or type(actionTable.Name) ~= "string") then + return false, "Action name is invalid" + end -configuration "vs*" - defines "_CRT_SECURE_NO_WARNINGS" + if (string.len(actionTable.Name) == 0) then + return false, "Action name is empty" + end + + if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then + return false, "Action description is invalid" + end + + if (string.len(actionTable.Description) == 0) then + return false, "Action description is empty" + end + + if (self.Actions[actionTable.name] ~= nil) then + return false, "Action name \"" .. actionTable.name .. " is already registred" + end + + if (actionTable.Function == nil or type(actionTable.Function) ~= "function") then + return false, "Action function is invalid" + end + + local actionTrigger = string.lower(actionTable.Name) + + self.Actions[actionTrigger] = actionTable + + newaction + { + trigger = actionTrigger, + description = actionTable.Description, + execute = actionTable.Function + } + + return true +end + +function NazaraBuild:RegisterExample(exampleTable) + if (exampleTable.Name == nil or type(exampleTable.Name) ~= "string") then + return false, "Example name is invalid" + end + + if (string.len(exampleTable.Name) == 0) then + return false, "Example name is empty" + end + + if (exampleTable.Files == nil or type(exampleTable.Files) ~= "table") then + return false, "Example files table is invalid" + end + + if (#exampleTable.Files == 0) then + return false, "Example files table is empty" + end + + local files = {} + for k, file in ipairs(exampleTable.Files) do + table.insert(files, "../examples/" .. exampleTable.Directory .. "/" .. file) + end + exampleTable.Files = files + + local libraries = {} + for k, library in ipairs(exampleTable.Libraries) do + if (string.sub(library, 1, 6) == "Nazara") then + if (_OPTIONS["united"]) then + table.insert(exampleTable.ConfigurationLibraries.DebugStatic, "NazaraEngine-s-d") + table.insert(exampleTable.ConfigurationLibraries.ReleaseStatic, "NazaraEngine-s") + table.insert(exampleTable.ConfigurationLibraries.DebugDynamic, "NazaraEngine-d") + table.insert(exampleTable.ConfigurationLibraries.ReleaseDynamic, "NazaraEngine") + else + table.insert(exampleTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(exampleTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(exampleTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(exampleTable.ConfigurationLibraries.ReleaseDynamic, library) + end + else + table.insert(libraries, library) + end + end + exampleTable.Libraries = libraries + + for platform, fileTable in ipairs(exampleTable.OsFiles) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in ipairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,v in ipairs(fileTable) do + table.insert(exampleTable.Files, v) + end + else + for k,v in ipairs(fileTable) do + table.insert(exampleTable.FilesExclusion, v) + end + end + end + exampleTable.OsFiles = nil + + for platform, libraryTable in ipairs(exampleTable.OsLibraries) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in ipairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,v in ipairs(libraryTable) do + table.insert(exampleTable.Libraries, v) + end + end + end + exampleTable.OsLibraries = nil + + table.insert(self.Examples, exampleTable) + return true +end + +function NazaraBuild:RegisterExternLibrary(libTable) + if (libTable.Name == nil or type(libTable.Name) ~= "string") then + return false, "Module name is invalid" + end + + if (string.len(libTable.Name) == 0) then + return false, "Module name is empty" + end + + if (libTable.Files == nil or type(libTable.Files) ~= "table") then + return false, "Module files table is invalid" + end + + if (#libTable.Files == 0) then + return false, "Module files table is empty" + end + + libTable.Libraries = libraries + + for platform, fileTable in pairs(libTable.OsFiles) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in pairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,v in pairs(fileTable) do + table.insert(libTable.Files, v) + end + else + for k,v in pairs(fileTable) do + table.insert(libTable.FilesExclusion, v) + end + end + end + libTable.OsFiles = nil + + for platform, libraryTable in pairs(libTable.OsLibraries) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in pairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,v in pairs(libraryTable) do + table.insert(libTable.Libraries, v) + end + end + end + libTable.OsLibraries = nil + + table.insert(self.ExtLibs, libTable) + return true +end + +function NazaraBuild:RegisterModule(moduleTable) + if (moduleTable.Name == nil or type(moduleTable.Name) ~= "string") then + return false, "Module name is invalid" + end + + if (string.len(moduleTable.Name) == 0) then + return false, "Module name is empty" + end + + table.insert(moduleTable.Files, "../include/Nazara/" .. moduleTable.Name .. "/**.hpp") + table.insert(moduleTable.Files, "../include/Nazara/" .. moduleTable.Name .. "/**.inl") + table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.hpp") + table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp") + table.insert(moduleTable.FilesExclusion, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp") + + local libraries = {} + for k, library in pairs(moduleTable.Libraries) do + if (string.sub(library, 1, 6) == "Nazara") then + if (not _OPTIONS["united"]) then + table.insert(moduleTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(moduleTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(moduleTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(moduleTable.ConfigurationLibraries.ReleaseDynamic, library) + end + else + local found = false + for k,extlibTable in pairs(self.ExtLibs) do + if (library == extlibTable.Name) then + table.insert(moduleTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(moduleTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(moduleTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") + table.insert(moduleTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") + found = true + break + end + end + + if (not found) then + table.insert(libraries, library) + end + end + end + moduleTable.Libraries = libraries + + for platform, fileTable in pairs(moduleTable.OsFiles) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in pairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,v in pairs(fileTable) do + table.insert(moduleTable.Files, v) + end + else + for k,v in pairs(fileTable) do + table.insert(moduleTable.FilesExclusion, v) + end + end + end + moduleTable.OsFiles = nil + + for platform, libraryTable in pairs(moduleTable.OsLibraries) do + platform = string.lower(platform) + if (platform == "posix") then + for k,v in pairs(PosixOSes) do + if (os.is(v)) then + platform = v + break + end + end + end + + if (os.is(platform)) then + for k,library in pairs(libraryTable) do + table.insert(moduleTable.Libraries, library) + end + end + end + moduleTable.OsLibraries = nil + + table.insert(self.Modules, moduleTable) + return true +end diff --git a/build/scripts/common_examples.lua b/build/scripts/common_examples.lua deleted file mode 100644 index 5eb19d552..000000000 --- a/build/scripts/common_examples.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Configuration générale -configurations -{ --- "DebugStatic", --- "ReleaseStatic", - "DebugDLL", - "ReleaseDLL" -} - -language "C++" -location("../examples/build/" .. _ACTION) - -debugdir "../examples/bin" - -includedirs { "../include", "../extlibs/include" } - -libdirs "../lib" - -if (_OPTIONS["x64"]) then - defines "NAZARA_PLATFORM_x64" - libdirs "../extlibs/lib/x64" -else - libdirs "../extlibs/lib/x86" -end - -targetdir "../examples/bin" - -configuration "Debug*" - defines "NAZARA_DEBUG" - flags "Symbols" - -configuration "Release*" - flags { "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } - -configuration "*Static" - defines "NAZARA_STATIC" - -configuration "codeblocks or codelite or gmake or xcode3*" - buildoptions "-std=c++11" diff --git a/build/scripts/common_extlibs.lua b/build/scripts/common_extlibs.lua deleted file mode 100644 index af414ca7a..000000000 --- a/build/scripts/common_extlibs.lua +++ /dev/null @@ -1,31 +0,0 @@ --- Configuration générale -configurations -{ - "Debug", - "Release" -} - -location("../extlibs/build/" .. _ACTION) -includedirs "../extlibs/include" - -if (_OPTIONS["x64"]) then - targetdir "../extlibs/lib/x64" -else - targetdir "../extlibs/lib/x86" -end - -configuration "Debug" - flags "Symbols" - targetsuffix "-d" - -configuration "Release" - flags { "EnableSSE", "EnableSSE2", "Optimize", "OptimizeSpeed", "NoFramePointer", "NoRTTI" } - --- Activation du SSE côté GCC -configuration { "Release*", "codeblocks or codelite or gmake or xcode3*" } - buildoptions "-mfpmath=sse" - -if (_OPTIONS["x64"]) then -configuration "codeblocks or codelite or gmake or xcode3*" - buildoptions "-m64" -end diff --git a/build/scripts/module/audio.lua b/build/scripts/module/audio.lua index 5da7dc9ac..41d1a9765 100644 --- a/build/scripts/module/audio.lua +++ b/build/scripts/module/audio.lua @@ -1,37 +1,20 @@ -if (not _OPTIONS["united"]) then - project "NazaraAudio" -end +MODULE.Name = "Audio" -defines "NAZARA_AUDIO_OPENAL" - -files -{ - "../include/Nazara/Audio/**.hpp", - "../include/Nazara/Audio/**.inl", - "../src/Nazara/Audio/**.hpp", - "../src/Nazara/Audio/**.cpp" +MODULE.Defines = { + "NAZARA_AUDIO_OPENAL" } -if (os.is("windows")) then - excludes { "../src/Nazara/Audio/Posix/*.hpp", "../src/Nazara/Audio/Posix/*.cpp" } - links "sndfile-1" -else - excludes { "../src/Nazara/Audio/Win32/*.hpp", "../src/Nazara/Audio/Win32/*.cpp" } - -- Link posix ? -end +MODULE.Libraries = { + "NazaraCore", + "sndfile-1" +} -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Audio/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" +MODULE.OsFiles.Windows = { + "../src/Nazara/Audio/Win32/**.hpp", + "../src/Nazara/Audio/Win32/**.cpp" +} - configuration "ReleaseStatic" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraCore" -end +MODULE.OsFiles.Posix = { + "../src/Nazara/Audio/Posix/**.hpp", + "../src/Nazara/Audio/Posix/**.cpp" +} \ No newline at end of file diff --git a/build/scripts/module/core.lua b/build/scripts/module/core.lua index 763153faa..c8f9eda6d 100644 --- a/build/scripts/module/core.lua +++ b/build/scripts/module/core.lua @@ -1,9 +1,6 @@ -if (not _OPTIONS["united"]) then - project "NazaraCore" -end +MODULE.Name = "Core" -files -{ +MODULE.Files = { "../include/Nazara/Prerequesites.hpp", "../include/Nazara/Core/**.hpp", "../include/Nazara/Core/**.inl", @@ -13,8 +10,12 @@ files "../src/Nazara/Core/**.cpp" } -if (os.is("windows")) then - excludes { "../src/Nazara/Core/Posix/**.hpp", "../src/Nazara/Core/Posix/**.cpp" } -else - excludes { "../src/Nazara/Core/Win32/**.hpp", "../src/Nazara/Core/Win32/**.cpp" } -end +MODULE.OsFiles.Windows = { + "../src/Nazara/Core/Win32/**.hpp", + "../src/Nazara/Core/Win32/**.cpp" +} + +MODULE.OsFiles.Posix = { + "../src/Nazara/Core/Posix/**.hpp", + "../src/Nazara/Core/Posix/**.cpp" +} diff --git a/build/scripts/module/graphics.lua b/build/scripts/module/graphics.lua index 34d33e1d0..9d393d3a7 100644 --- a/build/scripts/module/graphics.lua +++ b/build/scripts/module/graphics.lua @@ -1,41 +1,7 @@ -if (not _OPTIONS["united"]) then - project "NazaraGraphics" -end +MODULE.Name = "Graphics" -files -{ - "../include/Nazara/Graphics/**.hpp", - "../include/Nazara/Graphics/**.inl", - "../src/Nazara/Graphics/**.hpp", - "../src/Nazara/Graphics/**.cpp" +MODULE.Libraries = { + "NazaraCore", + "NazaraUtility", + "NazaraRenderer" } - -if (os.is("windows")) then - excludes { "../src/Nazara/Graphics/Posix/*.hpp", "../src/Nazara/Graphics/Posix/*.cpp" } -else - excludes { "../src/Nazara/Graphics/Win32/*.hpp", "../src/Nazara/Graphics/Win32/*.cpp" } -end - -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Graphics/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" - links "NazaraUtility-s-d" - links "NazaraRenderer-s-d" - - configuration "ReleaseStatic" - links "NazaraCore-s" - links "NazaraUtility-s" - links "NazaraRenderer-s" - - configuration "DebugDLL" - links "NazaraCore-d" - links "NazaraUtility-d" - links "NazaraRenderer-d" - - configuration "ReleaseDLL" - links "NazaraCore" - links "NazaraUtility" - links "NazaraRenderer" -end diff --git a/build/scripts/module/lua.lua b/build/scripts/module/lua.lua index 934753399..96fe0cbc1 100644 --- a/build/scripts/module/lua.lua +++ b/build/scripts/module/lua.lua @@ -1,39 +1,7 @@ -if (not _OPTIONS["united"]) then - project "NazaraLua" -end +-- Quelle ironie +MODULE.Name = "Lua" -files -{ - "../include/Nazara/Lua/**.hpp", - "../include/Nazara/Lua/**.inl", - "../src/Nazara/Lua/**.hpp", - "../src/Nazara/Lua/**.cpp" +MODULE.Libraries = { + "lua", + "NazaraCore" } - -if (os.is("windows")) then - excludes { "../src/Nazara/Lua/Posix/*.hpp", "../src/Nazara/Lua/Posix/*.cpp" } -else - excludes { "../src/Nazara/Lua/Win32/*.hpp", "../src/Nazara/Lua/Win32/*.cpp" } -end - -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Lua/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraCore" -end - -configuration "Debug*" - links "lua-s-d" - -configuration "Release*" - links "lua-s" diff --git a/build/scripts/module/noise.lua b/build/scripts/module/noise.lua index ec1c9a017..155cd83be 100644 --- a/build/scripts/module/noise.lua +++ b/build/scripts/module/noise.lua @@ -1,33 +1,5 @@ -if (not _OPTIONS["united"]) then - project "NazaraNoise" -end +MODULE.Name = "Noise" -files -{ - "../include/Nazara/Noise/**.hpp", - "../include/Nazara/Noise/**.inl", - "../src/Nazara/Noise/**.hpp", - "../src/Nazara/Noise/**.cpp" +MODULE.Libraries = { + "NazaraCore" } - -if (os.is("windows")) then - excludes { "../src/Nazara/Noise/Posix/*.hpp", "../src/Nazara/Noise/Posix/*.cpp" } -else - excludes { "../src/Nazara/Noise/Win32/*.hpp", "../src/Nazara/Noise/Win32/*.cpp" } -end - -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Noise/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraCore" -end diff --git a/build/scripts/module/physics.lua b/build/scripts/module/physics.lua index 09deb9c63..fbf6f39c8 100644 --- a/build/scripts/module/physics.lua +++ b/build/scripts/module/physics.lua @@ -1,39 +1,6 @@ -if (not _OPTIONS["united"]) then - project "NazaraPhysics" -end +MODULE.Name = "Physics" -files -{ - "../include/Nazara/Physics/**.hpp", - "../include/Nazara/Physics/**.inl", - "../src/Nazara/Physics/**.hpp", - "../src/Nazara/Physics/**.cpp" +MODULE.Libraries = { + "NazaraCore", + "newton" } - -if (os.is("windows")) then - excludes { "../src/Nazara/Physics/Posix/*.hpp", "../src/Nazara/Physics/Posix/*.cpp" } -else - excludes { "../src/Nazara/Physics/Win32/*.hpp", "../src/Nazara/Physics/Win32/*.cpp" } -end - -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Physics/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraCore" -end - -configuration "Debug*" - links "newton_d" - -configuration "Release*" - links "newton" diff --git a/build/scripts/module/renderer.lua b/build/scripts/module/renderer.lua index 0acdb85a4..0b0155249 100644 --- a/build/scripts/module/renderer.lua +++ b/build/scripts/module/renderer.lua @@ -1,42 +1,26 @@ -if (not _OPTIONS["united"]) then - project "NazaraRenderer" -end +MODULE.Name = "Renderer" -defines "NAZARA_RENDERER_OPENGL" - -files -{ - "../include/Nazara/Renderer/**.hpp", - "../include/Nazara/Renderer/**.inl", - "../src/Nazara/Renderer/**.hpp", - "../src/Nazara/Renderer/**.cpp" +MODULE.Defines = { + "NAZARA_RENDERER_OPENGL" } -if (os.is("windows")) then - excludes { "../src/Nazara/Renderer/Posix/*.hpp", "../src/Nazara/Renderer/Posix/*.cpp" } - links "gdi32" - links "opengl32" - links "winmm" -else - excludes { "../src/Nazara/Renderer/Win32/*.hpp", "../src/Nazara/Renderer/Win32/*.cpp" } -end +MODULE.Libraries = { + "NazaraCore", + "NazaraUtility" +} -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Renderer/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" - links "NazaraUtility-s-d" +MODULE.OsFiles.Windows = { + "../src/Nazara/Renderer/Win32/**.hpp", + "../src/Nazara/Renderer/Win32/**.cpp" +} - configuration "ReleaseStatic" - links "NazaraCore-s" - links "NazaraUtility-s" +MODULE.OsFiles.Posix = { + "../src/Nazara/Renderer/Posix/**.hpp", + "../src/Nazara/Renderer/Posix/**.cpp" +} - configuration "DebugDLL" - links "NazaraCore-d" - links "NazaraUtility-d" - - configuration "ReleaseDLL" - links "NazaraCore" - links "NazaraUtility" -end \ No newline at end of file +MODULE.OsLibraries.Windows = { + "gdi32", + "opengl32", + "winmm" +} diff --git a/build/scripts/module/utility.lua b/build/scripts/module/utility.lua index e6c25021e..ba2209bf4 100644 --- a/build/scripts/module/utility.lua +++ b/build/scripts/module/utility.lua @@ -1,42 +1,22 @@ -if (not _OPTIONS["united"]) then - project "NazaraUtility" -end +MODULE.Name = "Utility" -files -{ - "../include/Nazara/Utility/**.hpp", - "../include/Nazara/Utility/**.inl", - "../src/Nazara/Utility/**.hpp", - "../src/Nazara/Utility/**.cpp" +MODULE.Libraries = { + "freetype-s", + "NazaraCore", + "stb_image" } -links "freetype-s" +MODULE.OsFiles.Windows = { + "../src/Nazara/Utility/Win32/**.hpp", + "../src/Nazara/Utility/Win32/**.cpp" +} -if (os.is("windows")) then - excludes { "../src/Nazara/Utility/Posix/*.hpp", "../src/Nazara/Utility/Posix/*.cpp" } - links "gdi32" -else - excludes { "../src/Nazara/Utility/Win32/*.hpp", "../src/Nazara/Utility/Win32/*.cpp" } -end +MODULE.OsFiles.Posix = { + "../src/Nazara/Utility/Posix/**.hpp", + "../src/Nazara/Utility/Posix/**.cpp" +} -if (_OPTIONS["united"]) then - excludes "../src/Nazara/Utility/Debug/NewOverload.cpp" -else - configuration "DebugStatic" - links "NazaraCore-s-d" +MODULE.OsLibraries.Windows = { + "gdi32" +} - configuration "ReleaseStatic" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraCore" -end - -configuration "Debug*" - links "stb_image-s-d" - -configuration "Release*" - links "stb_image-s" diff --git a/examples/DopplerEffect/build.lua b/examples/DopplerEffect/build.lua index 92711ed35..8298ef526 100644 --- a/examples/DopplerEffect/build.lua +++ b/examples/DopplerEffect/build.lua @@ -1,37 +1,13 @@ -kind "ConsoleApp" +EXAMPLE.Name = "DopplerEffect" -files "main.cpp" +EXAMPLE.Console = true -if (_OPTIONS["united"]) then - configuration "DebugStatic" - links "NazaraEngine-s-d" +EXAMPLE.Files = { + "main.cpp" +} - configuration "ReleaseStatic" - links "NazaraEngine-s" - - configuration "DebugDLL" - links "NazaraEngine-d" - - configuration "ReleaseDLL" - links "NazaraEngine" -else - configuration "DebugStatic" - links "NazaraAudio-s-d" - links "NazaraUtility-s-d" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraAudio-s" - links "NazaraUtility-s" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraAudio-d" - links "NazaraUtility-d" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraAudio" - links "NazaraUtility" - links "NazaraCore" -end +EXAMPLE.Libraries = { + "NazaraAudio", + "NazaraCore", + "NazaraUtility" +} \ No newline at end of file diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index a9b899ad1..b7f8a146a 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -1,41 +1,14 @@ -kind "ConsoleApp" +EXAMPLE.Name = "FirstScene" -files "main.cpp" +EXAMPLE.Console = true -if (_OPTIONS["united"]) then - configuration "DebugStatic" - links "NazaraEngine-s-d" +EXAMPLE.Files = { + "main.cpp" +} - configuration "ReleaseStatic" - links "NazaraEngine-s" - - configuration "DebugDLL" - links "NazaraEngine-d" - - configuration "ReleaseDLL" - links "NazaraEngine" -else - configuration "DebugStatic" - links "NazaraGraphics-s-d" - links "NazaraRenderer-s-d" - links "NazaraUtility-s-d" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraGraphics-s" - links "NazaraRenderer-s" - links "NazaraUtility-s" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraGraphics-d" - links "NazaraRenderer-d" - links "NazaraUtility-d" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraGraphics" - links "NazaraRenderer" - links "NazaraUtility" - links "NazaraCore" -end +EXAMPLE.Libraries = { + "NazaraCore", + "NazaraGraphics", + "NazaraRenderer", + "NazaraUtility" +} diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index 63601943d..e1b487bd6 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -1,39 +1,17 @@ -kind "ConsoleApp" +EXAMPLE.Name = "HardwareInfo" -defines "NAZARA_RENDERER_OPENGL" +EXAMPLE.Console = true -files "main.cpp" +EXAMPLE.Defines = { + "NAZARA_RENDERER_OPENGL" +} -if (_OPTIONS["united"]) then - configuration "DebugStatic" - links "NazaraEngine-s-d" +EXAMPLE.Files = { + "main.cpp" +} - configuration "ReleaseStatic" - links "NazaraEngine-s" - - configuration "DebugDLL" - links "NazaraEngine-d" - - configuration "ReleaseDLL" - links "NazaraEngine" -else - configuration "DebugStatic" - links "NazaraRenderer-s-d" - links "NazaraUtility-s-d" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraRenderer-s" - links "NazaraUtility-s" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraRenderer-d" - links "NazaraUtility-d" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraRenderer" - links "NazaraUtility" - links "NazaraCore" -end +EXAMPLE.Libraries = { + "NazaraCore", + "NazaraRenderer", + "NazaraUtility" +} diff --git a/examples/MeshInfos/build.lua b/examples/MeshInfos/build.lua index 2e4c8c7a2..9372ef5c1 100644 --- a/examples/MeshInfos/build.lua +++ b/examples/MeshInfos/build.lua @@ -1,33 +1,13 @@ -kind "ConsoleApp" +EXAMPLE.Name = "MeshInfos" -files "main.cpp" +EXAMPLE.Console = true -if (_OPTIONS["united"]) then - configuration "DebugStatic" - links "NazaraEngine-s-d" +EXAMPLE.Files = { + "main.cpp" +} - configuration "ReleaseStatic" - links "NazaraEngine-s" +EXAMPLE.Libraries = { + "NazaraCore", + "NazaraUtility" +} - configuration "DebugDLL" - links "NazaraEngine-d" - - configuration "ReleaseDLL" - links "NazaraEngine" -else - configuration "DebugStatic" - links "NazaraUtility-s-d" - links "NazaraCore-s-d" - - configuration "ReleaseStatic" - links "NazaraUtility-s" - links "NazaraCore-s" - - configuration "DebugDLL" - links "NazaraUtility-d" - links "NazaraCore-d" - - configuration "ReleaseDLL" - links "NazaraUtility" - links "NazaraCore" -end