From 1662f5108fe7553ddda10729489a1c7d01d5e99d Mon Sep 17 00:00:00 2001
From: realvictorprm <mueller.vpr@gmail.com>
Date: Sun, 12 Mar 2017 22:19:18 +0100
Subject: [PATCH] Added support for VS 2017 project generation

Fixed also the regex for finding ms build tools.
It's required to open the batch files with the developer command prompt
of vs 2017 !
---
 build/GenerateProjects.bat | 11 +++++++++--
 build/Helpers.lua          | 15 ++++++++++-----
 build/scripts/LLVM.lua     |  2 +-
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/build/GenerateProjects.bat b/build/GenerateProjects.bat
index 99a73ce5..27be01eb 100644
--- a/build/GenerateProjects.bat
+++ b/build/GenerateProjects.bat
@@ -8,12 +8,15 @@ echo [0] Clean
 echo [1] Visual C++ 2012
 echo [2] Visual C++ 2013
 echo [3] Visual C++ 2015
-echo [4] GNU Make
+echo [4] Visual C++ 2017
+echo [5] GNU Make
+
 echo.
 
 :choice
 set /P C="Choice: "
-if "%C%"=="4" goto gmake
+if "%C%"=="5" goto gmake
+if "%C%"=="4" goto vs2017
 if "%C%"=="3" goto vs2015
 if "%C%"=="2" goto vs2013
 if "%C%"=="1" goto vs2012
@@ -35,6 +38,10 @@ goto quit
 "premake5" --file=premake5.lua vs2015
 goto quit
 
+:vs2017
+"premake5" --file=premake5.lua vs2017 
+goto quit
+
 :gmake
 "premake5" --file=premake5.lua gmake
 goto quit
diff --git a/build/Helpers.lua b/build/Helpers.lua
index 6cc37093..7ab45b2e 100644
--- a/build/Helpers.lua
+++ b/build/Helpers.lua
@@ -75,12 +75,17 @@ function SetupManagedProject()
     configuration(c)
   end
 
-  if action == "vs2015" then
+  if action == "vs2017" then
 
-  configuration "vs2015"
-    framework "4.6"
-
-  end
+        configuration "vs2017"
+			framework "4.6"
+    
+    elseif action == "vs2015" then
+        
+        configuration "vs2015"
+			framework "4.6"
+    
+    end
 
   configuration "vs2013"
     framework "4.5"
diff --git a/build/scripts/LLVM.lua b/build/scripts/LLVM.lua
index 7319e707..cac1794f 100644
--- a/build/scripts/LLVM.lua
+++ b/build/scripts/LLVM.lua
@@ -62,7 +62,7 @@ function get_toolset_configuration_name()
 
     if not string.starts(vsver, "vs") then
       local out = outputof("cl")
-      local ver, arch = string.match(out, '(%d+).%d+.%d+.?%d*%s+%w*%s+(%w+)')
+      local ver, arch = string.match(out, '(%d+).%d+.%d+.?%d*%s+')
       vsver = get_vs_version(ver)
     end