Prevent "not X" terms from matching file names when building file configurations; object fields are not nil if not set (instead of empty table)
This commit is contained in:
parent
0ff8a15947
commit
a05fafca93
@ -1191,7 +1191,7 @@
|
||||
|
||||
-- initialize list-type fields to empty tables
|
||||
for name, field in pairs(premake.fields) do
|
||||
if (field.kind ~= "string" and field.kind ~= "path") then
|
||||
if field.kind:endswith("-list") then
|
||||
cfg[name] = { }
|
||||
end
|
||||
end
|
||||
|
@ -412,7 +412,7 @@
|
||||
if(not cfg) then return end
|
||||
|
||||
local foundUsePrjs = {};
|
||||
for _, useName in ipairs(cfg[searchField]) do
|
||||
for _, useName in ipairs(cfg[searchField] or {}) do
|
||||
local testName = useName:lower();
|
||||
if((not foundList[testName])) then
|
||||
local theProj = nil;
|
||||
|
@ -236,12 +236,13 @@
|
||||
function oven.filter(block, anyOfThese, allOfThese)
|
||||
allOfThese = allOfThese or {}
|
||||
|
||||
-- All of these terms must match at least one block keyword
|
||||
-- All of these terms must match at least one block keyword;
|
||||
-- negative matches (i.e. "not X") do not count
|
||||
for _, term in ipairs(allOfThese) do
|
||||
local matched = false
|
||||
|
||||
for _, keyword in ipairs(block.keywords) do
|
||||
if oven.testkeyword(keyword, { term }) then
|
||||
if oven.testkeyword(keyword, { term }, true) then
|
||||
matched = true
|
||||
break
|
||||
end
|
||||
@ -271,13 +272,20 @@
|
||||
-- The keyword to test.
|
||||
-- @param terms
|
||||
-- The list of terms to filter against.
|
||||
-- @param skipNots
|
||||
-- Boolean flag indicating whether negative matches (i.e. "not X")
|
||||
-- should be considered (they are not for filename searches).
|
||||
-- @returns
|
||||
-- True if the keyword matches at least one filter term.
|
||||
--
|
||||
|
||||
function oven.testkeyword(keyword, terms)
|
||||
function oven.testkeyword(keyword, terms, skipNots)
|
||||
if keyword:startswith("not ") then
|
||||
return not oven.testkeyword(keyword:sub(5), terms)
|
||||
if skipNots then
|
||||
return false
|
||||
else
|
||||
return not oven.testkeyword(keyword:sub(5), terms)
|
||||
end
|
||||
end
|
||||
|
||||
for _, pattern in ipairs(keyword:explode(" or ")) do
|
||||
|
@ -101,3 +101,19 @@
|
||||
prepare()
|
||||
test.isequal({ "-Xc" }, fcfg.buildoptions)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- A "not" filter should not provide the positive match for a
|
||||
-- file configuration filename mask.
|
||||
--
|
||||
|
||||
function suite.fileIsUnmatched_onNotFilter()
|
||||
files "hello.c"
|
||||
configuration "not Debug"
|
||||
buildoptions "-Xc"
|
||||
prepare()
|
||||
test.isnil(fcfg.buildoptions)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user