Rename solution.lua to workspace.lua and change names internally
This commit is contained in:
parent
f5e27d1e6d
commit
a82466c6f4
@ -37,7 +37,7 @@
|
||||
|
||||
-- project objects
|
||||
"base/global.lua",
|
||||
"base/solution.lua",
|
||||
"base/workspace.lua",
|
||||
"base/group.lua",
|
||||
"base/project.lua",
|
||||
"base/config.lua",
|
||||
|
@ -1,15 +1,12 @@
|
||||
---
|
||||
-- solution.lua
|
||||
-- Work with the list of solutions loaded from the script.
|
||||
-- workspace.lua
|
||||
-- Work with the list of workspaces loaded from the script.
|
||||
-- Copyright (c) 2002-2015 Jason Perkins and the Premake project
|
||||
---
|
||||
|
||||
local p = premake
|
||||
p.solution = p.api.container("solution", p.global)
|
||||
|
||||
local solution = p.solution
|
||||
local tree = p.tree
|
||||
|
||||
|
||||
---
|
||||
-- Begin the switch from solution() to workspace()
|
||||
@ -24,55 +21,51 @@
|
||||
|
||||
|
||||
---
|
||||
-- Create a new solution container instance.
|
||||
-- Create a new workspace container instance.
|
||||
---
|
||||
|
||||
function workspace.new(name)
|
||||
local sln = p.container.new(workspace, name)
|
||||
return sln
|
||||
local wrk = p.container.new(workspace, name)
|
||||
return wrk
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Iterate over the configurations of a solution.
|
||||
-- Iterate over the configurations of a workspace.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution to query.
|
||||
-- @return
|
||||
-- A configuration iteration function.
|
||||
--
|
||||
|
||||
function workspace.eachconfig(sln)
|
||||
sln = premake.oven.bakeSolution(sln)
|
||||
function workspace.eachconfig(self)
|
||||
self = premake.oven.bakeSolution(self)
|
||||
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if i > #sln.configs then
|
||||
if i > #self.configs then
|
||||
return nil
|
||||
else
|
||||
return sln.configs[i]
|
||||
return self.configs[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Iterate over the projects of a solution (next-gen).
|
||||
-- Iterate over the projects of a workspace.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution.
|
||||
-- @return
|
||||
-- An iterator function, returning project configurations.
|
||||
--
|
||||
|
||||
function workspace.eachproject(sln)
|
||||
function workspace.eachproject(self)
|
||||
local i = 0
|
||||
return function ()
|
||||
i = i + 1
|
||||
if i <= #sln.projects then
|
||||
return p.workspace.getproject(sln, i)
|
||||
if i <= #self.projects then
|
||||
return p.workspace.getproject(self, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -81,17 +74,15 @@
|
||||
--
|
||||
-- Locate a project by name, case insensitive.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution to query.
|
||||
-- @param name
|
||||
-- The name of the projec to find.
|
||||
-- @return
|
||||
-- The project object, or nil if a matching project could not be found.
|
||||
--
|
||||
|
||||
function workspace.findproject(sln, name)
|
||||
function workspace.findproject(self, name)
|
||||
name = name:lower()
|
||||
for _, prj in ipairs(sln.projects) do
|
||||
for _, prj in ipairs(self.projects) do
|
||||
if name == prj.name:lower() then
|
||||
return prj
|
||||
end
|
||||
@ -103,35 +94,33 @@
|
||||
--
|
||||
-- Retrieve the tree of project groups.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution to query.
|
||||
-- @return
|
||||
-- The tree of project groups defined for the solution.
|
||||
-- The tree of project groups defined for the workspace.
|
||||
--
|
||||
|
||||
function workspace.grouptree(sln)
|
||||
function workspace.grouptree(self)
|
||||
-- check for a previously cached tree
|
||||
if sln.grouptree then
|
||||
return sln.grouptree
|
||||
if self.grouptree then
|
||||
return self.grouptree
|
||||
end
|
||||
|
||||
-- build the tree of groups
|
||||
|
||||
local tr = tree.new()
|
||||
for prj in workspace.eachproject(sln) do
|
||||
local tr = p.tree.new()
|
||||
for prj in workspace.eachproject(self) do
|
||||
local prjpath = path.join(prj.group, prj.name)
|
||||
local node = tree.add(tr, prjpath)
|
||||
local node = p.tree.add(tr, prjpath)
|
||||
node.project = prj
|
||||
end
|
||||
|
||||
-- assign UUIDs to each node in the tree
|
||||
tree.traverse(tr, {
|
||||
p.tree.traverse(tr, {
|
||||
onnode = function(node)
|
||||
node.uuid = os.uuid(node.path)
|
||||
end
|
||||
})
|
||||
|
||||
sln.grouptree = tr
|
||||
self.grouptree = tr
|
||||
return tr
|
||||
end
|
||||
|
||||
@ -139,26 +128,22 @@
|
||||
--
|
||||
-- Retrieve the project configuration at a particular index.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution.
|
||||
-- @param idx
|
||||
-- An index into the array of projects.
|
||||
-- @return
|
||||
-- The project configuration at the given index.
|
||||
--
|
||||
|
||||
function workspace.getproject(sln, idx)
|
||||
sln = p.oven.bakeSolution(sln)
|
||||
return sln.projects[idx]
|
||||
function workspace.getproject(self, idx)
|
||||
self = p.oven.bakeSolution(self)
|
||||
return self.projects[idx]
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Determines if the solution contains a project that meets certain criteria.
|
||||
-- Determines if the workspace contains a project that meets certain criteria.
|
||||
--
|
||||
-- @param self
|
||||
-- The solution.
|
||||
-- @param func
|
||||
-- A test function. Receives a project as its only argument and returns a
|
||||
-- boolean indicating whether it meets to matching criteria.
|
||||
@ -166,6 +151,6 @@
|
||||
-- True if the test function returned true.
|
||||
---
|
||||
|
||||
function solution.hasProject(self, func)
|
||||
function workspace.hasProject(self, func)
|
||||
return p.container.hasChild(self, p.project, func)
|
||||
end
|
Loading…
Reference in New Issue
Block a user