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
|
||||
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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue