summary refs log tree commit diff stats
path: root/tools/vccexe/vccexe.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tools/vccexe/vccexe.nim')
-rw-r--r--tools/vccexe/vccexe.nim28
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/vccexe/vccexe.nim b/tools/vccexe/vccexe.nim
index 1b5b2fb82..2a43f7422 100644
--- a/tools/vccexe/vccexe.nim
+++ b/tools/vccexe/vccexe.nim
@@ -41,6 +41,7 @@ const
   platformPrefix = "--platform"
   sdktypePrefix = "--sdktype"
   sdkversionPrefix = "--sdkversion"
+  vctoolsetPrefix = "--vctoolset"
   verbosePrefix = "--verbose"
 
   vccversionSepIdx = vccversionPrefix.len
@@ -49,6 +50,7 @@ const
   platformSepIdx = platformPrefix.len
   sdktypeSepIdx = sdktypePrefix.len
   sdkversionSepIdx = sdkversionPrefix.len
+  vctoolsetSepIdx = vctoolsetPrefix.len
 
   vcvarsallDefaultPath = "vcvarsall.bat"
 
@@ -93,10 +95,12 @@ Options:
   --sdktype:<type>    Specify the SDK flavor to use. Defaults to the Desktop SDK.
                       <type>: {empty} | store | uwp | onecore
   --sdkversion:<v>    Use a specific Windows SDK version:
-                      <v> is either the full Windows 10 SDK version number or 
+                      <v> is either the full Windows 10 SDK version number or
                       "8.1" to use the windows 8.1 SDK
   --verbose           Echoes the command line for loading the Developer Command Prompt
                       and the command line passed on to the secondary command.
+  --vctoolset         Optionally specifies the Visual Studio compiler toolset to use. 
+                      By default, the environment is set to use the current Visual Studio compiler toolset.
 
 Other command line arguments are passed on to the
 secondary command specified by --command or to the
@@ -104,12 +108,12 @@ Microsoft (R) C/C++ Optimizing Compiler if no secondary
 command was specified
 """
 
-proc parseVccexeCmdLine(argseq: seq[TaintedString],
+proc parseVccexeCmdLine(argseq: seq[string],
     vccversionArg: var seq[string], printPathArg: var bool,
     vcvarsallArg: var string, commandArg: var string, noCommandArg: var bool,
     platformArg: var VccArch, sdkTypeArg: var VccPlatformType,
-    sdkVersionArg: var string, verboseArg: var bool,
-    clArgs: var seq[TaintedString]) =
+    sdkVersionArg: var string,  vctoolsetArg: var string, verboseArg: var bool,
+    clArgs: var seq[string]) =
   ## Cannot use usual command-line argument parser here
   ## Since vccexe command-line arguments are intermingled
   ## with the secondary command-line arguments which have
@@ -125,7 +129,7 @@ proc parseVccexeCmdLine(argseq: seq[TaintedString],
         responseargs = parseCmdLine(responsecontent)
       parseVccexeCmdLine(responseargs, vccversionArg, printPathArg,
         vcvarsallArg, commandArg, noCommandArg, platformArg, sdkTypeArg,
-        sdkVersionArg, verboseArg, clArgs)
+        sdkVersionArg, vctoolsetArg, verboseArg, clArgs)
     elif wargv.startsWith(vccversionPrefix): # Check for vccversion
       vccversionArg.add(wargv.substr(vccversionSepIdx + 1))
     elif wargv.cmpIgnoreCase(printPathPrefix) == 0: # Check for printPath
@@ -142,6 +146,8 @@ proc parseVccexeCmdLine(argseq: seq[TaintedString],
       sdkTypeArg = parseEnum[VccPlatformType](wargv.substr(sdktypeSepIdx + 1))
     elif wargv.startsWith(sdkversionPrefix): # Check for sdkversion
       sdkVersionArg = wargv.substr(sdkversionSepIdx + 1)
+    elif wargv.startsWith(vctoolsetPrefix): # Check for vctoolset
+      vctoolsetArg = wargv.substr(vctoolsetSepIdx + 1)
     elif wargv.startsWith(verbosePrefix):
       verboseArg = true
     else: # Regular cl.exe argument -> store for final cl.exe invocation
@@ -158,13 +164,14 @@ when isMainModule:
   var platformArg: VccArch
   var sdkTypeArg: VccPlatformType
   var sdkVersionArg: string
+  var vctoolsetArg: string
   var verboseArg: bool = false
 
-  var clArgs: seq[TaintedString] = @[]
+  var clArgs: seq[string] = @[]
 
   let wrapperArgs = commandLineParams()
   parseVccexeCmdLine(wrapperArgs, vccversionArg, printPathArg, vcvarsallArg,
-    commandArg, noCommandArg, platformArg, sdkTypeArg, sdkVersionArg,
+    commandArg, noCommandArg, platformArg, sdkTypeArg, sdkVersionArg, vctoolsetArg,
     verboseArg,
     clArgs)
 
@@ -195,7 +202,7 @@ when isMainModule:
     echo "$1: $2" % [head, vcvarsallArg]
 
   # Call vcvarsall to get the appropriate VCC process environment
-  var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg, verboseArg)
+  var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg, vctoolsetArg, verboseArg)
   if vcvars != nil:
     for vccEnvKey, vccEnvVal in vcvars:
       putEnv(vccEnvKey, vccEnvVal)
@@ -204,6 +211,11 @@ when isMainModule:
   if verboseArg:
     vccOptions.incl poEchoCmd
 
+  let currentDir = getCurrentDir()
+  for arg in clArgs.mitems:
+    if fileExists(arg):
+      arg = relativePath(arg, currentDir)
+
   # Default to the cl.exe command if no secondary command was specified
   if commandArg.len < 1:
     commandArg = "cl.exe"