Project-level configurations no longer propagate up to solutions, require mapping instead
This commit is contained in:
parent
73146fa066
commit
3da76a113f
@ -2,8 +2,6 @@ syntax: glob
|
||||
|
||||
.DS_Store
|
||||
|
||||
*.orig
|
||||
|
||||
build
|
||||
bin
|
||||
obj
|
||||
@ -30,4 +28,4 @@ Makefile
|
||||
Scratchpad.txt
|
||||
Unix Worksheet.worksheet
|
||||
project.bbprojectdata
|
||||
Premake4.tmproj
|
||||
Premake4.tmproj
|
||||
|
@ -102,7 +102,7 @@
|
||||
_p(1,'GlobalSection(ProjectConfigurationPlatforms) = postSolution')
|
||||
for prj in solution.eachproject_ng(sln) do
|
||||
for slncfg in solution.eachconfig(sln) do
|
||||
local prjcfg = project.mapconfig(prj, slncfg.buildcfg, slncfg.platform)
|
||||
local prjcfg = project.getconfig(prj, slncfg.buildcfg, slncfg.platform)
|
||||
if prjcfg then
|
||||
local slnplatform = vstudio.platform(slncfg)
|
||||
local prjplatform = vstudio.projectplatform(prjcfg)
|
||||
|
@ -272,10 +272,27 @@
|
||||
prj = project.bake(prj, prj.solution)
|
||||
end
|
||||
|
||||
-- if no build configuration is specified, return the "root" project
|
||||
-- configurations, which includes all configuration values that
|
||||
-- weren't set with a specific configuration filter
|
||||
if not buildcfg then
|
||||
return prj
|
||||
end
|
||||
|
||||
-- if a configuration mapping is present, apply it
|
||||
if prj.cfgmap then
|
||||
local cfg = prj.cfgmap[buildcfg .. (platform or "")]
|
||||
if cfg then
|
||||
buildcfg = cfg[1]
|
||||
platform = cfg[2]
|
||||
end
|
||||
end
|
||||
|
||||
-- if the project has a platforms list, and the solution does
|
||||
-- not, default to the first project platform
|
||||
platform = platform or prj.platforms[1]
|
||||
|
||||
-- look up and return the associated config
|
||||
local key = (buildcfg or "*") .. (platform or "")
|
||||
return prj.configs[key]
|
||||
end
|
||||
@ -513,18 +530,3 @@
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Given a solution-level build configuration and platform, returns the
|
||||
-- corresponding project configuration, or nil if no such configuration exists.
|
||||
--
|
||||
|
||||
function project.mapconfig(prj, buildcfg, platform)
|
||||
if prj.cfgmap then
|
||||
local cfg = prj.cfgmap[buildcfg .. (platform or "")]
|
||||
buildcfg = cfg[1]
|
||||
platform = cfg[2]
|
||||
end
|
||||
return project.getconfig(prj, buildcfg, platform)
|
||||
end
|
||||
|
@ -66,7 +66,6 @@
|
||||
dofile("project/test_filtering.lua")
|
||||
dofile("project/test_getconfig.lua")
|
||||
dofile("project/test_hasconfig.lua")
|
||||
dofile("project/test_mapconfig.lua")
|
||||
dofile("project/test_vpaths.lua")
|
||||
|
||||
-- Configuration object tests
|
||||
|
@ -19,8 +19,68 @@
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = premake.project.getconfig(prj, "Debug")
|
||||
local function prepare(buildcfg)
|
||||
buildcfg = buildcfg or "Debug"
|
||||
cfg = premake.project.getconfig(prj, buildcfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When no configuration is specified in the project, the solution
|
||||
-- settings should map directly to a configuration object.
|
||||
--
|
||||
|
||||
function suite.solutionConfig_onNoProjectConfigs()
|
||||
prepare()
|
||||
test.isequal("Debug", cfg.buildcfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a project configuration mapping exists, it should be taken into
|
||||
-- account when fetching the configuration object.
|
||||
--
|
||||
|
||||
function suite.appliesCfgMapping_onMappingExists()
|
||||
configmap { ["Debug"] = "Development" }
|
||||
prepare()
|
||||
test.isequal("Development", cfg.buildcfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a configuration mapping exists, can also use the mapped value
|
||||
-- to fetch the configuration.
|
||||
--
|
||||
|
||||
function suite.fetchesMappedCfg_onMappedName()
|
||||
configmap { ["Debug"] = "Development" }
|
||||
prepare("Development")
|
||||
test.isequal("Development", cfg.buildcfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the specified configuration has been removed from the project,
|
||||
-- then nil should be returned.
|
||||
--
|
||||
|
||||
function suite.returnsNil_onRemovedConfig()
|
||||
removeconfigurations { "Debug" }
|
||||
prepare()
|
||||
test.isnil(cfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the project has a platforms list, and the solution does not,
|
||||
-- use the first project platform.
|
||||
--
|
||||
|
||||
function suite.usesFirstPlatform_onNoSolutionPlatforms()
|
||||
platforms { "x32", "x64" }
|
||||
prepare()
|
||||
test.isequal("x32", cfg.platform)
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
--
|
||||
-- tests/project/test_mapconfig.lua
|
||||
-- Tests mapping between solution and project configurations.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.project_mapconfig = { }
|
||||
local suite = T.project_mapconfig
|
||||
local project = premake5.project
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = premake.solution.getproject_ng(sln, 1)
|
||||
cfg = project.mapconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- No mapping should pass right through.
|
||||
--
|
||||
|
||||
function suite.exactMatch_onNoMapping()
|
||||
prepare()
|
||||
test.isequal("Debug", cfg.buildcfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the value is mapped, the corresponding config should be returned.
|
||||
--
|
||||
|
||||
function suite.returnsMappedCfg_onMapping()
|
||||
configmap { ["Debug"] = "Development" }
|
||||
prepare()
|
||||
test.isequal("Development", cfg.buildcfg)
|
||||
end
|
||||
|
Reference in New Issue
Block a user