v.pref: support a -n option, silencing only notices (#20331)

This commit is contained in:
Delyan Angelov 2024-01-01 23:30:21 +02:00 committed by GitHub
parent 763f94388b
commit ae82b67ef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

View file

@ -497,8 +497,8 @@ pub fn (mut b Builder) print_warnings_and_errors() {
} }
if b.pref.check_only { if b.pref.check_only {
if !b.pref.skip_notes {
for file in b.parsed_files { for file in b.parsed_files {
if !b.pref.skip_warnings {
for err in file.notices { for err in file.notices {
kind := if b.pref.is_verbose { kind := if b.pref.is_verbose {
'${err.reporter} notice #${b.nr_notices}:' '${err.reporter} notice #${b.nr_notices}:'
@ -521,8 +521,8 @@ pub fn (mut b Builder) print_warnings_and_errors() {
} }
} }
for file in b.parsed_files {
if !b.pref.skip_warnings { if !b.pref.skip_warnings {
for file in b.parsed_files {
for err in file.warnings { for err in file.warnings {
kind := if b.pref.is_verbose { kind := if b.pref.is_verbose {
'${err.reporter} warning #${b.nr_warnings}:' '${err.reporter} warning #${b.nr_warnings}:'
@ -547,7 +547,7 @@ pub fn (mut b Builder) print_warnings_and_errors() {
if b.pref.is_verbose && b.checker.nr_notices > 1 { if b.pref.is_verbose && b.checker.nr_notices > 1 {
println('${b.checker.nr_notices} notices') println('${b.checker.nr_notices} notices')
} }
if b.checker.nr_notices > 0 && !b.pref.skip_warnings { if b.checker.nr_notices > 0 && !b.pref.skip_notes {
for err in b.checker.notices { for err in b.checker.notices {
kind := if b.pref.is_verbose { kind := if b.pref.is_verbose {
'${err.reporter} notice #${b.checker.nr_notices}:' '${err.reporter} notice #${b.checker.nr_notices}:'

View file

@ -214,6 +214,12 @@ NB: the build flags are shared with the run command too:
The instrumented version will print detailed timing stats while processing The instrumented version will print detailed timing stats while processing
each .v file. each .v file.
-n
Hide all notices.
-N
Treat *all V notices* as errors.
-w -w
Hide all warnings. Hide all warnings.

View file

@ -212,6 +212,7 @@ pub mut:
// //
skip_running bool // when true, do no try to run the produced file (set by b.cc(), when -o x.c or -o x.js) skip_running bool // when true, do no try to run the produced file (set by b.cc(), when -o x.c or -o x.js)
skip_warnings bool // like C's "-w", forces warnings to be ignored. skip_warnings bool // like C's "-w", forces warnings to be ignored.
skip_notes bool // force notices to be ignored/not shown.
warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
notes_are_errors bool // -N, treat *every* notice as an error notes_are_errors bool // -N, treat *every* notice as an error
@ -720,9 +721,15 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
'-W' { '-W' {
res.warns_are_errors = true res.warns_are_errors = true
} }
'-w' {
res.skip_warnings = true
}
'-N' { '-N' {
res.notes_are_errors = true res.notes_are_errors = true
} }
'-n' {
res.skip_notes = true
}
'-no-rsp' { '-no-rsp' {
res.no_rsp = true res.no_rsp = true
} }
@ -732,9 +739,6 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
'-keepc' { '-keepc' {
res.reuse_tmpc = true res.reuse_tmpc = true
} }
'-w' {
res.skip_warnings = true
}
'-watch' { '-watch' {
eprintln_exit('The -watch option is deprecated. Please use the watch command `v watch file.v` instead.') eprintln_exit('The -watch option is deprecated. Please use the watch command `v watch file.v` instead.')
} }