Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@

- Added `--filenames:abs|canonical|magic` which replaces --listFullPaths:on|off

- Added `--processing:dots|filenames|off` which customizes `hintProcessing`

- Source+Edit links now appear on top of every docgen'd page when
`nim doc --git.url:url ...` is given.

Expand Down
2 changes: 1 addition & 1 deletion compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ proc genTypeInfoAuxBase(m: BModule; typ, origType: PType;
var flags = 0
if not containsGarbageCollectedRef(typ): flags = flags or 1
if not canFormAcycle(typ): flags = flags or 2
#else MessageOut("can contain a cycle: " & typeToString(typ))
#else echo("can contain a cycle: " & typeToString(typ))
if flags != 0:
m.s[cfsTypeInit3].addf("$1.flags = $2;$n", [nameHcr, rope(flags)])
discard cgsym(m, "TNimType")
Expand Down
10 changes: 10 additions & 0 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,16 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
of "canonical": conf.filenameOption = foCanonical
of "legacyrelproj": conf.filenameOption = foLegacyRelProj
else: localError(conf, info, "expected: abs|canonical|legacyRelProj, got: $1" % arg)
of "processing":
incl(conf.notes, hintProcessing)
incl(conf.mainPackageNotes, hintProcessing)
case arg.normalize
of "dots": conf.hintProcessingDots = true
of "filenames": conf.hintProcessingDots = false
of "off":
excl(conf.notes, hintProcessing)
excl(conf.mainPackageNotes, hintProcessing)
else: localError(conf, info, "expected: dots|filenames|off, got: $1" % arg)
of "listfullpaths":
# xxx in future work, use `warningDeprecated`
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
Expand Down
2 changes: 1 addition & 1 deletion compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
if conf.structuredErrorHook != nil:
conf.structuredErrorHook(conf, info, s & kindmsg, sev)
if not ignoreMsgBecauseOfIdeTools(conf, msg):
if msg == hintProcessing:
if msg == hintProcessing and conf.hintProcessingDots:
msgWrite(conf, ".")
else:
styledMsgWriteln(styleBright, loc, resetStyle, color, title, resetStyle, s, KindColor, kindmsg,
Expand Down
32 changes: 16 additions & 16 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ type
implicitCmd*: bool # whether some flag triggered an implicit `command`
selectedGC*: TGCMode # the selected GC (+)
exc*: ExceptionSystem
hintProcessingDots*: bool # true for dots, false for filenames
verbosity*: int # how verbose the compiler is
numberOfProcessors*: int # number of processors
lastCmdTime*: float # when caas is enabled, we measure each command
Expand Down Expand Up @@ -458,20 +459,25 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool
when defined(nimDebugUtils):
import debugutils

proc initConfigRefCommon(conf: ConfigRef) =
conf.selectedGC = gcRefc
conf.verbosity = 1
conf.hintProcessingDots = true
conf.options = DefaultOptions
conf.globalOptions = DefaultGlobalOptions
conf.filenameOption = foAbs
conf.foreignPackageNotes = foreignPackageNotesDefault
conf.notes = NotesVerbosity[1]
conf.mainPackageNotes = NotesVerbosity[1]

proc newConfigRef*(): ConfigRef =
result = ConfigRef(
selectedGC: gcRefc,
cCompiler: ccGcc,
verbosity: 1,
options: DefaultOptions,
globalOptions: DefaultGlobalOptions,
macrosToExpand: newStringTable(modeStyleInsensitive),
arcToExpand: newStringTable(modeStyleInsensitive),
m: initMsgConfig(),
filenameOption: foAbs,
cppDefines: initHashSet[string](),
headerFile: "", features: {}, legacyFeatures: {}, foreignPackageNotes: foreignPackageNotesDefault,
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1],
headerFile: "", features: {}, legacyFeatures: {},
configVars: newStringTable(modeStyleInsensitive),
symbols: newStringTable(modeStyleInsensitive),
packageCache: newPackageCache(),
Expand Down Expand Up @@ -513,6 +519,7 @@ proc newConfigRef*(): ConfigRef =
vmProfileData: newProfileData(),
spellSuggestMax: spellSuggestSecretSauce,
)
initConfigRefCommon(result)
setTargetFromSystem(result.target)
# enable colors by default on terminals
if terminal.isatty(stderr):
Expand All @@ -522,18 +529,11 @@ proc newConfigRef*(): ConfigRef =

proc newPartialConfigRef*(): ConfigRef =
## create a new ConfigRef that is only good enough for error reporting.
# xxx FACTOR with `newConfigRef`
when defined(nimDebugUtils):
result = getConfigRef()
else:
result = ConfigRef(
selectedGC: gcRefc,
verbosity: 1,
options: DefaultOptions,
globalOptions: DefaultGlobalOptions,
filenameOption: foAbs,
foreignPackageNotes: foreignPackageNotesDefault,
notes: NotesVerbosity[1], mainPackageNotes: NotesVerbosity[1])
result = ConfigRef()
initConfigRefCommon(result)

proc cppDefine*(c: ConfigRef; define: string) =
c.cppDefines.incl define
Expand Down
7 changes: 4 additions & 3 deletions compiler/passaux.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type
config: ConfigRef

proc verboseOpen(graph: ModuleGraph; s: PSym; idgen: IdGenerator): PPassContext =
#MessageOut('compiling ' + s.name.s);
result = VerboseRef(config: graph.config, idgen: idgen)
rawMessage(graph.config, hintProcessing, s.name.s)
let conf = graph.config
result = VerboseRef(config: conf, idgen: idgen)
let path = toFilenameOption(conf, s.position.FileIndex, conf.filenameOption)
rawMessage(conf, hintProcessing, path)

proc verboseProcess(context: PPassContext, n: PNode): PNode =
result = n
Expand Down
2 changes: 2 additions & 0 deletions doc/advopt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Advanced options:
--filenames:abs|canonical|legacyRelProj
customize how filenames are rendered in compiler messages,
defaults to `abs` (absolute)
--processing:dots|filenames|off
show files as they're being processed by nim compiler
--declaredLocs:on|off show declaration locations in messages
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
if `num` is not specified (or `auto`), return
Expand Down
2 changes: 1 addition & 1 deletion drnim/tests/config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ switch("path", "$nim/testament/lib") # so we can `import stdtest/foo` in this di
## prevent common user config settings to interfere with testament expectations
## Indifidual tests can override this if needed to test for these options.
switch("colors", "off")
switch("listFullPaths", "off")
switch("filenames", "canonical")
switch("excessiveStackTrace", "off")

# we only want to check the marked parts in the tests:
Expand Down
2 changes: 2 additions & 0 deletions nimsuggest/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# xxx not sure why this flag isn't needed: switch("processing", "filenames")
switch("filenames", "canonical")
9 changes: 6 additions & 3 deletions nimsuggest/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ proc runEpcTest(filename: string): int =
options={poStdErrToStdOut, poUsePath,
poInteractive, poDaemon})
let outp = p.outputStream
let inp = p.inputStream
var report = ""
var socket = newSocket()
try:
Expand Down Expand Up @@ -315,8 +314,12 @@ proc runTest(filename: string): int =
answer.add '\L'
doReport(filename, answer, resp, report)
finally:
inp.writeLine("quit")
inp.flush()
try:
inp.writeLine("quit")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if child already died, these could raise an IOError os OSError with EPIPE (or, before #17752, raise signal SIGPIPE), so it seems correct to protect this with try/except;

this diff is not needed for this PR but it helped during debugging and fixing tests as raise EPIPE would hide the error

inp.flush()
except:
# assume it's SIGPIPE, ie, the child already died
discard
close(p)
if report.len > 0:
echo "==== STDIN ======================================"
Expand Down
2 changes: 1 addition & 1 deletion nimsuggest/tests/tchk1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ proc main =
discard """
$nimsuggest --tester $file
>chk $1
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk1 [Processing]";;0
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/tchk1.nim [Processing]";;0
chk;;skUnknown;;;;Error;;$file;;12;;0;;"identifier expected, but got \'keyword template\'";;0
chk;;skUnknown;;;;Error;;$file;;14;;0;;"nestable statement requires indentation";;0
chk;;skUnknown;;;;Error;;$file;;12;;0;;"implementation of \'foo\' expected";;0
Expand Down
2 changes: 1 addition & 1 deletion nimsuggest/tests/tchk_compiles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ discard compiles(2 + "hello")
discard """
$nimsuggest --tester $file
>chk $1
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk_compiles [Processing]";;0
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/tchk_compiles.nim [Processing]";;0
"""
2 changes: 1 addition & 1 deletion nimsuggest/tests/ttempl_inst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ foo()
discard """
$nimsuggest --tester $file
>chk $1
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"ttempl_inst [Processing]";;0
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tests/ttempl_inst.nim [Processing]";;0
chk;;skUnknown;;;;Hint;;$file;;4;;3;;"template/generic instantiation from here";;0
chk;;skUnknown;;;;Warning;;$file;;2;;11;;"foo [User]";;0
"""
2 changes: 1 addition & 1 deletion testament/testament.nim
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ proc isSuccess(input: string): bool =
# not clear how to do the equivalent of pkg/regex's: re"FOO(.*?)BAR" in pegs
# note: this doesn't handle colors, eg: `\e[1m\e[0m\e[32mHint:`; while we
# could handle colors, there would be other issues such as handling other flags
# that may appear in user config (eg: `--listFullPaths`).
# 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]")
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/trunner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ else: # don't run twice the same test
of 5: nimcache / htmldocsDirname
else: file.parentDir / htmldocsDirname

var cmd = fmt"{nim} doc --index:on --listFullPaths --hint:successX:on --nimcache:{nimcache} {options[i]} {file}"
var cmd = fmt"{nim} doc --index:on --filenames:abs --hint:successX:on --nimcache:{nimcache} {options[i]} {file}"
removeDir(htmldocsDir)
let (outp, exitCode) = execCmdEx(cmd)
check exitCode == 0
Expand Down