From b6be16b3c3113aa1076ee236882547cc98ab518d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:51:32 +0200 Subject: [PATCH] Build: Add server option, allows to compile only the server-side part of Nazara Former-commit-id: 28347f372b3d4b0afef0fcf8f54ebf45589470a3 [formerly b432be7d6e4404bd1c5a10c4b0a7ef43fceed307] Former-commit-id: 1622472689c5f87d5d77ffe391f1dde9cece815d --- SDK/include/NDK/Components.hpp | 13 ++--- .../NDK/Components/CameraComponent.hpp | 2 + .../NDK/Components/GraphicsComponent.hpp | 2 + SDK/include/NDK/Components/LightComponent.hpp | 2 + .../NDK/Components/ListenerComponent.hpp | 2 + SDK/include/NDK/Systems.hpp | 9 +-- SDK/include/NDK/Systems/ListenerSystem.hpp | 2 + SDK/include/NDK/Systems/RenderSystem.hpp | 2 + build/scripts/common.lua | 57 +++++++++++++++---- build/scripts/modules/audio.lua | 2 + build/scripts/modules/renderer.lua | 2 + build/scripts/modules/vulkan.lua | 2 + build/scripts/tools/ndk.lua | 19 +++---- build/scripts/tools/ndk_server.lua | 19 ++++--- 14 files changed, 92 insertions(+), 43 deletions(-) diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index 46392ab7c..ca993b5b6 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -1,20 +1,17 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_COMPONENTS_GLOBAL_HPP #define NDK_COMPONENTS_GLOBAL_HPP +#include #include +#include +#include +#include #include #include #include -#ifndef NDK_SERVER -#include -#include -#include -#include -#endif - #endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index d5951109b..af2245b11 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_CAMERACOMPONENT_HPP #define NDK_COMPONENTS_CAMERACOMPONENT_HPP @@ -108,3 +109,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_CAMERACOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f8fa2bf66..86cefb782 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP #define NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP @@ -80,3 +81,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/LightComponent.hpp b/SDK/include/NDK/Components/LightComponent.hpp index c55ae57bb..80f84a759 100644 --- a/SDK/include/NDK/Components/LightComponent.hpp +++ b/SDK/include/NDK/Components/LightComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LIGHTCOMPONENT_HPP #define NDK_COMPONENTS_LIGHTCOMPONENT_HPP @@ -28,3 +29,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LIGHTCOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index bee1ac14a..3d472bed3 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LISTENERCOMPONENT_HPP #define NDK_COMPONENTS_LISTENERCOMPONENT_HPP @@ -30,3 +31,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LISTENERCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 193438b5e..176a956ee 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -1,16 +1,13 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_SYSTEMS_GLOBAL_HPP #define NDK_SYSTEMS_GLOBAL_HPP +#include #include +#include #include -#ifndef NDK_SERVER -#include -#include -#endif - #endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems/ListenerSystem.hpp b/SDK/include/NDK/Systems/ListenerSystem.hpp index 6f40fcdf9..bb166a4c1 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.hpp +++ b/SDK/include/NDK/Systems/ListenerSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_LISTENERSYSTEM_HPP #define NDK_SYSTEMS_LISTENERSYSTEM_HPP @@ -27,3 +28,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_LISTENERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 72aa1efb1..f2fbc7a65 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP #define NDK_SYSTEMS_RENDERSYSTEM_HPP @@ -70,3 +71,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_RENDERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 822067ea2..6cf0025ba 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -196,9 +196,7 @@ function NazaraBuild:Execute() targetdir("../lib/" .. makeLibDir .. "/x64") -- Copy the module binaries to the example folder - if (os.is("windows")) then - self:MakeCopyAfterBuild(moduleTable) - end + self:MakeCopyAfterBuild(moduleTable) configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") @@ -310,7 +308,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end - -- Copy the module binaries to the example folder + -- Copy the tool binaries to the example folder if (toolTable.CopyTargetToExampleDir) then self:MakeCopyAfterBuild(toolTable) end @@ -450,6 +448,11 @@ end function NazaraBuild:Initialize() -- Commençons par les options + newoption({ + trigger = "server", + description = "Excludes client-only modules/tools/examples" + }) + newoption({ trigger = "united", description = "Builds all the modules as one united library" @@ -605,13 +608,20 @@ function NazaraBuild:Initialize() self.OrderedExtLibs = {} self.OrderedModules = {} self.OrderedTools = {} - local tables = {self.Examples, self.ExtLibs, self.Modules, self.Tools} - local orderedTables = {self.OrderedExamples, self.OrderedExtLibs, self.OrderedModules, self.OrderedTools} + local tables = {self.ExtLibs, self.Modules, self.Tools, self.Examples} + local orderedTables = {self.OrderedExtLibs, self.OrderedModules, self.OrderedTools, self.OrderedExamples} for k,projects in ipairs(tables) do + -- Begin by resolving every project (because of dependencies in the same category) for projectId,projectTable in pairs(projects) do - self:Process(projectTable) - - table.insert(orderedTables[k], projectTable) + self:Resolve(projectTable) + end + + for projectId,projectTable in pairs(projects) do + if (self:Process(projectTable)) then + table.insert(orderedTables[k], projectTable) + else + print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) + end end table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end) @@ -772,13 +782,22 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - local libraries = {} + if (infoTable.ClientOnly and _OPTIONS["server"]) then + return false + end + + local libraries = {} for k, library in pairs(infoTable.Libraries) do local moduleName = library:match("Nazara(%w+)") local moduleTable = moduleName and self.Modules[moduleName:lower()] local toolTable = moduleName and self.Tools[moduleName:lower()] if (moduleTable) then + if (moduleTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + if (_OPTIONS["united"]) then library = "NazaraEngine" else @@ -794,6 +813,11 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then + if (extLibTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = extLibTable.Name table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") @@ -802,6 +826,11 @@ function NazaraBuild:Process(infoTable) table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then + if (toolTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = "Nazara" .. toolTable.Name -- Import tools includes @@ -862,6 +891,14 @@ function NazaraBuild:Process(infoTable) end end end + + return true +end + +function NazaraBuild:Resolve(infoTable) + if (type(infoTable.Libraries) == "function") then + infoTable.Libraries = infoTable.Libraries() + end end function NazaraBuild:MakeCopyAfterBuild(infoTable) diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index 27e49a08c..509972dc3 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -1,5 +1,7 @@ MODULE.Name = "Audio" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_AUDIO_OPENAL" } diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 7e3edadbe..bbc472b75 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -1,5 +1,7 @@ MODULE.Name = "Renderer" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_RENDERER_OPENGL" } diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua index 760a4e58c..62a00a745 100644 --- a/build/scripts/modules/vulkan.lua +++ b/build/scripts/modules/vulkan.lua @@ -1,5 +1,7 @@ MODULE.Name = "Vulkan" +MODULE.ClientOnly = true + MODULE.Defines = { "VK_NO_PROTOTYPES" } diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 5a1084f48..961fa6d7f 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -22,14 +22,11 @@ TOOL.Files = { "../SDK/src/NDK/**.cpp" } -TOOL.Libraries = { - "NazaraCore", - "NazaraAudio", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility", - "NazaraRenderer", - "NazaraGraphics" -} +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + table.insert(libraries, "Nazara" .. v.Name) + end + + return libraries +end \ No newline at end of file diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 978d620be..b1a71453e 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -37,11 +37,14 @@ TOOL.FilesExcluded = { "../SDK/**/LuaBinding_Renderer.*" } -TOOL.Libraries = { - "NazaraCore", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility" -} + +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + if (not v.ClientOnly) then + table.insert(libraries, "Nazara" .. v.Name) + end + end + + return libraries +end