code cleanup of caas
This commit is contained in:
parent
a6d5707faf
commit
01dfcf6310
2 changed files with 8 additions and 45 deletions
|
|
@ -15,7 +15,7 @@ when defined(gcc) and defined(windows):
|
||||||
|
|
||||||
import
|
import
|
||||||
times, commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
times, commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
||||||
extccomp, strutils, os, platform, main, parseopt
|
extccomp, strutils, os, platform, main, parseopt, service
|
||||||
|
|
||||||
when hasTinyCBackend:
|
when hasTinyCBackend:
|
||||||
import tccgen
|
import tccgen
|
||||||
|
|
@ -24,43 +24,6 @@ when defined(profiler):
|
||||||
{.hint: "Profiling support is turned on!".}
|
{.hint: "Profiling support is turned on!".}
|
||||||
import nimprof
|
import nimprof
|
||||||
|
|
||||||
var
|
|
||||||
arguments: string = "" # the arguments to be passed to the program that
|
|
||||||
# should be run
|
|
||||||
|
|
||||||
proc ProcessCmdLine(pass: TCmdLinePass) =
|
|
||||||
var p = parseopt.initOptParser()
|
|
||||||
var argsCount = 0
|
|
||||||
while true:
|
|
||||||
parseopt.next(p)
|
|
||||||
case p.kind
|
|
||||||
of cmdEnd: break
|
|
||||||
of cmdLongOption, cmdShortOption:
|
|
||||||
# hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
|
|
||||||
# we fix this here
|
|
||||||
var bracketLe = strutils.find(p.key, '[')
|
|
||||||
if bracketLe >= 0:
|
|
||||||
var key = substr(p.key, 0, bracketLe - 1)
|
|
||||||
var val = substr(p.key, bracketLe + 1) & ':' & p.val
|
|
||||||
ProcessSwitch(key, val, pass, gCmdLineInfo)
|
|
||||||
else:
|
|
||||||
ProcessSwitch(p.key, p.val, pass, gCmdLineInfo)
|
|
||||||
of cmdArgument:
|
|
||||||
if argsCount == 0:
|
|
||||||
options.command = p.key
|
|
||||||
else:
|
|
||||||
if pass == passCmd1: options.commandArgs.add p.key
|
|
||||||
if argsCount == 1:
|
|
||||||
# support UNIX style filenames anywhere for portable build scripts:
|
|
||||||
options.gProjectName = unixToNativePath(p.key)
|
|
||||||
arguments = cmdLineRest(p)
|
|
||||||
break
|
|
||||||
inc argsCount
|
|
||||||
|
|
||||||
if pass == passCmd2:
|
|
||||||
if optRun notin gGlobalOptions and arguments != "":
|
|
||||||
rawMessage(errArgsNeedRunOption, [])
|
|
||||||
|
|
||||||
proc prependCurDir(f: string): string =
|
proc prependCurDir(f: string): string =
|
||||||
when defined(unix):
|
when defined(unix):
|
||||||
if os.isAbsolute(f): result = f
|
if os.isAbsolute(f): result = f
|
||||||
|
|
@ -74,7 +37,7 @@ proc HandleCmdLine() =
|
||||||
writeCommandLineUsage()
|
writeCommandLineUsage()
|
||||||
else:
|
else:
|
||||||
# Process command line arguments:
|
# Process command line arguments:
|
||||||
ProcessCmdLine(passCmd1)
|
ProcessCmdLine(passCmd1, "")
|
||||||
if gProjectName != "":
|
if gProjectName != "":
|
||||||
try:
|
try:
|
||||||
gProjectFull = canonicalizePath(gProjectName)
|
gProjectFull = canonicalizePath(gProjectName)
|
||||||
|
|
@ -89,7 +52,7 @@ proc HandleCmdLine() =
|
||||||
# now process command line arguments again, because some options in the
|
# now process command line arguments again, because some options in the
|
||||||
# command line can overwite the config file's settings
|
# command line can overwite the config file's settings
|
||||||
extccomp.initVars()
|
extccomp.initVars()
|
||||||
ProcessCmdLine(passCmd2)
|
ProcessCmdLine(passCmd2, "")
|
||||||
MainCommand()
|
MainCommand()
|
||||||
if gVerbosity >= 2: echo(GC_getStatistics())
|
if gVerbosity >= 2: echo(GC_getStatistics())
|
||||||
#echo(GC_getStatistics())
|
#echo(GC_getStatistics())
|
||||||
|
|
@ -105,11 +68,11 @@ proc HandleCmdLine() =
|
||||||
if gCmd == cmdCompileToEcmaScript:
|
if gCmd == cmdCompileToEcmaScript:
|
||||||
var ex = quoteIfContainsWhite(
|
var ex = quoteIfContainsWhite(
|
||||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||||
execExternalProgram("node " & ex & ' ' & arguments)
|
execExternalProgram("node " & ex & ' ' & service.arguments)
|
||||||
else:
|
else:
|
||||||
var ex = quoteIfContainsWhite(
|
var ex = quoteIfContainsWhite(
|
||||||
changeFileExt(gProjectFull, exeExt).prependCurDir)
|
changeFileExt(gProjectFull, exeExt).prependCurDir)
|
||||||
execExternalProgram(ex & ' ' & arguments)
|
execExternalProgram(ex & ' ' & service.arguments)
|
||||||
|
|
||||||
#GC_disableMarkAndSweep()
|
#GC_disableMarkAndSweep()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,10 @@ import
|
||||||
# repeated CRC calculations may turn out to be too slow.
|
# repeated CRC calculations may turn out to be too slow.
|
||||||
|
|
||||||
var
|
var
|
||||||
arguments: string = "" # the arguments to be passed to the program that
|
arguments*: string = "" # the arguments to be passed to the program that
|
||||||
# should be run
|
# should be run
|
||||||
|
|
||||||
proc ProcessCmdLine(pass: TCmdLinePass, cmd: string) =
|
proc ProcessCmdLine*(pass: TCmdLinePass, cmd: string) =
|
||||||
# XXX remove duplication with nimrod.nim
|
|
||||||
var p = parseopt.initOptParser(cmd)
|
var p = parseopt.initOptParser(cmd)
|
||||||
var argsCount = 0
|
var argsCount = 0
|
||||||
while true:
|
while true:
|
||||||
|
|
@ -69,3 +68,4 @@ proc serve*(action: proc (){.nimcall.}) =
|
||||||
processCmdLine(passCmd2, inp.string)
|
processCmdLine(passCmd2, inp.string)
|
||||||
action()
|
action()
|
||||||
stdoutSocket.send("\c\L")
|
stdoutSocket.send("\c\L")
|
||||||
|
stdoutSocket.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue