Build: Rework build system + introduced SDK build file
Former-commit-id: 90727a78031a83753404d2fe09a6347315a00a39
This commit is contained in:
parent
7b7b74bdf3
commit
71e595fe49
|
|
@ -1,5 +1,3 @@
|
||||||
local PosixOSes = {"bsd", "linux", "macosx", "solaris"}
|
|
||||||
|
|
||||||
NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table
|
NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table
|
||||||
|
|
||||||
function NazaraBuild:Execute()
|
function NazaraBuild:Execute()
|
||||||
|
|
@ -10,7 +8,7 @@ function NazaraBuild:Execute()
|
||||||
if (self.Actions[_ACTION] ~= nil) then
|
if (self.Actions[_ACTION] ~= nil) then
|
||||||
self.Actions[_ACTION].Function()
|
self.Actions[_ACTION].Function()
|
||||||
else
|
else
|
||||||
if (_OPTIONS["with-extlibs"]) then
|
if (#self.OrderedExtLibs > 0) then
|
||||||
solution("NazaraExtlibs")
|
solution("NazaraExtlibs")
|
||||||
-- Configuration générale
|
-- Configuration générale
|
||||||
configurations({
|
configurations({
|
||||||
|
|
@ -49,8 +47,7 @@ function NazaraBuild:Execute()
|
||||||
configuration("codeblocks or codelite or gmake or xcode3 or xcode4")
|
configuration("codeblocks or codelite or gmake or xcode3 or xcode4")
|
||||||
buildoptions("-std=c++11")
|
buildoptions("-std=c++11")
|
||||||
|
|
||||||
for i=1, #self.ExtLibs do
|
for k, libTable in ipairs(self.OrderedExtLibs) do
|
||||||
local libTable = self.ExtLibs[i]
|
|
||||||
project(libTable.Name)
|
project(libTable.Name)
|
||||||
|
|
||||||
language(libTable.Language)
|
language(libTable.Language)
|
||||||
|
|
@ -61,6 +58,7 @@ function NazaraBuild:Execute()
|
||||||
|
|
||||||
defines(libTable.Defines)
|
defines(libTable.Defines)
|
||||||
flags(libTable.Flags)
|
flags(libTable.Flags)
|
||||||
|
includedirs(libTable.Includes)
|
||||||
links(libTable.Libraries)
|
links(libTable.Libraries)
|
||||||
|
|
||||||
for k,v in pairs(libTable.ConfigurationLibraries) do
|
for k,v in pairs(libTable.ConfigurationLibraries) do
|
||||||
|
|
@ -120,8 +118,7 @@ function NazaraBuild:Execute()
|
||||||
project("NazaraEngine")
|
project("NazaraEngine")
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, #self.Modules do
|
for k, moduleTable in ipairs(self.OrderedModules) do
|
||||||
local moduleTable = self.Modules[i]
|
|
||||||
if (not _OPTIONS["united"]) then
|
if (not _OPTIONS["united"]) then
|
||||||
project("Nazara" .. moduleTable.Name)
|
project("Nazara" .. moduleTable.Name)
|
||||||
end
|
end
|
||||||
|
|
@ -169,6 +166,7 @@ function NazaraBuild:Execute()
|
||||||
|
|
||||||
defines(moduleTable.Defines)
|
defines(moduleTable.Defines)
|
||||||
flags(moduleTable.Flags)
|
flags(moduleTable.Flags)
|
||||||
|
includedirs(moduleTable.Includes)
|
||||||
links(moduleTable.Libraries)
|
links(moduleTable.Libraries)
|
||||||
|
|
||||||
for k,v in pairs(moduleTable.ConfigurationLibraries) do
|
for k,v in pairs(moduleTable.ConfigurationLibraries) do
|
||||||
|
|
@ -178,23 +176,31 @@ function NazaraBuild:Execute()
|
||||||
|
|
||||||
configuration({})
|
configuration({})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if (_OPTIONS["with-examples"]) then
|
-- Tools
|
||||||
for i=1, #self.Examples do
|
for k, toolTable in ipairs(self.OrderedTools) do
|
||||||
local exampleTable = self.Examples[i]
|
project("Nazara" .. toolTable.Name)
|
||||||
project("Demo" .. exampleTable.Name)
|
|
||||||
|
|
||||||
location(_ACTION .. "/examples")
|
location(_ACTION .. "/tools")
|
||||||
|
targetdir(toolTable.Directory)
|
||||||
|
|
||||||
if (exampleTable.Console) then
|
if (toolTable.Kind == "library") then
|
||||||
|
kind("SharedLib")
|
||||||
|
elseif (toolTable.Kind == "consoleapp") then
|
||||||
|
debugdir(toolTable.Directory)
|
||||||
kind("ConsoleApp")
|
kind("ConsoleApp")
|
||||||
else
|
elseif (toolTable.Kind == "windowapp") then
|
||||||
|
debugdir(toolTable.Directory)
|
||||||
kind("Window")
|
kind("Window")
|
||||||
|
else
|
||||||
|
assert(false, "wut")
|
||||||
end
|
end
|
||||||
|
|
||||||
debugdir("../examples/bin")
|
includedirs({
|
||||||
includedirs("../include")
|
"../include",
|
||||||
|
"../extlibs/include"
|
||||||
|
})
|
||||||
|
|
||||||
libdirs("../lib")
|
libdirs("../lib")
|
||||||
|
|
||||||
if (_OPTIONS["x64"]) then
|
if (_OPTIONS["x64"]) then
|
||||||
|
|
@ -204,16 +210,34 @@ function NazaraBuild:Execute()
|
||||||
libdirs("../extlibs/lib/x86")
|
libdirs("../extlibs/lib/x86")
|
||||||
end
|
end
|
||||||
|
|
||||||
targetdir("../examples/bin")
|
targetdir("../lib")
|
||||||
|
|
||||||
files(exampleTable.Files)
|
configuration("*Static")
|
||||||
excludes(exampleTable.FilesExclusion)
|
kind("StaticLib")
|
||||||
|
|
||||||
defines(exampleTable.Defines)
|
configuration("*Dynamic")
|
||||||
flags(exampleTable.Flags)
|
kind("SharedLib")
|
||||||
links(exampleTable.Libraries)
|
|
||||||
|
|
||||||
for k,v in pairs(exampleTable.ConfigurationLibraries) do
|
configuration("DebugStatic")
|
||||||
|
targetsuffix("-s-d")
|
||||||
|
|
||||||
|
configuration("ReleaseStatic")
|
||||||
|
targetsuffix("-s")
|
||||||
|
|
||||||
|
configuration("DebugDynamic")
|
||||||
|
targetsuffix("-d")
|
||||||
|
|
||||||
|
configuration({})
|
||||||
|
|
||||||
|
files(toolTable.Files)
|
||||||
|
excludes(toolTable.FilesExclusion)
|
||||||
|
|
||||||
|
defines(toolTable.Defines)
|
||||||
|
flags(toolTable.Flags)
|
||||||
|
includedirs(toolTable.Includes)
|
||||||
|
links(toolTable.Libraries)
|
||||||
|
|
||||||
|
for k,v in pairs(toolTable.ConfigurationLibraries) do
|
||||||
configuration(k)
|
configuration(k)
|
||||||
links(v)
|
links(v)
|
||||||
end
|
end
|
||||||
|
|
@ -221,6 +245,49 @@ function NazaraBuild:Execute()
|
||||||
configuration({})
|
configuration({})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for k, exampleTable in ipairs(self.OrderedExamples) do
|
||||||
|
project("Demo" .. exampleTable.Name)
|
||||||
|
|
||||||
|
location(_ACTION .. "/examples")
|
||||||
|
|
||||||
|
if (exampleTable.Console) then
|
||||||
|
kind("ConsoleApp")
|
||||||
|
else
|
||||||
|
kind("Window")
|
||||||
|
end
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
files(exampleTable.Files)
|
||||||
|
excludes(exampleTable.FilesExclusion)
|
||||||
|
|
||||||
|
defines(exampleTable.Defines)
|
||||||
|
flags(exampleTable.Flags)
|
||||||
|
includedirs(exampleTable.Includes)
|
||||||
|
links(exampleTable.Libraries)
|
||||||
|
|
||||||
|
for k,v in pairs(exampleTable.ConfigurationLibraries) do
|
||||||
|
configuration(k)
|
||||||
|
links(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
configuration({})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:Initialize()
|
function NazaraBuild:Initialize()
|
||||||
|
|
@ -245,86 +312,13 @@ function NazaraBuild:Initialize()
|
||||||
description = "Builds the examples"
|
description = "Builds the examples"
|
||||||
})
|
})
|
||||||
|
|
||||||
-- 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 = {}
|
|
||||||
|
|
||||||
f()
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
-- 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")
|
|
||||||
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)
|
|
||||||
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 = {}
|
self.Actions = {}
|
||||||
|
self.Examples = {}
|
||||||
|
self.ExtLibs = {}
|
||||||
|
self.Modules = {}
|
||||||
|
self.Tools = {}
|
||||||
|
|
||||||
|
-- Actions
|
||||||
modules = os.matchfiles("scripts/actions/*.lua")
|
modules = os.matchfiles("scripts/actions/*.lua")
|
||||||
for k,v in pairs(modules) do
|
for k,v in pairs(modules) do
|
||||||
local f, err = loadfile(v)
|
local f, err = loadfile(v)
|
||||||
|
|
@ -343,49 +337,142 @@ function NazaraBuild:Initialize()
|
||||||
end
|
end
|
||||||
ACTION = nil
|
ACTION = nil
|
||||||
|
|
||||||
self.Examples = {}
|
-- Extern libraries
|
||||||
local examples = os.matchdirs("../examples/*")
|
if (_OPTIONS["with-extlibs"]) then
|
||||||
for k,v in pairs(examples) do
|
local extlibs = os.matchfiles("../extlibs/build/*.lua")
|
||||||
local dirName = v:match(".*/(.*)")
|
for k,v in pairs(extlibs) do
|
||||||
if (dirName ~= "bin" and dirName ~= "build") then
|
local f, err = loadfile(v)
|
||||||
local f, err = loadfile(v .. "/build.lua")
|
|
||||||
if (f) then
|
if (f) then
|
||||||
EXAMPLE = {}
|
LIBRARY = {}
|
||||||
EXAMPLE.ConfigurationLibraries = {}
|
self:SetupInfoTable(LIBRARY)
|
||||||
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()
|
f()
|
||||||
|
|
||||||
local succeed, err = self:RegisterExample(EXAMPLE)
|
local succeed, err = self:RegisterExternLibrary(LIBRARY)
|
||||||
if (not succeed) then
|
if (not succeed) then
|
||||||
print("Unable to register example: " .. err)
|
print("Unable to register extern library: " .. err)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("Unable to load example file: " .. err)
|
print("Unable to load extern library file: " .. err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
LIBRARY = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Then the modules
|
||||||
|
local modules = os.matchfiles("scripts/modules/*.lua")
|
||||||
|
for k,v in pairs(modules) do
|
||||||
|
local moduleName = v:match(".*/(.*).lua")
|
||||||
|
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)
|
||||||
|
if (f) then
|
||||||
|
MODULE = {}
|
||||||
|
self:SetupInfoTable(MODULE)
|
||||||
|
|
||||||
|
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
|
end
|
||||||
end
|
end
|
||||||
EXAMPLE = nil
|
MODULE = nil
|
||||||
|
|
||||||
|
-- Continue with the tools (ex: SDK)
|
||||||
|
local tools = os.matchfiles("scripts/tools/*.lua")
|
||||||
|
for k,v in pairs(tools) do
|
||||||
|
local toolName = v:match(".*/(.*).lua")
|
||||||
|
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)
|
||||||
|
if (f) then
|
||||||
|
TOOL = {}
|
||||||
|
self:SetupInfoTable(TOOL)
|
||||||
|
|
||||||
|
f()
|
||||||
|
|
||||||
|
local succeed, err = self:RegisterTool(TOOL)
|
||||||
|
if (not succeed) then
|
||||||
|
print("Unable to register tool: " .. err)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("Unable to load tool file: " .. err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
TOOL = nil
|
||||||
|
|
||||||
|
-- Examples
|
||||||
|
if (_OPTIONS["with-examples"]) then
|
||||||
|
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.Directory = dirName
|
||||||
|
self:SetupInfoTable(EXAMPLE)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- Once everything is registred, let's process all the tables
|
||||||
|
self.OrderedExamples = {}
|
||||||
|
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}
|
||||||
|
for k,projects in ipairs(tables) do
|
||||||
|
for projectId,projectTable in pairs(projects) do
|
||||||
|
self:Process(projectTable)
|
||||||
|
|
||||||
|
table.insert(orderedTables[k], projectTable)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:RegisterAction(actionTable)
|
function NazaraBuild:RegisterAction(actionTable)
|
||||||
if (actionTable.Name == nil or type(actionTable.Name) ~= "string") then
|
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
|
||||||
return false, "Action name is invalid"
|
return false, "Invalid action name"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (string.len(actionTable.Name) == 0) then
|
local lowerCaseName = string.lower(actionTable.Name)
|
||||||
return false, "Action name is empty"
|
if (self.Actions[lowerCaseName] ~= nil) then
|
||||||
|
return false, "This action name is already in use"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then
|
if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then
|
||||||
|
|
@ -404,13 +491,11 @@ function NazaraBuild:RegisterAction(actionTable)
|
||||||
return false, "Action function is invalid"
|
return false, "Action function is invalid"
|
||||||
end
|
end
|
||||||
|
|
||||||
local actionTrigger = string.lower(actionTable.Name)
|
self.Actions[lowerCaseName] = actionTable
|
||||||
|
|
||||||
self.Actions[actionTrigger] = actionTable
|
|
||||||
|
|
||||||
newaction
|
newaction
|
||||||
{
|
{
|
||||||
trigger = actionTrigger,
|
trigger = lowerCaseName,
|
||||||
description = actionTable.Description,
|
description = actionTable.Description,
|
||||||
execute = actionTable.Function
|
execute = actionTable.Function
|
||||||
}
|
}
|
||||||
|
|
@ -419,12 +504,13 @@ function NazaraBuild:RegisterAction(actionTable)
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:RegisterExample(exampleTable)
|
function NazaraBuild:RegisterExample(exampleTable)
|
||||||
if (exampleTable.Name == nil or type(exampleTable.Name) ~= "string") then
|
if (exampleTable.Name == nil or type(exampleTable.Name) ~= "string" or string.len(exampleTable.Name) == 0) then
|
||||||
return false, "Example name is invalid"
|
return false, "Invalid example name"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (string.len(exampleTable.Name) == 0) then
|
local lowerCaseName = exampleTable.Name:lower()
|
||||||
return false, "Example name is empty"
|
if (self.Examples[lowerCaseName] ~= nil) then
|
||||||
|
return false, "This library name is already in use"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (exampleTable.Files == nil or type(exampleTable.Files) ~= "table") then
|
if (exampleTable.Files == nil or type(exampleTable.Files) ~= "table") then
|
||||||
|
|
@ -432,7 +518,7 @@ function NazaraBuild:RegisterExample(exampleTable)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (#exampleTable.Files == 0) then
|
if (#exampleTable.Files == 0) then
|
||||||
return false, "Example files table is empty"
|
return false, "This example has no files"
|
||||||
end
|
end
|
||||||
|
|
||||||
local files = {}
|
local files = {}
|
||||||
|
|
@ -441,144 +527,42 @@ function NazaraBuild:RegisterExample(exampleTable)
|
||||||
end
|
end
|
||||||
exampleTable.Files = files
|
exampleTable.Files = files
|
||||||
|
|
||||||
local libraries = {}
|
exampleTable.Type = "Example"
|
||||||
for k, library in ipairs(exampleTable.Libraries) do
|
self.Examples[lowerCaseName] = exampleTable
|
||||||
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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:RegisterExternLibrary(libTable)
|
function NazaraBuild:RegisterExternLibrary(libTable)
|
||||||
if (libTable.Name == nil or type(libTable.Name) ~= "string") then
|
if (libTable.Name == nil or type(libTable.Name) ~= "string" or string.len(libTable.Name) == 0) then
|
||||||
return false, "Module name is invalid"
|
return false, "Invalid library name"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (string.len(libTable.Name) == 0) then
|
local lowerCaseName = libTable.Name:lower()
|
||||||
return false, "Module name is empty"
|
if (self.ExtLibs[lowerCaseName] ~= nil) then
|
||||||
|
return false, "This library name is already in use"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (libTable.Files == nil or type(libTable.Files) ~= "table") then
|
if (libTable.Files == nil or type(libTable.Files) ~= "table") then
|
||||||
return false, "Module files table is invalid"
|
return false, "Invalid file table"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (#libTable.Files == 0) then
|
if (#libTable.Files == 0) then
|
||||||
return false, "Module files table is empty"
|
return false, "This library has no files"
|
||||||
end
|
end
|
||||||
|
|
||||||
libTable.Libraries = libraries
|
libTable.Type = "ExternLib"
|
||||||
|
self.ExtLibs[lowerCaseName] = libTable
|
||||||
for platform, fileTable in pairs(libTable.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 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 ipairs(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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:RegisterModule(moduleTable)
|
function NazaraBuild:RegisterModule(moduleTable)
|
||||||
if (moduleTable.Name == nil or type(moduleTable.Name) ~= "string") then
|
if (moduleTable.Name == nil or type(moduleTable.Name) ~= "string" or string.len(moduleTable.Name) == 0) then
|
||||||
return false, "Module name is invalid"
|
return false, "Invalid module name"
|
||||||
end
|
end
|
||||||
|
|
||||||
if (string.len(moduleTable.Name) == 0) then
|
local lowerCaseName = moduleTable.Name:lower()
|
||||||
return false, "Module name is empty"
|
if (self.Modules[lowerCaseName] ~= nil) then
|
||||||
|
return false, "This module name is already in use"
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(moduleTable.Defines, "NAZARA_" .. moduleTable.Name:upper() .. "_BUILD")
|
table.insert(moduleTable.Defines, "NAZARA_" .. moduleTable.Name:upper() .. "_BUILD")
|
||||||
|
|
@ -587,79 +571,154 @@ function NazaraBuild:RegisterModule(moduleTable)
|
||||||
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.hpp")
|
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.hpp")
|
||||||
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl")
|
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl")
|
||||||
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp")
|
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp")
|
||||||
table.insert(moduleTable.FilesExclusion, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp")
|
|
||||||
|
|
||||||
local libraries = {}
|
if (_OPTIONS["united"] and lowerCaseName ~= "core") then
|
||||||
for k, library in pairs(moduleTable.Libraries) do
|
table.insert(moduleTable.FilesExclusion, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp")
|
||||||
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
|
end
|
||||||
moduleTable.Libraries = libraries
|
|
||||||
|
|
||||||
for platform, fileTable in pairs(moduleTable.OsFiles) do
|
moduleTable.Type = "Module"
|
||||||
platform = string.lower(platform)
|
self.Modules[lowerCaseName] = moduleTable
|
||||||
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 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 ipairs(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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:RegisterTool(toolTable)
|
||||||
|
if (toolTable.Name == nil or type(toolTable.Name) ~= "string" or string.len(toolTable.Name) == 0) then
|
||||||
|
return false, "Invalid tool name"
|
||||||
|
end
|
||||||
|
|
||||||
|
local lowerCaseName = toolTable.Name:lower()
|
||||||
|
if (self.Tools[lowerCaseName] ~= nil) then
|
||||||
|
return false, "This tool name is already in use"
|
||||||
|
end
|
||||||
|
|
||||||
|
if (toolTable.Directory == nil or type(toolTable.Directory) ~= "string" or string.len(toolTable.Directory) == 0) then
|
||||||
|
return false, "Invalid tool directory"
|
||||||
|
end
|
||||||
|
|
||||||
|
if (toolTable.Kind == nil or type(toolTable.Kind) ~= "string" or string.len(toolTable.Kind) == 0) then
|
||||||
|
return false, "Invalid tool type"
|
||||||
|
end
|
||||||
|
|
||||||
|
local lowerCaseKind = toolTable.Kind:lower()
|
||||||
|
if (lowerCaseKind == "library" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then
|
||||||
|
toolTable.Kind = lowerCaseKind
|
||||||
|
else
|
||||||
|
return false, "Invalid tool type"
|
||||||
|
end
|
||||||
|
|
||||||
|
toolTable.Type = "Tool"
|
||||||
|
self.Tools[lowerCaseName] = toolTable
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local PosixOSes = {
|
||||||
|
["bsd"] = true,
|
||||||
|
["linux"] = true,
|
||||||
|
["macosx"] = true,
|
||||||
|
["solaris"] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function NazaraBuild:Process(infoTable)
|
||||||
|
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 (_OPTIONS["united"]) then
|
||||||
|
library = "NazaraEngine"
|
||||||
|
else
|
||||||
|
library = "Nazara" .. moduleTable.Name
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not _OPTIONS["united"] or infoTable.Type ~= "Module") then
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local extLibTable = self.ExtLibs[library:lower()]
|
||||||
|
if (extLibTable) then
|
||||||
|
library = extLibTable.Name
|
||||||
|
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s")
|
||||||
|
else
|
||||||
|
if (toolTable and toolTable.Kind == "library") then
|
||||||
|
library = "Nazara" .. toolTable.Name
|
||||||
|
|
||||||
|
-- Import tools includes
|
||||||
|
for k,v in ipairs(toolTable.Includes) do
|
||||||
|
table.insert(infoTable.Includes, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
||||||
|
else
|
||||||
|
table.insert(libraries, library)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
infoTable.Libraries = libraries
|
||||||
|
|
||||||
|
for platform, fileTable in pairs(infoTable.OsFiles) do
|
||||||
|
platform = string.lower(platform)
|
||||||
|
if (platform == "posix") then
|
||||||
|
local osname = os.get()
|
||||||
|
if (PosixOSes[osname]) then
|
||||||
|
platform = osname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (os.is(platform)) then
|
||||||
|
for k,v in ipairs(fileTable) do
|
||||||
|
table.insert(infoTable.Files, v)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k,v in ipairs(fileTable) do
|
||||||
|
table.insert(infoTable.FilesExclusion, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
infoTable.OsFiles = nil
|
||||||
|
|
||||||
|
for platform, libraryTable in pairs(infoTable.OsLibraries) do
|
||||||
|
platform = string.lower(platform)
|
||||||
|
if (platform == "posix") then
|
||||||
|
local osname = os.get()
|
||||||
|
if (PosixOSes[osname]) then
|
||||||
|
platform = osname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (os.is(platform)) then
|
||||||
|
for k,v in ipairs(libraryTable) do
|
||||||
|
table.insert(infoTable.Libraries, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
infoTable.OsLibraries = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:SetupInfoTable(infoTable)
|
||||||
|
infoTable.ConfigurationLibraries = {}
|
||||||
|
infoTable.ConfigurationLibraries.DebugStatic = {}
|
||||||
|
infoTable.ConfigurationLibraries.ReleaseStatic = {}
|
||||||
|
infoTable.ConfigurationLibraries.DebugDynamic = {}
|
||||||
|
infoTable.ConfigurationLibraries.ReleaseDynamic = {}
|
||||||
|
infoTable.Defines = {}
|
||||||
|
infoTable.Files = {}
|
||||||
|
infoTable.FilesExclusion = {}
|
||||||
|
infoTable.Flags = {}
|
||||||
|
infoTable.Includes = {}
|
||||||
|
infoTable.Libraries = {}
|
||||||
|
infoTable.OsFiles = {}
|
||||||
|
infoTable.OsLibraries = {}
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
TOOL.Name = "SDK"
|
||||||
|
|
||||||
|
TOOL.Directory = "../SDK/lib"
|
||||||
|
TOOL.Kind = "Library"
|
||||||
|
|
||||||
|
TOOL.Defines = {
|
||||||
|
"NDK_BUILD"
|
||||||
|
}
|
||||||
|
|
||||||
|
TOOL.Includes = {
|
||||||
|
"../SDK/include"
|
||||||
|
}
|
||||||
|
|
||||||
|
TOOL.Files = {
|
||||||
|
"../SDK/include/NDK/**.hpp",
|
||||||
|
"../SDK/include/NDK/**.inl",
|
||||||
|
"../SDK/src/NDK/**.hpp",
|
||||||
|
"../SDK/src/NDK/**.inl",
|
||||||
|
"../SDK/src/NDK/**.cpp"
|
||||||
|
}
|
||||||
|
|
||||||
|
TOOL.Libraries = {
|
||||||
|
"NazaraCore",
|
||||||
|
"NazaraAudio",
|
||||||
|
"NazaraLua",
|
||||||
|
"NazaraNoise",
|
||||||
|
"NazaraPhysics",
|
||||||
|
"NazaraUtility",
|
||||||
|
"NazaraRenderer",
|
||||||
|
"NazaraGraphics",
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue