diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cmdlinehelper.nim | 23 | ||||
-rw-r--r-- | compiler/nim.nim | 9 |
2 files changed, 15 insertions, 17 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim index 4777af8df..a6b56b97e 100644 --- a/compiler/cmdlinehelper.nim +++ b/compiler/cmdlinehelper.nim @@ -34,7 +34,6 @@ type suggestMode*: bool supportsStdinFile*: bool processCmdLine*: proc(pass: TCmdLinePass, cmd: string; config: ConfigRef) - mainCommand*: proc(graph: ModuleGraph) proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) = condsyms.initDefines(conf.symbols) @@ -56,21 +55,21 @@ proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) = else: conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile getCurrentDir()) -proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: ConfigRef): bool = +proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: ConfigRef; + graph: ModuleGraph): bool = if self.suggestMode: conf.command = "nimsuggest" loadConfigs(DefaultConfig, cache, conf) # load all config files - block: + if not self.suggestMode: let scriptFile = conf.projectFull.changeFileExt("nims") - if not self.suggestMode: - # 'nim foo.nims' means to just run the NimScript file and do nothing more: - if fileExists(scriptFile) and scriptFile == conf.projectFull: - if conf.command == "": - conf.command = "e" - return false - elif conf.command.normalize == "e": - return false + # 'nim foo.nims' means to just run the NimScript file and do nothing more: + if fileExists(scriptFile) and scriptFile == conf.projectFull: + if conf.command == "": + conf.command = "e" + return false + elif conf.command.normalize == "e": + return false # now process command line arguments again, because some options in the # command line can overwrite the config file's settings @@ -79,7 +78,5 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi if conf.command == "": rawMessage(conf, errGenerated, "command missing") - let graph = newModuleGraph(cache, conf) graph.suggestMode = self.suggestMode - self.mainCommand(graph) return true diff --git a/compiler/nim.nim b/compiler/nim.nim index 2b0d78dd4..15aeccb33 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -22,7 +22,7 @@ import commands, options, msgs, extccomp, strutils, os, main, parseopt, idents, lineinfos, cmdlinehelper, - pathutils + pathutils, modulegraphs from std/browsers import openDefaultBrowser from nodejs import findNodeJs @@ -70,8 +70,7 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) = proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = let self = NimProg( supportsStdinFile: true, - processCmdLine: processCmdLine, - mainCommand: mainCommand + processCmdLine: processCmdLine ) self.initDefinesProg(conf, "nim_compiler") if paramCount() == 0: @@ -79,7 +78,9 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = return self.processCmdLineAndProjectPath(conf) - if not self.loadConfigsAndRunMainCommand(cache, conf): return + var graph = newModuleGraph(cache, conf) + if not self.loadConfigsAndRunMainCommand(cache, conf, graph): return + mainCommand(graph) if conf.hasHint(hintGCStats): echo(GC_getStatistics()) #echo(GC_getStatistics()) if conf.errorCounter != 0: return |