Initial community commit

This commit is contained in:
Jef 2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit fc06254474
16440 changed files with 4239995 additions and 2 deletions

View file

@ -0,0 +1,13 @@
Premake extension to support the [CodeLite](http://www.codelite.org/) IDE
### Features ###
* Support for C/C++ language projects
### Usage ###
Simply generate your project using the `codelite` action:
```bash
premake5 codelite
```
and open the generated project file in CodeLite.

View file

@ -0,0 +1,6 @@
return {
"_preload.lua",
"codelite.lua",
"codelite_workspace.lua",
"codelite_project.lua",
}

View file

@ -0,0 +1,58 @@
--
-- Name: codelite/_preload.lua
-- Purpose: Define the CodeLite action.
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Andrew Gough
-- Manu Evans
-- Created: 2013/05/06
-- Copyright: (c) 2008-2015 Jason Perkins and the Premake project
--
local p = premake
newaction
{
-- Metadata for the command line and help system
trigger = "codelite",
shortname = "CodeLite",
description = "Generate CodeLite project files",
toolset = "clang",
-- The capabilities of this action
valid_kinds = { "ConsoleApp", "WindowedApp", "Makefile", "SharedLib", "StaticLib", "Utility" },
valid_languages = { "C", "C++" },
valid_tools = {
cc = { "gcc", "clang", "msc" }
},
-- Workspace and project generation logic
onWorkspace = function(wks)
p.modules.codelite.generateWorkspace(wks)
end,
onProject = function(prj)
p.modules.codelite.generateProject(prj)
end,
onCleanWorkspace = function(wks)
p.modules.codelite.cleanWorkspace(wks)
end,
onCleanProject = function(prj)
p.modules.codelite.cleanProject(prj)
end,
onCleanTarget = function(prj)
p.modules.codelite.cleanTarget(prj)
end,
}
--
-- Decide when the full module should be loaded.
--
return function(cfg)
return (_ACTION == "codelite")
end

View file

@ -0,0 +1,86 @@
--
-- Name: codelite/codelite.lua
-- Purpose: Define the CodeLite action(s).
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Andrew Gough
-- Manu Evans
-- Jason Perkins
-- Created: 2013/05/06
-- Copyright: (c) 2008-2020 Jason Perkins and the Premake project
--
local p = premake
p.modules.codelite = {}
p.modules.codelite._VERSION = p._VERSION
local codelite = p.modules.codelite
local project = p.project
function codelite.cfgname(cfg)
local cfgname = cfg.buildcfg
if codelite.workspace.multiplePlatforms then
-- Codelite breaks if "|" is used here, see #1411
cfgname = string.format("%s-%s", cfg.platform, cfg.buildcfg)
end
return cfgname
end
-- Element text is not escaped the same as element attributes
function codelite.escElementText(value)
local result = value:gsub('&', '&')
result = result:gsub('<', '&lt;')
result = result:gsub('>', '&gt;')
return result
end
function codelite.esc(value)
local result = value:gsub('&', '&amp;')
result = result:gsub('<', '&lt;')
result = result:gsub('>', '&gt;')
result = result:gsub('"', '&quot;')
return result
end
function codelite.generateWorkspace(wks)
p.eol("\r\n")
p.indent(" ")
p.escaper(codelite.esc)
p.generate(wks, ".workspace", codelite.workspace.generate)
end
function codelite.generateProject(prj)
p.eol("\r\n")
p.indent(" ")
p.escaper(codelite.esc)
if project.isc(prj) or project.iscpp(prj) then
p.generate(prj, ".project", codelite.project.generate)
end
end
function codelite.cleanWorkspace(wks)
p.clean.file(wks, wks.name .. ".workspace")
p.clean.file(wks, wks.name .. "_wsp.mk")
p.clean.file(wks, wks.name .. ".tags")
p.clean.file(wks, ".clang")
end
function codelite.cleanProject(prj)
p.clean.file(prj, prj.name .. ".project")
p.clean.file(prj, prj.name .. ".mk")
p.clean.file(prj, prj.name .. ".list")
p.clean.file(prj, prj.name .. ".out")
end
function codelite.cleanTarget(prj)
-- TODO..
end
include("codelite_workspace.lua")
include("codelite_project.lua")
return codelite

View file

@ -0,0 +1,529 @@
--
-- Name: codelite/codelite_project.lua
-- Purpose: Generate a CodeLite C/C++ project file.
-- Author: Ryan Pusztai
-- Modified by: Andrea Zanellato
-- Manu Evans
-- Tom van Dijck
-- Created: 2013/05/06
-- Copyright: (c) 2008-2016 Jason Perkins and the Premake project
--
local p = premake
local tree = p.tree
local project = p.project
local config = p.config
local codelite = p.modules.codelite
codelite.project = {}
local m = codelite.project
function codelite.getLinks(cfg)
-- System libraries are undecorated, add the required extension
return config.getlinks(cfg, "system", "fullpath")
end
function codelite.getSiblingLinks(cfg)
-- If we need sibling projects to be listed explicitly, add them on
return config.getlinks(cfg, "siblings", "fullpath")
end
m.elements = {}
m.ctools = {
gcc = "gnu gcc",
clang = "clang",
msc = "Visual C++",
}
m.cxxtools = {
gcc = "gnu g++",
clang = "clang++",
msc = "Visual C++",
}
function m.getcompilername(cfg)
local tool = _OPTIONS.cc or cfg.toolset or p.CLANG
local toolset = p.tools[tool]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
if p.languages.isc(cfg.language) then
return m.ctools[tool]
elseif p.languages.iscpp(cfg.language) then
return m.cxxtools[tool]
end
end
function m.getcompiler(cfg)
local toolset = p.tools[_OPTIONS.cc or cfg.toolset or p.CLANG]
if not toolset then
error("Invalid toolset '" + (_OPTIONS.cc or cfg.toolset) + "'")
end
return toolset
end
local function configuration_iscustombuild(cfg)
return cfg and (cfg.kind == p.MAKEFILE) and (#cfg.buildcommands > 0)
end
local function configuration_isfilelist(cfg)
return cfg and (cfg.buildaction == "None") and not configuration_iscustombuild(cfg)
end
local function configuration_needresoptions(cfg)
return cfg and config.findfile(cfg, ".rc") and not configuration_iscustombuild(cfg)
end
m.internalTypeMap = {
ConsoleApp = "Console",
WindowedApp = "Console",
Makefile = "",
SharedLib = "Library",
StaticLib = "Library"
}
function m.header(prj)
_p('<?xml version="1.0" encoding="UTF-8"?>')
local type = m.internalTypeMap[prj.kind] or ""
_x('<CodeLite_Project Name="%s" InternalType="%s">', prj.name, type)
end
function m.plugins(prj)
-- _p(1, '<Plugins>')
-- <Plugin Name="CMakePlugin">
-- <Plugin Name="qmake">
-- _p(1, '</Plugins>')
_p(1, '<Plugins/>')
end
function m.description(prj)
_p(1, '<Description/>')
-- TODO: ...
end
function m.files(prj)
local tr = project.getsourcetree(prj)
tree.traverse(tr, {
-- folders are handled at the internal nodes
onbranchenter = function(node, depth)
_p(depth, '<VirtualDirectory Name="%s">', node.name)
end,
onbranchexit = function(node, depth)
_p(depth, '</VirtualDirectory>')
end,
-- source files are handled at the leaves
onleaf = function(node, depth)
local excludesFromBuild = {}
for cfg in project.eachconfig(prj) do
local cfgname = codelite.cfgname(cfg)
local fcfg = p.fileconfig.getconfig(node, cfg)
if not fcfg or fcfg.flags.ExcludeFromBuild then
table.insert(excludesFromBuild, cfgname)
end
end
if #excludesFromBuild > 0 then
_p(depth, '<File Name="%s" ExcludeProjConfig="%s" />', node.relpath, table.concat(excludesFromBuild, ';'))
else
_p(depth, '<File Name="%s"/>', node.relpath)
end
end,
}, true)
end
function m.dependencies(prj)
-- TODO: dependencies don't emit a line for each config if there aren't any...
-- _p(1, '<Dependencies/>')
local dependencies = project.getdependencies(prj)
for cfg in project.eachconfig(prj) do
cfgname = codelite.cfgname(cfg)
if #dependencies > 0 then
_p(1, '<Dependencies Name="%s">', cfgname)
for _, dependency in ipairs(dependencies) do
_p(2, '<Project Name="%s"/>', dependency.name)
end
_p(1, '</Dependencies>')
else
_p(1, '<Dependencies Name="%s"/>', cfgname)
end
end
end
function m.global_compiler(prj)
_p(3, '<Compiler Options="" C_Options="" Assembler="">')
_p(4, '<IncludePath Value="."/>')
_p(3, '</Compiler>')
end
function m.global_linker(prj)
_p(3, '<Linker Options="">')
_p(4, '<LibraryPath Value="."/>')
_p(3, '</Linker>')
end
function m.global_resourceCompiler(prj)
_p(3, '<ResourceCompiler Options=""/>')
end
m.elements.globalSettings = function(prj)
return {
m.global_compiler,
m.global_linker,
m.global_resourceCompiler,
}
end
function m.compiler(cfg)
if configuration_iscustombuild(cfg) or configuration_isfilelist(cfg) then
_p(3, '<Compiler Required="no"/>')
return
end
local toolset = m.getcompiler(cfg)
local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs, cfg.frameworkdirs)
local forceincludes = toolset.getforceincludes(cfg)
local cxxflags = table.concat(table.join(sysincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";")
local cflags = table.concat(table.join(sysincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";")
local asmflags = ""
local pch = p.tools.gcc.getpch(cfg)
local usepch = "yes"
if pch == nil then
pch = "";
usepch = "no"
end
_x(3, '<Compiler Options="%s" C_Options="%s" Assembler="%s" Required="yes" PreCompiledHeader="%s" PCHInCommandLine="%s" UseDifferentPCHFlags="no" PCHFlags="">', cxxflags, cflags, asmflags, pch, usepch)
for _, includedir in ipairs(cfg.includedirs) do
_x(4, '<IncludePath Value="%s"/>', project.getrelative(cfg.project, includedir))
end
for _, define in ipairs(cfg.defines) do
_p(4, '<Preprocessor Value="%s"/>', p.esc(define):gsub(' ', '\\ '))
end
_p(3, '</Compiler>')
end
function m.linker(cfg)
if configuration_iscustombuild(cfg) or configuration_isfilelist(cfg) then
_p(3, '<Linker Required="no"/>')
return
end
local toolset = m.getcompiler(cfg)
local flags = table.join(toolset.getldflags(cfg), toolset.getincludedirs(cfg, {}, nil, cfg.frameworkdirs), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), cfg.linkoptions, toolset.getlinks(cfg))
_x(3, '<Linker Required="yes" Options="%s">', table.concat(flags, ";"))
for _, libdir in ipairs(cfg.libdirs) do
_p(4, '<LibraryPath Value="%s"/>', project.getrelative(cfg.project, libdir))
end
_p(3, '</Linker>')
end
function m.resourceCompiler(cfg)
if not configuration_needresoptions(cfg) then
_p(3, '<ResourceCompiler Options="" Required="no"/>')
return
end
local toolset = m.getcompiler(cfg)
local defines = table.implode(toolset.getdefines(table.join(cfg.defines, cfg.resdefines)), "", ";", "")
local options = table.concat(cfg.resoptions, ";")
_x(3, '<ResourceCompiler Options="%s%s" Required="yes">', defines, options)
for _, includepath in ipairs(table.join(cfg.sysincludedirs, cfg.includedirs, cfg.resincludedirs)) do
_x(4, '<IncludePath Value="%s"/>', project.getrelative(cfg.project, includepath))
end
_p(3, '</ResourceCompiler>')
end
function m.general(cfg)
if configuration_isfilelist(cfg) then
_p(3, '<General IntermediateDirectory="." WorkingDirectory="." PauseExecWhenProcTerminates="no"/>')
return
end
local prj = cfg.project
local isExe = prj.kind == "WindowedApp" or prj.kind == "ConsoleApp"
local targetpath = project.getrelative(prj, cfg.buildtarget.directory)
local objdir = project.getrelative(prj, cfg.objdir)
local targetname = project.getrelative(prj, cfg.buildtarget.abspath)
local workingdir = cfg.debugdir or prj.location
local command = iif(isExe, path.getrelative(workingdir, cfg.buildtarget.abspath), "")
local cmdargs = iif(isExe, table.concat(cfg.debugargs, " "), "") -- TODO: should this be debugargs instead?
local useseparatedebugargs = "no"
local debugargs = ""
local workingdir = iif(isExe, project.getrelative(prj, cfg.debugdir), "")
local pauseexec = iif(prj.kind == "ConsoleApp", "yes", "no")
local isguiprogram = iif(prj.kind == "WindowedApp", "yes", "no")
local isenabled = iif(cfg.flags.ExcludeFromBuild, "no", "yes")
_x(3, '<General OutputFile="%s" IntermediateDirectory="%s" Command="%s" CommandArguments="%s" UseSeparateDebugArgs="%s" DebugArguments="%s" WorkingDirectory="%s" PauseExecWhenProcTerminates="%s" IsGUIProgram="%s" IsEnabled="%s"/>',
targetname, objdir, command, cmdargs, useseparatedebugargs, debugargs, workingdir, pauseexec, isguiprogram, isenabled)
end
function m.environment(cfg)
local envs = table.concat(cfg.debugenvs, "\n")
_p(3, '<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">')
_p(4, '<![CDATA[%s]]>', envs)
_p(3, '</Environment>')
end
function m.debugger(cfg)
_p(3, '<Debugger IsRemote="%s" RemoteHostName="%s" RemoteHostPort="%s" DebuggerPath="" IsExtended="%s">', iif(cfg.debugremotehost, "yes", "no"), cfg.debugremotehost or "", iif(cfg.debugport, tostring(cfg.debugport), ""), iif(cfg.debugextendedprotocol, "yes", "no"))
if #cfg.debugsearchpaths > 0 then
p.escaper(codelite.escElementText)
_p(4, '<DebuggerSearchPaths>%s</DebuggerSearchPaths>', table.concat(p.esc(project.getrelative(cfg.project, cfg.debugsearchpaths)), "\n"))
p.escaper(codelite.esc)
else
_p(4, '<DebuggerSearchPaths/>')
end
if #cfg.debugconnectcommands > 0 then
p.escaper(codelite.escElementText)
_p(4, '<PostConnectCommands>%s</PostConnectCommands>', table.concat(p.esc(cfg.debugconnectcommands), "\n"))
p.escaper(codelite.esc)
else
_p(4, '<PostConnectCommands/>')
end
if #cfg.debugstartupcommands > 0 then
p.escaper(codelite.escElementText)
_p(4, '<StartupCommands>%s</StartupCommands>', table.concat(p.esc(cfg.debugstartupcommands), "\n"))
p.escaper(codelite.esc)
else
_p(4, '<StartupCommands/>')
end
_p(3, '</Debugger>')
end
function m.preBuild(cfg)
if #cfg.prebuildcommands > 0 or cfg.prebuildmessage then
_p(3, '<PreBuild>')
p.escaper(codelite.escElementText)
if cfg.prebuildmessage then
local command = os.translateCommandsAndPaths("@{ECHO} " .. cfg.prebuildmessage, cfg.project.basedir, cfg.project.location)
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
local commands = os.translateCommandsAndPaths(cfg.prebuildcommands, cfg.project.basedir, cfg.project.location)
for _, command in ipairs(commands) do
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
p.escaper(codelite.esc)
_p(3, '</PreBuild>')
end
end
function m.postBuild(cfg)
if #cfg.postbuildcommands > 0 or cfg.postbuildmessage then
_p(3, '<PostBuild>')
p.escaper(codelite.escElementText)
if cfg.postbuildmessage then
local command = os.translateCommandsAndPaths("@{ECHO} " .. cfg.postbuildmessage, cfg.project.basedir, cfg.project.location)
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
local commands = os.translateCommandsAndPaths(cfg.postbuildcommands, cfg.project.basedir, cfg.project.location)
for _, command in ipairs(commands) do
_x(4, '<Command Enabled="yes">%s</Command>', command)
end
p.escaper(codelite.esc)
_p(3, '</PostBuild>')
end
end
function m.customBuild(cfg)
if not configuration_iscustombuild(cfg) then
_p(3, '<CustomBuild Enabled="no"/>')
return
end
local build = table.implode(cfg.buildcommands,"","","")
local clean = table.implode(cfg.cleancommands,"","","")
local rebuild = table.implode(cfg.rebuildcommands,"","","")
_p(3, '<CustomBuild Enabled="yes">')
_x(4, '<BuildCommand>%s</BuildCommand>', build)
_x(4, '<CleanCommand>%s</CleanCommand>', clean)
_x(4, '<RebuildCommand>%s</RebuildCommand>', rebuild)
_p(4, '<PreprocessFileCommand></PreprocessFileCommand>')
_p(4, '<SingleFileCommand></SingleFileCommand>')
_p(4, '<MakefileGenerationCommand></MakefileGenerationCommand>')
_p(4, '<ThirdPartyToolName></ThirdPartyToolName>')
_p(4, '<WorkingDirectory></WorkingDirectory>')
_p(3, '</CustomBuild>')
end
function m.additionalRules(cfg)
if configuration_iscustombuild(cfg) then
_p(3, '<AdditionalRules/>')
return
end
_p(3, '<AdditionalRules>')
_p(4, '<CustomPostBuild/>')
local dependencies = {}
local makefilerules = {}
local function addrule(dependencies, makefilerules, config, filename)
if #config.buildcommands == 0 or #config.buildOutputs == 0 then
return false
end
local inputs = table.implode(project.getrelative(cfg.project, config.buildInputs), "", "", " ")
if filename ~= "" and inputs ~= "" then
filename = filename .. " "
end
local outputs = project.getrelative(cfg.project, config.buildOutputs[1])
local buildmessage = ""
if config.buildmessage then
buildmessage = "\t@{ECHO} " .. config.buildmessage .. "\n"
end
local commands = table.implode(config.buildCommands,"\t","\n","")
table.insert(makefilerules, os.translateCommandsAndPaths(outputs .. ": " .. filename .. inputs .. "\n" .. buildmessage .. commands, cfg.project.basedir, cfg.project.location))
table.insertflat(dependencies, outputs)
return true
end
local tr = project.getsourcetree(cfg.project)
p.tree.traverse(tr, {
onleaf = function(node, depth)
local filecfg = p.fileconfig.getconfig(node, cfg)
local prj = cfg.project
local rule = p.global.getRuleForFile(node.name, prj.rules)
if not addrule(dependencies, makefilerules, filecfg, node.relpath) and rule then
local environ = table.shallowcopy(filecfg.environ)
if rule.propertydefinition then
p.rule.prepareEnvironment(rule, environ, cfg)
p.rule.prepareEnvironment(rule, environ, filecfg)
end
local rulecfg = p.context.extent(rule, environ)
addrule(dependencies, makefilerules, rulecfg, node.relpath)
end
end
})
addrule(dependencies, makefilerules, cfg, "")
if #makefilerules == 0 and #dependencies == 0 then
_p(4, '<CustomPreBuild/>')
else
_p(4, '<CustomPreBuild>' .. table.implode(dependencies,"",""," "))
_p(0, table.implode(makefilerules,"","","\n") .. '</CustomPreBuild>')
end
_p(3, '</AdditionalRules>')
end
function m.isCpp11(cfg)
return (cfg.cppdialect == 'gnu++11') or (cfg.cppdialect == 'C++11') or (cfg.cppdialect == 'gnu++0x') or (cfg.cppdialect == 'C++0x')
end
function m.isCpp14(cfg)
return (cfg.cppdialect == 'gnu++14') or (cfg.cppdialect == 'C++14') or (cfg.cppdialect == 'gnu++1y') or (cfg.cppdialect == 'C++1y')
end
function m.completion(cfg)
_p(3, '<Completion EnableCpp11="%s" EnableCpp14="%s">',
iif(m.isCpp11(cfg), "yes", "no"),
iif(m.isCpp14(cfg), "yes", "no")
)
_p(4, '<ClangCmpFlagsC/>')
_p(4, '<ClangCmpFlags/>')
_p(4, '<ClangPP/>') -- TODO: we might want to set special code completion macros...?
_p(4, '<SearchPaths/>') -- TODO: search paths for code completion?
_p(3, '</Completion>')
end
m.elements.settings = function(cfg)
return {
m.compiler,
m.linker,
m.resourceCompiler,
m.general,
m.environment,
m.debugger,
m.preBuild,
m.postBuild,
m.customBuild,
m.additionalRules,
m.completion,
}
end
m.types =
{
ConsoleApp = "Executable",
Makefile = "",
SharedLib = "Dynamic Library",
StaticLib = "Static Library",
WindowedApp = "Executable",
Utility = "",
}
m.debuggers =
{
Default = "GNU gdb debugger",
GDB = "GNU gdb debugger",
LLDB = "LLDB Debugger",
}
function m.settings(prj)
_p(1, '<Settings Type="%s">', m.types[prj.kind] or "")
_p(2, '<GlobalSettings>')
p.callArray(m.elements.globalSettings, prj)
_p(2, '</GlobalSettings>')
for cfg in project.eachconfig(prj) do
local cfgname = codelite.cfgname(cfg)
local compiler = m.getcompilername(cfg)
local debugger = m.debuggers[cfg.debugger] or m.debuggers.Default
local type = m.types[cfg.kind]
_x(2, '<Configuration Name="%s" CompilerType="%s" DebuggerType="%s" Type="%s" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">', cfgname, compiler, debugger, type)
p.callArray(m.elements.settings, cfg)
_p(2, '</Configuration>')
end
_p(1, '</Settings>')
end
m.elements.project = function(prj)
return {
m.header,
m.plugins,
m.description,
m.files,
m.dependencies,
m.settings,
}
end
--
-- Project: Generate the CodeLite project file.
--
function m.generate(prj)
p.utf8()
p.callArray(m.elements.project, prj)
_p('</CodeLite_Project>')
end

View file

@ -0,0 +1,105 @@
--
-- 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 codelite = p.modules.codelite
codelite.workspace = {}
local m = codelite.workspace
--
-- Generate a CodeLite workspace
--
function m.generate(wks)
p.utf8()
--
-- Header
--
p.w('<?xml version="1.0" encoding="UTF-8"?>')
local tagsdb = ""
-- local tagsdb = "./" .. wks.name .. ".tags"
p.push('<CodeLite_Workspace Name="%s" Database="%s" SWTLW="No">', wks.name, tagsdb)
--
-- Project list
--
local tr = workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
-- Build a relative path from the workspace file to the project file
local prjpath = p.filename(prj, ".project")
prjpath = path.getrelative(prj.workspace.location, prjpath)
if (prj.name == wks.startproject) then
p.w('<Project Name="%s" Path="%s" Active="Yes"/>', prj.name, prjpath)
else
p.w('<Project Name="%s" Path="%s"/>', prj.name, prjpath)
end
end,
onbranchenter = function(n)
p.push('<VirtualDirectory Name="%s">', n.name)
end,
onbranchexit = function(n)
p.pop('</VirtualDirectory>')
end,
})
--
-- Configurations
--
-- count the number of platforms
local platformsPresent = {}
local numPlatforms = 0
for cfg in workspace.eachconfig(wks) do
local platform = cfg.platform
if platform and not platformsPresent[platform] then
numPlatforms = numPlatforms + 1
platformsPresent[platform] = true
end
end
if numPlatforms >= 2 then
codelite.workspace.multiplePlatforms = true
end
-- for each workspace config
p.push('<BuildMatrix>')
local selected = "yes" -- only one configuration should be selected
for cfg in workspace.eachconfig(wks) do
local cfgname = codelite.cfgname(cfg)
p.push('<WorkspaceConfiguration Name="%s" Selected="%s">', cfgname, selected)
selected = "no"
local tr = workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
p.w('<Project Name="%s" ConfigName="%s"/>', prj.name, cfgname)
end
})
p.pop('</WorkspaceConfiguration>')
end
p.pop('</BuildMatrix>')
p.pop('</CodeLite_Workspace>')
end

