diff options
-rw-r--r-- | compiler/cmdlinehelper.nim | 2 | ||||
-rw-r--r-- | compiler/commands.nim | 6 | ||||
-rw-r--r-- | compiler/msgs.nim | 5 | ||||
-rw-r--r-- | compiler/nimconf.nim | 1 | ||||
-rw-r--r-- | compiler/options.nim | 4 | ||||
-rw-r--r-- | compiler/scriptconfig.nim | 3 |
6 files changed, 18 insertions, 3 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim index a03899071..9df6d37e0 100644 --- a/compiler/cmdlinehelper.nim +++ b/compiler/cmdlinehelper.nim @@ -27,7 +27,9 @@ proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) = defineSymbol conf.symbols, name proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) = + conf.isCmdLine = true self.processCmdLine(passCmd1, "", conf) + conf.isCmdLine = false if self.supportsStdinFile and conf.projectName == "-": handleStdinInput(conf) elif conf.projectName != "": diff --git a/compiler/commands.nim b/compiler/commands.nim index 638444efe..76203762c 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -204,11 +204,17 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass, incl(conf.notes, n) incl(conf.mainPackageNotes, n) incl(conf.enableNotes, n) + if conf.isCmdLine: + incl(conf.cmdLineNotes, n) + excl(conf.cmdLineDisabledNotes, n) of "off": excl(conf.notes, n) excl(conf.mainPackageNotes, n) incl(conf.disableNotes, n) excl(conf.foreignPackageNotes, n) + if conf.isCmdLine: + incl(conf.cmdLineDisabledNotes, n) + excl(conf.cmdLineNotes, n) else: localError(conf, info, errOnOrOffExpectedButXFound % arg) proc processCompile(conf: ConfigRef; filename: string) = diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 6d1ecb2b1..7fa8e8aef 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -418,7 +418,10 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) = inc(conf.warnCounter) of hintMin..hintMax: sev = Severity.Hint - if not conf.hasHint(msg): return + if msg in conf.cmdLineDisabledNotes: return # eg: `--hints:conf:off` passed on cmdline + # handle `--hints:off` (regardless of cmdline/cfg file) + # handle `--hints:conf:on` on cmdline + if not conf.hasHint(msg) and not (optHints in conf.options and msg in conf.cmdLineNotes)): return title = HintTitle color = HintColor if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)] diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim index df1ceb610..bd00832be 100644 --- a/compiler/nimconf.nim +++ b/compiler/nimconf.nim @@ -251,6 +251,7 @@ proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef) = template runNimScriptIfExists(path: AbsoluteFile) = let p = path # eval once if fileExists(p): + configFiles.add(p) runNimScript(cache, p, freshDefines = false, conf) if optSkipSystemConfigFile notin conf.globalOptions: diff --git a/compiler/options.nim b/compiler/options.nim index 7a7ab0bcd..fc37979e2 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -231,6 +231,8 @@ type foreignPackageNotes*: TNoteKinds notes*: TNoteKinds mainPackageNotes*: TNoteKinds + cmdLineNotes*: TNoteKinds + cmdLineDisabledNotes*: TNoteKinds mainPackageId*: int errorCounter*: int hintCounter*: int @@ -286,6 +288,7 @@ type structuredErrorHook*: proc (config: ConfigRef; info: TLineInfo; msg: string; severity: Severity) {.closure, gcsafe.} cppCustomNamespace*: string + isCmdLine*: bool # whether we are currently processing cmdline args, not cfg files proc hasHint*(conf: ConfigRef, note: TNoteKind): bool = optHints in conf.options and note in conf.notes @@ -391,6 +394,7 @@ proc newConfigRef*(): ConfigRef = arguments: "", suggestMaxResults: 10_000, maxLoopIterationsVM: 10_000_000, + isCmdLine: false, ) setTargetFromSystem(result.target) # enable colors by default on terminals diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim index e9e720b1b..6aad1b25f 100644 --- a/compiler/scriptconfig.nim +++ b/compiler/scriptconfig.nim @@ -199,7 +199,6 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string; proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile; freshDefines=true; conf: ConfigRef) = - rawMessage(conf, hintConf, scriptName.string) let oldSymbolFiles = conf.symbolFiles conf.symbolFiles = disabledSf @@ -224,7 +223,7 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile; incl(m.flags, sfMainModule) graph.vm = setupVM(m, cache, scriptName.string, graph) - graph.compileSystemModule() # TODO: see why this unsets hintConf in conf.notes + graph.compileSystemModule() discard graph.processModule(m, llStreamOpen(scriptName, fmRead)) # watch out, "newruntime" can be set within NimScript itself and then we need |