diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index f3ea0c4b..bcf0e4bb 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -1510,11 +1510,7 @@ function m.platformToolset(cfg) local tool, version = p.config.toolset(cfg) - if version then - if tonumber(version:sub(1,3)) ~= nil then - version = "v" .. version - end - else + if not version then local action = p.action.current() version = action.vstudio.platformToolset end diff --git a/src/base/string.lua b/src/base/string.lua index 3c28f521..afea319e 100644 --- a/src/base/string.lua +++ b/src/base/string.lua @@ -29,13 +29,19 @@ -- formed by splitting on boundaries formed by `pattern`. -- - function string.explode(s, pattern, plain) + function string.explode(s, pattern, plain, maxTokens) if (pattern == '') then return false end local pos = 0 local arr = { } for st,sp in function() return s:find(pattern, pos, plain) end do table.insert(arr, s:sub(pos, st-1)) pos = sp + 1 + if maxTokens ~= nil and maxTokens > 0 then + maxTokens = maxTokens - 1 + if maxTokens == 0 then + break + end + end end table.insert(arr, s:sub(pos)) return arr diff --git a/src/base/tools.lua b/src/base/tools.lua index 6582289d..f67292b3 100644 --- a/src/base/tools.lua +++ b/src/base/tools.lua @@ -31,16 +31,22 @@ function p.tools.canonical(identifier) local parts - if identifier:startswith("v") then - parts = { "msc", identifier:sub(2) } - elseif identifier:startswith("llvm-vs") then -- support LLVM toolset in VS - parts = { "msc", "LLVM-vs" .. identifier:sub(8) } + if identifier:startswith("v") then -- TODO: this should be deprecated? + parts = { "msc", identifier } else - parts = identifier:explode("-") + parts = identifier:explode("-", true, 1) - -- hack to check for LLVM toolsets, which would be corrupted by the previous line - if parts[1] == "msc" and parts[2] == "llvm" and parts[3]:startswith("vs") then - parts = { parts[1], "LLVM-" .. parts[3] } + -- 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 end return p.tools[parts[1]], parts[2] diff --git a/tests/actions/vstudio/vc2010/test_platform_toolset.lua b/tests/actions/vstudio/vc2010/test_platform_toolset.lua index 59b81475..cd0fd199 100644 --- a/tests/actions/vstudio/vc2010/test_platform_toolset.lua +++ b/tests/actions/vstudio/vc2010/test_platform_toolset.lua @@ -96,14 +96,6 @@ end function suite.canOverrideFromScript_withLLVM() - toolset "LLVM-vs2010" - prepare() - test.capture [[ -LLVM-vs2010 - ]] - end - - function suite.canOverrideFromScript_withMscAndLLVM() toolset "msc-llvm-vs2014_xp" prepare() test.capture [[