diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index d4bbccba6c..8b4128d114 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -237,7 +237,14 @@ pub fn (b &Builder) find_module_path(mod, fpath string) ?string { return error('module "$mod" not found in:\n$smodule_lookup_paths') } +fn (b &Builder) show_total_warns_and_errors_stats() { + if b.pref.is_stats { + println('checker summary: ${util.bold(b.checker.nr_errors.str())} V errors, ${util.bold(b.checker.nr_warnings.str())} V warnings') + } +} + fn (b &Builder) print_warnings_and_errors() { + defer { b.show_total_warns_and_errors_stats() } if b.pref.output_mode == .silent { if b.checker.nr_errors > 0 { exit(1) @@ -278,6 +285,7 @@ fn (b &Builder) print_warnings_and_errors() { return } } + b.show_total_warns_and_errors_stats() exit(1) } if b.table.redefined_fns.len > 0 { @@ -295,6 +303,7 @@ fn (b &Builder) print_warnings_and_errors() { } } } + b.show_total_warns_and_errors_stats() exit(1) } } @@ -304,10 +313,11 @@ fn verror(s string) { util.verror('builder error', s) } -pub fn (mut b Builder) timing_message(msg string) { +pub fn (mut b Builder) timing_message(msg string, ms int) { + formatted_message := '$msg: ${util.bold(ms.str())} ms' if b.pref.show_timings { - println(msg) + println(formatted_message) } else { - b.info(msg) + b.info(formatted_message) } } diff --git a/vlib/v/builder/c.v b/vlib/v/builder/c.v index 825a3a8f99..d9af7895d5 100644 --- a/vlib/v/builder/c.v +++ b/vlib/v/builder/c.v @@ -12,7 +12,7 @@ pub fn (mut b Builder) gen_c(v_files []string) string { b.parse_imports() t1 := time.ticks() parse_time := t1 - t0 - b.timing_message('PARSE: ${parse_time}ms') + b.timing_message('PARSE', parse_time) if b.pref.only_check_syntax { return '' } @@ -21,14 +21,14 @@ pub fn (mut b Builder) gen_c(v_files []string) string { b.checker.check_files(b.parsed_files) t2 := time.ticks() check_time := t2 - t1 - b.timing_message('CHECK: ${check_time}ms') + b.timing_message('CHECK', check_time) b.print_warnings_and_errors() // println('starting cgen...') // TODO: move gen.cgen() to c.gen() res := gen.cgen(b.parsed_files, b.table, b.pref) t3 := time.ticks() gen_time := t3 - t2 - b.timing_message('C GEN: ${gen_time}ms') + b.timing_message('C GEN', gen_time) // println('cgen done') // println(res) return res diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 8b9f3d885f..7696447d4c 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -493,7 +493,7 @@ fn (mut v Builder) cc() { println('$ccompiler took $diff ms') println('=========\n') } - v.timing_message('C ${ccompiler:3}: ${diff}ms') + v.timing_message('C ${ccompiler:3}', diff) // Link it if we are cross compiling and need an executable /* if v.os == .linux && !linux_host && v.pref.build_mode != .build { diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index 59775a4370..de4f6c79e8 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -6,6 +6,7 @@ module builder import time import os import v.pref +import v.util fn get_vtmp_folder() string { mut vtmp := os.getenv('VTMP') @@ -39,7 +40,7 @@ pub fn compile(command string, pref &pref.Preferences) { .x64 { b.compile_x64() } } if pref.is_stats { - println('compilation took: $sw.elapsed().milliseconds() ms') + println('compilation took: ${util.bold(sw.elapsed().milliseconds().str())} ms') } // running does not require the parsers anymore unsafe { diff --git a/vlib/v/builder/js.v b/vlib/v/builder/js.v index 3eeb63c3f8..b9a60e6165 100644 --- a/vlib/v/builder/js.v +++ b/vlib/v/builder/js.v @@ -13,16 +13,16 @@ pub fn (mut b Builder) gen_js(v_files []string) string { b.parse_imports() t1 := time.ticks() parse_time := t1 - t0 - b.timing_message('PARSE: ${parse_time}ms') + b.timing_message('PARSE', parse_time) b.checker.check_files(b.parsed_files) t2 := time.ticks() check_time := t2 - t1 - b.timing_message('CHECK: ${check_time}ms') + b.timing_message('CHECK', check_time) b.print_warnings_and_errors() res := js.gen(b.parsed_files, b.table, b.pref) t3 := time.ticks() gen_time := t3 - t2 - b.timing_message('JS GEN: ${gen_time}ms') + b.timing_message('JS GEN', gen_time) return res } diff --git a/vlib/v/builder/msvc.v b/vlib/v/builder/msvc.v index d664ce1f66..db695d84dd 100644 --- a/vlib/v/builder/msvc.v +++ b/vlib/v/builder/msvc.v @@ -312,7 +312,7 @@ pub fn (mut v Builder) cc_msvc() { return } diff := time.ticks() - ticks - v.timing_message('C msvc: ${diff}ms') + v.timing_message('C msvc', diff) if res.exit_code != 0 { verror(res.output) } diff --git a/vlib/v/builder/x64.v b/vlib/v/builder/x64.v index 5d4c8f2d96..0505018317 100644 --- a/vlib/v/builder/x64.v +++ b/vlib/v/builder/x64.v @@ -16,16 +16,16 @@ pub fn (mut b Builder) build_x64(v_files []string, out_file string) { b.parse_imports() t1 := time.ticks() parse_time := t1 - t0 - b.timing_message('PARSE: ${parse_time}ms') + b.timing_message('PARSE', parse_time) b.checker.check_files(b.parsed_files) t2 := time.ticks() check_time := t2 - t1 - b.timing_message('CHECK: ${check_time}ms') + b.timing_message('CHECK', check_time) x64.gen(b.parsed_files, out_file, b.pref) t3 := time.ticks() gen_time := t3 - t2 - b.timing_message('x64 GEN: ${gen_time}ms') + b.timing_message('x64 GEN', gen_time) } pub fn (mut b Builder) compile_x64() { diff --git a/vlib/v/util/errors.v b/vlib/v/util/errors.v index ed65b382cb..9007002177 100644 --- a/vlib/v/util/errors.v +++ b/vlib/v/util/errors.v @@ -43,10 +43,10 @@ pub fn (e &EManager) set_support_color(b bool) { unsafe { mut me := e me.support_color = b - } + } } -fn bold(msg string) string { +pub fn bold(msg string) string { if !emanager.support_color { return msg }