mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 03:14:08 +00:00
Exchanged debug compilation with verbose command-line argument
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import strutils, strtabs, os, osproc, vcvarsall, vccdiscover
|
||||
|
||||
when defined(release):
|
||||
let vccOptions = {poParentStreams}
|
||||
else:
|
||||
let vccOptions = {poEchoCmd, poParentStreams}
|
||||
|
||||
const
|
||||
vccversionPrefix = "--vccversion"
|
||||
vcvarsallPrefix = "--vcvarsall"
|
||||
@@ -12,6 +7,7 @@ const
|
||||
platformPrefix = "--platform"
|
||||
sdktypePrefix = "--sdktype"
|
||||
sdkversionPrefix = "--sdkversion"
|
||||
verbosePrefix = "--verbose"
|
||||
|
||||
vccversionSepIdx = vccversionPrefix.len
|
||||
vcvarsallSepIdx = vcvarsallPrefix.len
|
||||
@@ -65,6 +61,7 @@ when isMainModule:
|
||||
var platformArg: VccArch
|
||||
var sdkTypeArg: VccPlatformType
|
||||
var sdkVersionArg: string = nil
|
||||
var verboseArg: bool = false
|
||||
|
||||
var clArgs: seq[TaintedString] = @[]
|
||||
|
||||
@@ -83,6 +80,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(verbosePrefix):
|
||||
verboseArg = true
|
||||
else: # Regular cl.exe argument -> store for final cl.exe invocation
|
||||
if (wargv.len == 2) and (wargv[1] == '?'):
|
||||
echo HelpText
|
||||
@@ -100,11 +99,15 @@ when isMainModule:
|
||||
if vcvarsallArg.len < 1 and vccversionArg.len < 1:
|
||||
vcvarsallArg = discoverVccVcVarsAllPath()
|
||||
|
||||
var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg)
|
||||
var vcvars = vccVarsAll(vcvarsallArg, platformArg, sdkTypeArg, sdkVersionArg, verboseArg)
|
||||
if vcvars != nil:
|
||||
for vccEnvKey, vccEnvVal in vcvars:
|
||||
putEnv(vccEnvKey, vccEnvVal)
|
||||
|
||||
var vccOptions = {poParentStreams}
|
||||
if verboseArg:
|
||||
vccOptions.incl poEchoCmd
|
||||
|
||||
if commandArg.len < 1:
|
||||
commandArg = "cl.exe"
|
||||
let vccProcess = startProcess(
|
||||
|
||||
@@ -27,7 +27,7 @@ type
|
||||
vccplatUWP = "uwp",
|
||||
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
|
||||
# Assume that default executable is in current directory or in PATH
|
||||
if path == nil or path.len < 1:
|
||||
@@ -59,16 +59,14 @@ proc vccVarsAll*(path: string, arch: VccArch = vccarchUnspecified, platform_type
|
||||
comSpecCmd = "cmd"
|
||||
|
||||
let comSpecExec = "\"$1\" /C \"$2 && SET\"" % [comSpecCmd, vcvarsExec]
|
||||
when defined(release):
|
||||
let comSpecOpts = {poEvalCommand, poDemon, poStdErrToStdOut}
|
||||
else:
|
||||
let comSpecOpts = {poEchoCmd, poEvalCommand, poDemon, poStdErrToStdOut}
|
||||
var comSpecOpts = {poEvalCommand, poDemon, poStdErrToStdOut}
|
||||
if verbose:
|
||||
comSpecOpts.incl poEchoCmd
|
||||
let comSpecOut = execProcess(comSpecExec, options = comSpecOpts)
|
||||
result = newStringTable(modeCaseInsensitive)
|
||||
for line in comSpecOut.splitLines:
|
||||
let idx = line.find('=')
|
||||
if idx > 0:
|
||||
result[line[0..(idx - 1)]] = line[(idx + 1)..(line.len - 1)]
|
||||
else:
|
||||
when not defined(release) or defined(debug):
|
||||
echo line
|
||||
elif verbose:
|
||||
echo line
|
||||
|
||||
Reference in New Issue
Block a user