2016-11-09 19:29:33 +00:00
|
|
|
--
|
|
|
|
-- 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
|
|
|
|
--
|
2018-05-21 22:30:58 +00:00
|
|
|
p.w('<?xml version="1.0" encoding="UTF-8"?>')
|
2016-11-09 19:29:33 +00:00
|
|
|
|
|
|
|
local tagsdb = ""
|
|
|
|
-- local tagsdb = "./" .. wks.name .. ".tags"
|
2018-05-21 22:30:58 +00:00
|
|
|
p.push('<CodeLite_Workspace Name="%s" Database="%s" SWTLW="No">', wks.name, tagsdb)
|
2016-11-09 19:29:33 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- 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)
|
|
|
|
|
2017-04-17 14:41:48 +00:00
|
|
|
if (prj.name == wks.startproject) then
|
2018-05-21 22:30:58 +00:00
|
|
|
p.w('<Project Name="%s" Path="%s" Active="Yes"/>', prj.name, prjpath)
|
2017-04-17 14:41:48 +00:00
|
|
|
else
|
2018-05-21 22:30:58 +00:00
|
|
|
p.w('<Project Name="%s" Path="%s"/>', prj.name, prjpath)
|
2017-04-17 14:41:48 +00:00
|
|
|
end
|
2016-11-09 19:29:33 +00:00
|
|
|
end,
|
|
|
|
|
2018-05-21 22:30:58 +00:00
|
|
|
onbranchenter = function(n)
|
|
|
|
p.push('<VirtualDirectory Name="%s">', n.name)
|
|
|
|
end,
|
|
|
|
|
|
|
|
onbranchexit = function(n)
|
|
|
|
p.pop('</VirtualDirectory>')
|
2016-11-09 19:29:33 +00:00
|
|
|
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
|
2018-05-21 22:30:58 +00:00
|
|
|
p.push('<BuildMatrix>')
|
2020-09-29 11:24:26 +00:00
|
|
|
local selected = "yes" -- only one configuration should be selected
|
2016-11-09 19:29:33 +00:00
|
|
|
for cfg in workspace.eachconfig(wks) do
|
|
|
|
|
|
|
|
local cfgname = codelite.cfgname(cfg)
|
2020-09-29 11:24:26 +00:00
|
|
|
p.push('<WorkspaceConfiguration Name="%s" Selected="%s">', cfgname, selected)
|
|
|
|
selected = "no"
|
2016-11-09 19:29:33 +00:00
|
|
|
|
|
|
|
local tr = workspace.grouptree(wks)
|
|
|
|
tree.traverse(tr, {
|
|
|
|
onleaf = function(n)
|
|
|
|
local prj = n.project
|
2018-05-21 22:30:58 +00:00
|
|
|
p.w('<Project Name="%s" ConfigName="%s"/>', prj.name, cfgname)
|
2016-11-09 19:29:33 +00:00
|
|
|
end
|
|
|
|
})
|
2018-05-21 22:30:58 +00:00
|
|
|
p.pop('</WorkspaceConfiguration>')
|
2016-11-09 19:29:33 +00:00
|
|
|
|
|
|
|
end
|
2018-05-21 22:30:58 +00:00
|
|
|
p.pop('</BuildMatrix>')
|
2016-11-09 19:29:33 +00:00
|
|
|
|
2018-05-21 22:30:58 +00:00
|
|
|
p.pop('</CodeLite_Workspace>')
|
2016-11-09 19:29:33 +00:00
|
|
|
end
|