diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-01-15 06:18:37 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-01-15 15:18:37 +0100 |
commit | d88b52c0bc505db42ba6561518c9ee9b21a99e81 (patch) | |
tree | 987472b2e53f607ae4753590e95be789a053bc33 /compiler | |
parent | 51c072bd379dfb4bc82de643b6dac7abe6809e33 (diff) | |
download | Nim-d88b52c0bc505db42ba6561518c9ee9b21a99e81.tar.gz |
successX now correctly shows html output for `nim doc`, `nim jsondoc`; fix #13121 (#13116)
* successX now correctly shows html output for nim doc * fixes #13121 * fixup hintSuccessX to be less weird
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/docgen.nim | 2 | ||||
-rw-r--r-- | compiler/lineinfos.nim | 2 | ||||
-rw-r--r-- | compiler/main.nim | 3 | ||||
-rw-r--r-- | compiler/options.nim | 2 | ||||
-rw-r--r-- | compiler/pathutils.nim | 15 |
5 files changed, 18 insertions, 6 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim index e4325aaaf..a09f54c16 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -1072,6 +1072,7 @@ proc writeOutput*(d: PDoc, useWarning = false) = if not writeRope(content, outfile): rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile, outfile.string) + d.conf.outFile = outfile.extractFilename.RelativeFile proc writeOutputJson*(d: PDoc, useWarning = false) = runAllExamples(d) @@ -1089,6 +1090,7 @@ proc writeOutputJson*(d: PDoc, useWarning = false) = if open(f, d.destFile.string, fmWrite): write(f, $content) close(f) + d.conf.outFile = d.destFile.extractFilename.RelativeFile else: localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1), warnUser, "unable to open file \"" & d.destFile.string & diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index c0826bb5c..b5742e669 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -98,7 +98,7 @@ const warnUser: "$1", hintSuccess: "operation successful: $#", # keep in sync with `pegSuccess` see testament.nim - hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; $project proj; $output out", + hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output", hintCC: "CC: \'$1\'", # unused hintLineTooLong: "line too long", hintXDeclaredButNotUsed: "'$1' is declared but not used", diff --git a/compiler/main.nim b/compiler/main.nim index 700870241..3cafe1f2c 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -364,7 +364,8 @@ proc mainCommand*(graph: ModuleGraph) = else: "Debug" let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3) let project = if optListFullPaths in conf.globalOptions: $conf.projectFull else: $conf.projectName - let output = if optListFullPaths in conf.globalOptions: $conf.getOutFileFull else: $conf.outFile + var output = $conf.absOutFile + if optListFullPaths notin conf.globalOptions: output = output.AbsoluteFile.extractFilename rawMessage(conf, hintSuccessX, [ "loc", loc, "sec", sec, diff --git a/compiler/options.nim b/compiler/options.nim index 9a0fa45b0..9c17ea1e6 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -284,8 +284,6 @@ type severity: Severity) {.closure, gcsafe.} cppCustomNamespace*: string -proc getOutFileFull*(a: ConfigRef): AbsoluteFile = a.outDir / a.outFile - proc hcrOn*(conf: ConfigRef): bool = return optHotCodeReloading in conf.globalOptions template depConfigFields*(fn) {.dirty.} = diff --git a/compiler/pathutils.nim b/compiler/pathutils.nim index b73942a21..e3dd69628 100644 --- a/compiler/pathutils.nim +++ b/compiler/pathutils.nim @@ -54,8 +54,19 @@ when true: proc `==`*[T: AnyPath](x, y: T): bool = eqImpl(x.string, y.string) + template postProcessBase(base: AbsoluteDir): untyped = + # xxx: as argued here https://github.com/nim-lang/Nim/pull/10018#issuecomment-448192956 + # empty paths should not mean `cwd` so the correct behavior would be to throw + # here and make sure `outDir` is always correctly initialized; for now + # we simply preserve pre-existing external semantics and treat it as `cwd` + when false: + doAssert isAbsolute(base.string), base.string + base + else: + if base.isEmpty: getCurrentDir().AbsoluteDir else: base + proc `/`*(base: AbsoluteDir; f: RelativeFile): AbsoluteFile = - #assert isAbsolute(base.string) + let base = postProcessBase(base) assert(not isAbsolute(f.string)) result = AbsoluteFile newStringOfCap(base.string.len + f.string.len) var state = 0 @@ -63,7 +74,7 @@ when true: addNormalizePath(f.string, result.string, state) proc `/`*(base: AbsoluteDir; f: RelativeDir): AbsoluteDir = - #assert isAbsolute(base.string) + let base = postProcessBase(base) assert(not isAbsolute(f.string)) result = AbsoluteDir newStringOfCap(base.string.len + f.string.len) var state = 0 |