diff options
author | Araq <rumpf_a@web.de> | 2012-10-05 09:52:40 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-10-05 09:52:40 +0200 |
commit | 01dfcf63106fb18239a1c6dabf551405c33b6e7e (patch) | |
tree | 92061e35a252c0171c0ea6ef9d8af6695ea91645 /compiler | |
parent | a6d5707faff21722f22f91c56704c44fc03d47f6 (diff) | |
download | Nim-01dfcf63106fb18239a1c6dabf551405c33b6e7e.tar.gz |
code cleanup of caas
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/nimrod.nim | 47 | ||||
-rw-r--r-- | compiler/service.nim | 6 |
2 files changed, 8 insertions, 45 deletions
diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim index 0305396da..31ae355f6 100755 --- a/compiler/nimrod.nim +++ b/compiler/nimrod.nim @@ -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() diff --git a/compiler/service.nim b/compiler/service.nim index f6c2720a7..23a9bda66 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -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() |