Build: Remake install system

Former-commit-id: 5103cd29d3959802747d7d06bc9b90bc272215d4 [formerly 7c3ea867b6439d721f255306d812b5d10a3efe1a]
Former-commit-id: 5b5ab11770402db34a14df80b9ad6c1ce3fecaca
This commit is contained in:
Lynix 2016-06-12 11:39:31 +02:00
parent d42ae34c4f
commit 49650a94f3
10 changed files with 102 additions and 41 deletions

View File

@ -1,5 +1,14 @@
NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table
function NazaraBuild:AddExecutablePath(path)
self.ExecutableDir[path] = true
self.InstallDir[path] = true
end
function NazaraBuild:AddInstallPath(path)
self.InstallDir[path] = true
end
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
@ -196,7 +205,7 @@ function NazaraBuild:Execute()
targetdir("../lib/" .. makeLibDir .. "/x64")
-- Copy the module binaries to the example folder
self:MakeCopyAfterBuild(moduleTable)
self:MakeInstallCommands(moduleTable)
configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86")
@ -265,12 +274,16 @@ function NazaraBuild:Execute()
if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then
kind("SharedLib")
elseif (toolTable.Kind == "consoleapp") then
-- Copy the tool binaries to the example folder
self:MakeInstallCommands(toolTable)
elseif (toolTable.Kind == "application") then
debugdir(toolTable.Directory)
kind("ConsoleApp")
elseif (toolTable.Kind == "windowapp") then
debugdir(toolTable.Directory)
kind("WindowedApp")
if (toolTable.EnableConsole) then
kind("ConsoleApp")
else
kind("WindowedApp")
end
else
assert(false, "Invalid tool Kind")
end
@ -308,11 +321,6 @@ function NazaraBuild:Execute()
targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64")
end
-- Copy the tool binaries to the example folder
if (toolTable.CopyTargetToExampleDir) then
self:MakeCopyAfterBuild(toolTable)
end
configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86")
libdirs("../lib/msvc/x86")
@ -385,23 +393,34 @@ function NazaraBuild:Execute()
end
for k, exampleTable in ipairs(self.OrderedExamples) do
local destPath = "../examples/bin"
project("Demo" .. exampleTable.Name)
location(_ACTION .. "/examples")
if (exampleTable.Console) then
kind("ConsoleApp")
if (exampleTable.Kind == "plugin" or exampleTable.Kind == "library") then
kind("SharedLib")
self:MakeInstallCommands(toolTable)
elseif (exampleTable.Kind == "application") then
debugdir(exampleTable.Directory)
if (exampleTable.EnableConsole) then
kind("ConsoleApp")
else
kind("WindowedApp")
end
else
kind("Window")
assert(false, "Invalid tool Kind")
end
debugdir("../examples/bin")
debugdir(destPath)
includedirs({
"../include",
"../extlibs/include"
})
libdirs("../lib")
targetdir("../examples/bin")
targetdir(destPath)
files(exampleTable.Files)
excludes(exampleTable.FilesExcluded)
@ -448,6 +467,11 @@ end
function NazaraBuild:Initialize()
-- Commençons par les options
newoption({
trigger = "install-path",
description = "Setup additionnals install directories (library binaries will be copied there)"
})
newoption({
trigger = "server",
description = "Excludes client-only modules/tools/examples"
@ -470,9 +494,18 @@ function NazaraBuild:Initialize()
self.Actions = {}
self.Examples = {}
self.ExecutableDir = {}
self.ExtLibs = {}
self.InstallDir = {}
self.Modules = {}
self.Tools = {}
if (_OPTIONS["install-path"]) then
local paths = string.explode(_OPTIONS["install-path"], ";")
for k,v in pairs(paths) do
self:AddInstallPath(v)
end
end
-- Actions
modules = os.matchfiles("scripts/actions/*.lua")
@ -499,7 +532,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
LIBRARY = {}
self:SetupInfoTable(LIBRARY)
self:SetupExtlibTable(LIBRARY)
f()
@ -522,7 +555,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
MODULE = {}
self:SetupInfoTable(MODULE)
self:SetupModuleTable(MODULE)
f()
@ -545,7 +578,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
TOOL = {}
self:SetupInfoTable(TOOL)
self:SetupToolTable(TOOL)
f()
@ -569,7 +602,7 @@ function NazaraBuild:Initialize()
if (f) then
EXAMPLE = {}
EXAMPLE.Directory = dirName
self:SetupInfoTable(EXAMPLE)
self:SetupExampleTable(EXAMPLE)
f()
@ -745,7 +778,7 @@ function NazaraBuild:RegisterTool(toolTable)
end
local lowerCaseKind = toolTable.Kind:lower()
if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then
if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "application") then
toolTable.Kind = lowerCaseKind
else
return false, "Invalid tool type"
@ -873,6 +906,10 @@ function NazaraBuild:Process(infoTable)
end
end
if (infoTable.Kind == "application") then
self:AddExecutablePath(infoTable.Directory)
end
return true
end
@ -900,14 +937,18 @@ function NazaraBuild:Resolve(infoTable)
end
end
function NazaraBuild:MakeCopyAfterBuild(infoTable)
function NazaraBuild:MakeInstallCommands(infoTable)
if (PremakeVersion < 50) then
return
end
if (os.is("windows")) then
configuration({})
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]})
for k,v in pairs(self.InstallDir) do
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]})
end
for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do
local paths = {}
@ -918,14 +959,18 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable)
for k,v in pairs(paths) do
local config = v[1]
local path = v[2]
if (os.isfile(path)) then
local srcPath = v[2]
if (os.isfile(srcPath)) then
if (infoTable.Kind == "plugin") then
path = "../../" .. path
srcPath = "../../" .. srcPath
end
configuration(config)
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]})
for k,v in pairs(self.ExecutableDir) do
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]})
end
end
end
end
@ -945,4 +990,25 @@ function NazaraBuild:SetupInfoTable(infoTable)
infoTable[v] = {}
infoTable["Os" .. v] = {}
end
end
end
function NazaraBuild:SetupExampleTable(infoTable)
self:SetupInfoTable(infoTable)
infoTable.Directory = "../example/bin"
infoTable.Kind = "application"
end
function NazaraBuild:SetupExtlibTable(infoTable)
self:SetupInfoTable(infoTable)
infoTable.Kind = "library"
end
function NazaraBuild:SetupModuleTable(infoTable)
self:SetupInfoTable(infoTable)
infoTable.Kind = "library"
end
NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable

