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 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() function NazaraBuild:Execute()
if (_ACTION == nil) then -- Si aucune action n'est spécifiée 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 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") targetdir("../lib/" .. makeLibDir .. "/x64")
-- Copy the module binaries to the example folder -- Copy the module binaries to the example folder
self:MakeCopyAfterBuild(moduleTable) self:MakeInstallCommands(moduleTable)
configuration({"vs*", "x32"}) configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86") libdirs("../extlibs/lib/msvc/x86")
@ -265,12 +274,16 @@ function NazaraBuild:Execute()
if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then
kind("SharedLib") 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) debugdir(toolTable.Directory)
kind("ConsoleApp") if (toolTable.EnableConsole) then
elseif (toolTable.Kind == "windowapp") then kind("ConsoleApp")
debugdir(toolTable.Directory) else
kind("WindowedApp") kind("WindowedApp")
end
else else
assert(false, "Invalid tool Kind") assert(false, "Invalid tool Kind")
end end
@ -308,11 +321,6 @@ function NazaraBuild:Execute()
targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64")
end end
-- Copy the tool binaries to the example folder
if (toolTable.CopyTargetToExampleDir) then
self:MakeCopyAfterBuild(toolTable)
end
configuration({"vs*", "x32"}) configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86") libdirs("../extlibs/lib/msvc/x86")
libdirs("../lib/msvc/x86") libdirs("../lib/msvc/x86")
@ -385,23 +393,34 @@ function NazaraBuild:Execute()
end end
for k, exampleTable in ipairs(self.OrderedExamples) do for k, exampleTable in ipairs(self.OrderedExamples) do
local destPath = "../examples/bin"
project("Demo" .. exampleTable.Name) project("Demo" .. exampleTable.Name)
location(_ACTION .. "/examples") location(_ACTION .. "/examples")
if (exampleTable.Console) then if (exampleTable.Kind == "plugin" or exampleTable.Kind == "library") then
kind("ConsoleApp") kind("SharedLib")
self:MakeInstallCommands(toolTable)
elseif (exampleTable.Kind == "application") then
debugdir(exampleTable.Directory)
if (exampleTable.EnableConsole) then
kind("ConsoleApp")
else
kind("WindowedApp")
end
else else
kind("Window") assert(false, "Invalid tool Kind")
end end
debugdir("../examples/bin") debugdir(destPath)
includedirs({ includedirs({
"../include", "../include",
"../extlibs/include" "../extlibs/include"
}) })
libdirs("../lib") libdirs("../lib")
targetdir("../examples/bin") targetdir(destPath)
files(exampleTable.Files) files(exampleTable.Files)
excludes(exampleTable.FilesExcluded) excludes(exampleTable.FilesExcluded)
@ -448,6 +467,11 @@ end
function NazaraBuild:Initialize() function NazaraBuild:Initialize()
-- Commençons par les options -- Commençons par les options
newoption({
trigger = "install-path",
description = "Setup additionnals install directories (library binaries will be copied there)"
})
newoption({ newoption({
trigger = "server", trigger = "server",
description = "Excludes client-only modules/tools/examples" description = "Excludes client-only modules/tools/examples"
@ -470,10 +494,19 @@ function NazaraBuild:Initialize()
self.Actions = {} self.Actions = {}
self.Examples = {} self.Examples = {}
self.ExecutableDir = {}
self.ExtLibs = {} self.ExtLibs = {}
self.InstallDir = {}
self.Modules = {} self.Modules = {}
self.Tools = {} 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 -- 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
@ -499,7 +532,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v) local f, err = loadfile(v)
if (f) then if (f) then
LIBRARY = {} LIBRARY = {}
self:SetupInfoTable(LIBRARY) self:SetupExtlibTable(LIBRARY)
f() f()
@ -522,7 +555,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v) local f, err = loadfile(v)
if (f) then if (f) then
MODULE = {} MODULE = {}
self:SetupInfoTable(MODULE) self:SetupModuleTable(MODULE)
f() f()
@ -545,7 +578,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v) local f, err = loadfile(v)
if (f) then if (f) then
TOOL = {} TOOL = {}
self:SetupInfoTable(TOOL) self:SetupToolTable(TOOL)
f() f()
@ -569,7 +602,7 @@ function NazaraBuild:Initialize()
if (f) then if (f) then
EXAMPLE = {} EXAMPLE = {}
EXAMPLE.Directory = dirName EXAMPLE.Directory = dirName
self:SetupInfoTable(EXAMPLE) self:SetupExampleTable(EXAMPLE)
f() f()
@ -745,7 +778,7 @@ function NazaraBuild:RegisterTool(toolTable)
end end
local lowerCaseKind = toolTable.Kind:lower() 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 toolTable.Kind = lowerCaseKind
else else
return false, "Invalid tool type" return false, "Invalid tool type"
@ -873,6 +906,10 @@ function NazaraBuild:Process(infoTable)
end end
end end
if (infoTable.Kind == "application") then
self:AddExecutablePath(infoTable.Directory)
end
return true return true
end end
@ -900,14 +937,18 @@ function NazaraBuild:Resolve(infoTable)
end end
end end
function NazaraBuild:MakeCopyAfterBuild(infoTable) function NazaraBuild:MakeInstallCommands(infoTable)
if (PremakeVersion < 50) then if (PremakeVersion < 50) then
return return
end end
if (os.is("windows")) then if (os.is("windows")) then
configuration({}) 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 for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do
local paths = {} local paths = {}
@ -918,14 +959,18 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable)
for k,v in pairs(paths) do for k,v in pairs(paths) do
local config = v[1] local config = v[1]
local path = v[2] local srcPath = v[2]
if (os.isfile(path)) then if (os.isfile(srcPath)) then
if (infoTable.Kind == "plugin") then if (infoTable.Kind == "plugin") then
path = "../../" .. path srcPath = "../../" .. srcPath
end end
configuration(config) 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 end
end end
@ -946,3 +991,24 @@ function NazaraBuild:SetupInfoTable(infoTable)
infoTable["Os" .. v] = {} infoTable["Os" .. v] = {}
end 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.Directory = "../SDK/lib"
TOOL.Kind = "Plugin" TOOL.Kind = "Plugin"
TOOL.CopyTargetToExampleDir = true
TOOL.Includes = { TOOL.Includes = {
"../include", "../include",
"../plugins/Assimp" "../plugins/Assimp"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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