From b589e3c499649aa956a9ebf98ae2aca260156471 Mon Sep 17 00:00:00 2001 From: bayo-code Date: Sun, 10 Nov 2024 07:16:13 +0100 Subject: [PATCH 1/3] List the supported targets using `odin targets` --- src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 3a32639b8..2f2c3207f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -288,6 +288,7 @@ gb_internal void usage(String argv0, String argv1 = {}) { print_usage_line(1, "test Builds and runs procedures with the attribute @(test) in the initial package."); print_usage_line(1, "doc Generates documentation on a directory of .odin files."); print_usage_line(1, "version Prints version."); + print_usage_line(1, "targets Prints the supported targets."); print_usage_line(1, "report Prints information useful to reporting a bug."); print_usage_line(1, "root Prints the root path where Odin looks for the builtin collections."); print_usage_line(0, ""); @@ -3182,6 +3183,12 @@ int main(int arg_count, char const **arg_ptr) { gb_printf("\n"); return 0; + } else if (command == "targets") { + gb_printf_err("All supported targets:\n"); + for (isize i = 0; i < gb_count_of(named_targets); i++) { + gb_printf_err("\t%.*s\n", LIT(named_targets[i].name)); + } + return 0; } else if (command == "report") { build_context.command_kind = Command_bug_report; print_bug_report_help(); From d5b221f972b69e4b97c48bebe503f364bb2428d4 Mon Sep 17 00:00:00 2001 From: bayo-code Date: Mon, 11 Nov 2024 04:09:53 +0100 Subject: [PATCH 2/3] Revert "List the supported targets using `odin targets`" This reverts commit b589e3c499649aa956a9ebf98ae2aca260156471. --- src/main.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2f2c3207f..3a32639b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -288,7 +288,6 @@ gb_internal void usage(String argv0, String argv1 = {}) { print_usage_line(1, "test Builds and runs procedures with the attribute @(test) in the initial package."); print_usage_line(1, "doc Generates documentation on a directory of .odin files."); print_usage_line(1, "version Prints version."); - print_usage_line(1, "targets Prints the supported targets."); print_usage_line(1, "report Prints information useful to reporting a bug."); print_usage_line(1, "root Prints the root path where Odin looks for the builtin collections."); print_usage_line(0, ""); @@ -3183,12 +3182,6 @@ int main(int arg_count, char const **arg_ptr) { gb_printf("\n"); return 0; - } else if (command == "targets") { - gb_printf_err("All supported targets:\n"); - for (isize i = 0; i < gb_count_of(named_targets); i++) { - gb_printf_err("\t%.*s\n", LIT(named_targets[i].name)); - } - return 0; } else if (command == "report") { build_context.command_kind = Command_bug_report; print_bug_report_help(); From 8585fdf25fa440ee682fbf1b63b2f23ff5a63df8 Mon Sep 17 00:00:00 2001 From: bayo-code Date: Mon, 11 Nov 2024 04:15:24 +0100 Subject: [PATCH 3/3] Added support for `odin build -target:?` --- src/main.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3a32639b8..450049bd8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1060,27 +1060,29 @@ gb_internal bool parse_build_flags(Array args) { } if (!found) { - struct DistanceAndTargetIndex { - isize distance; - isize target_index; - }; + if (str != "?") { + struct DistanceAndTargetIndex { + isize distance; + isize target_index; + }; - DistanceAndTargetIndex distances[gb_count_of(named_targets)] = {}; - for (isize i = 0; i < gb_count_of(named_targets); i++) { - distances[i].target_index = i; - distances[i].distance = levenstein_distance_case_insensitive(str, named_targets[i].name); - } - gb_sort_array(distances, gb_count_of(distances), gb_isize_cmp(gb_offset_of(DistanceAndTargetIndex, distance))); - - gb_printf_err("Unknown target '%.*s'\n", LIT(str)); - - if (distances[0].distance <= MAX_SMALLEST_DID_YOU_MEAN_DISTANCE) { - gb_printf_err("Did you mean:\n"); + DistanceAndTargetIndex distances[gb_count_of(named_targets)] = {}; for (isize i = 0; i < gb_count_of(named_targets); i++) { - if (distances[i].distance > MAX_SMALLEST_DID_YOU_MEAN_DISTANCE) { - break; + distances[i].target_index = i; + distances[i].distance = levenstein_distance_case_insensitive(str, named_targets[i].name); + } + gb_sort_array(distances, gb_count_of(distances), gb_isize_cmp(gb_offset_of(DistanceAndTargetIndex, distance))); + + gb_printf_err("Unknown target '%.*s'\n", LIT(str)); + + if (distances[0].distance <= MAX_SMALLEST_DID_YOU_MEAN_DISTANCE) { + gb_printf_err("Did you mean:\n"); + for (isize i = 0; i < gb_count_of(named_targets); i++) { + if (distances[i].distance > MAX_SMALLEST_DID_YOU_MEAN_DISTANCE) { + break; + } + gb_printf_err("\t%.*s\n", LIT(named_targets[distances[i].target_index].name)); } - gb_printf_err("\t%.*s\n", LIT(named_targets[distances[i].target_index].name)); } } gb_printf_err("All supported targets:\n"); @@ -1747,7 +1749,7 @@ gb_internal void check_defines(BuildContext *bc, Checker *c) { String name = make_string_c(entry.key); ExactValue value = entry.value; GB_ASSERT(value.kind != ExactValue_Invalid); - + bool found = false; for_array(i, c->info.defineables) { Defineable *def = &c->info.defineables[i]; @@ -1776,9 +1778,9 @@ gb_internal void temp_alloc_defineable_strings(Checker *c) { gb_internal GB_COMPARE_PROC(defineables_cmp) { Defineable *x = (Defineable *)a; Defineable *y = (Defineable *)b; - + int cmp = 0; - + String x_file = get_file_path_string(x->pos.file_id); String y_file = get_file_path_string(y->pos.file_id); cmp = string_compare(x_file, y_file); @@ -3397,7 +3399,7 @@ int main(int arg_count, char const **arg_ptr) { if (LLVM_VERSION_MAJOR < 17) { gb_printf_err("Invalid LLVM version %s, RISC-V targets require at least LLVM 17\n", LLVM_VERSION_STRING); gb_exit(1); - } + } } if (build_context.show_debug_messages) {