View file

@ -0,0 +1,8 @@
require ("codelite")
return {
"test_codelite_workspace.lua",
"test_codelite_project.lua",
"test_codelite_config.lua",
"test_codelite_additional_rules.lua",
}

View file

@ -0,0 +1,256 @@
---
-- codelite/tests/test_codelite_config.lua
-- Automated test suite for CodeLite project generation.
-- Copyright (c) 2021 Joris Dauphin and the Premake project
---
local suite = test.declare("codelite_cproj_additional_rules")
local p = premake
local codelite = p.modules.codelite
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
local function prepare_rule()
rule "TestRule"
display "Test Rule"
fileextension ".rule"
propertydefinition {
name = "TestProperty",
kind = "boolean",
value = false,
switch = "-p"
}
propertydefinition {
name = "TestProperty2",
kind = "boolean",
value = false,
switch = "-p2"
}
propertydefinition {
name = "TestListProperty",
kind = "list"
}
propertydefinition {
name = "TestListPropertyWithSwitch",
kind = "list",
switch = "-S"
}
propertydefinition {
name = "TestListPropertySeparator",
kind = "list",
separator = ","
}
propertydefinition {
name = "TestListPropertySeparatorWithSwitch",
kind = "list",
separator = ",",
switch = "-O"
}
propertydefinition {
name = "TestEnumProperty",
values = { [0] = "V0", [1] = "V1"},
switch = { [0] = "S0", [1] = "S1"},
value = 0
}
buildmessage 'Rule-ing %{file.name}'
buildcommands 'dorule %{TestProperty} %{TestProperty2} %{TestListProperty} %{TestListPropertyWithSwitch} %{TestListPropertySeparator} %{TestListPropertySeparatorWithSwitch} %{TestEnumProperty} "%{file.path}"'
buildoutputs { "%{file.basename}.obj" }
end
function suite.setup()
p.action.set("codelite")
p.escaper(codelite.esc)
p.indent(" ")
prepare_rule()
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks, 1)
cfg = test.getconfig(prj, "Debug")
end
function suite.customRuleEmpty()
prepare()
codelite.project.additionalRules(prj)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild/>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinition()
rules { "TestRule" }
files { "test.rule", "test2.rule" }
testRuleVars {
TestProperty = true
}
filter "files:test2.rule"
testRuleVars {
TestProperty2 = true
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule -p "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule -p -p2 "test2.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinitionSeparator()
rules { "TestRule" }
files { "test.rule", "test2.rule", "test3.rule", "test4.rule" }
filter "files:test.rule"
testRuleVars {
TestListProperty = { "testValue1", "testValue2" }
}
filter "files:test2.rule"
testRuleVars {
TestListPropertyWithSwitch = { "testValue1", "testValue2" }
}
filter "files:test3.rule"
testRuleVars {
TestListPropertySeparator = { "testValue1", "testValue2" }
}
filter "files:test4.rule"
testRuleVars {
TestListPropertySeparatorWithSwitch = { "testValue1", "testValue2" }
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj test3.obj test4.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule testValue1 testValue2 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule -StestValue1 -StestValue2 "test2.rule"
test3.obj: test3.rule
@echo Rule-ing test3.rule
dorule testValue1,testValue2 "test3.rule"
test4.obj: test4.rule
@echo Rule-ing test4.rule
dorule -OtestValue1,testValue2 "test4.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.customRuleWithPropertyDefinitionEnum()
rules { "TestRule" }
files { "test.rule", "test2.rule" }
testRuleVars {
TestEnumProperty = "V0"
}
filter "files:test2.rule"
testRuleVars {
TestEnumProperty = "V1"
}
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>test.obj test2.obj
test.obj: test.rule
@echo Rule-ing test.rule
dorule S0 "test.rule"
test2.obj: test2.rule
@echo Rule-ing test2.rule
dorule S1 "test2.rule"
</CustomPreBuild>
</AdditionalRules>
]]
end
function suite.buildCommand()
files {"foo.txt", "bar.txt"}
buildinputs { "toto.txt", "extra_dependency" }
buildoutputs { "toto.c" }
buildcommands { "test", "test toto.c" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>toto.c
toto.c: toto.txt extra_dependency
@echo Some message
test
test toto.c
</CustomPreBuild>
</AdditionalRules>]]
end
function suite.buildCommandPerFile()
files {"foo.txt", "bar.txt"}
filter "files:**.txt"
buildinputs { "%{file.basename}.h", "extra_dependency" }
buildoutputs { "%{file.basename}.c" }
buildcommands { "test", "test %{file.basename}" }
buildmessage "Some message"
prepare()
codelite.project.additionalRules(cfg)
test.capture [[
<AdditionalRules>
<CustomPostBuild/>
<CustomPreBuild>bar.c foo.c
bar.c: bar.txt bar.h extra_dependency
@echo Some message
test
test bar
foo.c: foo.txt foo.h extra_dependency
@echo Some message
test
test foo
</CustomPreBuild>
</AdditionalRules>]]
end

View file

@ -0,0 +1,377 @@
---
-- codelite/tests/test_codelite_config.lua
-- Automated test suite for CodeLite project generation.
-- Copyright (c) 2015 Manu Evans and the Premake project
---
local suite = test.declare("codelite_cproj_config")
local p = premake
local codelite = p.modules.codelite
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj, cfg
function suite.setup()
p.action.set("codelite")
p.escaper(codelite.esc)
p.indent(" ")
wks = test.createWorkspace()
end
local function prepare()
prj = test.getproject(wks,1)
cfg = test.getconfig(prj, "Debug")
end
function suite.OnProjectCfg_Compiler()
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
function suite.OnProjectCfg_Flags()
optimize "Debug"
exceptionhandling "Off"
rtti "Off"
pic "On"
symbols "On"
language "C++"
cppdialect "C++11"
flags { "NoBufferSecurityCheck" }
forceincludes { "forced_include1.h", "forced_include2.h" }
buildoptions { "-opt1", "-opt2" }
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="-O0;-fPIC;-g;-std=c++11;-fno-exceptions;-fno-stack-protector;-fno-rtti;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" C_Options="-O0;-fPIC;-g;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
function suite.OnProjectCfg_Includes()
includedirs { "dir/", "dir2" }
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
<IncludePath Value="dir"/>
<IncludePath Value="dir2"/>
</Compiler>
]]
end
function suite.OnProjectCfg_SysIncludes()
sysincludedirs { "sysdir", "sysdir2/"}
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="-isystem sysdir;-isystem sysdir2" C_Options="-isystem sysdir;-isystem sysdir2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
function suite.OnProjectCfg_Defines()
defines { "TEST", "DEF", "VAL=1", "ESCAPE=\"WITH SPACE\"" }
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
<Preprocessor Value="TEST"/>
<Preprocessor Value="DEF"/>
<Preprocessor Value="VAL=1"/>
<Preprocessor Value="ESCAPE=&quot;WITH\ SPACE&quot;"/>
</Compiler>
]]
end
function suite.OnProjectCfg_Pch()
pchheader "pch.h"
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="pch.h" PCHInCommandLine="yes" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
function suite.OnProjectCfg_Linker()
prepare()
codelite.project.linker(cfg)
test.capture [[
<Linker Required="yes" Options="">
</Linker>
]]
end
function suite.OnProjectCfg_LibPath()
libdirs { "test/", "test2" }
prepare()
codelite.project.linker(cfg)
test.capture [[
<Linker Required="yes" Options="">
<LibraryPath Value="test"/>
<LibraryPath Value="test2"/>
</Linker>
]]
end
function suite.OnProjectCfg_Libs()
links { "a", "b" }
prepare()
codelite.project.linker(cfg)
test.capture [[
<Linker Required="yes" Options="-la;-lb">
</Linker>
]]
end
-- TODO: test sibling lib project links
function suite.OnProjectCfg_ResCompiler()
prepare()
codelite.project.resourceCompiler(cfg)
test.capture [[
<ResourceCompiler Options="" Required="no"/>
]]
end
function suite.OnProjectCfg_ResInclude()
files { "x.rc" }
resincludedirs { "dir/" }
prepare()
codelite.project.resourceCompiler(cfg)
test.capture [[
<ResourceCompiler Options="" Required="yes">
<IncludePath Value="dir"/>
</ResourceCompiler>
]]
end
function suite.OnProjectCfg_ResRegularInclude()
files { "x.rc" }
includedirs { "regulardir/" }
prepare()
codelite.project.resourceCompiler(cfg)
test.capture [[
<ResourceCompiler Options="" Required="yes">
<IncludePath Value="regulardir"/>
</ResourceCompiler>
]]
end
function suite.OnProjectCfg_ResSysInclude()
files { "x.rc" }
sysincludedirs { "sysdir/" }
prepare()
codelite.project.resourceCompiler(cfg)
test.capture [[
<ResourceCompiler Options="" Required="yes">
<IncludePath Value="sysdir"/>
</ResourceCompiler>
]]
end
function suite.OnProjectCfg_PreBuildMessage()
prebuildmessage "test"
prepare()
codelite.project.preBuild(cfg)
test.capture [[
<PreBuild>
<Command Enabled="yes">@echo test</Command>
</PreBuild>
]]
end
function suite.OnProjectCfg_PostBuildMessage()
postbuildmessage "test"
prepare()
codelite.project.postBuild(cfg)
test.capture [[
<PostBuild>
<Command Enabled="yes">@echo test</Command>
</PostBuild>
]]
end
function suite.OnProjectCfg_General()
system "Windows"
prepare()
codelite.project.general(cfg)
test.capture [[
<General OutputFile="bin/Debug/MyProject.exe" IntermediateDirectory="obj/Debug" Command="bin/Debug/MyProject.exe" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
]]
end
function suite.OnProjectCfg_Environment()
debugenvs { "ENV_ONE=1", "ENV_TWO=2" }
prepare()
codelite.project.environment(cfg)
test.capture(
' <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">\n' ..
' <![CDATA[ENV_ONE=1\n' ..
'ENV_TWO=2]]>\n' ..
' </Environment>'
)
end
function suite.OnProjectCfg_EnvironmentEscaping()
debugenvs { "\"ENV\"=<&>" }
prepare()
codelite.project.environment(cfg)
test.capture(
' <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">\n' ..
' <![CDATA["ENV"=<&>]]>\n' ..
' </Environment>'
)
end
function suite.OnProjectCfg_Debugger()
prepare()
codelite.project.debugger(cfg)
test.capture [[
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
<DebuggerSearchPaths/>
<PostConnectCommands/>
<StartupCommands/>
</Debugger>
]]
end
function suite.OnProjectCfg_DebuggerOpts()
debugremotehost "localhost"
debugport(2345)
debugextendedprotocol(true)
debugsearchpaths { "search/", "path" }
debugconnectcommands { "connectcmd1", "cmd2" }
debugstartupcommands { "startcmd1", "cmd2" }
prepare()
codelite.project.debugger(cfg)
test.capture [[
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
<DebuggerSearchPaths>search
path</DebuggerSearchPaths>
<PostConnectCommands>connectcmd1
cmd2</PostConnectCommands>
<StartupCommands>startcmd1
cmd2</StartupCommands>
</Debugger>
]]
end
function suite.OnProjectCfg_DebuggerOptsEscaping()
debugremotehost "localhost"
debugport(2345)
debugextendedprotocol(true)
debugsearchpaths { "\"search\" && <path>" }
debugconnectcommands { "\"connect\" && <cmd>" }
debugstartupcommands { "\"start\" && <cmd>" }
prepare()
codelite.project.debugger(cfg)
test.capture [[
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
<DebuggerSearchPaths>"search" &amp;&amp; &lt;path&gt;</DebuggerSearchPaths>
<PostConnectCommands>"connect" &amp;&amp; &lt;cmd&gt;</PostConnectCommands>
<StartupCommands>"start" &amp;&amp; &lt;cmd&gt;</StartupCommands>
</Debugger>
]]
end
function suite.OnProjectCfg_PreBuild()
prebuildcommands { "cmd0", "cmd1" }
prepare()
codelite.project.preBuild(prj)
test.capture [[
<PreBuild>
<Command Enabled="yes">cmd0</Command>
<Command Enabled="yes">cmd1</Command>
</PreBuild>
]]
end
function suite.OnProjectCfg_PreBuild_Escaped()
prebuildcommands {
"touch \"./build/copyright\" && echo OK",
"cat \"./lib/copyright\" >> \"./build/copyright\""
}
prepare()
codelite.project.preBuild(prj)
test.capture [[
<PreBuild>
<Command Enabled="yes">touch "./build/copyright" &amp;&amp; echo OK</Command>
<Command Enabled="yes">cat "./lib/copyright" &gt;&gt; "./build/copyright"</Command>
</PreBuild>
]]
end
function suite.OnProjectCfg_PostBuild()
postbuildcommands { "cmd0", "cmd1" }
prepare()
codelite.project.postBuild(prj)
test.capture [[
<PostBuild>
<Command Enabled="yes">cmd0</Command>
<Command Enabled="yes">cmd1</Command>
</PostBuild>
]]
end
function suite.OnProjectCfg_PostBuild_Escaped()
postbuildcommands {
"touch \"./build/copyright\" && echo OK",
"cat \"./lib/copyright\" >> \"./build/copyright\""
}
prepare()
codelite.project.postBuild(prj)
test.capture [[
<PostBuild>
<Command Enabled="yes">touch "./build/copyright" &amp;&amp; echo OK</Command>
<Command Enabled="yes">cat "./lib/copyright" &gt;&gt; "./build/copyright"</Command>
</PostBuild>
]]
end
function suite.OnProjectCfg_Completion()
language "C++"
cppdialect "C++11"
prepare()
codelite.project.completion(prj)
test.capture [[
<Completion EnableCpp11="yes" EnableCpp14="no">
<ClangCmpFlagsC/>
<ClangCmpFlags/>
<ClangPP/>
<SearchPaths/>
</Completion>
]]
end
function suite.OnProjectCfg_UnsignedCharOn()
unsignedchar "On"
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="-funsigned-char" C_Options="-funsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end
function suite.OnProjectCfg_UnsignedCharOff()
unsignedchar "Off"
prepare()
codelite.project.compiler(cfg)
test.capture [[
<Compiler Options="-fno-unsigned-char" C_Options="-fno-unsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
</Compiler>
]]
end

View file

@ -0,0 +1,102 @@
---
-- codelite/tests/test_codelite_project.lua
-- Automated test suite for CodeLite project generation.
-- Copyright (c) 2015 Manu Evans and the Premake project
---
local suite = test.declare("codelite_cproj")
local p = premake
local codelite = p.modules.codelite
---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------
local wks, prj
function suite.setup()
p.action.set("codelite")
p.escaper(codelite.esc)
p.indent(" ")
wks = test.createWorkspace()
end
local function prepare()
wks = p.oven.bakeWorkspace(wks)
prj = test.getproject(wks, 1)
end
function suite.OnProject_Header()
prepare()
codelite.project.header(prj)
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="MyProject" InternalType="Console">
]]
end
function suite.OnProject_Header_Windowed()
kind "WindowedApp"
prepare()
codelite.project.header(prj)
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="MyProject" InternalType="Console">
]]
end
function suite.OnProject_Header_Shared()
kind "SharedLib"
prepare()
codelite.project.header(prj)
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="MyProject" InternalType="Library">
]]
end
function suite.OnProject_Plugins()
prepare()
codelite.project.plugins(prj)
test.capture [[
<Plugins/>
]]
end
function suite.OnProject_Description()
prepare()
codelite.project.description(prj)
test.capture [[
<Description/>
]]
end
function suite.OnProject_Dependencies()
prepare()
codelite.project.dependencies(prj)
test.capture [[
<Dependencies Name="Debug"/>
<Dependencies Name="Release"/>
]]
end
-- TODO: dependencies with actual dependencies...
-- GlobalSettings is currently constants, so we'll just test it here
function suite.OnProject_Settings()
prepare()
codelite.project.settings(prj)
test.capture [[
<Settings Type="Executable">
<GlobalSettings>
<Compiler Options="" C_Options="" Assembler="">
<IncludePath Value="."/>
</Compiler>
<Linker Options="">
<LibraryPath Value="."/>
</Linker>
<ResourceCompiler Options=""/>
</GlobalSettings>
]]
end

