diff --git a/src/base/api.lua b/src/base/api.lua index 00da8ad6..388a38b0 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -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 diff --git a/src/base/bake.lua b/src/base/bake.lua index f9eed986..313360de 100644 --- a/src/base/bake.lua +++ b/src/base/bake.lua @@ -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; diff --git a/src/project/oven.lua b/src/project/oven.lua index 22be2638..05c5603e 100755 --- a/src/project/oven.lua +++ b/src/project/oven.lua @@ -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 diff --git a/tests/config/test_fileconfig.lua b/tests/config/test_fileconfig.lua index 44e088b8..6d64c36c 100644 --- a/tests/config/test_fileconfig.lua +++ b/tests/config/test_fileconfig.lua @@ -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 + +