From ae5030dbdaa89ebdfa2bc3705459080ff8da878b Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 10 Feb 2020 13:54:44 -0800 Subject: [PATCH] fix #13374 `nim c -r -` now generates $nimcache/stdinfile --- compiler/cmdlinehelper.nim | 5 +---- compiler/commands.nim | 12 ++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim index a50d47ad21bc..b3c0c46c2be0 100644 --- a/compiler/cmdlinehelper.nim +++ b/compiler/cmdlinehelper.nim @@ -29,10 +29,7 @@ proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) = proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) = self.processCmdLine(passCmd1, "", conf) if self.supportsStdinFile and conf.projectName == "-": - conf.projectName = "stdinfile" - conf.projectFull = AbsoluteFile "stdinfile" - conf.projectPath = AbsoluteDir getCurrentDir() - conf.projectIsStdin = true + handleStdinInput(conf) elif conf.projectName != "": try: conf.projectFull = canonicalizePath(conf, AbsoluteFile conf.projectName) diff --git a/compiler/commands.nim b/compiler/commands.nim index 9b79dc47a1bc..ca6ef5d94588 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -369,6 +369,14 @@ proc dynlibOverride(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, in expectArg(conf, switch, arg, pass, info) options.inclDynlibOverride(conf, arg) +proc handleStdinInput*(conf: ConfigRef) = + conf.projectName = "stdinfile" + conf.projectFull = conf.projectName.AbsoluteFile + conf.projectPath = AbsoluteDir getCurrentDir() + conf.projectIsStdin = true + if conf.outDir.isEmpty: + conf.outDir = getNimcacheDir(conf) + proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; conf: ConfigRef) = var @@ -861,8 +869,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo; localError(conf, info, "unknown Nim version; currently supported values are: {1.0}") of "benchmarkvm": processOnOffSwitchG(conf, {optBenchmarkVM}, arg, pass, info) - of "": - conf.projectName = "-" + of "": # comes from "-" in for example: `nim c -r -` (gets stripped from -) + handleStdinInput(conf) else: if strutils.find(switch, '.') >= 0: options.setConfigVar(conf, switch, arg) else: invalidCmdLineOption(conf, pass, switch, info)