Merge branch 'master' into culling

This commit is contained in:
Jérôme Leclercq
2016-11-07 11:26:48 +01:00
85 changed files with 2580 additions and 1234 deletions

View File

@@ -0,0 +1,4 @@
dofile("codeblocks/_codeblocks.lua")
dofile("codeblocks/codeblocks.lua")
ACTION.Manual = true

View File

@@ -0,0 +1,44 @@
--
-- _codeblocks.lua
-- Define the Code::Blocks action(s).
-- Copyright (c) 2002-2011 Jason Perkins and the Premake project
--
local p = premake
p.modules.codeblocks = {}
p.modules.codeblocks._VERSION = p._VERSION
local codeblocks = p.modules.codeblocks
newaction {
trigger = "codeblocks",
shortname = "Code::Blocks",
description = "Generate Code::Blocks project files",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C", "C++" },
valid_tools = {
cc = { "clang", "gcc", "ow" },
},
onWorkspace = function(wks)
p.modules.codeblocks.generateWorkspace(wks)
end,
onProject = function(prj)
p.modules.codeblocks.generateProject(prj)
end,
onCleanWorkspace = function(wks)
p.clean.file(wks, wks.name .. ".workspace")
p.clean.file(wks, wks.name .. ".workspace.layout")
end,
onCleanProject = function(prj)
p.clean.file(prj, prj.name .. ".workspace")
p.clean.file(prj, prj.name .. ".depend")
p.clean.file(prj, prj.name .. ".layout")
end
}

View File

@@ -0,0 +1,67 @@
--
-- codeblocks_workspace.lua
-- Generate a Code::Blocks workspace.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
local p = premake
p.modules.codeblocks = {}
p.modules.codeblocks._VERSION = p._VERSION
local codeblocks = p.modules.codeblocks
local project = p.project
function codeblocks.cfgname(cfg)
local cfgname = cfg.buildcfg
if codeblocks.workspace.multiplePlatforms then
cfgname = string.format("%s|%s", cfg.platform, cfg.buildcfg)
end
return cfgname
end
function codeblocks.esc(value)
local result = value:gsub('"', '"')
result = result:gsub('<', '&lt;')
result = result:gsub('>', '&gt;')
return result
end
function codeblocks.generateWorkspace(wks)
p.eol("\r\n")
p.indent("\t")
p.escaper(codeblocks.esc)
p.generate(wks, ".workspace", codeblocks.workspace.generate)
end
function codeblocks.generateProject(prj)
p.eol("\r\n")
p.indent("\t")
p.escaper(codeblocks.esc)
if project.iscpp(prj) then
p.generate(prj, ".cbp", codeblocks.project.generate)
end
end
function codeblocks.cleanWorkspace(wks)
p.clean.file(wks, wks.name .. ".workspace")
p.clean.file(wks, wks.name .. ".workspace.layout")
end
function codeblocks.cleanProject(prj)
p.clean.file(prj, prj.name .. ".workspace")
p.clean.file(prj, prj.name .. ".depend")
p.clean.file(prj, prj.name .. ".layout")
end
function codeblocks.cleanTarget(prj)
-- TODO..
end
include("codeblocks_workspace.lua")
include("codeblocks_project.lua")

View File

