mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 18:34:43 +00:00
merge BuildMode into SuccessX, remove code duplication w drnim, add useful info to successx, add gc to compilesettings (#18252)
* merge BuildMode into SuccessX, add more info * refactor duplicated with drnim * fixup * address comment
This commit is contained in:
@@ -65,7 +65,7 @@ type
|
||||
warnFileChanged = "FileChanged",
|
||||
warnUser = "User",
|
||||
|
||||
hintSuccess = "Success", hintSuccessX = "SuccessX", hintBuildMode = "BuildMode",
|
||||
hintSuccess = "Success", hintSuccessX = "SuccessX",
|
||||
hintCC = "CC",
|
||||
hintLineTooLong = "LineTooLong", hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
|
||||
hintXCannotRaiseY = "XCannotRaiseY", hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
|
||||
@@ -145,8 +145,7 @@ const
|
||||
warnUser: "$1",
|
||||
hintSuccess: "operation successful: $#",
|
||||
# keep in sync with `testament.isSuccess`
|
||||
hintSuccessX: "$loc lines; ${sec}s; $mem; proj: $project; out: $output",
|
||||
hintBuildMode: "$1",
|
||||
hintSuccessX: "$build\n$loc lines; ${sec}s; $mem; proj: $project; out: $output",
|
||||
hintCC: "CC: $1",
|
||||
hintLineTooLong: "line too long",
|
||||
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
||||
@@ -200,7 +199,7 @@ proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
|
||||
result[1] = result[2] - {warnProveField, warnProveIndex,
|
||||
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,
|
||||
hintSource, hintGlobalVar, hintGCStats, hintMsgOrigin, hintPerformance}
|
||||
result[0] = result[1] - {hintSuccessX, hintBuildMode, hintSuccess, hintConf,
|
||||
result[0] = result[1] - {hintSuccessX, hintSuccess, hintConf,
|
||||
hintProcessing, hintPattern, hintExecuting, hintLinking, hintCC}
|
||||
|
||||
const
|
||||
|
||||
@@ -13,13 +13,14 @@ when not defined(nimcore):
|
||||
{.error: "nimcore MUST be defined for Nim's core tooling".}
|
||||
|
||||
import
|
||||
llstream, strutils, os, ast, lexer, syntaxes, options, msgs,
|
||||
condsyms, times,
|
||||
std/[strutils, os, times, tables, sha1, with, json],
|
||||
llstream, ast, lexer, syntaxes, options, msgs,
|
||||
condsyms,
|
||||
sem, idents, passes, extccomp,
|
||||
cgen, json, nversion,
|
||||
cgen, nversion,
|
||||
platform, nimconf, passaux, depends, vm,
|
||||
modules,
|
||||
modulegraphs, tables, lineinfos, pathutils, vmprofiler, std/[sha1, with]
|
||||
modulegraphs, lineinfos, pathutils, vmprofiler
|
||||
|
||||
import ic / [cbackend, integrity, navigator]
|
||||
from ic / ic import rodViewer
|
||||
@@ -387,38 +388,9 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||
rawMessage(conf, errGenerated, "invalid command: " & conf.command)
|
||||
|
||||
if conf.errorCounter == 0 and conf.cmd notin {cmdTcc, cmdDump, cmdNop}:
|
||||
# D20210419T170230:here
|
||||
let mem =
|
||||
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
||||
else: formatSize(getTotalMem()) & " totmem"
|
||||
let loc = $conf.linesCompiled
|
||||
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
|
||||
var output: string
|
||||
if optCompileOnly in conf.globalOptions and conf.cmd != cmdJsonscript:
|
||||
output = $conf.jsonBuildFile
|
||||
elif conf.outFile.isEmpty and conf.cmd notin {cmdJsonscript} + cmdDocLike + cmdBackends:
|
||||
# for some cmd we expect a valid absOutFile
|
||||
output = "unknownOutput"
|
||||
else:
|
||||
output = $conf.absOutFile
|
||||
if conf.filenameOption != foAbs: output = output.AbsoluteFile.extractFilename
|
||||
# xxx honor filenameOption more accurately
|
||||
if optProfileVM in conf.globalOptions:
|
||||
echo conf.dump(conf.vmProfileData)
|
||||
rawMessage(conf, hintSuccessX, [
|
||||
"loc", loc,
|
||||
"sec", sec,
|
||||
"mem", mem,
|
||||
"project", project,
|
||||
"output", output,
|
||||
])
|
||||
if conf.cmd in cmdBackends:
|
||||
rawMessage(conf, hintBuildMode, build)
|
||||
genSuccessX(conf)
|
||||
|
||||
when PrintRopeCacheStats:
|
||||
echo "rope cache stats: "
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
#
|
||||
|
||||
import
|
||||
options, strutils, os, tables, ropes, terminal, macros,
|
||||
lineinfos, pathutils
|
||||
import std/private/miscdollars
|
||||
import strutils2
|
||||
std/[strutils, os, tables, terminal, macros, times],
|
||||
std/private/miscdollars,
|
||||
options, ropes, lineinfos, pathutils, strutils2
|
||||
|
||||
type InstantiationInfo* = typeof(instantiationInfo())
|
||||
template instLoc*(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
||||
@@ -656,3 +655,39 @@ proc uniqueModuleName*(conf: ConfigRef; fid: FileIndex): string =
|
||||
# We mangle upper letters and digits too so that there cannot
|
||||
# be clashes with our special meanings of 'Z' and 'O'
|
||||
result.addInt ord(c)
|
||||
|
||||
proc genSuccessX*(conf: ConfigRef) =
|
||||
let mem =
|
||||
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
||||
else: formatSize(getTotalMem()) & " totmem"
|
||||
let loc = $conf.linesCompiled
|
||||
var build = ""
|
||||
if conf.cmd in cmdBackends:
|
||||
build.add "gc: $#; " % $conf.selectedGC
|
||||
if optThreads in conf.globalOptions: build.add "threads: on; "
|
||||
build.add "opt: "
|
||||
if optOptimizeSpeed in conf.options: build.add "speed"
|
||||
elif optOptimizeSize in conf.options: build.add "size"
|
||||
else: build.add "none (DEBUG BUILD, `-d:release` generates faster code)"
|
||||
# pending https://github.com/timotheecour/Nim/issues/752, point to optimization.html
|
||||
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
|
||||
var output: string
|
||||
if optCompileOnly in conf.globalOptions and conf.cmd != cmdJsonscript:
|
||||
output = $conf.jsonBuildFile
|
||||
elif conf.outFile.isEmpty and conf.cmd notin {cmdJsonscript} + cmdDocLike + cmdBackends:
|
||||
# for some cmd we expect a valid absOutFile
|
||||
output = "unknownOutput"
|
||||
else:
|
||||
output = $conf.absOutFile
|
||||
if conf.filenameOption != foAbs: output = output.AbsoluteFile.extractFilename
|
||||
# xxx honor filenameOption more accurately
|
||||
rawMessage(conf, hintSuccessX, [
|
||||
"build", build,
|
||||
"loc", loc,
|
||||
"sec", sec,
|
||||
"mem", mem,
|
||||
"project", project,
|
||||
"output", output,
|
||||
])
|
||||
|
||||
@@ -167,8 +167,17 @@ const
|
||||
type
|
||||
TStringSeq* = seq[string]
|
||||
TGCMode* = enum # the selected GC
|
||||
gcUnselected, gcNone, gcBoehm, gcRegions, gcArc, gcOrc,
|
||||
gcMarkAndSweep, gcHooks, gcRefc, gcV2, gcGo
|
||||
gcUnselected = "unselected"
|
||||
gcNone = "none"
|
||||
gcBoehm = "boehm"
|
||||
gcRegions = "regions"
|
||||
gcArc = "arc"
|
||||
gcOrc = "orc"
|
||||
gcMarkAndSweep = "markAndSweep"
|
||||
gcHooks = "hooks"
|
||||
gcRefc = "refc"
|
||||
gcV2 = "v2"
|
||||
gcGo = "go"
|
||||
# gcRefc and the GCs that follow it use a write barrier,
|
||||
# as far as usesWriteBarrier() is concerned
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ when defined(nimHasInvariant):
|
||||
of ccompilerPath: result = conf.cCompilerPath
|
||||
of backend: result = $conf.backend
|
||||
of libPath: result = conf.libpath.string
|
||||
of gc: result = $conf.selectedGC
|
||||
|
||||
proc querySettingSeqImpl(conf: ConfigRef, switch: BiggestInt): seq[string] =
|
||||
template copySeq(field: untyped): untyped =
|
||||
|
||||
@@ -108,7 +108,6 @@ 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.
|
||||
|
||||
@@ -1205,24 +1205,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||
registerPass graph, semPass
|
||||
compileProject(graph)
|
||||
if conf.errorCounter == 0:
|
||||
# xxx deduplicate with D20210419T170230
|
||||
let mem =
|
||||
when declared(system.getMaxMem): formatSize(getMaxMem()) & " peakmem"
|
||||
else: formatSize(getTotalMem()) & " totmem"
|
||||
let loc = $conf.linesCompiled
|
||||
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,
|
||||
"project", project,
|
||||
"output", ""
|
||||
])
|
||||
rawMessage(conf, hintBuildMode, build)
|
||||
genSuccessX(graph.config)
|
||||
|
||||
proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
|
||||
var p = parseopt.initOptParser(cmd)
|
||||
|
||||
@@ -32,6 +32,7 @@ type
|
||||
backend ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
|
||||
## and `nim js` would imply backend=js
|
||||
libPath ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
|
||||
gc ## gc selected
|
||||
|
||||
MultipleValueSetting* {.pure.} = enum ## \
|
||||
## settings resulting in a seq of string values
|
||||
|
||||
@@ -108,8 +108,7 @@ 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]") or input.endsWith("[BuildMode]"))
|
||||
input.startsWith("Hint: ") and input.endsWith("[SuccessX]")
|
||||
|
||||
proc getFileDir(filename: string): string =
|
||||
result = filename.splitFile().dir
|
||||
|
||||
@@ -23,7 +23,7 @@ proc isDots(a: string): bool =
|
||||
a.startsWith(".") and a.strip(chars = {'.'}) == ""
|
||||
|
||||
const
|
||||
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"
|
||||
defaultHintsOff = "--hint:successx: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()
|
||||
|
||||
Reference in New Issue
Block a user