From 6281f8ff89f673a9c0bedccbb282a535a47a0775 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 3 Dec 2024 23:37:23 +0100 Subject: [PATCH] Add `-q` option, make `--run-once` implicitly `-q`. Add `-v`, `-vv` and `-vvv` options for increasing verbosity, replacing debug-log and debug-stats options. #1601 --- releasenotes.md | 2 ++ src/build/build.h | 3 ++ src/build/build_options.c | 48 ++++++++++++++++++++++---------- src/build/builder.c | 6 ++-- src/compiler/compiler.c | 30 ++++++++++---------- src/compiler/compiler_internal.h | 2 ++ src/compiler/linker.c | 4 +-- src/main.c | 1 - src/utils/lib.h | 2 +- 9 files changed, 63 insertions(+), 35 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index adff8fff9..efce97879 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -9,6 +9,8 @@ - Improve support for Windows cross compilation on targets with case sensitive file systems. - Add "sources" support to library `manifest.json`, defaults to root folder if unspecified. - Add char_at method in DString and operators [], len, []= and &[]. +- Add `-q` option, make `--run-once` implicitly `-q`. +- Add `-v`, `-vv` and `-vvv` options for increasing verbosity, replacing debug-log and debug-stats options. ### Fixes - Fix bug where `a > 0 ? f() : g()` could cause a compiler crash if both returned `void!`. diff --git a/src/build/build.h b/src/build/build.h index eb112e5ea..bac58119a 100644 --- a/src/build/build.h +++ b/src/build/build.h @@ -479,6 +479,7 @@ typedef struct BuildOptions_ bool print_output; bool print_input; bool run_once; + int verbosity_level; const char *panicfn; const char *benchfn; const char *testfn; @@ -589,6 +590,7 @@ typedef struct bool emit_object_files; bool benchmarking; bool testing; + bool silent; bool read_stdin; bool print_output; bool print_input; @@ -596,6 +598,7 @@ typedef struct bool no_entry; bool kernel_build; bool silence_deprecation; + bool print_stats; int build_threads; TrustLevel trust_level; OptimizationSetting optsetting; diff --git a/src/build/build_options.c b/src/build/build_options.c index 755c011d9..2aa1a9df8 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -83,6 +83,8 @@ static void usage(void) PRINTF(" --max-mem - Sets the preferred max memory size."); PRINTF(" --run-once - After running the output file, delete it immediately."); PRINTF(" -V --version - Print version information."); + PRINTF(" -q --quiet - Silence unnecessary output."); + PRINTF(" -v -vv -vvv - Verbose output, -v for default, -vv and -vvv gives more information."); PRINTF(" -E - Lex only."); PRINTF(" -P - Only parse and output the AST as JSON."); PRINTF(" -C - Only lex, parse and check."); @@ -144,11 +146,7 @@ static void usage(void) PRINTF(" --fp-math=