Skip to content

Commit

Permalink
fix #13412 nim now recompiles for stdin input; SuccessX now indicates…
Browse files Browse the repository at this point in the history
… whether it recompiled
  • Loading branch information
timotheecour committed Feb 27, 2020
1 parent 42dad3a commit 70f8174
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,9 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
lit ",\L\"extraCmds\": "
lit $(%* conf.extraCmds)

lit ",\L\"stdinInput\": "
lit $(%* conf.projectIsStdin)

if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
lit ",\L\"cmdline\": "
str conf.commandLine
Expand All @@ -1097,6 +1100,13 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol
return true
if hashNimExe() != data["nimexe"].getStr:
return true
if not data.hasKey("stdinInput"): return true
let stdinInput = data["stdinInput"].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

let depfilesPairs = data["depfiles"]
doAssert depfilesPairs.kind == JArray
for p in depfilesPairs:
Expand Down
4 changes: 2 additions & 2 deletions compiler/lineinfos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const
warnCycleCreated: "$1",
warnUser: "$1",
hintSuccess: "operation successful: $#",
# keep in sync with `pegSuccess` see testament.nim
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
# keep in sync with `testament.isSuccess`
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output recompiled: $projectRecompiled",
hintCC: "CC: \'$1\'", # unused
hintLineTooLong: "line too long",
hintXDeclaredButNotUsed: "'$1' is declared but not used",
Expand Down
2 changes: 2 additions & 0 deletions compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ proc commandCompileToC(graph: ModuleGraph) =
graph.config.notes = graph.config.mainPackageNotes
return

graph.config.projectRecompiled = true
compileProject(graph)
if graph.config.errorCounter > 0:
return # issue #9933
Expand Down Expand Up @@ -379,6 +380,7 @@ proc mainCommand*(graph: ModuleGraph) =
"build", build,
"project", project,
"output", output,
"projectRecompiled", $conf.projectRecompiled,
])

when PrintRopeCacheStats:
Expand Down
2 changes: 2 additions & 0 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ type
structuredErrorHook*: proc (config: ConfigRef; info: TLineInfo; msg: string;
severity: Severity) {.closure, gcsafe.}
cppCustomNamespace*: string
projectRecompiled*: bool

proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
optHints in conf.options and note in conf.notes
Expand Down Expand Up @@ -391,6 +392,7 @@ proc newConfigRef*(): ConfigRef =
arguments: "",
suggestMaxResults: 10_000,
maxLoopIterationsVM: 10_000_000,
projectRecompiled: false,
)
setTargetFromSystem(result.target)
# enable colors by default on terminals
Expand Down

0 comments on commit 70f8174

Please sign in to comment.