This repository has been archived by the owner on Jun 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
codelite_workspace.lua
executable file
·97 lines (79 loc) · 2.34 KB
/
codelite_workspace.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
--
-- 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('<?xml version="1.0" encoding="UTF-8"?>')
local tagsdb = ""
-- local tagsdb = "./" .. wks.name .. ".tags"
_p('<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)
local active = iif(prj.name == wks.startproject, ' Active="Yes"', '')
_x(1, '<Project Name="%s" Path="%s"%s/>', prj.name, prjpath, active)
end,
onbranch = function(n)
-- TODO: not sure what situation this appears...?
-- premake5.lua emit's one of these for 'contrib', which is a top-level folder with the zip projects
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(1, '<BuildMatrix>')
for cfg in workspace.eachconfig(wks) do
local cfgname = codelite.cfgname(cfg)
_p(2, '<WorkspaceConfiguration Name="%s" Selected="yes">', cfgname)
local tr = workspace.grouptree(wks)
tree.traverse(tr, {
onleaf = function(n)
local prj = n.project
_p(3, '<Project Name="%s" ConfigName="%s"/>', prj.name, cfgname)
end
})
_p(2, '</WorkspaceConfiguration>')
end
_p(1, '</BuildMatrix>')
_p('</CodeLite_Workspace>')
end