More solution object refactoring
This commit is contained in:
parent
293e2353ba
commit
505efec180
@ -20,7 +20,7 @@
|
|||||||
if not platform then return true end
|
if not platform then return true end
|
||||||
platform = premake.checkvalue(platform, premake.fields.platforms.allowed)
|
platform = premake.checkvalue(platform, premake.fields.platforms.allowed)
|
||||||
|
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
local platforms = sln.platforms or { }
|
local platforms = sln.platforms or { }
|
||||||
|
|
||||||
-- an empty table is equivalent to a native build
|
-- an empty table is equivalent to a native build
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
function _MAKE.getmakefilename(this, searchprjs)
|
function _MAKE.getmakefilename(this, searchprjs)
|
||||||
-- how many projects/solutions use this location?
|
-- how many projects/solutions use this location?
|
||||||
local count = 0
|
local count = 0
|
||||||
for _,sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
if (sln.location == this.location) then count = count + 1 end
|
if (sln.location == this.location) then count = count + 1 end
|
||||||
if (searchprjs) then
|
if (searchprjs) then
|
||||||
for _,prj in ipairs(sln.projects) do
|
for _,prj in ipairs(sln.projects) do
|
||||||
|
@ -50,8 +50,7 @@
|
|||||||
|
|
||||||
function premake.action.call(name)
|
function premake.action.call(name)
|
||||||
local a = premake.action.list[name]
|
local a = premake.action.list[name]
|
||||||
|
for sln in premake.solution.each() do
|
||||||
for _,sln in ipairs(_SOLUTIONS) do
|
|
||||||
if a.onsolution then
|
if a.onsolution then
|
||||||
a.onsolution(sln)
|
a.onsolution(sln)
|
||||||
end
|
end
|
||||||
|
@ -613,25 +613,9 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
premake.CurrentContainer = _SOLUTIONS[name]
|
premake.CurrentContainer = premake.solution.get(name)
|
||||||
if (not premake.CurrentContainer) then
|
if (not premake.CurrentContainer) then
|
||||||
local sln = { }
|
premake.CurrentContainer = premake.solution.new(name)
|
||||||
premake.CurrentContainer = sln
|
|
||||||
|
|
||||||
-- add to master list keyed by both name and index
|
|
||||||
table.insert(_SOLUTIONS, sln)
|
|
||||||
_SOLUTIONS[name] = sln
|
|
||||||
|
|
||||||
-- attach a type
|
|
||||||
setmetatable(sln, {
|
|
||||||
__type="solution"
|
|
||||||
})
|
|
||||||
|
|
||||||
sln.name = name
|
|
||||||
sln.basedir = os.getcwd()
|
|
||||||
sln.projects = { }
|
|
||||||
sln.blocks = { }
|
|
||||||
sln.configurations = { }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add an empty, global configuration
|
-- add an empty, global configuration
|
||||||
|
@ -343,7 +343,7 @@
|
|||||||
local cfg_dirs = {}
|
local cfg_dirs = {}
|
||||||
local hit_counts = {}
|
local hit_counts = {}
|
||||||
|
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
for _, cfg in pairs(prj.__configs) do
|
for _, cfg in pairs(prj.__configs) do
|
||||||
|
|
||||||
@ -368,7 +368,7 @@
|
|||||||
|
|
||||||
-- Now assign an object directory to each configuration, skipping those
|
-- Now assign an object directory to each configuration, skipping those
|
||||||
-- that are in use somewhere else in the session
|
-- that are in use somewhere else in the session
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
for _, cfg in pairs(prj.__configs) do
|
for _, cfg in pairs(prj.__configs) do
|
||||||
|
|
||||||
@ -392,7 +392,7 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
local function buildtargets()
|
local function buildtargets()
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
for _, cfg in pairs(prj.__configs) do
|
for _, cfg in pairs(prj.__configs) do
|
||||||
-- determine which conventions the target should follow for this config
|
-- determine which conventions the target should follow for this config
|
||||||
@ -423,7 +423,7 @@
|
|||||||
function premake.buildconfigs()
|
function premake.buildconfigs()
|
||||||
|
|
||||||
-- convert project path fields to be relative to project location
|
-- convert project path fields to be relative to project location
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
prj.location = prj.location or sln.location or prj.basedir
|
prj.location = prj.location or sln.location or prj.basedir
|
||||||
adjustpaths(prj.location, prj)
|
adjustpaths(prj.location, prj)
|
||||||
@ -436,7 +436,7 @@
|
|||||||
|
|
||||||
-- collapse configuration blocks, so that there is only one block per build
|
-- collapse configuration blocks, so that there is only one block per build
|
||||||
-- configuration/platform pair, filtered to the current operating environment
|
-- configuration/platform pair, filtered to the current operating environment
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
local basis = collapse(sln)
|
local basis = collapse(sln)
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
prj.__configs = collapse(prj, basis)
|
prj.__configs = collapse(prj, basis)
|
||||||
|
@ -5,16 +5,6 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
-- The list of defined solutions (which contain projects, etc.)
|
|
||||||
|
|
||||||
_SOLUTIONS = { }
|
|
||||||
|
|
||||||
|
|
||||||
-- The list of built-in output templates
|
|
||||||
|
|
||||||
_TEMPLATES = { }
|
|
||||||
|
|
||||||
|
|
||||||
-- A top-level namespace for support functions
|
-- A top-level namespace for support functions
|
||||||
|
|
||||||
premake = { }
|
premake = { }
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
function premake.findproject(name)
|
function premake.findproject(name)
|
||||||
name = name:lower()
|
name = name:lower()
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
for _, prj in ipairs(sln.projects) do
|
for _, prj in ipairs(sln.projects) do
|
||||||
if (prj.name:lower() == name) then
|
if (prj.name:lower() == name) then
|
||||||
return prj
|
return prj
|
||||||
|
@ -7,6 +7,55 @@
|
|||||||
premake.solution = { }
|
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 = { }
|
||||||
|
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.
|
-- Iterate over the projects of a solution.
|
||||||
--
|
--
|
||||||
@ -27,6 +76,20 @@
|
|||||||
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.
|
-- Retrieve the project at a particular index.
|
||||||
--
|
--
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
function premake.checkprojects()
|
function premake.checkprojects()
|
||||||
local action = premake.action.current()
|
local action = premake.action.current()
|
||||||
|
|
||||||
for _, sln in ipairs(_SOLUTIONS) do
|
for sln in premake.solution.each() do
|
||||||
|
|
||||||
-- every solution must have at least one project
|
-- every solution must have at least one project
|
||||||
if (#sln.projects == 0) then
|
if (#sln.projects == 0) then
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
_ACTION = "test"
|
_ACTION = "test"
|
||||||
_ARGS = { }
|
_ARGS = { }
|
||||||
_OPTIONS = { }
|
_OPTIONS = { }
|
||||||
_SOLUTIONS = { }
|
premake.solution.list = { }
|
||||||
|
|
||||||
-- reset captured I/O values
|
-- reset captured I/O values
|
||||||
test.value_openedfilename = nil
|
test.value_openedfilename = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user