summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/extccomp.nim9
-rw-r--r--compiler/nim.nim8
-rw-r--r--compiler/options.nim2
3 files changed, 18 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
diff --git a/compiler/nim.nim b/compiler/nim.nim
index 1f8a55897..5fcf043b5 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -48,12 +48,20 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
     case p.kind
     of cmdEnd: break
     of cmdLongOption, cmdShortOption:
+      config.commandLine.add " "
+      config.commandLine.add p.key
+      if p.val.len > 0:
+        config.commandLine.add ':'
+        config.commandLine.add p.val
+
       if p.key == " ":
         p.key = "-"
         if processArgument(pass, p, argsCount, config): break
       else:
         processSwitch(pass, p, config)
     of cmdArgument:
+      config.commandLine.add " "
+      config.commandLine.add p.key
       if processArgument(pass, p, argsCount, config): break
   if pass == passCmd2:
     if {optRun, optWasNimscript} * config.globalOptions == {} and
diff --git a/compiler/options.nim b/compiler/options.nim
index 7b391f4e9..985955d98 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -229,6 +229,7 @@ type
     projectMainIdx*: FileIndex # the canonical path id of the main module
     command*: string # the main command (e.g. cc, check, scan, etc)
     commandArgs*: seq[string] # any arguments after the main command
+    commandLine*: string
     keepComments*: bool # whether the parser needs to keep comments
     implicitImports*: seq[string] # modules that are to be implicitly imported
     implicitIncludes*: seq[string] # modules that are to be implicitly included
@@ -335,6 +336,7 @@ proc newConfigRef*(): ConfigRef =
     projectMainIdx: FileIndex(0'i32), # the canonical path id of the main module
     command: "", # the main command (e.g. cc, check, scan, etc)
     commandArgs: @[], # any arguments after the main command
+    commandLine: "",
     keepComments: true, # whether the parser needs to keep comments
     implicitImports: @[], # modules that are to be implicitly imported
     implicitIncludes: @[], # modules that are to be implicitly included