diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-11-09 09:07:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-09 16:07:22 +0100 |
commit | c1664f93b0024b558ff359f13ab6cd2e6c1b5cc7 (patch) | |
tree | 731b28344b508781f15872cfba44f09fc0bdae71 /compiler/extccomp.nim | |
parent | 53eca459f1d96c710238be95bd3fb048b336f2f3 (diff) | |
download | Nim-c1664f93b0024b558ff359f13ab6cd2e6c1b5cc7.tar.gz |
new: `nim -e:cmd` to run a command directly; also fixes #15731 (#15687)
* new: `nim -i cmd` * rename -i to -e (for eval); consistent with majority of other programing languages * `nim e -e:cmd` now works; bugfix: `echo cmd | nim e -` now works * honor --betterRun * address comments * --eval alias for -e (replaces undocumented --eval which was a noop) * --eval now defaults to e (nimscript) instead of r * address comment: remove -e, only keep --eval * address comment * fixup * Update compiler/nimconf.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler/extccomp.nim')
-rw-r--r-- | compiler/extccomp.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 11b001f9d..d97f9a887 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -1022,6 +1022,10 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) = lit ",\L\"stdinInput\": " lit $(%* conf.projectIsStdin) + lit ",\L\"projectIsCmd\": " + lit $(%* conf.projectIsCmd) + lit ",\L\"cmdInput\": " + lit $(%* conf.cmdInput) if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"): lit ",\L\"cmdline\": " @@ -1051,11 +1055,18 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol return true if not data.hasKey("stdinInput"): return true let stdinInput = data["stdinInput"].getBool + let projectIsCmd = data["projectIsCmd"].getBool if conf.projectIsStdin or stdinInput: # could optimize by returning false if stdin input was the same, # but I'm not sure how to get full stding input return true + if conf.projectIsCmd or projectIsCmd: + if not (conf.projectIsCmd and projectIsCmd): return true + if not data.hasKey("cmdInput"): return true + let cmdInput = data["cmdInput"].getStr + if cmdInput != conf.cmdInput: return true + let depfilesPairs = data["depfiles"] doAssert depfilesPairs.kind == JArray for p in depfilesPairs: |