diff --git a/src/build/build_options.c b/src/build/build_options.c index 85d96cb1a..f122e2885 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -4,7 +4,6 @@ #include "../utils/whereami.h" #include "build.h" -#include "project.h" #include "build_internal.h" #include "git_hash.h" @@ -34,6 +33,8 @@ static void add_linker_arg(BuildOptions *options, const char *arg); static void update_feature_flags(const char ***flags, const char ***removed_flag, const char *arg, bool add); static void print_all_targets(void); static int parse_multi_option(const char *start, unsigned count, const char **elements); +static void print_cmd(const char *command, const char *desc); +static void print_opt(const char *option, const char *desc); const char *arch_os_target[ARCH_OS_TARGET_LAST + 1]; const char *trust_level[3]; @@ -49,158 +50,155 @@ static void usage(bool full) PRINTF(""); PRINTF("Commands:"); PRINTF(""); - PRINTF(" compile [ ...] Compile files without a project into an executable."); - PRINTF(" init Initialize a new project structure."); - PRINTF(" init-lib Initialize a new library structure."); - PRINTF(" build [] Build the target in the current project."); - PRINTF(" benchmark [-- [ ...]] Run the benchmarks in the current project."); - PRINTF(" test [-- [] [-- [ ...]] Run (and build if needed) the target in the current project."); - PRINTF(" dist [] Clean and build a target for distribution."); - PRINTF(" bench [] Benchmark a target."); - PRINTF(" clean-run [] [-- [ ...]] Clean, then run the target."); - PRINTF(" compile-run [ ...] [-- [ ...]] Compile files then immediately run the result."); - PRINTF(" compile-only [ ...] Compile files but do not perform linking."); - PRINTF(" compile-benchmark [ ...] Compile files into an executable and run benchmarks."); - PRINTF(" compile-test [ ...] Compile files into an executable and run unit tests."); - PRINTF(" static-lib [ ...] Compile files without a project into a static library."); - PRINTF(" dynamic-lib [ ...] Compile files without a project into a dynamic library."); - PRINTF(" vendor-fetch ... Fetches one or more libraries from the vendor collection."); - PRINTF(" project ... Manipulate or view project files."); + print_cmd("compile [ ...]", "Compile files without a project into an executable."); + print_cmd("init ", "Initialize a new project structure."); + print_cmd("init-lib ", "Initialize a new library structure."); + print_cmd("build []", "Build the target in the current project."); + print_cmd("benchmark []", "Run the benchmarks for the target in the current project."); + print_cmd("test []", "Run the unit tests for the target in the current project."); + print_cmd("clean", "Clean all build files."); + print_cmd("run [] [-- [ ...]] ", "Run (and build if needed) the target in the current project."); + print_cmd("dist []", "Clean and build a target for distribution."); + print_cmd("clean-run [] [-- [ ...]]", "Clean, then run the target."); + print_cmd("compile-run [ ...] [-- [ ...]]", "Compile files then immediately run the result."); + print_cmd("compile-only [ ...]", "Compile files but do not perform linking."); + print_cmd("compile-benchmark [ ...]", "Compile files into a test-executable and run benchmarks."); + print_cmd("compile-test [ ...]", "Compile files into a benchmark-executable and run unit tests."); + print_cmd("static-lib [ ...]", "Compile files without a project into a static library."); + print_cmd("dynamic-lib [ ...]", "Compile files without a project into a dynamic library."); + print_cmd("vendor-fetch ...", "Fetches one or more libraries from the vendor collection."); + print_cmd("project ...", "Manipulate or view project files."); PRINTF(""); full ? PRINTF("Options:") : PRINTF("Common options:"); - PRINTF(" -h -hh --help - Print the help, -h for the normal options, -hh for the full help."); - 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."); - PRINTF(" - - Read code from standard in."); - PRINTF(" -o - Write output to ."); - PRINTF(" -O0 - Safe, no optimizations, emit debug info."); - PRINTF(" -O1 - Safe, high optimization, emit debug info."); - PRINTF(" -O2 - Unsafe, high optimization, emit debug info."); - PRINTF(" -O3 - Unsafe, high optimization, single module, emit debug info."); - PRINTF(" -O4 - Unsafe, highest optimization, relaxed maths, single module, emit debug info, no panic messages."); - PRINTF(" -O5 - Unsafe, highest optimization, fast maths, single module, emit debug info, no panic messages, no backtrace."); - PRINTF(" -Os - Unsafe, high optimization, small code, single module, no debug info, no panic messages."); - PRINTF(" -Oz - Unsafe, high optimization, tiny code, single module, no debug info, no panic messages, no backtrace."); - PRINTF(" -D - Add feature flag ."); - PRINTF(" -U - Remove feature flag ."); + print_opt("-h -hh --help", "Print the help, -h for the normal options, -hh for the full help."); + print_opt("-V --version", "Print version information."); + print_opt("-q --quiet", "Silence unnecessary output."); + print_opt("-v -vv -vvv", "Verbose output, -v for default, -vv and -vvv gives more information."); + print_opt("-E", "Lex only."); + print_opt("-P", "Only parse and output the AST as JSON."); + print_opt("-C", "Only lex, parse and check."); + print_opt("-", "Read code from standard in."); + print_opt("-o ", "Write output to ."); + print_opt("-O0", "Safe, no optimizations, emit debug info."); + print_opt("-O1", "Safe, high optimization, emit debug info."); + print_opt("-O2", "Unsafe, high optimization, emit debug info."); + print_opt("-O3", "Unsafe, high optimization, single module, emit debug info."); + print_opt("-O4", "Unsafe, highest optimization, relaxed maths, single module, emit debug info, no panic messages."); + print_opt("-O5", "Unsafe, highest optimization, fast maths, single module, emit debug info, no panic messages, no backtrace."); + print_opt("-Os", "Unsafe, high optimization, small code, single module, no debug info, no panic messages."); + print_opt("-Oz", "Unsafe, high optimization, tiny code, single module, no debug info, no panic messages, no backtrace."); + print_opt("-D ", "Add feature flag ."); + print_opt("-U ", "Remove feature flag ."); PRINTF(""); - PRINTF(" --about - Prints a short description of C3."); - PRINTF(" --libdir - Add this directory to the c3l library search paths."); - PRINTF(" --lib - Add this c3l library to the compilation."); + print_opt("--about", "Prints a short description of C3."); + print_opt("--libdir ", "Add this directory to the c3l library search paths."); + print_opt("--lib ", "Add this c3l library to the compilation."); if (full) { - PRINTF(" --validation=