Solution.bake() now returns a temporary result; does not overwrite original solution object

This commit is contained in:
Jason Perkins 2012-04-24 16:57:02 -04:00
parent 15662f30c9
commit b44817ebd7
2 changed files with 29 additions and 23 deletions

View File

@ -67,23 +67,34 @@
--
function solution.bake(sln)
-- flatten out all of the projects and their configurations
for _, prj in ipairs(sln.projects) do
prj.baked = project.bake(prj)
end
-- start by copying all field values into the baked result
local result = oven.merge({}, sln)
result.baked = true
-- assign unique object directories to every project configuration
solution.bakeobjdirs(sln)
-- keep a reference to the original configuration blocks, in
-- case additional filtering (i.e. for files) is needed later
result.blocks = sln.blocks
-- bake all of the projects in the list, and store that result
local projects = {}
for i, prj in ipairs(sln.projects) do
projects[i] = project.bake(prj)
projects[prj.name] = projects[i]
end
result.projects = projects
-- assign unique object directories to every project configurations
solution.bakeobjdirs(result)
-- expand all tokens contained by the solution
for prj in solution.eachproject_ng(sln) do
for prj in solution.eachproject_ng(result) do
oven.expandtokens(prj, "project")
for cfg in project.eachconfig(prj) do
oven.expandtokens(cfg, "config")
end
end
return sln
return result
end
@ -357,14 +368,10 @@
--
function solution.getproject_ng(sln, idx)
-- fetch the "raw" project object
local prj = sln.projects[idx]
-- if there is a baked version available, use it
if prj.baked then
return prj.baked
-- to make testing a little easier, allow this function to
-- accept an unbaked solution, and fix it on the fly
if not sln.baked then
sln = solution.bake(sln)
end
-- otherwise, bake a new copy on-the-fly
return project.bake(prj)
return sln.projects[idx]
end

View File

@ -22,8 +22,7 @@
local function prepare()
local platforms = sln.platforms or {}
prj = project("MyProject")
premake.solution.bake(sln)
project("MyProject")
prj = premake.solution.getproject_ng(sln, "MyProject")
cfg = premake5.project.getconfig(prj, "Debug", platforms[1])
end
@ -45,7 +44,7 @@
-- be used to make unique.
--
function suite.directoryIncludesPlatform_onConflictAndPlatform()
function suite.directoryIncludesPlatform_onPlatformConflict()
configurations { "Debug" }
platforms { "x32", "x64" }
prepare()
@ -58,7 +57,7 @@
-- configuration names should be used to make unique.
--
function suite.directoryIncludesBuildCfg_onConflictAndNoPlatforms()
function suite.directoryIncludesBuildCfg_onBuildCfgConflict()
configurations { "Debug", "Release" }
prepare()
test.isequal("obj/Debug", cfg.objdir)
@ -70,7 +69,7 @@
-- both should be used to make unique.
--
function suite.directoryIncludesBuildCfg_onConflictAndNoPlatforms()
function suite.directoryIncludesBuildCfg_onPlatformAndBuildCfgConflict()
configurations { "Debug", "Release" }
platforms { "x32", "x64" }
prepare()
@ -83,7 +82,7 @@
-- used to make unique.
--
function suite.directoryIncludesBuildCfg_onConflictAndNoPlatforms()
function suite.directoryIncludesBuildCfg_onProjectConflict()
configurations { "Debug", "Release" }
project "MyProject2"
prepare()