diff --git a/build/scripts/actions/codeblocks.lua b/build/scripts/actions/codeblocks.lua new file mode 100644 index 000000000..2a1f8b249 --- /dev/null +++ b/build/scripts/actions/codeblocks.lua @@ -0,0 +1,6 @@ +if (PremakeVersion >= 50) then + dofile("codeblocks/_codeblocks.lua") + dofile("codeblocks/codeblocks.lua") +end + +ACTION.Manual = true diff --git a/build/scripts/actions/codeblocks/_codeblocks.lua b/build/scripts/actions/codeblocks/_codeblocks.lua new file mode 100644 index 000000000..6a52bc404 --- /dev/null +++ b/build/scripts/actions/codeblocks/_codeblocks.lua @@ -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 + } diff --git a/build/scripts/actions/codeblocks/codeblocks.lua b/build/scripts/actions/codeblocks/codeblocks.lua new file mode 100644 index 000000000..ebd8d11fa --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks.lua @@ -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('<', '<') + result = result:gsub('>', '>') + 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") + + diff --git a/build/scripts/actions/codeblocks/codeblocks_project.lua b/build/scripts/actions/codeblocks/codeblocks_project.lua new file mode 100644 index 000000000..9882d5fbe --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks_project.lua @@ -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('') + _p('') + _p(1,'') + + -- write project block header + _p(1,'') + _p(2,'') + _p('') + 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,'') + 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,'', cfg.longname) + + _p(4,'') + end + end + _p(2,'') + 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,'', node.relpath) + else + _p(2,'', node.name) + _p(3,'') + + 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,'') + _p(4,'', 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 .. ' ' end + end + _p(5,'',args) + _p(4,'') + _p(3,'') + else + error('Sorry at this moment there is no support for debug environment variables with this debugger and codeblocks') + end + end + end + end diff --git a/build/scripts/actions/codeblocks/codeblocks_workspace.lua b/build/scripts/actions/codeblocks/codeblocks_workspace.lua new file mode 100644 index 000000000..3de935877 --- /dev/null +++ b/build/scripts/actions/codeblocks/codeblocks_workspace.lua @@ -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('') + _p('') + _p(1,'', 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,'', fname, active) + for _,dep in ipairs(project.getdependencies(prj)) do + _p(3,'', path.join(path.getrelative(wks.location, dep.location), dep.name)) + end + + _p(2,'') + end + + _p(1,'') + _p('') + end \ No newline at end of file diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 423ebad0d..42a565fd6 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -14,6 +14,12 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end + if (PremakeVersion >= 50) then + filter { "kind:SharedLib", "action:codeblocks or codelite or gmake or xcode3 or xcode4" } + implibprefix "lib" + implibextension ".a" + end + local platformData if (os.is64bit()) then platformData = {"x64", "x32"} @@ -721,7 +727,7 @@ function NazaraBuild:MakeInstallCommands(infoTable) 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 @@ -877,40 +883,38 @@ function NazaraBuild:Process(infoTable) 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