Skip to content

Commit

Permalink
Build: Remake install system
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Jun 12, 2016
1 parent 6ab75fe commit d8fea94
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 41 deletions.
122 changes: 94 additions & 28 deletions build/scripts/common.lua
@@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -265,12 +274,16 @@ function NazaraBuild:Execute()

if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then
kind("SharedLib")
elseif (toolTable.Kind == "consoleapp") then
debugdir(toolTable.Directory)
kind("ConsoleApp")
elseif (toolTable.Kind == "windowapp") then
-- Copy the tool binaries to the example folder
self:MakeInstallCommands(toolTable)
elseif (toolTable.Kind == "application") then
debugdir(toolTable.Directory)
kind("WindowedApp")
if (toolTable.EnableConsole) then
kind("ConsoleApp")
else
kind("WindowedApp")
end
else
assert(false, "Invalid tool Kind")
end
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -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")
Expand All @@ -499,7 +532,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
LIBRARY = {}
self:SetupInfoTable(LIBRARY)
self:SetupExtlibTable(LIBRARY)

f()

Expand All @@ -522,7 +555,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
MODULE = {}
self:SetupInfoTable(MODULE)
self:SetupModuleTable(MODULE)

f()

Expand All @@ -545,7 +578,7 @@ function NazaraBuild:Initialize()
local f, err = loadfile(v)
if (f) then
TOOL = {}
self:SetupInfoTable(TOOL)
self:SetupToolTable(TOOL)

f()

Expand All @@ -569,7 +602,7 @@ function NazaraBuild:Initialize()
if (f) then
EXAMPLE = {}
EXAMPLE.Directory = dirName
self:SetupInfoTable(EXAMPLE)
self:SetupExampleTable(EXAMPLE)

f()

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -873,6 +906,10 @@ function NazaraBuild:Process(infoTable)
end
end

if (infoTable.Kind == "application") then
self:AddExecutablePath(infoTable.Directory)
end

return true
end

Expand Down Expand Up @@ -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 = {}
Expand All @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions build/scripts/tools/assimp.lua
Expand Up @@ -3,8 +3,6 @@ TOOL.Name = "Assimp"
TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Plugin"

TOOL.CopyTargetToExampleDir = true

TOOL.Includes = {
"../include",
"../plugins/Assimp"
Expand Down
2 changes: 0 additions & 2 deletions build/scripts/tools/ndk.lua
@@ -1,7 +1,5 @@
TOOL.Name = "SDK"

TOOL.CopyTargetToExampleDir = true

TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Library"

Expand Down
4 changes: 1 addition & 3 deletions build/scripts/tools/ndk_server.lua
@@ -1,7 +1,5 @@
TOOL.Name = "SDKServer"

TOOL.CopyTargetToExampleDir = true

TOOL.Directory = "../SDK/lib"
TOOL.Kind = "Library"

Expand All @@ -23,7 +21,7 @@ TOOL.Files = {
"../SDK/src/NDK/**.cpp"
}

-- Exlude client-only files
-- Excludes client-only files
TOOL.FilesExcluded = {
"../SDK/**/CameraComponent.*",
"../SDK/**/Console.*",
Expand Down
3 changes: 2 additions & 1 deletion build/scripts/tools/unittests.lua
@@ -1,7 +1,8 @@
TOOL.Name = "UnitTests"

TOOL.Directory = "../tests"
TOOL.Kind = "ConsoleApp"
TOOL.EnableConsole = true
TOOL.Kind = "Application"

TOOL.Defines = {
}
Expand Down
2 changes: 1 addition & 1 deletion examples/DopplerEffect/build.lua
@@ -1,6 +1,6 @@
EXAMPLE.Name = "DopplerEffect"

EXAMPLE.Console = true
EXAMPLE.EnableConsole = true

EXAMPLE.Files = {
"main.cpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/FirstScene/build.lua
@@ -1,6 +1,6 @@
EXAMPLE.Name = "FirstScene"

EXAMPLE.Console = true
EXAMPLE.EnableConsole = true

EXAMPLE.Files = {
"main.cpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/MeshInfos/build.lua
@@ -1,6 +1,6 @@
EXAMPLE.Name = "MeshInfos"

EXAMPLE.Console = true
EXAMPLE.EnableConsole = true

EXAMPLE.Files = {
"main.cpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/Tut00/build.lua
@@ -1,6 +1,6 @@
EXAMPLE.Name = "Tut00_EmptyProject"

EXAMPLE.Console = true
EXAMPLE.EnableConsole = true

EXAMPLE.Files = {
"main.cpp"
Expand Down
2 changes: 1 addition & 1 deletion examples/Tut01/build.lua
@@ -1,6 +1,6 @@
EXAMPLE.Name = "Tut01_HelloWorld"

EXAMPLE.Console = true
EXAMPLE.EnableConsole = true

EXAMPLE.Files = {
"main.cpp"
Expand Down

0 comments on commit d8fea94

Please sign in to comment.