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