Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Implement https://forum.nim-lang.org/t/7848#50018 with just the same
`SuccessX` hint category, build mode on a separate, final line, and
no change to how the mode is spelled for -d:release/-d:danger.

* Change to add a new BuildMode hint category and keep testament in sync
as per comment.

* Add "--hint:buildmode:off" to `defaultHintsOff`.

* Remove as requested.

* As requested for tests clean up.

* Address code review.

* Address code review.

* Mirror db45642
  • Loading branch information
c-blake authored Apr 29, 2021
1 parent 7637cff commit 601c050
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions compiler/lineinfos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ type
warnFileChanged = "FileChanged",
warnUser = "User",

hintSuccess = "Success", hintSuccessX = "SuccessX", hintCC = "CC",
hintSuccess = "Success", hintSuccessX = "SuccessX", hintBuildMode = "BuildMode",
hintCC = "CC",
hintLineTooLong = "LineTooLong", hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
hintXCannotRaiseY = "XCannotRaiseY", hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
hintConvFromXtoItselfNotNeeded = "ConvFromXtoItselfNotNeeded", hintExprAlwaysX = "ExprAlwaysX",
Expand Down Expand Up @@ -142,7 +143,8 @@ const
warnUser: "$1",
hintSuccess: "operation successful: $#",
# keep in sync with `testament.isSuccess`
hintSuccessX: "${loc} lines; ${sec}s; $mem; $build build; proj: $project; out: $output",
hintSuccessX: "$loc lines; ${sec}s; $mem; proj: $project; out: $output",
hintBuildMode: "$1",
hintCC: "CC: $1",
hintLineTooLong: "line too long",
hintXDeclaredButNotUsed: "'$1' is declared but not used",
Expand Down Expand Up @@ -196,7 +198,7 @@ proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
result[1] = result[2] - {warnProveField, warnProveIndex,
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,
hintSource, hintGlobalVar, hintGCStats, hintMsgOrigin}
result[0] = result[1] - {hintSuccessX, hintSuccess, hintConf,
result[0] = result[1] - {hintSuccessX, hintBuildMode, hintSuccess, hintConf,
hintProcessing, hintPattern, hintExecuting, hintLinking, hintCC}

const
Expand Down
8 changes: 4 additions & 4 deletions compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ proc mainCommand*(graph: ModuleGraph) =
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
else: formatSize(getTotalMem()) & " totmem"
let loc = $conf.linesCompiled
let build = if isDefined(conf, "danger"): "Dangerous Release"
elif isDefined(conf, "release"): "Release"
else: "Debug"
let build = if isDefined(conf, "danger"): "Dangerous Release build"
elif isDefined(conf, "release"): "Release build"
else: "***SLOW, DEBUG BUILD***; -d:release makes code run faster."
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
let project = if conf.filenameOption == foAbs: $conf.projectFull else: $conf.projectName
# xxx honor conf.filenameOption more accurately
Expand All @@ -406,10 +406,10 @@ proc mainCommand*(graph: ModuleGraph) =
"loc", loc,
"sec", sec,
"mem", mem,
"build", build,
"project", project,
"output", output,
])
rawMessage(conf, hintBuildMode, build)

when PrintRopeCacheStats:
echo "rope cache stats: "
Expand Down
1 change: 1 addition & 0 deletions doc/nimc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Source The source line that triggered a diagnostic
message.
StackTrace
Success, SuccessX Successful compilation of a library or a binary.
BuildMode Kind of build: debug, release, danger
User
UserRaw
XDeclaredButNotUsed Unused symbols in the code.
Expand Down
8 changes: 4 additions & 4 deletions drnim/drnim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1210,19 +1210,19 @@ proc mainCommand(graph: ModuleGraph) =
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
else: formatSize(getTotalMem()) & " totmem"
let loc = $conf.linesCompiled
let build = if isDefined(conf, "danger"): "Dangerous Release"
elif isDefined(conf, "release"): "Release"
else: "Debug"
let build = if isDefined(conf, "danger"): "Dangerous Release build"
elif isDefined(conf, "release"): "Release build"
else: "***SLOW, DEBUG BUILD***; -d:release makes code run faster."
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
let project = if conf.filenameOption == foAbs: $conf.projectFull else: $conf.projectName
rawMessage(conf, hintSuccessX, [
"loc", loc,
"sec", sec,
"mem", mem,
"build", build,
"project", project,
"output", ""
])
rawMessage(conf, hintBuildMode, build)

proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
var p = parseopt.initOptParser(cmd)
Expand Down
3 changes: 2 additions & 1 deletion testament/testament.nim
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ proc isSuccess(input: string): bool =
# that may appear in user config (eg: `--filenames`).
# Passing `XDG_CONFIG_HOME= testament args...` can be used to ignore user config
# stored in XDG_CONFIG_HOME, refs https://wiki.archlinux.org/index.php/XDG_Base_Directory
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
input.startsWith("Hint: ") and
(input.endsWith("[SuccessX]") or input.endsWith("[BuildMode]"))

proc getFileDir(filename: string): string =
result = filename.splitFile().dir
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/trunner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ proc isDots(a: string): bool =
a.startsWith(".") and a.strip(chars = {'.'}) == ""

const
defaultHintsOff = "--hint:successx:off --hint:exec:off --hint:link:off --hint:cc:off --hint:conf:off --hint:processing:off --hint:QuitCalled:off"
defaultHintsOff = "--hint:successx:off --hint:buildmode:off --hint:exec:off --hint:link:off --hint:cc:off --hint:conf:off --hint:processing:off --hint:QuitCalled:off"
# useful when you want to turn only some hints on, and some common ones off.
# pending https://github.com/timotheecour/Nim/issues/453, simplify to: `--hints:off`
nim = getCurrentCompilerExe()
Expand Down

0 comments on commit 601c050

Please sign in to comment.