View File

@ -3,8 +3,6 @@ TOOL.Name = "Assimp"
TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Plugin"
TOOL.CopyTargetToExampleDir = true
TOOL.Includes = {
"../include",
"../plugins/Assimp"

View File

@ -1,7 +1,5 @@
TOOL.Name = "SDK"
TOOL.CopyTargetToExampleDir = true
TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Library"

View File

@ -1,7 +1,5 @@
TOOL.Name = "SDKServer"
TOOL.CopyTargetToExampleDir = true
TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Library"
@ -23,7 +21,7 @@ TOOL.Files = {
"../SDK/src/NDK/**.cpp"
}
-- Exlude client-only files
-- Excludes client-only files
TOOL.FilesExcluded = {
"../SDK/**/CameraComponent.*",
"../SDK/**/Console.*",

View File

@ -1,7 +1,8 @@
TOOL.Name = "UnitTests"
TOOL.Directory = "../tests"
TOOL.Kind = "ConsoleApp"
TOOL.EnableConsole = true
TOOL.Kind = "Application"
TOOL.Defines = {
}

View File

@ -1,6 +1,6 @@
EXAMPLE.Name = "DopplerEffect"
EXAMPLE.Console = true
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"

View File

@ -1,6 +1,6 @@
EXAMPLE.Name = "FirstScene"
EXAMPLE.Console = true
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"

View File

@ -1,6 +1,6 @@
EXAMPLE.Name = "MeshInfos"
EXAMPLE.Console = true
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"

View File

@ -1,6 +1,6 @@
EXAMPLE.Name = "Tut00_EmptyProject"
EXAMPLE.Console = true
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"

View File

@ -1,6 +1,6 @@
EXAMPLE.Name = "Tut01_HelloWorld"
EXAMPLE.Console = true
EXAMPLE.EnableConsole = true
EXAMPLE.Files = {
"main.cpp"