* honor --errorMax even for tools (eg drnim, nim doc) (#14546)
* fix a bug that prevented nim doc compiler/nim on windows
This commit is contained in:
parent
621384b8ef
commit
4301a3da9d
9 changed files with 22 additions and 15 deletions
|
|
@ -51,7 +51,7 @@ proc commandGenDepend(graph: ModuleGraph) =
|
||||||
' ' & changeFileExt(project, "dot").string)
|
' ' & changeFileExt(project, "dot").string)
|
||||||
|
|
||||||
proc commandCheck(graph: ModuleGraph) =
|
proc commandCheck(graph: ModuleGraph) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.setErrorMaxHighMaybe
|
||||||
defineSymbol(graph.config.symbols, "nimcheck")
|
defineSymbol(graph.config.symbols, "nimcheck")
|
||||||
semanticPasses(graph) # use an empty backend for semantic checking only
|
semanticPasses(graph) # use an empty backend for semantic checking only
|
||||||
compileProject(graph)
|
compileProject(graph)
|
||||||
|
|
@ -59,7 +59,7 @@ proc commandCheck(graph: ModuleGraph) =
|
||||||
when not defined(leanCompiler):
|
when not defined(leanCompiler):
|
||||||
proc commandDoc2(graph: ModuleGraph; json: bool) =
|
proc commandDoc2(graph: ModuleGraph; json: bool) =
|
||||||
handleDocOutputOptions graph.config
|
handleDocOutputOptions graph.config
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.setErrorMaxHighMaybe
|
||||||
semanticPasses(graph)
|
semanticPasses(graph)
|
||||||
if json: registerPass(graph, docgen2JsonPass)
|
if json: registerPass(graph, docgen2JsonPass)
|
||||||
else: registerPass(graph, docgen2Pass)
|
else: registerPass(graph, docgen2Pass)
|
||||||
|
|
@ -136,7 +136,7 @@ proc interactivePasses(graph: ModuleGraph) =
|
||||||
registerPass(graph, evalPass)
|
registerPass(graph, evalPass)
|
||||||
|
|
||||||
proc commandInteractive(graph: ModuleGraph) =
|
proc commandInteractive(graph: ModuleGraph) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.setErrorMaxHighMaybe
|
||||||
interactivePasses(graph)
|
interactivePasses(graph)
|
||||||
compileSystemModule(graph)
|
compileSystemModule(graph)
|
||||||
if graph.config.commandArgs.len > 0:
|
if graph.config.commandArgs.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ proc destroyInterpreter*(i: Interpreter) =
|
||||||
proc runRepl*(r: TLLRepl;
|
proc runRepl*(r: TLLRepl;
|
||||||
searchPaths: openArray[string];
|
searchPaths: openArray[string];
|
||||||
supportNimscript: bool) =
|
supportNimscript: bool) =
|
||||||
|
## deadcode but please don't remove... might be revived
|
||||||
var conf = newConfigRef()
|
var conf = newConfigRef()
|
||||||
var cache = newIdentCache()
|
var cache = newIdentCache()
|
||||||
var graph = newModuleGraph(cache, conf)
|
var graph = newModuleGraph(cache, conf)
|
||||||
|
|
@ -146,7 +147,7 @@ proc runRepl*(r: TLLRepl;
|
||||||
if conf.libpath.isEmpty: conf.libpath = AbsoluteDir p
|
if conf.libpath.isEmpty: conf.libpath = AbsoluteDir p
|
||||||
|
|
||||||
conf.cmd = cmdInteractive
|
conf.cmd = cmdInteractive
|
||||||
conf.errorMax = high(int)
|
conf.setErrorMaxHighMaybe
|
||||||
initDefines(conf.symbols)
|
initDefines(conf.symbols)
|
||||||
defineSymbol(conf.symbols, "nimscript")
|
defineSymbol(conf.symbols, "nimscript")
|
||||||
if supportNimscript: defineSymbol(conf.symbols, "nimconfig")
|
if supportNimscript: defineSymbol(conf.symbols, "nimconfig")
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,14 @@ type
|
||||||
severity: Severity) {.closure, gcsafe.}
|
severity: Severity) {.closure, gcsafe.}
|
||||||
cppCustomNamespace*: string
|
cppCustomNamespace*: string
|
||||||
|
|
||||||
|
proc assignIfDefault*[T](result: var T, val: T, def = default(T)) =
|
||||||
|
## if `result` was already assigned to a value (that wasn't `def`), this is a noop.
|
||||||
|
if result == def: result = val
|
||||||
|
|
||||||
|
template setErrorMaxHighMaybe*(conf: ConfigRef) =
|
||||||
|
## do not stop after first error (but honor --errorMax if provided)
|
||||||
|
assignIfDefault(conf.errorMax, high(int))
|
||||||
|
|
||||||
proc setNoteDefaults*(conf: ConfigRef, note: TNoteKind, enabled = true) =
|
proc setNoteDefaults*(conf: ConfigRef, note: TNoteKind, enabled = true) =
|
||||||
template fun(op) =
|
template fun(op) =
|
||||||
conf.notes.op note
|
conf.notes.op note
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ proc tryConstExpr(c: PContext, n: PNode): PNode =
|
||||||
let oldErrorOutputs = c.config.m.errorOutputs
|
let oldErrorOutputs = c.config.m.errorOutputs
|
||||||
|
|
||||||
c.config.m.errorOutputs = {}
|
c.config.m.errorOutputs = {}
|
||||||
c.config.errorMax = high(int)
|
c.config.errorMax = high(int) # `setErrorMaxHighMaybe` not appropriate here
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = evalConstExpr(c.module, c.graph, e)
|
result = evalConstExpr(c.module, c.graph, e)
|
||||||
|
|
|
||||||
|
|
@ -2074,8 +2074,7 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
if c.compilesContextId == 0:
|
if c.compilesContextId == 0:
|
||||||
inc c.compilesContextIdGenerator
|
inc c.compilesContextIdGenerator
|
||||||
c.compilesContextId = c.compilesContextIdGenerator
|
c.compilesContextId = c.compilesContextIdGenerator
|
||||||
# do not halt after first error:
|
c.config.errorMax = high(int) # `setErrorMaxHighMaybe` not appropriate here
|
||||||
c.config.errorMax = high(int)
|
|
||||||
|
|
||||||
# open a scope for temporary symbol inclusions:
|
# open a scope for temporary symbol inclusions:
|
||||||
let oldScope = c.currentScope
|
let oldScope = c.currentScope
|
||||||
|
|
|
||||||
|
|
@ -1192,7 +1192,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
graph.strongSemCheck = strongSemCheck
|
graph.strongSemCheck = strongSemCheck
|
||||||
graph.compatibleProps = compatibleProps
|
graph.compatibleProps = compatibleProps
|
||||||
|
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.setErrorMaxHighMaybe
|
||||||
defineSymbol(graph.config.symbols, "nimcheck")
|
defineSymbol(graph.config.symbols, "nimcheck")
|
||||||
defineSymbol(graph.config.symbols, "nimDrNim")
|
defineSymbol(graph.config.symbols, "nimDrNim")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -525,8 +525,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
|
|
||||||
add(conf.searchPaths, conf.libpath)
|
add(conf.searchPaths, conf.libpath)
|
||||||
|
|
||||||
# do not stop after the first error:
|
conf.setErrorMaxHighMaybe # honor --errorMax even if it may not make sense here
|
||||||
conf.errorMax = high(int)
|
|
||||||
# do not print errors, but log them
|
# do not print errors, but log them
|
||||||
conf.writelnHook = myLog
|
conf.writelnHook = myLog
|
||||||
conf.structuredErrorHook = nil
|
conf.structuredErrorHook = nil
|
||||||
|
|
@ -674,8 +673,7 @@ else:
|
||||||
|
|
||||||
add(conf.searchPaths, conf.libpath)
|
add(conf.searchPaths, conf.libpath)
|
||||||
|
|
||||||
# do not stop after the first error:
|
conf.setErrorMaxHighMaybe
|
||||||
conf.errorMax = high(int)
|
|
||||||
# do not print errors, but log them
|
# do not print errors, but log them
|
||||||
conf.writelnHook = myLog
|
conf.writelnHook = myLog
|
||||||
conf.structuredErrorHook = nil
|
conf.structuredErrorHook = nil
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ import "../compiler/nimpaths"
|
||||||
|
|
||||||
const
|
const
|
||||||
gaCode* = " --doc.googleAnalytics:UA-48159761-1"
|
gaCode* = " --doc.googleAnalytics:UA-48159761-1"
|
||||||
nimArgs = "--hint:Conf:off --hint:Path:off --hint:Processing:off -d:boot --putenv:nimversion=$#" % system.NimVersion
|
# errormax: subsequent errors are probably consequences of 1st one; a simple
|
||||||
|
# bug could cause unlimited number of errors otherwise, hard to debug in CI.
|
||||||
|
nimArgs = "--errormax:3 --hint:Conf:off --hint:Path:off --hint:Processing:off -d:boot --putenv:nimversion=$#" % system.NimVersion
|
||||||
gitUrl = "https://github.com/nim-lang/Nim"
|
gitUrl = "https://github.com/nim-lang/Nim"
|
||||||
docHtmlOutput = "doc/html"
|
docHtmlOutput = "doc/html"
|
||||||
webUploadOutput = "web/upload"
|
webUploadOutput = "web/upload"
|
||||||
|
|
|
||||||
|
|
@ -169,8 +169,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
if not fileExists(conf.projectFull):
|
if not fileExists(conf.projectFull):
|
||||||
quit "cannot find file: " & conf.projectFull.string
|
quit "cannot find file: " & conf.projectFull.string
|
||||||
add(conf.searchPaths, conf.libpath)
|
add(conf.searchPaths, conf.libpath)
|
||||||
# do not stop after the first error:
|
conf.setErrorMaxHighMaybe
|
||||||
conf.errorMax = high(int)
|
|
||||||
try:
|
try:
|
||||||
compileProject(graph)
|
compileProject(graph)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue