compiler: support for -color/-nocolor option overrides
parent
80070516fd
commit
9d4fe88d09
|
@ -103,6 +103,12 @@ The build flags are shared by the build and run commands:
|
||||||
NB: an useful, although not entirely accurate regexp based Universal Ctags options file
|
NB: an useful, although not entirely accurate regexp based Universal Ctags options file
|
||||||
for V is located in `.ctags.d/v.ctags` . If you use https://ctags.io/ , it will be used
|
for V is located in `.ctags.d/v.ctags` . If you use https://ctags.io/ , it will be used
|
||||||
up automatically, or you can specify it explicitly with --options=.ctags.d/v.ctags .
|
up automatically, or you can specify it explicitly with --options=.ctags.d/v.ctags .
|
||||||
|
|
||||||
|
-color, -nocolor
|
||||||
|
Force the use of ANSI colors for the error/warning messages, or disable them completely.
|
||||||
|
By default V tries to show its errors/warnings in ANSI color. The heuristic that it uses
|
||||||
|
to detect whether or not to use ANSI colors may not work in all cases.
|
||||||
|
These options allow you to override the default detection.
|
||||||
|
|
||||||
For C-specific build flags, use `v help build-c`.
|
For C-specific build flags, use `v help build-c`.
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,12 @@ pub fn new_builder(pref &pref.Preferences) Builder {
|
||||||
rdir := os.real_path(pref.path)
|
rdir := os.real_path(pref.path)
|
||||||
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
compiled_dir := if os.is_dir(rdir) { rdir } else { os.dir(rdir) }
|
||||||
table := table.new_table()
|
table := table.new_table()
|
||||||
|
if pref.use_color == .always {
|
||||||
|
util.emanager.set_support_color(true)
|
||||||
|
}
|
||||||
|
if pref.use_color == .never {
|
||||||
|
util.emanager.set_support_color(false)
|
||||||
|
}
|
||||||
return Builder{
|
return Builder{
|
||||||
pref: pref
|
pref: pref
|
||||||
table: table
|
table: table
|
||||||
|
|
|
@ -20,6 +20,12 @@ pub enum OutputMode {
|
||||||
silent
|
silent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ColorOutput {
|
||||||
|
auto
|
||||||
|
always
|
||||||
|
never
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Backend {
|
pub enum Backend {
|
||||||
c // The (default) C backend
|
c // The (default) C backend
|
||||||
js // The JavaScript backend
|
js // The JavaScript backend
|
||||||
|
@ -101,6 +107,7 @@ pub mut:
|
||||||
print_v_files bool // when true, just print the list of all parsed .v files then stop.
|
print_v_files bool // when true, just print the list of all parsed .v files then stop.
|
||||||
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"
|
skip_warnings bool // like C's "-w"
|
||||||
|
use_color ColorOutput // whether the warnings/errors should use ANSI color escapes.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_args(args []string) (&Preferences, string) {
|
pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
|
@ -166,6 +173,12 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
'-translated' {
|
'-translated' {
|
||||||
res.translated = true
|
res.translated = true
|
||||||
}
|
}
|
||||||
|
'-color' {
|
||||||
|
res.use_color=.always
|
||||||
|
}
|
||||||
|
'-nocolor' {
|
||||||
|
res.use_color=.never
|
||||||
|
}
|
||||||
'-showcc' {
|
'-showcc' {
|
||||||
res.show_cc = true
|
res.show_cc = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub const (
|
||||||
)
|
)
|
||||||
|
|
||||||
pub struct EManager {
|
pub struct EManager {
|
||||||
pub mut:
|
mut:
|
||||||
support_color bool
|
support_color bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,10 @@ pub fn new_error_manager() &EManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (e &EManager) set_support_color(b bool) {
|
||||||
|
e.support_color = b
|
||||||
|
}
|
||||||
|
|
||||||
fn bold(msg string) string {
|
fn bold(msg string) string {
|
||||||
if !emanager.support_color {
|
if !emanager.support_color {
|
||||||
return msg
|
return msg
|
||||||
|
|
Loading…
Reference in New Issue