View file

@ -0,0 +1,224 @@
---
-- codelite/tests/test_codelite_workspace.lua
-- Validate generation for CodeLite workspaces.
-- Author Manu Evans
-- Copyright (c) 2015 Manu Evans and the Premake project
---
local suite = test.declare("codelite_workspace")
local p = premake
local codelite = p.modules.codelite
--
-- Setup
--
local wks, prj
function suite.setup()
p.action.set("codelite")
p.escaper(codelite.esc)
p.indent(" ")
wks = test.createWorkspace()
end
local function prepare()
wks = test.getWorkspace(wks)
codelite.workspace.generate(wks)
end
--
-- Check the basic structure of a workspace.
--
function suite.onEmptyWorkspace()
wks.projects = {}
prepare()
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]]
end
function suite.onDefaultWorkspace()
prepare()
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="MyProject.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyProject" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyProject" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]]
end
function suite.onMultipleProjects()
test.createproject(wks)
prepare()
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="MyProject.project"/>
<Project Name="MyProject2" Path="MyProject2.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyProject" ConfigName="Debug"/>
<Project Name="MyProject2" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyProject" ConfigName="Release"/>
<Project Name="MyProject2" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]]
end
--
-- Projects should include relative path from workspace.
--
function suite.onNestedProjectPath()
location "MyProject"
prepare()
test.capture([[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="MyProject/MyProject.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyProject" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyProject" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]])
end
function suite.onExternalProjectPath()
location "../MyProject"
prepare()
test.capture([[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="../MyProject/MyProject.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyProject" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyProject" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]])
end
function suite.onActiveProject()
workspace("MyWorkspace")
startproject "MyProject"
prepare()
test.capture([[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="MyProject.project" Active="Yes"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyProject" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyProject" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]])
end
function suite.onGroupedProjects()
wks.projects = {}
project "MyGrouplessProject"
group "MyGroup"
project "MyGroupedProject"
group "My/Nested/Group"
project "MyNestedGroupedProject"
prepare()
test.capture([[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<VirtualDirectory Name="My">
<VirtualDirectory Name="Nested">
<VirtualDirectory Name="Group">
<Project Name="MyNestedGroupedProject" Path="MyNestedGroupedProject.project"/>
</VirtualDirectory>
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="MyGroup">
<Project Name="MyGroupedProject" Path="MyGroupedProject.project"/>
</VirtualDirectory>
<Project Name="MyGrouplessProject" Path="MyGrouplessProject.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="MyNestedGroupedProject" ConfigName="Debug"/>
<Project Name="MyGroupedProject" ConfigName="Debug"/>
<Project Name="MyGrouplessProject" ConfigName="Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="no">
<Project Name="MyNestedGroupedProject" ConfigName="Release"/>
<Project Name="MyGroupedProject" ConfigName="Release"/>
<Project Name="MyGrouplessProject" ConfigName="Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]])
end
---
-- Test handling of platforms
---
function suite.onPlatforms()
workspace "MyWorkspace"
platforms { "x86_64", "x86" }
prepare()
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
<Project Name="MyProject" Path="MyProject.project"/>
<BuildMatrix>
<WorkspaceConfiguration Name="x86_64-Debug" Selected="yes">
<Project Name="MyProject" ConfigName="x86_64-Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="x86-Debug" Selected="no">
<Project Name="MyProject" ConfigName="x86-Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="x86_64-Release" Selected="no">
<Project Name="MyProject" ConfigName="x86_64-Release"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="x86-Release" Selected="no">
<Project Name="MyProject" ConfigName="x86-Release"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CodeLite_Workspace>
]]
end