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)
|
table.foreachi(value, recurse)
|
||||||
|
|
||||||
elseif hasDeprecatedValues and value:contains("*") then
|
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)
|
local mask = path.wildcards(value)
|
||||||
for _, item in ipairs(current) do
|
for _, item in ipairs(current) do
|
||||||
if item:match(mask) == item then
|
if item:match(mask) == item then
|
||||||
recurse(item)
|
recurse(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(removes, value)
|
|
||||||
|
|
||||||
else
|
else
|
||||||
local value, err, additional = api.checkValue(field, value)
|
local value, err, additional = api.checkValue(field, value)
|
||||||
if err then
|
if err then
|
||||||
@ -1100,9 +1105,7 @@
|
|||||||
|
|
||||||
function configuration(terms)
|
function configuration(terms)
|
||||||
if terms then
|
if terms then
|
||||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or
|
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or (terms == "*") then
|
||||||
(terms == "*")
|
|
||||||
then
|
|
||||||
terms = nil
|
terms = nil
|
||||||
end
|
end
|
||||||
configset.addblock(api.scope.current, {terms}, os.getcwd())
|
configset.addblock(api.scope.current, {terms}, os.getcwd())
|
||||||
@ -1119,9 +1122,7 @@
|
|||||||
|
|
||||||
function filter(terms)
|
function filter(terms)
|
||||||
if terms then
|
if terms then
|
||||||
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or
|
if (type(terms) == "table" and #terms == 1 and terms[1] == "*") or (terms == "*") then
|
||||||
(terms == "*")
|
|
||||||
then
|
|
||||||
terms = nil
|
terms = nil
|
||||||
end
|
end
|
||||||
local ok, err = configset.addFilter(api.scope.current, {terms}, os.getcwd())
|
local ok, err = configset.addFilter(api.scope.current, {terms}, os.getcwd())
|
||||||
|
@ -81,6 +81,15 @@
|
|||||||
end
|
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)
|
function configset._fetchDirect(cset, field, filter, ctx, origin)
|
||||||
-- If the originating configset hasn't been compiled, then the value will still
|
-- If the originating configset hasn't been compiled, then the value will still
|
||||||
-- be on that configset.
|
-- be on that configset.
|
||||||
@ -107,7 +116,7 @@
|
|||||||
filter.files = path.getrelative(basedir, abspath)
|
filter.files = path.getrelative(basedir, abspath)
|
||||||
end
|
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
|
-- 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
|
-- changes later made to it by the caller won't alter the
|
||||||
-- original value (that was a tough bug to find)
|
-- original value (that was a tough bug to find)
|
||||||
@ -181,7 +190,7 @@
|
|||||||
filter.files = path.getrelative(basedir, abspath)
|
filter.files = path.getrelative(basedir, abspath)
|
||||||
end
|
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
|
if block._removes and block._removes[key] then
|
||||||
remove(block._removes[key])
|
remove(block._removes[key])
|
||||||
end
|
end
|
||||||
|
@ -94,6 +94,7 @@
|
|||||||
local crit = {}
|
local crit = {}
|
||||||
crit.patterns = patterns
|
crit.patterns = patterns
|
||||||
crit.data = criteria._compile(patterns)
|
crit.data = criteria._compile(patterns)
|
||||||
|
crit.terms = terms
|
||||||
return crit
|
return crit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ return {
|
|||||||
"api/test_register.lua",
|
"api/test_register.lua",
|
||||||
"api/test_string_kind.lua",
|
"api/test_string_kind.lua",
|
||||||
"api/test_table_kind.lua",
|
"api/test_table_kind.lua",
|
||||||
|
"api/test_deprecations.lua",
|
||||||
|
|
||||||
-- Control system tests
|
-- Control system tests
|
||||||
"test_premake.lua",
|
"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