@@ -0,0 +1,243 @@
--
-- codeblocks_cbp.lua
-- Generate a Code::Blocks C/C++ project.
-- Copyright (c) 2009, 2011 Jason Perkins and the Premake project
--
local p = premake
local project = p.project
local config = p.config
local tree = p.tree
local codeblocks = p.modules.codeblocks
codeblocks.project = {}
local m = codeblocks.project
m.elements = {}
m.ctools = {
gcc = "gcc",
msc = "Visual C++",
}
function m.getcompilername(cfg)
local tool = _OPTIONS.cc or cfg.toolset or p.GCC
local toolset = p.tools[tool]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
return m.ctools[tool]
end
function m.getcompiler(cfg)
local toolset = p.tools[_OPTIONS.cc or cfg.toolset or p.GCC]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
return toolset
end
function m.header(prj)
_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
_p('<CodeBlocks_project_file>')
_p(1,'<FileVersion major="1" minor="6" />')
-- write project block header
_p(1,'<Project>')
_p(2,'<Option title="%s" />', prj.name)
_p(2,'<Option pch_mode="2" />')
end
function m.footer(prj)
-- write project block footer
_p(1,'</Project>')
_p('</CodeBlocks_project_file>')
end
m.elements.project = function(prj)
return {
m.header,
m.configurations,
m.files,
m.extensions,
m.footer
}
end
--
-- Project: Generate the CodeBlocks project file.
--
function m.generate(prj)
p.utf8()
p.callArray(m.elements.project, prj)
end
function m.configurations(prj)
-- write configuration blocks
_p(2,'<Build>')
local platforms = {}
for cfg in project.eachconfig(prj) do
local found = false
for k,v in pairs(platforms) do
if (v.platform == cfg.platform) then
table.insert(v.configs, cfg)
found = true
break
end
end
if (not found) then
table.insert(platforms, {platform = cfg.platform, configs = {cfg}})
end
end
for k,platform in pairs(platforms) do
for k,cfg in pairs(platform.configs) do
local compiler = m.getcompiler(cfg)
_p(3,'<Target title="%s">', cfg.longname)
_p(4,'<Option output="%s" prefix_auto="0" extension_auto="0" />', p.esc(cfg.buildtarget.relpath))
if cfg.debugdir then
_p(4,'<Option working_dir="%s" />', p.esc(path.getrelative(prj.location, cfg.debugdir)))
end
_p(4,'<Option object_output="%s" />', p.esc(path.getrelative(prj.location, cfg.objdir)))
-- identify the type of binary
local types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }
_p(4,'<Option type="%d" />', types[cfg.kind])
_p(4,'<Option compiler="%s" />', m.getcompilername(cfg))
if (cfg.kind == "SharedLib") then
_p(4,'<Option createDefFile="0" />')
_p(4,'<Option createStaticLib="%s" />', iif(cfg.flags.NoImportLib, 0, 1))
end
-- begin compiler block --
_p(4,'<Compiler>')
for _,flag in ipairs(table.join(compiler.getcflags(cfg), compiler.getcxxflags(cfg), compiler.getdefines(cfg.defines), cfg.buildoptions)) do
_p(5,'<Add option="%s" />', p.esc(flag))
end
if not cfg.flags.NoPCH and cfg.pchheader then
_p(5,'<Add option="-Winvalid-pch" />')
_p(5,'<Add option="-include &quot;%s&quot;" />', p.esc(cfg.pchheader))
end
for _,v in ipairs(cfg.includedirs) do
_p(5,'<Add directory="%s" />', p.esc(path.getrelative(prj.location, v)))
end
_p(4,'</Compiler>')
-- end compiler block --
-- begin linker block --
_p(4,'<Linker>')
for _,flag in ipairs(table.join(compiler.getldflags(cfg), cfg.linkoptions)) do
_p(5,'<Add option="%s" />', p.esc(flag))
end
for _,v in ipairs(config.getlinks(cfg, "all", "directory")) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
for _,v in ipairs(config.getlinks(cfg, "all", "basename")) do
_p(5,'<Add library="%s" />', p.esc(v))
end
_p(4,'</Linker>')
-- end linker block --
-- begin resource compiler block --
if config.findfile(cfg, ".rc") then
_p(4,'<ResourceCompiler>')
for _,v in ipairs(cfg.includedirs) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
for _,v in ipairs(cfg.resincludedirs) do
_p(5,'<Add directory="%s" />', p.esc(v))
end
_p(4,'</ResourceCompiler>')
end
-- end resource compiler block --
-- begin build steps --
if #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then
_p(4,'<ExtraCommands>')
for _,v in ipairs(cfg.prebuildcommands) do
_p(5,'<Add before="%s" />', p.esc(v))
end
for _,v in ipairs(cfg.postbuildcommands) do
_p(5,'<Add after="%s" />', p.esc(v))
end
_p(4,'</ExtraCommands>')
end
-- end build steps --
_p(3,'</Target>')
end
end
_p(2,'</Build>')
end
--
-- Write out a list of the source code files in the project.
--
function m.files(prj)
local pchheader
if (prj.pchheader) then
pchheader = path.getrelative(prj.location, prj.pchheader)
end
local tr = project.getsourcetree(prj)
tree.traverse(tr, {
-- source files are handled at the leaves
onleaf = function(node, depth)
if node.relpath == node.vpath then
_p(2,'<Unit filename="%s">', node.relpath)
else
_p(2,'<Unit filename="%s">', node.name)
_p(3,'<Option virtualFolder="%s" />', path.getdirectory(node.vpath))
end
if path.isresourcefile(node.name) then
_p(3,'<Option compilerVar="WINDRES" />')
elseif path.iscfile(node.name) and prj.language == "C++" then
_p(3,'<Option compilerVar="CC" />')
end
if not prj.flags.NoPCH and node.name == pchheader then
_p(3,'<Option compilerVar="%s" />', iif(prj.language == "C", "CC", "CPP"))
_p(3,'<Option compile="1" />')
_p(3,'<Option weight="0" />')
_p(3,'<Add option="-x c++-header" />')
end
_p(2,'</Unit>')
end,
}, false, 1)
end
function m.extensions(prj)
for cfg in project.eachconfig(prj) do
if cfg.debugenvs and #cfg.debugenvs > 0 then
--Assumption: if gcc is being used then so is gdb although this section will be ignored by
--other debuggers. If using gcc and not gdb it will silently not pass the
--environment arguments to the debugger
if m.getcompilername(cfg) == "gcc" then
_p(3,'<debugger>')
_p(4,'<remote_debugging target="%s">', p.esc(cfg.longname))
local args = ''
local sz = #cfg.debugenvs
for idx, v in ipairs(cfg.debugenvs) do
args = args .. 'set env ' .. v
if sz ~= idx then args = args .. '&#x0A;' end
end
_p(5,'<options additional_cmds_before="%s" />',args)
_p(4,'</remote_debugging>')
_p(3,'</debugger>')
else
error('Sorry at this moment there is no support for debug environment variables with this debugger and codeblocks')
end
end
end
end

