better run also considers the command line; fixes #11719 [feature]
This commit is contained in:
parent
423e8cca91
commit
d55cc0888d
3 changed files with 18 additions and 1 deletions
|
|
@ -1024,6 +1024,8 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
|
||||||
str getLinkCmd(conf, conf.absOutFile, objfiles)
|
str getLinkCmd(conf, conf.absOutFile, objfiles)
|
||||||
|
|
||||||
if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
|
if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"):
|
||||||
|
lit ",\L\"cmdline\": "
|
||||||
|
str conf.commandLine
|
||||||
lit ",\L\"nimfiles\":[\L"
|
lit ",\L\"nimfiles\":[\L"
|
||||||
nimfiles(conf, f)
|
nimfiles(conf, f)
|
||||||
lit "]\L"
|
lit "]\L"
|
||||||
|
|
@ -1038,6 +1040,11 @@ 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("nimfiles") or not data.hasKey("cmdline"):
|
||||||
|
return true
|
||||||
|
let oldCmdLine = data["cmdline"].getStr
|
||||||
|
if conf.commandLine != oldCmdLine:
|
||||||
|
return true
|
||||||
let nimfilesPairs = data["nimfiles"]
|
let nimfilesPairs = data["nimfiles"]
|
||||||
doAssert nimfilesPairs.kind == JArray
|
doAssert nimfilesPairs.kind == JArray
|
||||||
for p in nimfilesPairs:
|
for p in nimfilesPairs:
|
||||||
|
|
@ -1048,7 +1055,7 @@ proc changeDetectedViaJsonBuildInstructions*(conf: ConfigRef; projectfile: Absol
|
||||||
let oldHashValue = p[1].getStr
|
let oldHashValue = p[1].getStr
|
||||||
let newHashValue = $secureHashFile(nimFilename)
|
let newHashValue = $secureHashFile(nimFilename)
|
||||||
if oldHashValue != newHashValue:
|
if oldHashValue != newHashValue:
|
||||||
result = true
|
return true
|
||||||
except IOError, OSError, ValueError:
|
except IOError, OSError, ValueError:
|
||||||
echo "Warning: JSON processing failed: ", getCurrentExceptionMsg()
|
echo "Warning: JSON processing failed: ", getCurrentExceptionMsg()
|
||||||
result = true
|
result = true
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,20 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
|
||||||
case p.kind
|
case p.kind
|
||||||
of cmdEnd: break
|
of cmdEnd: break
|
||||||
of cmdLongOption, cmdShortOption:
|
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 == " ":
|
if p.key == " ":
|
||||||
p.key = "-"
|
p.key = "-"
|
||||||
if processArgument(pass, p, argsCount, config): break
|
if processArgument(pass, p, argsCount, config): break
|
||||||
else:
|
else:
|
||||||
processSwitch(pass, p, config)
|
processSwitch(pass, p, config)
|
||||||
of cmdArgument:
|
of cmdArgument:
|
||||||
|
config.commandLine.add " "
|
||||||
|
config.commandLine.add p.key
|
||||||
if processArgument(pass, p, argsCount, config): break
|
if processArgument(pass, p, argsCount, config): break
|
||||||
if pass == passCmd2:
|
if pass == passCmd2:
|
||||||
if {optRun, optWasNimscript} * config.globalOptions == {} and
|
if {optRun, optWasNimscript} * config.globalOptions == {} and
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@ type
|
||||||
projectMainIdx*: FileIndex # the canonical path id of the main module
|
projectMainIdx*: FileIndex # the canonical path id of the main module
|
||||||
command*: string # the main command (e.g. cc, check, scan, etc)
|
command*: string # the main command (e.g. cc, check, scan, etc)
|
||||||
commandArgs*: seq[string] # any arguments after the main command
|
commandArgs*: seq[string] # any arguments after the main command
|
||||||
|
commandLine*: string
|
||||||
keepComments*: bool # whether the parser needs to keep comments
|
keepComments*: bool # whether the parser needs to keep comments
|
||||||
implicitImports*: seq[string] # modules that are to be implicitly imported
|
implicitImports*: seq[string] # modules that are to be implicitly imported
|
||||||
implicitIncludes*: seq[string] # modules that are to be implicitly included
|
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
|
projectMainIdx: FileIndex(0'i32), # the canonical path id of the main module
|
||||||
command: "", # the main command (e.g. cc, check, scan, etc)
|
command: "", # the main command (e.g. cc, check, scan, etc)
|
||||||
commandArgs: @[], # any arguments after the main command
|
commandArgs: @[], # any arguments after the main command
|
||||||
|
commandLine: "",
|
||||||
keepComments: true, # whether the parser needs to keep comments
|
keepComments: true, # whether the parser needs to keep comments
|
||||||
implicitImports: @[], # modules that are to be implicitly imported
|
implicitImports: @[], # modules that are to be implicitly imported
|
||||||
implicitIncludes: @[], # modules that are to be implicitly included
|
implicitIncludes: @[], # modules that are to be implicitly included
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue