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.nim82
1 files changed, 57 insertions, 25 deletions
diff --git a/tools/vccexe/vccexe.nim b/tools/vccexe/vccexe.nim
index e78f9da5e..2a43f7422 100644
--- a/tools/vccexe/vccexe.nim
+++ b/tools/vccexe/vccexe.nim
@@ -32,7 +32,7 @@ proc discoverVccVcVarsAllPath*(version: VccVersion = vccUndefined): string =
 
   # All attempts to discover vcc failed
 
-const 
+const
   vccversionPrefix = "--vccversion"
   printPathPrefix = "--printPath"
   vcvarsallPrefix = "--vcvarsall"
@@ -41,6 +41,7 @@ const
   platformPrefix = "--platform"
   sdktypePrefix = "--sdktype"
   sdkversionPrefix = "--sdkversion"
+  vctoolsetPrefix = "--vctoolset"
   verbosePrefix = "--verbose"
 
   vccversionSepIdx = vccversionPrefix.len
@@ -49,7 +50,8 @@ const
   platformSepIdx = platformPrefix.len
   sdktypeSepIdx = sdktypePrefix.len
   sdkversionSepIdx = sdkversionPrefix.len
-  
+  vctoolsetSepIdx = vctoolsetPrefix.len
+
   vcvarsallDefaultPath = "vcvarsall.bat"
 
   helpText = """
@@ -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,28 +108,29 @@ Microsoft (R) C/C++ Optimizing Compiler if no secondary
 command was specified
 """
 
-when isMainModule:
-  var vccversionArg: seq[string] = @[]
-  var printPathArg: bool = false
-  var vcvarsallArg: string
-  var commandArg: string
-  var noCommandArg: bool = false
-  var platformArg: VccArch
-  var sdkTypeArg: VccPlatformType
-  var sdkVersionArg: string
-  var verboseArg: bool = false
-
-  var clArgs: seq[TaintedString] = @[]
-
-  # Cannot use usual command-line argument parser here
-  # Since vccexe command-line arguments are intermingled
-  # with the secondary command-line arguments which have
-  # a syntax that is not supported by the default nim
-  # argument parser.
-  var wrapperArgs = commandLineParams()
-  for wargv in wrapperArgs:
+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,  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
+  ## a syntax that is not supported by the default nim
+  ## argument parser.
+  for wargv in argseq:
     # Check whether the current argument contains -- prefix
-    if wargv.startsWith(vccversionPrefix): # Check for vccversion
+    if wargv.startsWith("@"): # Check for response file prefix
+      let
+        responsefilename = wargv.substr(1)
+        responsefilehandle = open(responsefilename)
+        responsecontent = responsefilehandle.readAll()
+        responseargs = parseCmdLine(responsecontent)
+      parseVccexeCmdLine(responseargs, vccversionArg, printPathArg,
+        vcvarsallArg, commandArg, noCommandArg, platformArg, sdkTypeArg,
+        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
       printPathArg = true
@@ -141,6 +146,8 @@ when isMainModule:
       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
@@ -148,6 +155,26 @@ when isMainModule:
         echo helpText
       clArgs.add(wargv)
 
+when isMainModule:
+  var vccversionArg: seq[string] = @[]
+  var printPathArg: bool = false
+  var vcvarsallArg: string
+  var commandArg: string
+  var noCommandArg: bool = false
+  var platformArg: VccArch
+  var sdkTypeArg: VccPlatformType
+  var sdkVersionArg: string
+  var vctoolsetArg: string
+  var verboseArg: bool = false
+
+  var clArgs: seq[string] = @[]
+
+  let wrapperArgs = commandLineParams()
+  parseVccexeCmdLine(wrapperArgs, vccversionArg, printPathArg, vcvarsallArg,
+    commandArg, noCommandArg, platformArg, sdkTypeArg, sdkVersionArg, vctoolsetArg,
+    verboseArg,
+    clArgs)
+
   # Support for multiple specified versions. Attempt VCC discovery for each version
   # specified, first successful discovery wins
   var vccversionValue: VccVersion = vccUndefined
@@ -175,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)
@@ -184,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"
Kartik K. Agaram <vc@akkartik.com> 2017-06-09 11:29:15 -0700 3902 - drop redundant redraw of recipe side on F4' href='/akkartik/mu/commit/sandbox/008-sandbox-edit.mu?h=main&id=6d12a8c4ebe25527c92a934702e2628ce8c4bd4c'>6d12a8c4 ^
294b2ab3 ^




















fa94f4d9 ^


607ddf33 ^

ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^





294b2ab3 ^
fa94f4d9 ^

607ddf33 ^

ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^



607ddf33 ^
fa94f4d9 ^
3d8b137c ^
607ddf33 ^


29cc15d6 ^
aaf61a53 ^
ada5eb55 ^
fa94f4d9 ^


607ddf33 ^
2d91279b ^
fa94f4d9 ^
be422222 ^
607ddf33 ^
3d8b137c ^
f116818c ^
607ddf33 ^
2d91279b ^
607ddf33 ^
3d8b137c ^



f116818c ^
607ddf33 ^
2d91279b ^
607ddf33 ^
fa94f4d9 ^

2d91279b ^
fa94f4d9 ^
be422222 ^
607ddf33 ^
2d91279b ^
607ddf33 ^


ea19d0dc ^
2d91279b ^
607ddf33 ^



fa94f4d9 ^


6f65d591 ^
e00d4854 ^
fa94f4d9 ^
294b2ab3 ^



7b38bc8e ^
6d12a8c4 ^
fa94f4d9 ^



294b2ab3 ^
fa94f4d9 ^


ceeb92d4 ^
607ddf33 ^
7b38bc8e ^
fa94f4d9 ^





ceeb92d4 ^
fa94f4d9 ^
fa94f4d9 ^


607ddf33 ^
fa94f4d9 ^

294b2ab3 ^
fa94f4d9 ^


7b38bc8e ^
ceeb92d4 ^
fa94f4d9 ^



e0d69d3b ^

6f65d591 ^
e0d69d3b ^


294b2ab3 ^


6f65d591 ^
e0d69d3b ^






11569717 ^

e0d69d3b ^
294b2ab3 ^
e0d69d3b ^

ceeb92d4 ^
607ddf33 ^
e0d69d3b ^

ceeb92d4 ^
e0d69d3b ^



607ddf33 ^
e0d69d3b ^

294b2ab3 ^
e0d69d3b ^




ceeb92d4 ^
607ddf33 ^
e0d69d3b ^

ceeb92d4 ^
e0d69d3b ^


95425355 ^

6f65d591 ^
95425355 ^


294b2ab3 ^


6f65d591 ^
294b2ab3 ^
95425355 ^






294b2ab3 ^
95425355 ^


ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^


607ddf33 ^
95425355 ^


294b2ab3 ^
95425355 ^




ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^


11569717 ^


95425355 ^

294b2ab3 ^
95425355 ^
294b2ab3 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
95425355 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319