View File

@@ -0,0 +1,44 @@
--
-- Name: codelite/codelite_workspace.lua
-- Purpose: Generate a CodeLite workspace.
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Manu Evans
-- Created: 2013/05/06
-- Copyright: (c) 2008-2015 Jason Perkins and the Premake project
--
local p = premake
local project = p.project
local workspace = p.workspace
local tree = p.tree
local codeblocks = p.modules.codeblocks
codeblocks.workspace = {}
local m = codeblocks.workspace
--
-- Generate a CodeBlocks workspace
--
function m.generate(wks)
p.utf8()
_p('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>')
_p('<CodeBlocks_workspace_file>')
_p(1,'<Workspace title="%s">', wks.name)
for prj in workspace.eachproject(wks) do
local fname = path.join(path.getrelative(wks.location, prj.location), prj.name)
local active = iif(prj.project == wks.projects[1], ' active="1"', '')
_p(2,'<Project filename="%s.cbp"%s>', fname, active)
for _,dep in ipairs(project.getdependencies(prj)) do
_p(3,'<Depends filename="%s.cbp" />', path.join(path.getrelative(wks.location, dep.location), dep.name))
end
_p(2,'</Project>')
end
_p(1,'</Workspace>')
_p('</CodeBlocks_workspace_file>')
end

View File

@@ -67,7 +67,7 @@ ACTION.Function = function ()
error("Failed to create header file (" .. v.Target .. "): " .. err)
end
header:write("// This file was automatically generated on " .. os.date("%d %b %Y at %X") .. "\n\n")
header:write("// This file was automatically generated\n\n")
if (v.Header) then
header:write(v.Header)
end

