Merge filtering fixes
This commit is contained in:
commit
19df1c5722
@ -4,3 +4,8 @@
|
||||
|
||||
See https://bitbucket.org/premake/premake-dev/wiki/What's_New_in_5.0
|
||||
for the complete list of changes from the Premake 4.x series.
|
||||
|
||||
Since 5.0-alpha1:
|
||||
|
||||
* filter() now accepts field value aliases in the conditions
|
||||
* Fixed _ACTION and _OPTIONS filter prefixes
|
||||
|
@ -5,11 +5,13 @@
|
||||
-- and wildcard matches. Provides functions match match these criteria
|
||||
-- against various contexts.
|
||||
--
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
premake.criteria = criteria
|
||||
local criteria = premake.criteria
|
||||
local p = premake
|
||||
|
||||
p.criteria = criteria -- criteria namespace is defined in C host
|
||||
local criteria = p.criteria
|
||||
|
||||
|
||||
--
|
||||
@ -19,14 +21,14 @@
|
||||
--
|
||||
|
||||
criteria._validPrefixes = {
|
||||
_ACTION = true,
|
||||
_action = true,
|
||||
action = true,
|
||||
architecture = true,
|
||||
configurations = true,
|
||||
files = true,
|
||||
kind = true,
|
||||
language = true,
|
||||
_OPTIONS = true,
|
||||
_options = true,
|
||||
options = true,
|
||||
platforms = true,
|
||||
system = true,
|
||||
@ -69,6 +71,15 @@
|
||||
if prefix and not criteria._validPrefixes[prefix] then
|
||||
return nil, string.format("Invalid field prefix '%s'", prefix)
|
||||
end
|
||||
|
||||
-- check for field value aliases
|
||||
if prefix then
|
||||
local fld = p.field.get(prefix)
|
||||
if fld and fld.aliases then
|
||||
word[1] = fld.aliases[word[1]] or word[1]
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(pattern, word)
|
||||
end
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
-- Lists to hold all of the registered fields and data kinds
|
||||
|
||||
field._list = {}
|
||||
field._loweredList = {}
|
||||
field._kinds = {}
|
||||
|
||||
-- For historical reasons
|
||||
@ -94,6 +95,8 @@
|
||||
end
|
||||
|
||||
field._list[f.name] = f
|
||||
field._loweredList[f.name:lower()] = f
|
||||
|
||||
return f
|
||||
end
|
||||
|
||||
@ -105,6 +108,7 @@
|
||||
|
||||
function field.unregister(f)
|
||||
field._list[f.name] = nil
|
||||
field._loweredList[f.name:lower()] = nil
|
||||
end
|
||||
|
||||
|
||||
@ -253,7 +257,7 @@
|
||||
---
|
||||
|
||||
function field.get(name)
|
||||
return field._list[name]
|
||||
return field._list[name] or field._loweredList[name:lower()]
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--
|
||||
-- tests/base/test_criteria.lua
|
||||
-- Test suite for the criteria matching API.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("criteria")
|
||||
@ -308,3 +308,21 @@
|
||||
test.isnil(crit)
|
||||
test.isnotnil(err)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should respect field value aliases, if present.
|
||||
--
|
||||
|
||||
function suite.passes_onAliasedValue()
|
||||
premake.api.addAliases("system", { ["gnu-linux"] = "linux" })
|
||||
crit = criteria.new { "system:gnu-linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onAliasedValue_withMixedCase()
|
||||
premake.api.addAliases("system", { ["gnu-linux"] = "linux" })
|
||||
crit = criteria.new { "System:GNU-Linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user