blob: c623e1af960894f55338537d5ee1681b5ecd4b2e (
plain) (
blame)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
--
-- solution.lua
-- Work with the list of solutions loaded from the script.
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project
--
premake.solution = { }
-- The list of defined solutions (which contain projects, etc.)
premake.solution.list = { }
--
-- Create a new solution and add it to the session.
--
-- @param name
-- The new solution's name.
--
function premake.solution.new(name)
local sln = { }
-- add to master list keyed by both name and index
table.insert(premake.solution.list, sln)
premake.solution.list[name] = sln
-- attach a type descriptor
setmetatable(sln, { __type="solution" })
sln.name = name
sln.basedir = os.getcwd()
sln.projects = { }
sln.blocks = { }
sln.configurations = { }
sln.groups = { }
sln.importedprojects = { }
return sln
end
--
-- Iterate over the collection of solutions in a session.
--
-- @returns
-- An iterator function.
--
function premake.solution.each()
local i = 0
return function ()
i = i + 1
if i <= #premake.solution.list then
return premake.solution.list[i]
end
end
end
--
-- Iterate over the projects of a solution.
--
-- @param sln
-- The solution.
-- @returns
-- An iterator function.
--
function premake.solution.eachproject(sln)
local i = 0
return function ()
i = i + 1
if (i <= #sln.projects) then
return premake.solution.getproject(sln, i)
end
end
end
--
-- Iterate over the groups of a solution
--
-- @param sln
-- The solution.
-- @returns
-- An iterator function.
function premake.solution.eachgroup(sln)
local i = 0
return function()
i = i + 1
if(i <= #sln.groups) then
return premake.solution.getgroup(sln, i)
end
end
end
--
-- Retrieve a solution by name or index.
--
-- @param key
-- The solution key, either a string name or integer index.
-- @returns
-- The solution with the provided key.
--
function premake.solution.get(key)
return premake.solution.list[key]
end
--
-- Retrieve the project at a particular index.
--
-- @param sln
-- The solution.
-- @param idx
-- An index into the array of projects.
-- @returns
-- The project at the given index.
--
function premake.solution.getproject(sln, idx)
-- retrieve the root configuration of the project, with all of
-- the global (not configuration specific) settings collapsed
local prj = sln.projects[idx]
local cfg = premake.getconfig(prj)
-- root configuration doesn't have a name; use the project's
cfg.name = prj.name
return cfg
end
--
-- Retrieve the group at a particular index
--
-- @param sln
-- The solution.
-- @param idx
-- The index into the array of groups
-- @returns
-- The group at the given index
function premake.solution.getgroup(sln, idx)
local grp = sln.groups[idx]
return grp
end
|