View File

@@ -1,4 +1,7 @@
NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table
NazaraBuild = {}
-- I wish Premake had a way to know the compiler in advance
local clangGccActions = "action:" .. table.concat({"codeblocks", "codelite", "gmake", "xcode3", "xcode4"}, " or ")
function NazaraBuild:AddExecutablePath(path)
self.ExecutableDir[path] = true
@@ -9,21 +12,47 @@ function NazaraBuild:AddInstallPath(path)
self.InstallDir[path] = true
end
function NazaraBuild:FilterLibDirectory(prefix, func)
filter({"action:codeblocks or codelite or gmake", "architecture:x86", "system:Windows"})
func(prefix .. "mingw/x86")
filter({"action:codeblocks or codelite or gmake", "architecture:x86_64", "system:Windows"})
func(prefix .. "mingw/x64")
filter({"action:codeblocks or codelite or gmake", "architecture:x86", "system:not Windows"})
func(prefix .. "gmake/x86")
filter({"action:codeblocks or codelite or gmake", "architecture:x86_64", "system:not Windows"})
func(prefix .. "gmake/x64")
filter({"action:vs*", "architecture:x86"})
func(prefix .. "msvc/x86")
filter({"action:vs*", "architecture:x86_64"})
func(prefix .. "msvc/x64")
filter({"action:xcode3 or xcode4", "architecture:x86"})
func(prefix .. "xcode/x86")
filter({"action:xcode3 or xcode4", "architecture:x86_64"})
func(prefix .. "xcode/x64")
filter({})
end
function NazaraBuild:Execute()
if (_ACTION == nil) then -- Si aucune action n'est spécifiée
if (_ACTION == nil) then -- If no action is specified, the user probably only wants to know how all of this works
return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien
end
local platformData
if (os.is64bit()) then
platformData = {"x64", "x32"}
platformData = {"x64", "x86"}
else
platformData = {"x32", "x64"}
platformData = {"x86", "x64"}
end
if (self.Actions[_ACTION] == nil) then
local makeLibDir = os.is("windows") and "mingw" or "gmake"
if (self.Config["BuildDependencies"]) then
workspace("NazaraExtlibs")
platforms(platformData)
@@ -34,63 +63,19 @@ function NazaraBuild:Execute()
"ReleaseStatic"
})
self:PrepareGeneric()
self:FilterLibDirectory("../extlibs/lib/", targetdir)
filter(clangGccActions)
buildoptions("-U__STRICT_ANSI__")
filter({})
includedirs("../extlibs/include")
libdirs("../extlibs/lib/common")
location(_ACTION)
kind("StaticLib")
configuration({"codeblocks or codelite or gmake", "x32"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
targetdir("../extlibs/lib/" .. makeLibDir .. "/x86")
configuration({"codeblocks or codelite or gmake", "x64"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
targetdir("../extlibs/lib/" .. makeLibDir .. "/x64")
configuration("vs*")
buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj
configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86")
targetdir("../extlibs/lib/msvc/x86")
configuration({"vs*", "x64"})
libdirs("../extlibs/lib/msvc/x64")
targetdir("../extlibs/lib/msvc/x64")
configuration({"xcode3 or xcode4", "x32"})
libdirs("../extlibs/lib/xcode/x86")
targetdir("../extlibs/lib/xcode/x86")
configuration({"xcode3 or xcode4", "x64"})
libdirs("../extlibs/lib/xcode/x64")
targetdir("../extlibs/lib/xcode/x64")
configuration("Debug*")
flags("Symbols")
configuration("Release*")
flags("NoFramePointer")
optimize("Speed")
rtti("Off")
vectorextensions("SSE2")
configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"})
buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants
buildoptions("-ftree-vectorize") -- Activation de la vectorisation du code
configuration("DebugStatic")
targetsuffix("-s-d")
configuration("ReleaseStatic")
targetsuffix("-s")
configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"})
buildoptions("-fPIC")
configuration("codeblocks or codelite or gmake or xcode3 or xcode4")
buildoptions({"-std=c++14", "-U__STRICT_ANSI__"})
for k, libTable in ipairs(self.OrderedExtLibs) do
project(libTable.Name)
@@ -105,25 +90,30 @@ function NazaraBuild:Execute()
includedirs(libTable.Includes)
links(libTable.Libraries)
configuration("x32")
filter("architecture:x86")
libdirs(libTable.LibraryPaths.x86)
configuration("x64")
filter("architecture:x86_64")
libdirs(libTable.LibraryPaths.x64)
for k,v in pairs(libTable.ConfigurationLibraries) do
configuration(k)
links(v)
filter(k)
links(v)
end
configuration({})
filter({})
end
end
-- Start defining projects
workspace("NazaraEngine")
platforms(platformData)
-- Configuration générale
self:PrepareMainWorkspace()
-- Add lib/conf/arch to library search path
self:FilterLibDirectory("../lib/", libdirs)
configurations({
-- "DebugStatic",
-- "ReleaseStatic",
@@ -134,36 +124,7 @@ function NazaraBuild:Execute()
language("C++")
location(_ACTION)
configuration("Debug*")
defines("NAZARA_DEBUG")
flags("Symbols")
configuration("Release*")
flags("NoFramePointer")
optimize("Speed")
vectorextensions("SSE2")
configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"})
buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants
buildoptions("-ftree-vectorize") -- Activation de la vectorisation du code
configuration("*Static")
defines("NAZARA_STATIC")
configuration("codeblocks or codelite or gmake or xcode3 or xcode4")
buildoptions("-std=c++14")
configuration({"linux or bsd or macosx", "gmake"})
buildoptions("-fvisibility=hidden")
configuration("vs*")
buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj
flags("NoMinimalRebuild")
defines("_CRT_SECURE_NO_WARNINGS")
defines("_SCL_SECURE_NO_WARNINGS")
-- Spécification des modules
-- Modules
if (_OPTIONS["united"]) then
project("NazaraEngine")
end
@@ -175,78 +136,12 @@ function NazaraBuild:Execute()
location(_ACTION .. "/modules")
defines("NAZARA_BUILD")
includedirs({
"../include",
"../src/",
"../extlibs/include"
})
libdirs("../lib")
libdirs("../extlibs/lib/common")
configuration("x32")
libdirs(moduleTable.LibraryPaths.x86)
configuration("x64")
defines("NAZARA_PLATFORM_x64")
libdirs(moduleTable.LibraryPaths.x64)
configuration({"codeblocks or codelite or gmake", "x32"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
libdirs("../lib/" .. makeLibDir .. "/x86")
targetdir("../lib/" .. makeLibDir .. "/x86")
configuration({"codeblocks or codelite or gmake", "x64"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
libdirs("../lib/" .. makeLibDir .. "/x64")
targetdir("../lib/" .. makeLibDir .. "/x64")
-- Copy the module binaries to the example folder
self:MakeInstallCommands(moduleTable)
configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86")
libdirs("../lib/msvc/x86")
targetdir("../lib/msvc/x86")
configuration({"vs*", "x64"})
libdirs("../extlibs/lib/msvc/x64")
libdirs("../lib/msvc/x64")
targetdir("../lib/msvc/x64")
configuration({"xcode3 or xcode4", "x32"})
libdirs("../extlibs/lib/xcode/x86")
libdirs("../lib/xcode/x86")
targetdir("../lib/xcode/x86")
configuration({"xcode3 or xcode4", "x64"})
libdirs("../extlibs/lib/xcode/x64")
libdirs("../lib/xcode/x64")
targetdir("../lib/xcode/x64")
configuration("*Static")
defines("NAZARA_STATIC")
kind("StaticLib")
configuration("*Dynamic")
kind("SharedLib")
configuration("DebugStatic")
targetsuffix("-s-d")
configuration("ReleaseStatic")
targetsuffix("-s")
configuration("DebugDynamic")
targetsuffix("-d")
configuration("Release*")
rtti(moduleTable.EnableRTTI and "On" or "Off")
configuration({})
files(moduleTable.Files)
excludes(moduleTable.FilesExcluded)
@@ -255,12 +150,29 @@ function NazaraBuild:Execute()
includedirs(moduleTable.Includes)
links(moduleTable.Libraries)
libdirs({
"../extlibs/lib/common",
"../lib"
})
-- Output to lib/conf/arch
self:FilterLibDirectory("../lib/", targetdir)
-- Copy the module binaries to the example folder
self:MakeInstallCommands(moduleTable)
filter("architecture:x86")
libdirs(moduleTable.LibraryPaths.x86)
filter("architecture:x86_64")
libdirs(moduleTable.LibraryPaths.x64)
for k,v in pairs(moduleTable.ConfigurationLibraries) do
configuration(k)
filter(k)
links(v)
end
configuration({})
filter({})
end
-- Tools
@@ -288,7 +200,7 @@ function NazaraBuild:Execute()
kind("WindowedApp")
end
else
assert(false, "Invalid tool Kind")
assert(false, "Invalid tool kind")
end
includedirs({
@@ -296,94 +208,10 @@ function NazaraBuild:Execute()
"../extlibs/include"
})
libdirs("../lib")
libdirs("../extlibs/lib/common")
configuration("x32")
libdirs(toolTable.LibraryPaths.x86)
configuration("x64")
defines("NAZARA_PLATFORM_x64")
libdirs(toolTable.LibraryPaths.x64)
configuration({"codeblocks or codelite or gmake", "x32"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
libdirs("../lib/" .. makeLibDir .. "/x86")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/" .. makeLibDir .. "/x86")
end
configuration({"codeblocks or codelite or gmake", "x64"})
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
libdirs("../lib/" .. makeLibDir .. "/x64")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/" .. makeLibDir .. "/x64")
end
configuration({"vs*", "x32"})
libdirs("../extlibs/lib/msvc/x86")
libdirs("../lib/msvc/x86")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/msvc/x86")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/msvc/x86")
end
configuration({"vs*", "x64"})
libdirs("../extlibs/lib/msvc/x64")
libdirs("../lib/msvc/x64")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/msvc/x64")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/msvc/x64")
end
configuration({"xcode3 or xcode4", "x32"})
libdirs("../extlibs/lib/xcode/x86")
libdirs("../lib/xcode/x86")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/xcode/x86")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/xcode/x86")
end
configuration({"xcode3 or xcode4", "x64"})
libdirs("../extlibs/lib/xcode/x64")
libdirs("../lib/xcode/x64")
if (toolTable.Kind == "library") then
targetdir(toolTable.TargetDirectory .. "/xcode/x64")
elseif (toolTable.Kind == "plugin") then
targetdir("../plugins/lib/xcode/x64")
end
configuration("*Static")
defines("NAZARA_STATIC")
configuration("Release*")
rtti(toolTable.EnableRTTI and "On" or "Off")
if (toolTable.Kind == "library" or toolTable.Kind == "plugin") then
configuration("*Static")
kind("StaticLib")
configuration("*Dynamic")
kind("SharedLib")
configuration("DebugStatic")
targetsuffix("-s-d")
configuration("ReleaseStatic")
targetsuffix("-s")
configuration("DebugDynamic")
targetsuffix("-d")
end
configuration({})
libdirs({
"../extlibs/lib/common",
"../lib"
})
files(toolTable.Files)
excludes(toolTable.FilesExcluded)
@@ -393,12 +221,25 @@ function NazaraBuild:Execute()
includedirs(toolTable.Includes)
links(toolTable.Libraries)
-- Output to lib/conf/arch
if (toolTable.Kind == "library") then
self:FilterLibDirectory(toolTable.TargetDirectory .. "/", targetdir)
elseif (toolTable.Kind == "plugin") then
self:FilterLibDirectory("../plugins/lib/", targetdir)
end
filter("architecture:x86")
libdirs(toolTable.LibraryPaths.x86)
filter("architecture:x86_64")
libdirs(toolTable.LibraryPaths.x64)
for k,v in pairs(toolTable.ConfigurationLibraries) do
configuration(k)
filter(k)
links(v)
end
configuration({})
filter({})
end
for k, exampleTable in ipairs(self.OrderedExamples) do
@@ -429,7 +270,6 @@ function NazaraBuild:Execute()
"../extlibs/include"
})
libdirs("../lib")
targetdir(destPath)
files(exampleTable.Files)
excludes(exampleTable.FilesExcluded)
@@ -438,41 +278,14 @@ function NazaraBuild:Execute()
flags(exampleTable.Flags)
includedirs(exampleTable.Includes)
links(exampleTable.Libraries)
configuration("Release*")
rtti(exampleTable.EnableRTTI and "On" or "Off")
configuration("x32")
libdirs(exampleTable.LibraryPaths.x86)
configuration("x64")
defines("NAZARA_PLATFORM_x64")
libdirs(exampleTable.LibraryPaths.x64)
configuration({"codeblocks or codelite or gmake", "x32"})
libdirs("../lib/" .. makeLibDir .. "/x86")
configuration({"codeblocks or codelite or gmake", "x64"})
libdirs("../lib/" .. makeLibDir .. "/x64")
configuration({"vs*", "x32"})
libdirs("../lib/msvc/x86")
configuration({"vs*", "x64"})
libdirs("../lib/msvc/x64")
configuration({"xcode3 or xcode4", "x32"})
libdirs("../lib/xcode/x86")
configuration({"xcode3 or xcode4", "x64"})
libdirs("../lib/xcode/x64")
targetdir(destPath)
for k,v in pairs(exampleTable.ConfigurationLibraries) do
configuration(k)
filter(k)
links(v)
end
configuration({})
filter({})
end
end
end
@@ -712,39 +525,37 @@ function NazaraBuild:LoadConfig()
end
function NazaraBuild:MakeInstallCommands(infoTable)
if (PremakeVersion < 50) then
return
end
if (os.is("windows")) then
configuration("*Dynamic")
filter("kind:SharedLib")
postbuildmessage("Copying " .. infoTable.Name .. " library and its dependencies to install/executable directories...")
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]]})
postbuildcommands({[[xcopy "%{path.translate(cfg.buildtarget.relpath)}" "]] .. destPath .. [[\" /E /Y]]})
end
for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do
local paths = {}
for k,v in pairs(infoTable.BinaryPaths.x86) do
table.insert(paths, {"x32", v .. "/" .. fileName .. ".dll"})
table.insert(paths, {"x32", v .. "/lib" .. fileName .. ".dll"})
table.insert(paths, {"x86", v .. "/" .. fileName .. ".dll"})
table.insert(paths, {"x86", v .. "/lib" .. fileName .. ".dll"})
end
for k,v in pairs(infoTable.BinaryPaths.x64) do
table.insert(paths, {"x64", v .. "/" .. fileName .. ".dll"})
table.insert(paths, {"x64", v .. "/lib" .. fileName .. ".dll"})
table.insert(paths, {"x86_64", v .. "/" .. fileName .. ".dll"})
table.insert(paths, {"x86_64", v .. "/lib" .. fileName .. ".dll"})
end
for k,v in pairs(paths) do
local config = v[1]
local arch = v[1]
local srcPath = v[2]
if (os.isfile(srcPath)) then
if (infoTable.Kind == "plugin") then
srcPath = "../../" .. srcPath
end
configuration(config)
filter("architecture:" .. arch)
for k,v in pairs(self.ExecutableDir) do
local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]]
@@ -754,6 +565,8 @@ function NazaraBuild:MakeInstallCommands(infoTable)
end
end
end
filter({})
end
end
@@ -876,41 +689,123 @@ function NazaraBuild:Process(infoTable)
return true
end
function NazaraBuild:PrepareGeneric()
flags({
"C++14",
"MultiProcessorCompile",
"NoMinimalRebuild"
})
self:FilterLibDirectory("../extlibs/lib/", libdirs)
-- Fixes Premake stuff
filter({"kind:SharedLib", clangGccActions})
implibprefix("lib")
filter({"kind:*Lib", clangGccActions, "system:Windows"})
implibextension(".a")
filter({"kind:StaticLib", clangGccActions})
targetextension(".a")
targetprefix("lib")
-- General configuration
filter("kind:*Lib")
pic("On")
filter({"kind:*Lib", "configurations:DebugStatic"})
targetsuffix("-s-d")
filter({"kind:*Lib", "configurations:ReleaseStatic"})
targetsuffix("-s")
filter({"kind:*Lib", "configurations:DebugDynamic"})
targetsuffix("-d")
filter("configurations:Debug*")
symbols("On")
-- Setup some optimizations for release
filter("configurations:Release*")
flags("NoFramePointer")
optimize("Speed")
rtti("Off")
vectorextensions("SSE2")
filter("configurations:*Static")
kind("StaticLib")
filter("configurations:*Dynamic")
kind("SharedLib")
-- Enable SSE math and vectorization optimizations
filter({"configurations:Release*", clangGccActions})
buildoptions("-mfpmath=sse")
buildoptions("-ftree-vectorize")
filter({})
end
function NazaraBuild:PrepareMainWorkspace()
self:PrepareGeneric()
filter("action:vs*")
buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj
defines("_CRT_SECURE_NO_WARNINGS")
defines("_SCL_SECURE_NO_WARNINGS")
filter("architecture:x86_64")
defines("NAZARA_PLATFORM_x64")
filter("configurations:Debug*")
defines("NAZARA_DEBUG")
filter("configurations:*Static")
defines("NAZARA_STATIC")
filter("kind:*Lib")
defines("NAZARA_BUILD")
filter({"system:Windows", clangGccActions})
buildoptions("-Wa,-mbig-obj") -- big object
filter({"system:not Windows", clangGccActions})
buildoptions("-fvisibility=hidden")
filter({})
end
function NazaraBuild:RegisterAction(actionTable)
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
return false, "Invalid action name"
if (not actionTable.Manual) then
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
return false, "Invalid action name"
end
local lowerCaseName = string.lower(actionTable.Name)
if (self.Actions[lowerCaseName] ~= nil) then
return false, "This action name is already in use"
end
if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then
return false, "Action description is invalid"
end
if (string.len(actionTable.Description) == 0) then
return false, "Action description is empty"
end
if (actionTable.Function == nil or type(actionTable.Function) ~= "function") then
return false, "Action function is invalid"
end
self.Actions[lowerCaseName] = actionTable
newaction
{
trigger = lowerCaseName,
description = actionTable.Description,
execute = function () actionTable:Function() end
}
end
local lowerCaseName = string.lower(actionTable.Name)
if (self.Actions[lowerCaseName] ~= nil) then
return false, "This action name is already in use"
end
if (actionTable.Description == nil or type(actionTable.Description) ~= "string") then
return false, "Action description is invalid"
end
if (string.len(actionTable.Description) == 0) then
return false, "Action description is empty"
end
if (self.Actions[actionTable.name] ~= nil) then
return false, "Action name \"" .. actionTable.name .. " is already registred"
end
if (actionTable.Function == nil or type(actionTable.Function) ~= "function") then
return false, "Action function is invalid"
end
self.Actions[lowerCaseName] = actionTable
newaction
{
trigger = lowerCaseName,
description = actionTable.Description,
execute = function () actionTable:Function() end
}
return true
end