summary refs log tree commit diff stats
path: root/compiler/extccomp.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/extccomp.nim')
-rw-r--r--compiler/extccomp.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 76b31cc4d..4ecad6d58 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -1024,6 +1024,8 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
     str getLinkCmd(conf, conf.absOutFile, objfiles)
 
     if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
+      lit ",\L\"cmdline\": "
+      str conf.commandLine
       lit ",\L\"nimfiles\":[\L"
       nimfiles(conf, f)
       lit "]\L"
@@ -1038,6 +1040,11 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol
   result = false
   try:
     let data = json.parseFile(jsonFile.string)
+    if not data.hasKey("nimfiles") or not data.hasKey("cmdline"):
+      return true
+    let oldCmdLine = data["cmdline"].getStr
+    if conf.commandLine != oldCmdLine:
+      return true
     let nimfilesPairs = data["nimfiles"]
     doAssert nimfilesPairs.kind == JArray
     for p in nimfilesPairs:
@@ -1048,7 +1055,7 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol
       let oldHashValue = p[1].getStr
       let newHashValue = $secureHashFile(nimFilename)
       if oldHashValue != newHashValue:
-        result = true
+        return true
   except IOError, OSError, ValueError:
     echo "Warning: JSON processing failed: ", getCurrentExceptionMsg()
     result = true