parent
1d2e2b5a5b
commit
854ff26ac5
1 changed files with 13 additions and 2 deletions
|
|
@ -1026,6 +1026,8 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
|
||||||
lit $(%* conf.projectIsCmd)
|
lit $(%* conf.projectIsCmd)
|
||||||
lit ",\L\"cmdInput\": "
|
lit ",\L\"cmdInput\": "
|
||||||
lit $(%* conf.cmdInput)
|
lit $(%* conf.cmdInput)
|
||||||
|
lit ",\L\"currentDir\": "
|
||||||
|
lit $(%* getCurrentDir())
|
||||||
|
|
||||||
if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
|
if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
|
||||||
lit ",\L\"cmdline\": "
|
lit ",\L\"cmdline\": "
|
||||||
|
|
@ -1046,14 +1048,23 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol
|
||||||
result = false
|
result = false
|
||||||
try:
|
try:
|
||||||
let data = json.parseFile(jsonFile.string)
|
let data = json.parseFile(jsonFile.string)
|
||||||
if not data.hasKey("depfiles") or not data.hasKey("cmdline"):
|
for key in "depfiles cmdline stdinInput currentDir".split:
|
||||||
|
if not data.hasKey(key): return true
|
||||||
|
if getCurrentDir() != data["currentDir"].getStr:
|
||||||
|
# fixes bug #16271
|
||||||
|
# Note that simply comparing `expandFilename(projectFile)` would
|
||||||
|
# not be sufficient in case other flags depend implicitly on `getCurrentDir`,
|
||||||
|
# and would require much more care. Simply re-compiling is safer for now.
|
||||||
|
# A better strategy for future work would be to cache (with an LRU cache)
|
||||||
|
# the N most recent unique build instructions, as done with `rdmd`,
|
||||||
|
# which is both robust and avoids recompilation when switching back and forth
|
||||||
|
# between projects, see https://github.com/timotheecour/Nim/issues/199
|
||||||
return true
|
return true
|
||||||
let oldCmdLine = data["cmdline"].getStr
|
let oldCmdLine = data["cmdline"].getStr
|
||||||
if conf.commandLine != oldCmdLine:
|
if conf.commandLine != oldCmdLine:
|
||||||
return true
|
return true
|
||||||
if hashNimExe() != data["nimexe"].getStr:
|
if hashNimExe() != data["nimexe"].getStr:
|
||||||
return true
|
return true
|
||||||
if not data.hasKey("stdinInput"): return true
|
|
||||||
let stdinInput = data["stdinInput"].getBool
|
let stdinInput = data["stdinInput"].getBool
|
||||||
let projectIsCmd = data["projectIsCmd"].getBool
|
let projectIsCmd = data["projectIsCmd"].getBool
|
||||||
if conf.projectIsStdin or stdinInput:
|
if conf.projectIsStdin or stdinInput:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue