Exchanged debug compilation with verbose command-line argument
This commit is contained in:
parent
513b0fed4d
commit
24f07d9b71
2 changed files with 15 additions and 14 deletions
|
|
@ -1,10 +1,5 @@
|
||||||
import strutils, strtabs, os, osproc, vcvarsall, vccdiscover
|
import strutils, strtabs, os, osproc, vcvarsall, vccdiscover
|
||||||
|
|
||||||
when defined(release):
|
|
||||||
let vccOptions = {poParentStreams}
|
|
||||||
else:
|
|
||||||
let vccOptions = {poEchoCmd, poParentStreams}
|
|
||||||
|
|
||||||
const
|
const
|
||||||
vccversionPrefix = "--vccversion"
|
vccversionPrefix = "--vccversion"
|
||||||
vcvarsallPrefix = "--vcvarsall"
|
vcvarsallPrefix = "--vcvarsall"
|
||||||
|
|
@ -12,6 +7,7 @@ const
|
||||||
platformPrefix = "--platform"
|
platformPrefix = "--platform"
|
||||||
sdktypePrefix = "--sdktype"
|
sdktypePrefix = "--sdktype"
|
||||||
sdkversionPrefix = "--sdkversion"
|
sdkversionPrefix = "--sdkversion"
|
||||||
|
verbosePrefix = "--verbose"
|
||||||
|
|
||||||
vccversionSepIdx = vccversionPrefix.len
|
vccversionSepIdx = vccversionPrefix.len
|
||||||
vcvarsallSepIdx = vcvarsallPrefix.len
|
vcvarsallSepIdx = vcvarsallPrefix.len
|
||||||
|
|
@ -65,6 +61,7 @@ when isMainModule:
|
||||||
var platformArg: VccArch
|
var platformArg: VccArch
|
||||||
var sdkTypeArg: VccPlatformType
|
var sdkTypeArg: VccPlatformType
|
||||||
var sdkVersionArg: string = nil
|
var sdkVersionArg: string = nil
|
||||||
|
var verboseArg: bool = false
|
||||||
|
|
||||||
var clArgs: seq[TaintedString] = @[]
|
var clArgs: seq[TaintedString] = @[]
|
||||||
|
|
||||||
|
|
@ -83,6 +80,8 @@ when isMainModule:
|
||||||
sdkTypeArg = parseEnum[VccPlatformType](wargv.substr(sdktypeSepIdx + 1))
|
sdkTypeArg = parseEnum[VccPlatformType](wargv.substr(sdktypeSepIdx + 1))
|
||||||
elif wargv.startsWith(sdkversionPrefix): # Check for sdkversion
|
elif wargv.startsWith(sdkversionPrefix): # Check for sdkversion
|
||||||
sdkVersionArg = wargv.substr(sdkversionSepIdx + 1)
|
sdkVersionArg = wargv.substr(sdkversionSepIdx + 1)
|
||||||
|
elif wargv.startsWith(verbosePrefix):
|
||||||
|
verboseArg = true
|
||||||
else: # Regular cl.exe argument -> store for final cl.exe invocation
|
else: # Regular cl.exe argument -> store for final cl.exe invocation
|
||||||
if (wargv.len == 2) and (wargv[1] == '?'):
|
if (wargv.len == 2) and (wargv[1] == '?'):
|
||||||
echo HelpText
|
echo HelpText
|
||||||
|
|
@ -100,11 +99,15 @@ when isMainModule:
|
||||||
if vcvarsallArg.len < 1 and vccversionArg.len < 1:
|
if vcvarsallArg.len < 1 and vccversionArg.len < 1:
|
||||||
vcvarsallArg = discoverVccVcVarsAllPath()
|
vcvarsallArg = discoverVccVcVarsAllPath()
|
||||||
|
|
||||||
var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg)
|
var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg, verboseArg)
|
||||||
if vcvars != nil:
|
if vcvars != nil:
|
||||||
for vccEnvKey, vccEnvVal in vcvars:
|
for vccEnvKey, vccEnvVal in vcvars:
|
||||||
putEnv(vccEnvKey, vccEnvVal)
|
putEnv(vccEnvKey, vccEnvVal)
|
||||||
|
|
||||||
|
var vccOptions = {poParentStreams}
|
||||||
|
if verboseArg:
|
||||||
|
vccOptions.incl poEchoCmd
|
||||||
|
|
||||||
if commandArg.len < 1:
|
if commandArg.len < 1:
|
||||||
commandArg = "cl.exe"
|
commandArg = "cl.exe"
|
||||||
let vccProcess = startProcess(
|
let vccProcess = startProcess(
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type
|
||||||
vccplatUWP = "uwp",
|
vccplatUWP = "uwp",
|
||||||
vccplatOneCore = "onecore"
|
vccplatOneCore = "onecore"
|
||||||
|
|
||||||
proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type: VccPlatformType = vccplatEmpty, sdk_version: string = nil): StringTableRef =
|
proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type: VccPlatformType = vccplatEmpty, sdk_version: string = nil, verbose: bool = false): StringTableRef =
|
||||||
var vccvarsallpath = path
|
var vccvarsallpath = path
|
||||||
# Assume that default executable is in current directory or in PATH
|
# Assume that default executable is in current directory or in PATH
|
||||||
if path == nil or path.len < 1:
|
if path == nil or path.len < 1:
|
||||||
|
|
@ -59,16 +59,14 @@ proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type
|
||||||
comSpecCmd = "cmd"
|
comSpecCmd = "cmd"
|
||||||
|
|
||||||
let comSpecExec = "\"$1\" /C \"$2 && SET\"" % [comSpecCmd, vcvarsExec]
|
let comSpecExec = "\"$1\" /C \"$2 && SET\"" % [comSpecCmd, vcvarsExec]
|
||||||
when defined(release):
|
var comSpecOpts = {poEvalCommand, poDemon, poStdErrToStdOut}
|
||||||
let comSpecOpts = {poEvalCommand, poDemon, poStdErrToStdOut}
|
if verbose:
|
||||||
else:
|
comSpecOpts.incl poEchoCmd
|
||||||
let comSpecOpts = {poEchoCmd, poEvalCommand, poDemon, poStdErrToStdOut}
|
|
||||||
let comSpecOut = execProcess(comSpecExec, options = comSpecOpts)
|
let comSpecOut = execProcess(comSpecExec, options = comSpecOpts)
|
||||||
result = newStringTable(modeCaseInsensitive)
|
result = newStringTable(modeCaseInsensitive)
|
||||||
for line in comSpecOut.splitLines:
|
for line in comSpecOut.splitLines:
|
||||||
let idx = line.find('=')
|
let idx = line.find('=')
|
||||||
if idx > 0:
|
if idx > 0:
|
||||||
result[line[0..(idx - 1)]] = line[(idx + 1)..(line.len - 1)]
|
result[line[0..(idx - 1)]] = line[(idx + 1)..(line.len - 1)]
|
||||||
else:
|
elif verbose:
|
||||||
when not defined(release) or defined(debug):
|
echo line
|
||||||
echo line
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue