From c94d19718b3a14beb0c2852b522fa1b7ee706b31 Mon Sep 17 00:00:00 2001 From: Joshua Mark Manton Date: Wed, 16 May 2018 23:03:05 -0700 Subject: added compiler command for only parsing and typechecking --- src/main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 46bf2cd71..b815615e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -162,6 +162,7 @@ void usage(String argv0) { print_usage_line(0, "Commands:"); print_usage_line(1, "build compile .odin file as executable"); print_usage_line(1, "run compile and run .odin file"); + print_usage_line(1, "check parse and typecheck .odin file"); print_usage_line(1, "docs generate documentation for a .odin file"); print_usage_line(1, "version print version"); } @@ -724,6 +725,13 @@ int main(int arg_count, char **arg_ptr) { return 1; } init_filename = args[2]; + } else if (command == "check") { + if (args.count < 3) { + usage(args[0]); + return 1; + } + build_context.no_output_files = true; + init_filename = args[2]; } else if (command == "docs") { if (args.count < 3) { usage(args[0]); @@ -750,7 +758,9 @@ int main(int arg_count, char **arg_ptr) { return 1; } - + if (build_context.no_output_files) { + // are there any flags that it shouldn't work with? maybe -out or -keep-temp-files? + } // NOTE(bill): add 'shared' directory if it is not already set if (!find_library_collection_path(str_lit("shared"), nullptr)) { @@ -795,6 +805,14 @@ int main(int arg_count, char **arg_ptr) { check_parsed_files(&checker); + if (build_context.no_output_files) { + if (build_context.show_timings) { + show_timings(&checker, &timings); + } + + return 0; + } + irGen ir_gen = {0}; if (!ir_gen_init(&ir_gen, &checker)) { return 1; -- cgit v1.2.3 From 81420ab246d3af80dced54cd2de0c5f636a5a78d Mon Sep 17 00:00:00 2001 From: Joshua Mark Manton Date: Wed, 16 May 2018 23:07:27 -0700 Subject: removed unneeded block --- src/main.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b815615e8..2e22b1a96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -758,10 +758,6 @@ int main(int arg_count, char **arg_ptr) { return 1; } - if (build_context.no_output_files) { - // are there any flags that it shouldn't work with? maybe -out or -keep-temp-files? - } - // NOTE(bill): add 'shared' directory if it is not already set if (!find_library_collection_path(str_lit("shared"), nullptr)) { add_library_collection(str_lit("shared"), -- cgit v1.2.3 From 703393fc634317fef38587f096199e5eb46f2d0e Mon Sep 17 00:00:00 2001 From: Joshua Mark Manton Date: Wed, 16 May 2018 23:08:01 -0700 Subject: whitespace --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 2e22b1a96..5760a3c42 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -758,6 +758,8 @@ int main(int arg_count, char **arg_ptr) { return 1; } + + // NOTE(bill): add 'shared' directory if it is not already set if (!find_library_collection_path(str_lit("shared"), nullptr)) { add_library_collection(str_lit("shared"), -- cgit v1.2.3 From 1ee4f849cb8e517c2390db0d53792397e404b529 Mon Sep 17 00:00:00 2001 From: Joshua Mark Manton Date: Thu, 17 May 2018 02:08:04 -0700 Subject: now return 1 if there were errors --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 5760a3c42..a3fc783a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -162,7 +162,7 @@ void usage(String argv0) { print_usage_line(0, "Commands:"); print_usage_line(1, "build compile .odin file as executable"); print_usage_line(1, "run compile and run .odin file"); - print_usage_line(1, "check parse and typecheck .odin file"); + print_usage_line(1, "check parse and type check .odin file"); print_usage_line(1, "docs generate documentation for a .odin file"); print_usage_line(1, "version print version"); } @@ -808,6 +808,10 @@ int main(int arg_count, char **arg_ptr) { show_timings(&checker, &timings); } + if (global_error_collector.count != 0) { + return 1; + } + return 0; } -- cgit v1.2.3