Merge pull request #573 from Blizzard/workaround-572
Workaround for #572
This commit is contained in:
commit
7d7daae3a7
@ -555,15 +555,20 @@
|
||||
table.foreachi(value, recurse)
|
||||
|
||||
elseif hasDeprecatedValues and value:contains("*") then
|
||||
local current = configset.fetch(target, field)
|
||||
local current = configset.fetch(target, field, {
|
||||
matcher = function(cset, block, filter)
|
||||
local current = cset.current
|
||||
return criteria.matches(current._criteria, block._criteria.terms or {}) or
|
||||
criteria.matches(block._criteria, current._criteria.terms or {})
|
||||
end
|
||||
})
|
||||
|
||||
local mask = path.wildcards(value)
|
||||
for _, item in ipairs(current) do
|
||||
if item:match(mask) == item then
|
||||
recurse(item)
|
||||
end
|
||||
end
|
||||
table.insert(removes, value)
|
||||
|
||||
else
|
||||
local value, err, additional = api.checkValue(field, value)
|
||||
if err then
|
||||
@ -1100,9 +1105,7 @@
|
||||
|
||||
function configuration(terms)
|
||||
if terms then
|
||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or
|
||||
(terms == "*")
|
||||
then
|
||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or (terms == "*") then
|
||||
terms = nil
|
||||
end
|
||||
configset.addblock(api.scope.current, {terms}, os.getcwd())
|
||||
@ -1119,9 +1122,7 @@
|
||||
|
||||
function filter(terms)
|
||||
if terms then
|
||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or
|
||||
(terms == "*")
|
||||
then
|
||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or (terms == "*") then
|
||||
terms = nil
|
||||
end
|
||||
local ok, err = configset.addFilter(api.scope.current, {terms}, os.getcwd())
|
||||
|
@ -81,6 +81,15 @@
|
||||
end
|
||||
|
||||
|
||||
function configset._dofilter(cset, block, filter)
|
||||
if not filter.matcher then
|
||||
return (cset.compiled or criteria.matches(block._criteria, filter))
|
||||
else
|
||||
return filter.matcher(cset, block, filter)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function configset._fetchDirect(cset, field, filter, ctx, origin)
|
||||
-- If the originating configset hasn't been compiled, then the value will still
|
||||
-- be on that configset.
|
||||
@ -107,7 +116,7 @@
|
||||
filter.files = path.getrelative(basedir, abspath)
|
||||
end
|
||||
|
||||
if value ~= nil and (cset.compiled or criteria.matches(block._criteria, filter)) then
|
||||
if value ~= nil and configset._dofilter(cset, block, filter) then
|
||||
-- If value is an object, return a copy of it so that any
|
||||
-- changes later made to it by the caller won't alter the
|
||||
-- original value (that was a tough bug to find)
|
||||
@ -181,7 +190,7 @@
|
||||
filter.files = path.getrelative(basedir, abspath)
|
||||
end
|
||||
|
||||
if cset.compiled or criteria.matches(block._criteria, filter) then
|
||||
if configset._dofilter(cset, block, filter) then
|
||||
if block._removes and block._removes[key] then
|
||||
remove(block._removes[key])
|
||||
end
|
||||
|
@ -94,6 +94,7 @@
|
||||
local crit = {}
|
||||
crit.patterns = patterns
|
||||
crit.data = criteria._compile(patterns)
|
||||
crit.terms = terms
|
||||
return crit
|
||||
end
|
||||
|
||||
|
@ -50,6 +50,7 @@ return {
|
||||
"api/test_register.lua",
|
||||
"api/test_string_kind.lua",
|
||||
"api/test_table_kind.lua",
|
||||
"api/test_deprecations.lua",
|
||||
|
||||
-- Control system tests
|
||||
"test_premake.lua",
|
||||
|
65
tests/api/test_deprecations.lua
Normal file
65
tests/api/test_deprecations.lua
Normal file
@ -0,0 +1,65 @@
|
||||
--
|
||||
-- tests/api/test_table_kind.lua
|
||||
-- Tests the table API value type.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("api_deprecations")
|
||||
local api = premake.api
|
||||
|
||||
|
||||
function suite.setup()
|
||||
workspace("MyWorkspace")
|
||||
configurations { "Debug", "Release" }
|
||||
end
|
||||
|
||||
function suite.setsNewValue_whenOldValueIsRemovedViaWildcard_inSubConfig()
|
||||
local prj = project "MyProject"
|
||||
filter { "configurations:Debug" }
|
||||
flags { "Symbols" }
|
||||
|
||||
filter { "*" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
local cfg = test.getconfig(prj, "Debug", platform)
|
||||
test.isequal("Default", cfg.Symbols)
|
||||
end
|
||||
|
||||
|
||||
function suite.setsNewValue_whenOldValueIsRemovedInOtherConfig_inSubConfig()
|
||||
local prj = project "MyProject"
|
||||
flags { "Symbols" }
|
||||
|
||||
filter { "configurations:Release" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
test.isequal("On", test.getconfig(prj, "Debug", platform).Symbols)
|
||||
test.isequal("Default", test.getconfig(prj, "Release", platform).Symbols)
|
||||
end
|
||||
|
||||
|
||||
function suite.dontRemoveFlagIfSetThroughNewApi()
|
||||
local prj = project "MyProject"
|
||||
floatingpoint "Fast"
|
||||
removeflags "*"
|
||||
|
||||
-- test output.
|
||||
local cfg = test.getconfig(prj, "Debug", platform)
|
||||
test.isequal("Fast", cfg.floatingpoint)
|
||||
end
|
||||
|
||||
|
||||
function suite.setsNewValue_whenOldValueFromParentIsRemovedInOtherConfig_inSubConfig()
|
||||
flags { "Symbols" }
|
||||
|
||||
local prj = project "MyProject"
|
||||
filter { "configurations:Release" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
test.isequal("On", test.getconfig(prj, "Debug", platform).Symbols)
|
||||
test.isequal("Default", test.getconfig(prj, "Release", platform).Symbols)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user