diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 74c3b4a5..f67f5eb7 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -1149,7 +1149,9 @@ value = value:lower() local tool, version = p.tools.canonical(value) if tool then - return value + return p.tools.normalize(value) + else + return nil end end, } diff --git a/src/base/tools.lua b/src/base/tools.lua index 65488bd5..e8371908 100644 --- a/src/base/tools.lua +++ b/src/base/tools.lua @@ -29,25 +29,33 @@ -- returns nil. --- - function p.tools.canonical(identifier) - local parts + function p.tools.normalize(identifier) if identifier:startswith("v") then -- TODO: this should be deprecated? - parts = { "msc", identifier } - else - parts = identifier:explode("-", true, 1) - - -- couple of little hacks here to fix up version names - if parts[2] ~= nil then - -- 'msc-100' is accepted, but the code expects 'v100' - if parts[1] == "msc" and tonumber(parts[2]:sub(1,3)) ~= nil then - parts[2] = "v" .. parts[2] - end - - -- perform case-correction of the LLVM toolset - if parts[2]:startswith("llvm-vs") then - parts[2] = "LLVM-" .. parts[2]:sub(6) - end - end + identifier = 'msc-' .. identifier end + + local parts = identifier:explode("-", true, 1) + if parts[2] == nil then + return parts[1] + end + + -- 'msc-100' is accepted, but the code expects 'v100' + if parts[1] == "msc" and tonumber(parts[2]:sub(1,3)) ~= nil then + parts[2] = "v" .. parts[2] + end + + -- perform case-correction of the LLVM toolset + if parts[2]:startswith("llvm-vs") then + parts[2] = "LLVM-" .. parts[2]:sub(6) + end + + return parts[1] .. '-' .. parts[2] + end + + + function p.tools.canonical(identifier) + identifier = p.tools.normalize(identifier) + + local parts = identifier:explode("-", true, 1) return p.tools[parts[1]], parts[2] end diff --git a/tests/oven/test_filtering.lua b/tests/oven/test_filtering.lua index d890491d..176b69cf 100644 --- a/tests/oven/test_filtering.lua +++ b/tests/oven/test_filtering.lua @@ -108,6 +108,15 @@ test.isequal({}, cfg.defines) end + function suite.onFilterToolsetNormalization() + toolset "v140" + filter { "toolset:msc-v140" } + defines { "USE_MSC" } + prepare() + test.isequal({ "USE_MSC" }, cfg.defines) + end + + -- -- Test filtering on system. --