mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 03:14:08 +00:00
code cleanup of caas
This commit is contained in:
@@ -15,7 +15,7 @@ when defined(gcc) and defined(windows):
|
||||
|
||||
import
|
||||
times, commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
||||
extccomp, strutils, os, platform, main, parseopt
|
||||
extccomp, strutils, os, platform, main, parseopt, service
|
||||
|
||||
when hasTinyCBackend:
|
||||
import tccgen
|
||||
@@ -23,43 +23,6 @@ when hasTinyCBackend:
|
||||
when defined(profiler):
|
||||
{.hint: "Profiling support is turned on!".}
|
||||
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 =
|
||||
when defined(unix):
|
||||
@@ -74,7 +37,7 @@ proc HandleCmdLine() =
|
||||
writeCommandLineUsage()
|
||||
else:
|
||||
# Process command line arguments:
|
||||
ProcessCmdLine(passCmd1)
|
||||
ProcessCmdLine(passCmd1, "")
|
||||
if gProjectName != "":
|
||||
try:
|
||||
gProjectFull = canonicalizePath(gProjectName)
|
||||
@@ -89,7 +52,7 @@ proc HandleCmdLine() =
|
||||
# now process command line arguments again, because some options in the
|
||||
# command line can overwite the config file's settings
|
||||
extccomp.initVars()
|
||||
ProcessCmdLine(passCmd2)
|
||||
ProcessCmdLine(passCmd2, "")
|
||||
MainCommand()
|
||||
if gVerbosity >= 2: echo(GC_getStatistics())
|
||||
#echo(GC_getStatistics())
|
||||
@@ -105,11 +68,11 @@ proc HandleCmdLine() =
|
||||
if gCmd == cmdCompileToEcmaScript:
|
||||
var ex = quoteIfContainsWhite(
|
||||
completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir))
|
||||
execExternalProgram("node " & ex & ' ' & arguments)
|
||||
execExternalProgram("node " & ex & ' ' & service.arguments)
|
||||
else:
|
||||
var ex = quoteIfContainsWhite(
|
||||
changeFileExt(gProjectFull, exeExt).prependCurDir)
|
||||
execExternalProgram(ex & ' ' & arguments)
|
||||
execExternalProgram(ex & ' ' & service.arguments)
|
||||
|
||||
#GC_disableMarkAndSweep()
|
||||
|
||||
|
||||
@@ -19,11 +19,10 @@ import
|
||||
# repeated CRC calculations may turn out to be too slow.
|
||||
|
||||
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
|
||||
|
||||
proc ProcessCmdLine(pass: TCmdLinePass, cmd: string) =
|
||||
# XXX remove duplication with nimrod.nim
|
||||
proc ProcessCmdLine*(pass: TCmdLinePass, cmd: string) =
|
||||
var p = parseopt.initOptParser(cmd)
|
||||
var argsCount = 0
|
||||
while true:
|
||||
@@ -69,3 +68,4 @@ proc serve*(action: proc (){.nimcall.}) =
|
||||
processCmdLine(passCmd2, inp.string)
|
||||
action()
|
||||
stdoutSocket.send("\c\L")
|
||||
stdoutSocket.close()
|
||||
|
||||
Reference in New Issue
Block a user