Build: Remake exclusion system

Allows to excludes pretty much everything and now also excludes projects
relying on an excluded dependency


Former-commit-id: 5260c724bd0b7ee82e58abdd16c99d0b78772c08 [formerly 3b107d86de1501964ea8f5babcdac4488759282b]
Former-commit-id: 00b7cbc69751720da768efd56beca9ba6143cd32
This commit is contained in:
Lynix 2016-06-12 10:03:05 +02:00
parent 420d5a84b2
commit 6819d4a26c
2 changed files with 58 additions and 55 deletions

View File

@ -519,14 +519,6 @@ function NazaraBuild:Initialize()
local moduleName = v:match(".*/(.*).lua") local moduleName = v:match(".*/(.*).lua")
local moduleNameLower = moduleName:lower() local moduleNameLower = moduleName:lower()
if (moduleNameLower ~= "core") then -- exclure le noyau n'aurait aucun sens
newoption({
trigger = "exclude-" .. moduleNameLower,
description = "Exclude the " .. moduleName .. " module from the build system"
})
end
if (not _OPTIONS["exclude-" .. moduleNameLower]) then
local f, err = loadfile(v) local f, err = loadfile(v)
if (f) then if (f) then
MODULE = {} MODULE = {}
@ -542,7 +534,6 @@ function NazaraBuild:Initialize()
print("Unable to load module file: " .. err) print("Unable to load module file: " .. err)
end end
end end
end
MODULE = nil MODULE = nil
-- Continue with the tools (ex: SDK) -- Continue with the tools (ex: SDK)
@ -551,12 +542,6 @@ function NazaraBuild:Initialize()
local toolName = v:match(".*/(.*).lua") local toolName = v:match(".*/(.*).lua")
local toolNameLower = toolName:lower() local toolNameLower = toolName:lower()
newoption({
trigger = "exclude-" .. toolNameLower,
description = "Exclude the " .. toolName .. " tool from the build system"
})
if (not _OPTIONS["exclude-" .. toolNameLower]) then
local f, err = loadfile(v) local f, err = loadfile(v)
if (f) then if (f) then
TOOL = {} TOOL = {}
@ -572,7 +557,6 @@ function NazaraBuild:Initialize()
print("Unable to load tool file: " .. err) print("Unable to load tool file: " .. err)
end end
end end
end
TOOL = nil TOOL = nil
-- Examples -- Examples
@ -618,7 +602,7 @@ function NazaraBuild:Initialize()
if (self:Process(projectTable)) then if (self:Process(projectTable)) then
table.insert(orderedTables[k], projectTable) table.insert(orderedTables[k], projectTable)
else else
print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason)
end end
end end
@ -780,20 +764,17 @@ local PosixOSes = {
} }
function NazaraBuild:Process(infoTable) function NazaraBuild:Process(infoTable)
if (infoTable.ClientOnly and _OPTIONS["server"]) then
return false
end
local libraries = {} local libraries = {}
for k, library in pairs(infoTable.Libraries) do for k, library in pairs(infoTable.Libraries) do
local moduleName = library:match("Nazara(%w+)") local projectName = library:match("Nazara(%w+)")
local moduleTable = moduleName and self.Modules[moduleName:lower()] local moduleTable = projectName and self.Modules[projectName:lower()]
local toolTable = moduleName and self.Tools[moduleName:lower()] local toolTable = projectName and self.Tools[projectName:lower()]
if (moduleTable) then if (moduleTable) then
if (moduleTable.ClientOnly and _OPTIONS["server"]) then if (moduleTable.Excluded) then
infoTable.ClientOnly = true infoTable.Excluded = true
return false -- We depend on a client-only library infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module"
return false
end end
if (_OPTIONS["united"]) then if (_OPTIONS["united"]) then
@ -811,9 +792,10 @@ function NazaraBuild:Process(infoTable)
else else
local extLibTable = self.ExtLibs[library:lower()] local extLibTable = self.ExtLibs[library:lower()]
if (extLibTable) then if (extLibTable) then
if (extLibTable.ClientOnly and _OPTIONS["server"]) then if (extLibTable.Excluded) then
infoTable.ClientOnly = true infoTable.Excluded = true
return false -- We depend on a client-only library infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library"
return false
end end
library = extLibTable.Name library = extLibTable.Name
@ -824,9 +806,10 @@ function NazaraBuild:Process(infoTable)
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s")
else else
if (toolTable and toolTable.Kind == "library") then if (toolTable and toolTable.Kind == "library") then
if (toolTable.ClientOnly and _OPTIONS["server"]) then if (toolTable.Excluded) then
infoTable.ClientOnly = true infoTable.Excluded = true
return false -- We depend on a client-only library infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool"
return false
end end
library = "Nazara" .. toolTable.Name library = "Nazara" .. toolTable.Name
@ -894,6 +877,24 @@ function NazaraBuild:Process(infoTable)
end end
function NazaraBuild:Resolve(infoTable) function NazaraBuild:Resolve(infoTable)
if (infoTable.ClientOnly and _OPTIONS["server"]) then
infoTable.Excluded = true
infoTable.ExcludeReason = "excluded by command-line options (client-only)"
end
if (infoTable.Excludable) then
local optionName = "excludes-" .. string.lower(infoTable.Type .. "-" .. infoTable.Name)
newoption({
trigger = optionName,
description = "Excludes the " .. infoTable.Name .. " " .. string.lower(infoTable.Type) .. " and projects relying on it"
})
if (_OPTIONS[optionName]) then
infoTable.Excluded = true
infoTable.ExcludeReason = "excluded by command-line options"
end
end
if (type(infoTable.Libraries) == "function") then if (type(infoTable.Libraries) == "function") then
infoTable.Libraries = infoTable.Libraries() infoTable.Libraries = infoTable.Libraries()
end end
@ -932,6 +933,7 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable)
end end
function NazaraBuild:SetupInfoTable(infoTable) function NazaraBuild:SetupInfoTable(infoTable)
infoTable.Excludable = true
infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries = {}
infoTable.ConfigurationLibraries.DebugStatic = {} infoTable.ConfigurationLibraries.DebugStatic = {}
infoTable.ConfigurationLibraries.ReleaseStatic = {} infoTable.ConfigurationLibraries.ReleaseStatic = {}

View File

@ -1,6 +1,7 @@
MODULE.Name = "Core" MODULE.Name = "Core"
MODULE.Excludable = false -- Excluding the core makes no sense as everything relies on it
MODULE.Files = { -- Les autres fichiers seront ajoutés automatiquement MODULE.Files = { -- Other files will be automatically added
"../include/Nazara/Prerequesites.hpp", "../include/Nazara/Prerequesites.hpp",
"../include/Nazara/Math/**.hpp", "../include/Nazara/Math/**.hpp",
"../include/Nazara/Math/**.inl", "../include/Nazara/Math/**.inl",