From d1e2fee8d8a7767b18d767660c8633b5e05bc648 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 20 Jun 2020 11:55:45 -0500 Subject: [PATCH] Progress: featureless make Continue current development, saving work to reduce any changes of accidental losses. --- level_3/fake/c/fake.c | 4 +- level_3/fake/c/private-fake.c | 2 +- level_3/fake/c/private-make.c | 213 +++++++++++++++++++++++++++++++++++++-- level_3/fake/c/private-make.h | 49 ++++++++- level_3/fake/c/private-print.c | 112 ++++++++++++++++++++ level_3/fake/c/private-print.h | 92 +++++++++++++++++ level_3/fake/data/build/fakefile | 32 ++++++ 7 files changed, 492 insertions(+), 12 deletions(-) diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index b92d443..2cc468b 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -311,7 +311,7 @@ extern "C" { /*if (data->verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The operation '"); fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", fake_other_operation_make); fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' is not yet implemented."); }*/ @@ -323,7 +323,7 @@ extern "C" { if (F_status_is_error(status)) { if (data->verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The operation '"); fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", operations_name[i]); fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' failed."); } diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 37cc38c..4e800a7 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -506,7 +506,7 @@ extern "C" { if (data->parameters[parameters_id[i]].total > 1) { if (data->verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: The operation '"); fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", parameters_name[i]); fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' specified too many times."); } diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 9e41acf..530791e 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -89,6 +89,7 @@ extern "C" { } missing_settings = F_false; + continue; } else if (fl_string_dynamic_partial_compare(name_main, data_make->buffer, name_main_range, list_objects.array[i]) == F_equal_to) { if (!missing_main) { @@ -97,8 +98,25 @@ extern "C" { } missing_main = F_false; - data_make->main = i; + data_make->main = data_make->fakefile.used; } + + data_make->fakefile.array[data_make->fakefile.used].name = list_objects.array[i]; + + content_range.start = list_contents.array[i].array[0].start; + content_range.stop = list_contents.array[i].array[0].stop; + + *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents); + if (F_status_is_error(*status)) { + fake_print_error_fss(data.context, data.verbosity, *status, "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true); + + f_macro_fss_set_delete_simple(settings); + f_macro_fss_objects_delete_simple(list_objects); + f_macro_fss_contents_delete_simple(list_contents); + return; + } + + data_make->fakefile.used++; } // for } @@ -183,15 +201,11 @@ extern "C" { if (F_status_is_error(*status)) { fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fll_fss_snatch_map_mash_apart", F_true); - //@todo fake_print_error_fss(data.context, data.verbosity, *status, "fll_fss_snatch_map", data.file_data_build_fakefile.string, content_range, F_true); - f_macro_fss_set_delete_simple(settings); return; } } - // @todo load any defaults for unassigned values. - f_macro_fss_set_delete_simple(settings); } } @@ -207,20 +221,207 @@ extern "C" { f_status status = F_none; f_mode mode = f_mode_initialize; + f_string_lengths list_stack = f_string_lengths_initialize; fake_make_data data_make = fake_make_data_initialize; f_macro_mode_set_default_umask(mode, data.umask); fake_make_load_setting(data, &data_make, &status); - // @todo + fake_make_operate_section(data, data_make, data_make.main, &list_stack, &status); + f_macro_string_lengths_delete_simple(list_stack); fake_macro_make_data_delete_simple(data_make); return status; } #endif // _di_fake_make_operate_ +#ifndef _di_fake_make_operation_expand_ + void fake_make_operation_expand(const fake_data data, const fake_make_data data_make, const f_string_range section_name, const f_array_length operation, const f_string_static operation_name, const f_fss_content content, f_string_dynamics *arguments, f_status *status) { + if (F_status_is_error(*status)) return; + + if (data.verbosity == fake_verbosity_verbose) { + fl_color_print(f_type_output, data.context.standout, data.context.reset, "Expanding content values for section operation '"); + + fl_color_print_code(f_type_output, data.context.notable); + f_print_string_dynamic(f_type_output, operation_name); + fl_color_print_code(f_type_output, data.context.reset); + + fl_color_print_line(f_type_output, data.context.standout, data.context.reset, "'."); + } + } +#endif // _di_fake_make_operation_expand_ + +#ifndef _di_fake_make_operate_section_ + void fake_make_operate_section(const fake_data data, const fake_make_data data_make, const f_array_length section_id, f_string_lengths *section_stack, f_status *status) { + if (F_status_is_error(*status)) return; + + if (section_id > data_make.fakefile.used) { + *status = F_status_set_error(F_parameter); + + fake_print_error(data.context, data.verbosity, F_parameter, "fake_make_operate_section", F_true); + return; + } + + const f_fss_named *section = &data_make.fakefile.array[section_id]; + + if (data.verbosity != fake_verbosity_quiet) { + printf("%c", f_string_eol[0]); + + fl_color_print(f_type_output, data.color_section_set, data.color_section_reset, "Processing Section '"); + + fl_color_print_code(f_type_output, data.context.notable); + f_print_string_dynamic_partial(f_type_output, data_make.buffer, section->name); + fl_color_print_code(f_type_output, data.context.reset); + + fl_color_print_line(f_type_output, data.color_section_set, data.color_section_reset, "'."); + } + + const f_string_static operations_name[] = { + f_macro_string_static_initialize(fake_make_operation_archive, fake_make_operation_archive_length), + f_macro_string_static_initialize(fake_make_operation_build, fake_make_operation_build_length), + f_macro_string_static_initialize(fake_make_operation_clean, fake_make_operation_clean_length), + f_macro_string_static_initialize(fake_make_operation_compile, fake_make_operation_compile_length), + f_macro_string_static_initialize(fake_make_operation_create, fake_make_operation_create_length), + f_macro_string_static_initialize(fake_make_operation_delete, fake_make_operation_delete_length), + f_macro_string_static_initialize(fake_make_operation_else, fake_make_operation_else_length), + f_macro_string_static_initialize(fake_make_operation_fail, fake_make_operation_fail_length), + f_macro_string_static_initialize(fake_make_operation_group, fake_make_operation_group_length), + f_macro_string_static_initialize(fake_make_operation_if, fake_make_operation_if_length), + f_macro_string_static_initialize(fake_make_operation_link, fake_make_operation_link_length), + f_macro_string_static_initialize(fake_make_operation_mode, fake_make_operation_mode_length), + f_macro_string_static_initialize(fake_make_operation_operate, fake_make_operation_operate_length), + f_macro_string_static_initialize(fake_make_operation_owner, fake_make_operation_owner_length), + f_macro_string_static_initialize(fake_make_operation_pop, fake_make_operation_pop_length), + f_macro_string_static_initialize(fake_make_operation_print, fake_make_operation_print_length), + f_macro_string_static_initialize(fake_make_operation_run, fake_make_operation_run_length), + f_macro_string_static_initialize(fake_make_operation_shell, fake_make_operation_shell_length), + f_macro_string_static_initialize(fake_make_operation_skeleton, fake_make_operation_skeleton_length), + f_macro_string_static_initialize(fake_make_operation_to, fake_make_operation_to_length), + f_macro_string_static_initialize(fake_make_operation_top, fake_make_operation_top_length), + f_macro_string_static_initialize(fake_make_operation_touch, fake_make_operation_touch_length), + }; + + const f_string_range operations_range[] = { + f_macro_string_range_initialize(fake_make_operation_archive_length), + f_macro_string_range_initialize(fake_make_operation_build_length), + f_macro_string_range_initialize(fake_make_operation_clean_length), + f_macro_string_range_initialize(fake_make_operation_compile_length), + f_macro_string_range_initialize(fake_make_operation_create_length), + f_macro_string_range_initialize(fake_make_operation_delete_length), + f_macro_string_range_initialize(fake_make_operation_else_length), + f_macro_string_range_initialize(fake_make_operation_fail_length), + f_macro_string_range_initialize(fake_make_operation_group_length), + f_macro_string_range_initialize(fake_make_operation_if_length), + f_macro_string_range_initialize(fake_make_operation_link_length), + f_macro_string_range_initialize(fake_make_operation_mode_length), + f_macro_string_range_initialize(fake_make_operation_operate_length), + f_macro_string_range_initialize(fake_make_operation_owner_length), + f_macro_string_range_initialize(fake_make_operation_pop_length), + f_macro_string_range_initialize(fake_make_operation_print_length), + f_macro_string_range_initialize(fake_make_operation_run_length), + f_macro_string_range_initialize(fake_make_operation_shell_length), + f_macro_string_range_initialize(fake_make_operation_skeleton_length), + f_macro_string_range_initialize(fake_make_operation_to_length), + f_macro_string_range_initialize(fake_make_operation_top_length), + f_macro_string_range_initialize(fake_make_operation_touch_length), + }; + + const f_array_length operations_type[] = { + fake_make_operation_type_archive , + fake_make_operation_type_build, + fake_make_operation_type_clean, + fake_make_operation_type_compile, + fake_make_operation_type_create, + fake_make_operation_type_delete, + fake_make_operation_type_else, + fake_make_operation_type_fail, + fake_make_operation_type_group, + fake_make_operation_type_if, + fake_make_operation_type_link, + fake_make_operation_type_mode, + fake_make_operation_type_operate, + fake_make_operation_type_owner, + fake_make_operation_type_pop, + fake_make_operation_type_print, + fake_make_operation_type_run, + fake_make_operation_type_shell, + fake_make_operation_type_skeleton, + fake_make_operation_type_to, + fake_make_operation_type_top, + fake_make_operation_type_touch, + }; + + f_array_length operation = 0; + f_array_length operations[section->objects.used]; + + const f_string_static *operation_name = 0; + + f_string_dynamics arguments[section->objects.used]; + + f_array_length i = 0; + f_array_length j = 0; + + memset(operations, 0, sizeof(f_array_length) * section->objects.used); + memset(arguments, 0, sizeof(f_string_dynamics) * section->objects.used); + + // pre-process the list to identify invalid commands so that nothing is processed if any operation is invalid. + for (; i < section->objects.used; i++) { + operation = 0; + operation_name = 0; + + for (j = 0; j < fake_make_operation_total; j++) { + if (fl_string_dynamic_partial_compare(operations_name[j], data_make.buffer, operations_range[j], section->objects.array[i]) == F_equal_to) { + operation = operations_type[j]; + operation_name = &operations_name[j]; + break; + } + } // for + + if (operation == 0) { + fake_print_error_fakefile_section_operation_unknown(data.context, data.verbosity, data_make.buffer, section->name, section->objects.array[i]); + + *status = F_status_set_error(F_invalid); + } + else if (operation == fake_make_operation_type_operate) { + if (section_stack->used + 1 > fake_make_section_stack_max) { + fake_print_error_fakefile_section_operation_stack_max(data.context, data.verbosity, data_make.buffer, section->name, section->objects.array[i], fake_make_section_stack_max); + + *status = F_status_set_error(F_recurse); + } + } + + // find and report all unknown operations before exiting. + if (F_status_is_error(*status)) continue; + + operations[i] = operation; + + fake_make_operation_expand(data, data_make, section->name, operation, *operation_name, section->contents.array[i], &arguments[i], status); + + //fake_make_operation_validate(); + } // for + + if (F_status_is_error(*status)) { + for (i = 0; i < section->objects.used; i++) { + f_macro_string_dynamics_delete_simple(arguments[i]); + } // for + + return; + } + + for (; i < section->objects.used; i++) { + // 3: expand the operation content into dynamic strings. + // 4: process any variables and then re-validate any operations with replacements. + // 5: perform the operation. + } // for + + for (i = 0; i < section->objects.used; i++) { + f_macro_string_dynamics_delete_simple(arguments[i]); + } // for + } +#endif // _di_fake_make_operate_section_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index 77b271b..b483c91 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -18,6 +18,8 @@ extern "C" { #define fake_make_section_main_length 4 #define fake_make_section_settings_length 8 + + #define fake_make_section_stack_max 8192 // maximum stack call depth. #endif // _di_fake_make_section_ // @todo safety checks that ensures operations on files only happen inside the project directory, represented by "top". @@ -47,7 +49,7 @@ extern "C" { #define fake_make_setting_load_build_length 10 #define fake_make_setting_parameter_length 9 - #define fake_make_setting_total_length 3 + #define fake_make_setting_total 3 #endif // _di_fake_make_setting_ // @todo "operate" should use a call stack, but do not allow recursive calls (check to see if named operation is already on the call stack). @@ -99,7 +101,7 @@ extern "C" { #define fake_make_operation_touch_length 5 enum { - fake_make_operation_type_archive, + fake_make_operation_type_archive = 1, fake_make_operation_type_build, fake_make_operation_type_clean, fake_make_operation_type_compile, @@ -122,6 +124,8 @@ extern "C" { fake_make_operation_type_top, fake_make_operation_type_touch, }; + + #define fake_make_operation_total 22 #endif // _di_fake_make_operation_ // @todo each one of these should be made available to be passed to the program as "$parameter_define[X]" for multi-value (define) or "$parameter_no_color" for single-value (no_color). @@ -212,7 +216,7 @@ extern "C" { f_fss_nameds fakefile; f_string_dynamic buffer; - f_string_length main; + f_array_length main; } fake_make_data; #define fake_make_data_initialize { \ @@ -272,6 +276,45 @@ extern "C" { extern f_return_status fake_make_operate(const fake_data data) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_operate_ +/** + * Execute the make operation. + * + * @param data + * The program data. + * @param data_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param section_id + * The array location id within the fakefile of the section to operate on. + * @param status + * The return status. + * + * Status codes (with error bit) are returned on any problem. + */ +#ifndef _di_fake_make_operation_expand_ + extern void fake_make_operation_expand(const fake_data data, const fake_make_data data_make, const f_string_range section_name, const f_array_length operation, const f_string_static operation_name, const f_fss_content content, f_string_dynamics *arguments, f_status *status) f_gcc_attribute_visibility_internal; +#endif // _di_fake_make_operation_expand_ + +/** + * Process a make operation section. + * + * @param data + * The program data. + * @param data_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param section_id + * The array location id within the fakefile of the section to operate on. + * @param section_stack + * The current operation stack. + * @param status + * The return status. + * + * F_invalid (with error bit set) is returned if any part of the section is invalid, such as an invalid operation name. + * F_recurse (with error bit set) is returned if unable to recurse to another operation section (usually max stack depth reached). + */ +#ifndef _di_fake_make_operate_section_ + void fake_make_operate_section(const fake_data data, const fake_make_data data_make, const f_array_length section_id, f_string_lengths *section_stack, f_status *status) f_gcc_attribute_visibility_internal; +#endif // _di_fake_make_operate_section_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 446ed81..b948371 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -44,6 +44,118 @@ extern "C" { } #endif // _di_fake_print_error_ +#ifndef _di_fake_print_error_fakefile_section_ + bool fake_print_error_fakefile_section(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string_static buffer, const f_string_range section_name, const bool fallback) { + + if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.error, context.reset, ") occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print(f_type_error, context.error, context.reset, "() for section '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, section_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print_line(f_type_error, context.error, context.reset, "'."); + } + + return F_true; + } +#endif // _di_fake_print_error_fakefile_section_ + +#ifndef _di_fake_print_error_fakefile_section_line_ + bool fake_print_error_fakefile_section_line(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const bool fallback) { + + f_string_length line = 0; + + f_fss_count_lines(buffer, operation_name.start, &line); + + if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.error, context.reset, ") occurred while calling "); + fl_color_print(f_type_error, context.notable, context.reset, "%s", function); + fl_color_print(f_type_error, context.error, context.reset, "() for section '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, section_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print(f_type_error, context.error, context.reset, " on line "); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", line); + fl_color_print(f_type_error, context.error, context.reset, ", operation '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, operation_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print_line(f_type_error, context.error, context.reset, "'."); + } + + return F_true; + } +#endif // _di_fake_print_error_fakefile_section_line_ + +#ifndef _di_fake_print_error_fakefile_section_operation_stack_max_ + void fake_print_error_fakefile_section_operation_stack_max(const fl_color_context context, const uint8_t verbosity, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max) { + if (verbosity == fake_verbosity_quiet) return; + + f_string_length line = 0; + + f_fss_count_lines(buffer, operation_name.start, &line); + + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The section operation '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, operation_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print(f_type_error, context.error, context.reset, "' from section '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, section_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print(f_type_error, context.error, context.reset, "' on line "); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", line); + fl_color_print(f_type_error, context.error, context.reset, " cannot be processed because the max stack depth of "); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", stack_max); + fl_color_print_line(f_type_error, context.error, context.reset, " has been reached."); + } +#endif // _di_fake_print_error_fakefile_section_operation_stack_max_ + +#ifndef _di_fake_print_error_fakefile_section_operation_unknown_ + void fake_print_error_fakefile_section_operation_unknown(const fl_color_context context, const uint8_t verbosity, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) { + if (verbosity == fake_verbosity_quiet) return; + + f_string_length line = 0; + + f_fss_count_lines(buffer, operation_name.start, &line); + + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, context.error, context.reset, "ERROR: The section operation '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, operation_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print(f_type_error, context.error, context.reset, "' from section '"); + + fl_color_print_code(f_type_error, context.notable); + f_print_string_dynamic_partial(f_type_error, buffer, section_name); + fl_color_print_code(f_type_error, context.reset); + + fl_color_print(f_type_error, context.error, context.reset, "' on line "); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", line); + fl_color_print_line(f_type_error, context.error, context.reset, " is not a known operation name."); + } +#endif // _di_fake_print_error_fakefile_section_operation_unknown_ + #ifndef _di_fake_print_error_fakefile_settings_content_invalid_ void fake_print_error_fakefile_settings_content_invalid(const fl_color_context context, const uint8_t verbosity, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string_range range_content, const f_string settings_name) { if (verbosity != fake_verbosity_verbose) return; diff --git a/level_3/fake/c/private-print.h b/level_3/fake/c/private-print.h index 6d056b7..b86896f 100644 --- a/level_3/fake/c/private-print.h +++ b/level_3/fake/c/private-print.h @@ -35,6 +35,98 @@ extern "C" { #endif // _di_fake_print_error_ /** + * Print error messages when processing some fakefile section. + * + * @param context + * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. + * @param status + * The status code representing an error. + * @param function + * The name of the function where the error happened. + * @param buffer + * The buffer containing the fakefile data. + * @param section_name + * The range within the buffer representing the section name. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_none is returned on successful print of known errors. + * F_unknown is returned if the status code has no print message. + */ +#ifndef _di_fake_print_error_fakefile_section_ + extern bool fake_print_error_fakefile_section(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string_static buffer, const f_string_range section_name, const bool fallback) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_fakefile_section_ + +/** + * Print error messages when processing some fakefile section, for a specific line and operation. + * + * @param context + * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. + * @param status + * The status code representing an error. + * @param function + * The name of the function where the error happened. + * @param buffer + * The buffer containing the fakefile data. + * @param section_name + * The range within the buffer representing the section name. + * @param operation_name + * The range within the buffer representing the operation name within the section. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_none is returned on successful print of known errors. + * F_unknown is returned if the status code has no print message. + */ +#ifndef _di_fake_print_error_fakefile_section_line_ + extern bool fake_print_error_fakefile_section_line(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const bool fallback) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_fakefile_section_line_ + +/** + * Print error messages when processing some fakefile section, for a specific line and operation, and that the max stack depth is reached. + * + * @param context + * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. + * @param buffer + * The buffer containing the fakefile data. + * @param section_name + * The range within the buffer representing the section name. + * @param operation_name + * The range within the buffer representing the operation name within the section. + * @param stack_max + * The max stack depth. + */ +#ifndef _di_fake_print_error_fakefile_section_operation_stack_max_ + extern void fake_print_error_fakefile_section_operation_stack_max(const fl_color_context context, const uint8_t verbosity, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_fakefile_section_operation_stack_max_ + +/** + * Print error messages when processing some fakefile section, for a specific line and operation, and that operation is invalid. + * + * @param context + * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. + * @param buffer + * The buffer containing the fakefile data. + * @param section_name + * The range within the buffer representing the section name. + * @param operation_name + * The range within the buffer representing the operation name within the section. + */ +#ifndef _di_fake_print_error_fakefile_section_operation_unknown_ + extern void fake_print_error_fakefile_section_operation_unknown(const fl_color_context context, const uint8_t verbosity, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_fakefile_section_operation_unknown_ + +/** * Print error message when fake settings content is invalid. * * @param context diff --git a/level_3/fake/data/build/fakefile b/level_3/fake/data/build/fakefile index 68cccd2..6cf82e3 100644 --- a/level_3/fake/data/build/fakefile +++ b/level_3/fake/data/build/fakefile @@ -8,4 +8,36 @@ settings: main: print This is a line. + invalid + print This is another line. + + another invalid + + archive // run the ar linker (all arguments are passed as arguments, except for reserved parameter words, with $ in front, such as $build_1). + build // run the fake build operation ($1 = path to settings file, if missing use default, auto-passes verbosity and other Fake parameters.). + clean // run the fake clean operation (auto-passes verbosity and other Fake parameters.). + compile // run the gcc compiler (all arguments are passed as arguments, except for reserved parameter words, with $ in front, such as $build_1). + create // create a file or directory ($1 = 'file' or 'directory') ($2 = path to file or directory) ($3 = 'recursive' (optional) for 'directory' only). + delete // delete a file or directory ($1 = 'file' or 'directory') ($2 = path to file or directory) ($3 = 'recursive' (optional) for 'directory' only). + else // execute next line if immediately previous if condition fails (if exists file_name.txt, if defined environment_name, if equals some string or define another string or define, if succeed for previous run/shell command succeeding, if fail for previous run/shell command failing). + fail // what to do when a command fails, either 'exit', 'warn' or 'ignore'. + group // change group on file or directory ($1 = path to file or directory). + if // execute next line if condition succeeds (if exists file_name.txt, if defined environment_name, if equals some string or define another string or define, if succeed for previous run/shell command succeeding, if fail for previous run/shell command failing). + link // create a symbolic link ($1 = target) ($2 = point). (@todo also don't allow linking outside project directory). + mode // change mode of a file or directory ($1 = path to file or directory). + operate // enter into a given named operation except for reserved . + owner // change owner on file or directory ($1 = path to file or directory). + pop // pop the previous directory off the stack, changing to the popped directory. + print // print to an output or file ($1 = color, out, error, warning) ($2 = if $1 = color, then out, error, warning; else string to print) ($3 = if $1 = color, then string to print). + run // execute command via PATH ($1 = program name, all other arguments are passed as arguments, except for reserved parameter words, with $ in front, such as $build_1). + shell // execute command at path ($1 = path to program/script, all other arguments are passed as arguments, except for reserved parameter words, with $ in front, such as $build_1). + skeleton // run the fake skeleton operation (auto-passes verbosity and other Fake parameters.). + to // change into a given directory, adding it to the directory stack ($1 = directory name). + top // change to project root, clearing directory stack. + touch // perform touch operation on file or directoy ($1 = path to file or directory). + + + and + so + forth -- 1.8.3.1