Remove all configuration values from project; prevent top-level settings from bleeding through and causing side-effects at the config level
This commit is contained in:
parent
f19694fd9a
commit
391ec4eee6
@ -86,7 +86,11 @@
|
||||
if _ACTION > "vs2003" then
|
||||
_x(1,'RootNamespace="%s"', prj.name)
|
||||
end
|
||||
_p(1,'Keyword="%s"', iif(prj.flags.Managed, "ManagedCProj", "Win32Proj"))
|
||||
|
||||
-- flags are located on the configurations; grab one
|
||||
local cfg = project.getconfig(prj, prj.configurations[1], prj.platforms[1])
|
||||
_p(1,'Keyword="%s"', iif(cfg.flags.Managed, "ManagedCProj", "Win32Proj"))
|
||||
|
||||
_p(1,'>')
|
||||
end
|
||||
|
||||
@ -731,7 +735,7 @@
|
||||
local hasSettings = (filecfg ~= nil and filecfg.terms ~= nil)
|
||||
|
||||
-- check to see if this is the PCH source file
|
||||
local isPchSource = (prj.pchsource == node.abspath and not cfg.flags.NoPCH)
|
||||
local isPchSource = (cfg.pchsource == node.abspath and not cfg.flags.NoPCH)
|
||||
|
||||
-- only write the element if we have something to say
|
||||
if compileAs or isPchSource or not filecfg or hasSettings then
|
||||
|
@ -104,12 +104,17 @@
|
||||
function vc2010.globals(prj)
|
||||
_p(1,'<PropertyGroup Label="Globals">')
|
||||
_p(2,'<ProjectGuid>{%s}</ProjectGuid>', prj.uuid)
|
||||
if prj.flags.Managed then
|
||||
|
||||
-- flags are located on the configurations; grab one
|
||||
local cfg = project.getconfig(prj, prj.configurations[1], prj.platforms[1])
|
||||
|
||||
if cfg.flags.Managed then
|
||||
_p(2,'<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>')
|
||||
_p(2,'<Keyword>ManagedCProj</Keyword>')
|
||||
else
|
||||
_p(2,'<Keyword>Win32Proj</Keyword>')
|
||||
end
|
||||
|
||||
_p(2,'<RootNamespace>%s</RootNamespace>', prj.name)
|
||||
_p(1,'</PropertyGroup>')
|
||||
end
|
||||
@ -395,7 +400,7 @@
|
||||
_p(3,'<ExcludedFromBuild %s>true</ExcludedFromBuild>', vc2010.condition(cfg))
|
||||
end
|
||||
|
||||
if prj.pchsource == file.abspath and not cfg.flags.NoPCH then
|
||||
if cfg.pchsource == file.abspath and not cfg.flags.NoPCH then
|
||||
_p(3,'<PrecompiledHeader %s>Create</PrecompiledHeader>', vc2010.condition(cfg))
|
||||
end
|
||||
end
|
||||
|
@ -56,10 +56,7 @@
|
||||
-- If there is a basis object, start with that
|
||||
if basis then
|
||||
cfg = oven.bake(basis, nil, filterTerms, filterField)
|
||||
end
|
||||
|
||||
-- Merge container level (solution, project) in the result
|
||||
cfg = oven.merge(cfg, container)
|
||||
end
|
||||
|
||||
-- Walk the blocks available in this container, and merge their values
|
||||
-- into my configuration-in-progress, if they pass the keyword filter
|
||||
|
@ -17,8 +17,9 @@
|
||||
function project.bake(prj, sln)
|
||||
-- bake the project's "root" configuration, which are all of the
|
||||
-- values that aren't part of a more specific configuration
|
||||
local result = project.bakeconfig(prj)
|
||||
local result = oven.merge(oven.merge({}, sln), prj)
|
||||
result.solution = sln
|
||||
result.platforms = result.platforms or {}
|
||||
result.blocks = prj.blocks
|
||||
result.baked = true
|
||||
|
||||
@ -72,7 +73,7 @@
|
||||
-- use that to further filter the results
|
||||
local cfg = oven.bake(prj, prj.solution, filter, "system")
|
||||
filter.system = cfg.system or system or premake.action.current().os or os.get()
|
||||
|
||||
|
||||
cfg = oven.bake(prj, prj.solution, filter)
|
||||
cfg.solution = prj.solution
|
||||
cfg.project = prj
|
||||
@ -126,7 +127,7 @@
|
||||
|
||||
-- pair up the project's original list of build cfgs and platforms
|
||||
local slncfgs = table.fold(prj.configurations or {}, prj.platforms or {})
|
||||
|
||||
|
||||
-- apply the set of mappings
|
||||
local prjcfgs = {}
|
||||
for patterns, replacements in pairs(prj.configmap or {}) do
|
||||
|
@ -37,108 +37,113 @@
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a debug command is provided, it should be specified relative to
|
||||
-- the project.
|
||||
--
|
||||
|
||||
function suite.debugCommand_onRelativePath()
|
||||
location "build"
|
||||
debugcommand "bin/emulator.exe"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Command="..\bin\emulator.exe"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a working directory is provided, it should be specified relative to
|
||||
-- the project.
|
||||
--
|
||||
|
||||
function suite.workingDir_onRelativePath()
|
||||
location "build"
|
||||
debugdir "bin/debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
WorkingDirectory="..\bin\debug"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Make sure debug arguments are being written.
|
||||
--
|
||||
|
||||
function suite.commandArguments_onDebugArgs()
|
||||
debugargs { "arg1", "arg2" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
CommandArguments="arg1 arg2"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Make sure environment variables are being written.
|
||||
--
|
||||
|
||||
function suite.environmentVarsSet_onDebugEnvs()
|
||||
debugenvs { "key=value" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
||||
|
||||
--
|
||||
-- If a debug command is provided, it should be specified relative to
|
||||
-- the project.
|
||||
--
|
||||
|
||||
function suite.debugCommand_onRelativePath()
|
||||
location "build"
|
||||
debugcommand "bin/emulator.exe"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Command="..\bin\emulator.exe"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a working directory is provided, it should be specified relative to
|
||||
-- the project.
|
||||
--
|
||||
|
||||
function suite.workingDir_onRelativePath()
|
||||
location "build"
|
||||
debugdir "bin/debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
WorkingDirectory="..\bin\debug"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure debug arguments are being written.
|
||||
--
|
||||
|
||||
function suite.commandArguments_onDebugArgs()
|
||||
debugargs { "arg1", "arg2" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
CommandArguments="arg1 arg2"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure environment variables are being written.
|
||||
--
|
||||
|
||||
function suite.environmentVarsSet_onDebugEnvs()
|
||||
debugenvs { "key=value" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Make sure quotes around environment variables are properly escaped.
|
||||
--
|
||||
|
||||
function suite.environmentVarsEscaped_onQuotes()
|
||||
debugenvs { 'key="value"' }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
||||
|
||||
--
|
||||
-- Make sure quotes around environment variables are properly escaped.
|
||||
--
|
||||
|
||||
function suite.environmentVarsEscaped_onQuotes()
|
||||
debugenvs { 'key="value"' }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key="value""
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- If multiple environment variables are specified, make sure they get
|
||||
-- separated properly.
|
||||
--
|
||||
|
||||
function suite.environmentVars_onMultipleValues()
|
||||
debugenvs { "key=value", "foo=bar" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
||||
--
|
||||
-- If multiple environment variables are specified, make sure they get
|
||||
-- separated properly.
|
||||
--
|
||||
|
||||
function suite.environmentVars_onMultipleValues()
|
||||
debugenvs { "key=value", "foo=bar" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value
foo=bar"
|
||||
/>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Make sure that environment merging is turned off if the build
|
||||
-- flag is set.
|
||||
--
|
||||
|
||||
function suite.environmentVarsSet_onDebugEnvs()
|
||||
debugenvs { "key=value" }
|
||||
flags { "DebugEnvsDontMerge" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that environment merging is turned off if the build
|
||||
-- flag is set.
|
||||
--
|
||||
|
||||
function suite.environmentVarsSet_onDebugEnvs()
|
||||
debugenvs { "key=value" }
|
||||
flags { "DebugEnvsDontMerge" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<DebugSettings
|
||||
Environment="key=value"
|
||||
EnvironmentMerge="false"
|
||||
|
@ -20,29 +20,6 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When a solution is baked, a reference to that solution should be
|
||||
-- placed in the resulting configuration.
|
||||
--
|
||||
|
||||
function suite.solutionSet_whenCalledOnSolution()
|
||||
local cfg = oven.bake(sln)
|
||||
test.istrue(sln == cfg.solution)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When a project is baked, a reference to that project should be
|
||||
-- placed in the resulting configuration.
|
||||
--
|
||||
|
||||
function suite.solutionSet_whenCalledOnSolution()
|
||||
prj = project("MyProject")
|
||||
local cfg = oven.bake(prj, sln)
|
||||
test.istrue(prj == cfg.project)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test pulling "project global" values, which are associated with
|
||||
-- all configurations in the project.
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
function suite.valuePresentInResult()
|
||||
configmap { ["key"] = "value" }
|
||||
local cfg = oven.bake(sln)
|
||||
local cfg = oven.merge({}, sln)
|
||||
test.isequal("value", cfg.configmap["key"][1])
|
||||
end
|
||||
|
||||
@ -40,6 +40,6 @@
|
||||
configmap { ["sln"] = "slnvalue" }
|
||||
prj = project("MyProject")
|
||||
configmap { ["prj"] = "prjvalue" }
|
||||
local cfg = oven.bake(prj, sln)
|
||||
local cfg = oven.merge(prj, sln)
|
||||
test.istrue(cfg.configmap.sln ~= nil and cfg.configmap.prj ~= nil)
|
||||
end
|
||||
|
@ -6,18 +6,23 @@
|
||||
|
||||
T.oven_removes = { }
|
||||
local suite = T.oven_removes
|
||||
local oven = premake5.oven
|
||||
local project = premake5.project
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln = solution("MySolution")
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = premake5.project.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
@ -27,15 +32,15 @@
|
||||
function suite.remove_onExactValueMatch()
|
||||
flags { "Symbols", "Optimize", "NoRTTI" }
|
||||
removeflags "Optimize"
|
||||
cfg = oven.bake(sln)
|
||||
test.isequal("Symbols|NoRTTI", table.concat(cfg.flags, "|"))
|
||||
prepare()
|
||||
test.isequal({ "Symbols", "NoRTTI" }, cfg.flags)
|
||||
end
|
||||
|
||||
function suite.remove_onMultipleValues()
|
||||
flags { "Symbols", "NoExceptions", "Optimize", "NoRTTI" }
|
||||
removeflags { "NoExceptions", "NoRTTI" }
|
||||
cfg = oven.bake(sln)
|
||||
test.isequal("Symbols|Optimize", table.concat(cfg.flags, "|"))
|
||||
prepare()
|
||||
test.isequal({ "Symbols", "Optimize" }, cfg.flags)
|
||||
end
|
||||
|
||||
|
||||
@ -46,8 +51,8 @@
|
||||
function suite.remove_onWildcard()
|
||||
defines { "WIN32", "WIN64", "LINUX", "MACOSX" }
|
||||
removedefines { "WIN*" }
|
||||
cfg = oven.bake(sln)
|
||||
test.isequal("LINUX|MACOSX", table.concat(cfg.defines, "|"))
|
||||
prepare()
|
||||
test.isequal({ "LINUX", "MACOSX" }, cfg.defines)
|
||||
end
|
||||
|
||||
--
|
||||
@ -57,7 +62,7 @@
|
||||
function suite.remove_onExactValueMatch()
|
||||
flags { "Symbols", "Optimize", "NoRTTI" }
|
||||
removeflags "Optimize"
|
||||
cfg = oven.bake(sln)
|
||||
prepare()
|
||||
test.isnil(cfg.flags.Optimize)
|
||||
end
|
||||
|
||||
@ -68,7 +73,7 @@
|
||||
function suite.remove_onFileField()
|
||||
files { "hello.c", "goodbye.c" }
|
||||
removefiles { "goodbye.c" }
|
||||
cfg = oven.bake(sln)
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "hello.c"), table.concat(cfg.files))
|
||||
end
|
||||
|
||||
@ -77,9 +82,7 @@
|
||||
--
|
||||
|
||||
function suite.remove_onContainerField()
|
||||
configurations { "Debug", "Release" }
|
||||
local prj = project "MyProject"
|
||||
removeconfigurations { "Debug" }
|
||||
cfg = oven.bake(prj, sln)
|
||||
test.isequal({ "Release" }, cfg.configurations)
|
||||
removeconfigurations { "Release" }
|
||||
prepare()
|
||||
test.isequal({ "Debug" }, cfg.project.configurations)
|
||||
end
|
||||
|
@ -33,7 +33,7 @@
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
function prepare()
|
||||
local function prepare()
|
||||
-- some values are only accessible after a full bake
|
||||
solution.bake(sln)
|
||||
prj = solution.getproject_ng(sln, 1)
|
||||
|
@ -20,7 +20,7 @@
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = premake.project.getconfig(prj)
|
||||
cfg = premake.project.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
-- operating environment.
|
||||
--
|
||||
|
||||
function suite.usesCurrentOS_onNoSystemSpecified()
|
||||
function suite.actionOverridesOS()
|
||||
_OS = "linux"
|
||||
_ACTION = "vs2005"
|
||||
configuration { "windows" }
|
||||
@ -59,7 +59,7 @@
|
||||
-- the current operating environment, as well as the tool's target OS.
|
||||
--
|
||||
|
||||
function suite.usesCurrentOS_onNoSystemSpecified()
|
||||
function suite.usesCfgSystem()
|
||||
_OS = "linux"
|
||||
_ACTION = "vs2005"
|
||||
system "macosx"
|
||||
@ -74,7 +74,7 @@
|
||||
-- The current action should be taken into account.
|
||||
--
|
||||
|
||||
function suite.usesCurrentOS_onNoSystemSpecified()
|
||||
function suite.appliesActionToFilters()
|
||||
_ACTION = "vs2005"
|
||||
configuration { "vs2005" }
|
||||
defines { "correct" }
|
||||
|
@ -13,13 +13,15 @@
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = premake.solution.getproject_ng(sln, 1)
|
||||
cfg = project.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
@ -113,7 +115,7 @@
|
||||
files "src/hello.h"
|
||||
vpaths { [""] = "src" }
|
||||
prepare()
|
||||
test.isequal("hello.h", project.getvpath(prj, prj.files[1]))
|
||||
test.isequal("hello.h", project.getvpath(prj, cfg.files[1]))
|
||||
end
|
||||
|
||||
function suite.MatchFilePattern_OnProjectLocationSet()
|
||||
@ -121,7 +123,7 @@
|
||||
files "src/hello.h"
|
||||
vpaths { ["Headers"] = "**.h" }
|
||||
prepare()
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, prj.files[1]))
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
||||
end
|
||||
|
||||
function suite.MatchFilePatternWithPath_OnProjectLocationSet()
|
||||
@ -129,5 +131,5 @@
|
||||
files "src/hello.h"
|
||||
vpaths { ["Headers"] = "src/**.h" }
|
||||
prepare()
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, prj.files[1]))
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user