diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-11-25 05:44:13 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-11-25 14:44:13 +0100 |
commit | dfe5d115fbc644413fa8747d68c9cf63848e3dee (patch) | |
tree | 78f6aadedde68f6531500bd82ac5d71bde2a4aab /compiler | |
parent | 04614a30bdb7d9dec95c3e89d2bbc54ba80111ec (diff) | |
download | Nim-dfe5d115fbc644413fa8747d68c9cf63848e3dee.tar.gz |
fixes #12663 staticRead now creates a dependency for rebuilds (#12731) [backport]
* fix #12663 staticRead * address comments
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/extccomp.nim | 25 | ||||
-rw-r--r-- | compiler/vmdeps.nim | 2 |
2 files changed, 15 insertions, 12 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 42020822c..711ca8737 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -1037,15 +1037,16 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) = pastStart = true lit "\L" - proc nimfiles(conf: ConfigRef; f: File) = + proc depfiles(conf: ConfigRef; f: File) = var i = 0 for it in conf.m.fileInfos: - if isAbsolute(it.fullPath.string): + let path = it.fullPath.string + if isAbsolute(path): # TODO: else? if i > 0: lit "],\L" lit "[" - str it.fullPath.string + str path lit ", " - str $secureHashFile(it.fullPath.string) + str $secureHashFile(path) inc i lit "]\L" @@ -1069,8 +1070,8 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) = if optRun in conf.globalOptions or isDefined(conf, "nimBetterRun"): lit ",\L\"cmdline\": " str conf.commandLine - lit ",\L\"nimfiles\":[\L" - nimfiles(conf, f) + lit ",\L\"depfiles\":[\L" + depfiles(conf, f) lit "],\L\"nimexe\": \L" str hashNimExe() lit "\L" @@ -1085,22 +1086,22 @@ 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"): + if not data.hasKey("depfiles") or not data.hasKey("cmdline"): return true let oldCmdLine = data["cmdline"].getStr if conf.commandLine != oldCmdLine: return true if hashNimExe() != data["nimexe"].getStr: return true - let nimfilesPairs = data["nimfiles"] - doAssert nimfilesPairs.kind == JArray - for p in nimfilesPairs: + let depfilesPairs = data["depfiles"] + doAssert depfilesPairs.kind == JArray + for p in depfilesPairs: doAssert p.kind == JArray # >= 2 for forwards compatibility with potential later .json files: doAssert p.len >= 2 - let nimFilename = p[0].getStr + let depFilename = p[0].getStr let oldHashValue = p[1].getStr - let newHashValue = $secureHashFile(nimFilename) + let newHashValue = $secureHashFile(depFilename) if oldHashValue != newHashValue: return true except IOError, OSError, ValueError: diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index e3d9533aa..5be25ba1b 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -8,6 +8,7 @@ # import ast, types, msgs, os, options, idents, lineinfos +from pathutils import AbsoluteFile proc opSlurp*(file: string, info: TLineInfo, module: PSym; conf: ConfigRef): string = try: @@ -17,6 +18,7 @@ proc opSlurp*(file: string, info: TLineInfo, module: PSym; conf: ConfigRef): str result = readFile(filename) # we produce a fake include statement for every slurped filename, so that # the module dependencies are accurate: + discard conf.fileInfoIdx(AbsoluteFile filename) appendToModule(module, newNode(nkIncludeStmt, info, @[ newStrNode(nkStrLit, filename)])) except IOError: |