From: Kevin Day Date: Sat, 5 Sep 2020 22:35:41 +0000 (-0500) Subject: Progress: featureless make. X-Git-Tag: 0.5.0~19 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=868712986ac32c0be9fc416b05326ee362e1c97d;p=fll Progress: featureless make. The fake_execute() should return the "return code" for optional processing by caller. Implement the reserved parameter IKI vocabulary name "return". Remove the arguments.used checks inside of fake_make_operate_process(), the validation process already handles this. Fix names for fake_make_parameter_variable_* defines. Relocate some define/parameter documentation from specification to documentation and update the specification accordingly. --- diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index fee84c5..07dbb43 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -9,8 +9,8 @@ extern "C" { #endif #ifndef _di_fake_execute_ - void fake_execute(const fake_data_t data, const fake_environment_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) { - if (F_status_is_error(*status)) return; + int fake_execute(const fake_data_t data, const fake_environment_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) { + if (F_status_is_error(*status)) return 1; if (data.verbosity == fake_verbosity_verbose) { printf("%s", program.string); @@ -27,33 +27,35 @@ extern "C" { fflush(f_type_output); } - { - int result = 0; + int return_code = 0; - if (program.used) { - *status = fll_execute_program_environment(program.string, arguments, environment.names, environment.values, &result); - } - else { - *status = F_status_set_error(F_file_found_not); - } + if (program.used) { + *status = fll_execute_program_environment(program.string, arguments, environment.names, environment.values, &return_code); + } + else { + *status = F_status_set_error(F_file_found_not); + } - if (result != 0) { - *status = F_status_set_error(F_failure); - } - else if (F_status_is_error(*status)) { - if (F_status_set_fine(*status) == F_file_found_not) { - 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: Failed to find program '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", program.used ? program.string : ""); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' for executing."); - } - } - else { - fake_print_error(data, F_status_set_fine(*status), "fll_execute_program_environment", F_true); + if (return_code != 0) { + *status = F_status_set_error(F_failure); + } + else if (F_status_is_error(*status)) { + return_code = 1; + + if (F_status_set_fine(*status) == F_file_found_not) { + 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: Failed to find program '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", program.used ? program.string : ""); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' for executing."); } } + else { + fake_print_error(data, F_status_set_fine(*status), "fll_execute_program_environment", F_true); + } } + + return return_code; } #endif // _di_fake_execute_ diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 267cf6a..a768078 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -53,9 +53,13 @@ extern "C" { * The arguments to be passed to the program. * @param status * The return status. + * + * @return + * The return code result from execution. + * A value of 1 is returned if status has the error bit set. */ #ifndef _di_fake_execute_ - extern void fake_execute(const fake_data_t data, const fake_environment_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) f_gcc_attribute_visibility_internal; + extern int fake_execute(const fake_data_t data, const fake_environment_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) f_gcc_attribute_visibility_internal; #endif // _di_fake_execute_ /** diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index ce2f91e..bfe9963 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -880,6 +880,31 @@ extern "C" { if (parameter->used) { for (k = 0; k < parameter->used; k++) { + + // check against reserved parameter names and if matches use them instead. + if (fl_string_dynamic_compare_string(fake_make_parameter_variable_return, parameter->array[k].name, fake_make_parameter_variable_return_length) == F_equal_to) { + + if (data_make->setting_make.parameter.array[0].value.array[0].used) { + *status = fl_string_dynamic_append(data_make->setting_make.parameter.array[0].value.array[0], &arguments->array[arguments->used]); + if (F_status_is_error(*status)) { + fake_print_message(data, F_status_set_fine(*status), "fl_string_append", F_true, data_make->print); + break; + } + } + else { + *status = fl_string_append("0", 1, &arguments->array[arguments->used]); + if (F_status_is_error(*status)) { + fake_print_message(data, F_status_set_fine(*status), "fl_string_append", F_true, data_make->print); + break; + } + } + + arguments->used++; + continue; + } + // @todo: else, handle all other reserved parameter names. + + // check against iki variable list. *status = fl_string_dynamic_partial_compare_dynamic(parameter->array[k].name, data_make->buffer, iki_content.array[j]); if (*status == F_equal_to) { @@ -1708,20 +1733,20 @@ extern "C" { void fake_make_operate_process(const fake_data_t data, const f_string_range_t section_name, const uint8_t operation, const f_string_static_t operation_name, const f_string_dynamics_t arguments, const bool success, uint8_t *operation_if, fake_make_data_t *data_make, f_string_lengths_t *section_stack, f_status_t *status) { if (operation == fake_make_operation_type_archive) { - if (!arguments.used) { - return; - } - - fake_execute(data, data_make->environment, data_make->setting_build.build_linker, arguments, status); + int return_code = fake_execute(data, data_make->environment, data_make->setting_build.build_linker, arguments, status); if (F_status_is_error(*status)) { fake_print_message(data, F_status_set_fine(*status), "fake_execute", F_true, data_make->print); } + else { + fake_make_operate_process_return(data, return_code, data_make, status); + } return; } if (operation == fake_make_operation_type_break) { + if (!arguments.used || fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to) { *status = F_signal_abort; } @@ -1756,23 +1781,19 @@ extern "C" { } if (operation == fake_make_operation_type_compile) { - if (!arguments.used) { - return; - } - - fake_execute(data, data_make->environment, data_make->setting_build.build_compiler, arguments, status); + int return_code = fake_execute(data, data_make->environment, data_make->setting_build.build_compiler, arguments, status); if (F_status_is_error(*status)) { fake_print_message(data, F_status_set_fine(*status), "fake_execute", F_true, data_make->print); } + else { + fake_make_operate_process_return(data, return_code, data_make, status); + } return; } if (operation == fake_make_operation_type_define) { - if (!arguments.used) { - return; - } if (arguments.used > 1) { *status = f_environment_set(arguments.array[0].string, arguments.array[1].string, F_true); @@ -1857,6 +1878,7 @@ extern "C" { } if (operation == fake_make_operation_type_else) { + if (*operation_if == fake_make_operation_if_type_else_false_next || *operation_if == fake_make_operation_if_type_else_false_next_always) { *operation_if = fake_make_operation_if_type_else_false; } @@ -1868,6 +1890,7 @@ extern "C" { } if (operation == fake_make_operation_type_exit) { + if (!arguments.used || fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to) { *status = F_signal_quit; } @@ -1892,9 +1915,6 @@ extern "C" { } if (operation == fake_make_operation_type_fail) { - if (!arguments.used) { - return; - } if (fl_string_dynamic_compare_string(fake_make_operation_argument_exit, arguments.array[0], fake_make_operation_argument_exit_length) == F_equal_to) { data_make->setting_make.fail = fake_make_operation_fail_type_exit; @@ -1933,10 +1953,6 @@ extern "C" { } if (operation == fake_make_operation_type_group) { - if (!arguments.used) { - return; - } - gid_t id = 0; *status = fake_make_get_id_group(data, data_make->print, arguments.array[0], &id); @@ -1957,10 +1973,6 @@ extern "C" { } if (operation == fake_make_operation_type_groups) { - if (!arguments.used) { - return; - } - gid_t id = 0; *status = fake_make_get_id_group(data, data_make->print, arguments.array[0], &id); @@ -1982,9 +1994,6 @@ extern "C" { } if (operation == fake_make_operation_type_if) { - if (!arguments.used) { - return; - } if (*operation_if == fake_make_operation_if_type_if_success) { if (success) { @@ -2456,10 +2465,6 @@ extern "C" { } if (operation == fake_make_operation_type_link) { - if (!arguments.used) { - return; - } - *status = f_file_link(arguments.array[0].string, arguments.array[1].string); if (F_status_is_error(*status)) { @@ -2473,10 +2478,6 @@ extern "C" { } if (operation == fake_make_operation_type_mode) { - if (!arguments.used) { - return; - } - f_file_mode_t mode_rule = 0; uint8_t replace = 0; @@ -2516,10 +2517,6 @@ extern "C" { } if (operation == fake_make_operation_type_modes) { - if (!arguments.used) { - return; - } - f_file_mode_t mode_rule = 0; uint8_t replace = 0; @@ -2560,10 +2557,6 @@ extern "C" { } if (operation == fake_make_operation_type_operate) { - if (!arguments.used) { - return; - } - f_array_length_t id_section = 0; for (; id_section < data_make->fakefile.used; id_section++) { @@ -2590,10 +2583,6 @@ extern "C" { } if (operation == fake_make_operation_type_owner) { - if (!arguments.used) { - return; - } - uid_t id = 0; *status = fake_make_get_id_owner(data, data_make->print, arguments.array[0], &id); @@ -2615,10 +2604,6 @@ extern "C" { } if (operation == fake_make_operation_type_owners) { - if (!arguments.used) { - return; - } - uid_t id = 0; *status = fake_make_get_id_owner(data, data_make->print, arguments.array[0], &id); @@ -2696,11 +2681,9 @@ extern "C" { } if (operation == fake_make_operation_type_to) { - if (!arguments.used) { - return; - } *status = fake_make_assure_inside_project(data, arguments.array[0], data_make); + if (F_status_is_error(*status)) { fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[0].string, data_make->print); @@ -2712,6 +2695,7 @@ extern "C" { } *status = f_path_change(arguments.array[0].string); + if (F_status_is_error(*status)) { fake_print_message_section_operation_path_stack_max(data, F_status_set_fine(*status), "f_path_change", arguments.array[0].string, data_make->print); } @@ -2741,6 +2725,7 @@ extern "C" { if (data.verbosity == fake_verbosity_verbose) { *status = fake_make_path_relative(data, data_make->path.stack.array[data_make->path.stack.used], data_make); + if (F_status_is_error(*status)) { fake_print_message(data, F_status_set_fine(*status), "fake_make_path_relative", F_true, data_make->print); return; @@ -2758,9 +2743,6 @@ extern "C" { } if (operation == fake_make_operation_type_top) { - if (!arguments.used) { - return; - } *status = f_path_change_at(data_make->path.top); if (F_status_is_error(*status)) { @@ -2782,15 +2764,12 @@ extern "C" { } if (operation == fake_make_operation_type_touch) { - if (!arguments.used) { - return; - } - f_mode_t mode = f_mode_t_initialize; f_macro_mode_t_set_default_umask(mode, data.umask); for (f_array_length_t i = 1; i < arguments.used; i++) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_file, arguments.array[0], fake_make_operation_argument_file_length) == F_equal_to) { *status = f_file_touch(arguments.array[i].string, mode.regular, F_false); diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index d7e58e9..b7dceea 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -267,20 +267,20 @@ extern "C" { #define fake_make_parameter_variable_verbose "verbose" #define fake_make_parameter_variable_work "work" - #define fake_make_file_parameter_variable_build_length 5 - #define fake_make_file_parameter_variable_dark_length 5 - #define fake_make_file_parameter_variable_data_length 5 - #define fake_make_file_parameter_variable_define_length 6 - #define fake_make_file_parameter_variable_light_length 5 - #define fake_make_file_parameter_variable_mode_length 4 - #define fake_make_file_parameter_variable_no_color_length 8 - #define fake_make_file_parameter_variable_process_length 7 - #define fake_make_file_parameter_variable_quiet_length 5 - #define fake_make_file_parameter_variable_return_length 6 - #define fake_make_file_parameter_variable_settings_length 8 - #define fake_make_file_parameter_variable_sources_length 7 - #define fake_make_file_parameter_variable_verbose_length 7 - #define fake_make_file_parameter_variable_work_length 4 + #define fake_make_parameter_variable_build_length 5 + #define fake_make_parameter_variable_dark_length 5 + #define fake_make_parameter_variable_data_length 5 + #define fake_make_parameter_variable_define_length 6 + #define fake_make_parameter_variable_light_length 5 + #define fake_make_parameter_variable_mode_length 4 + #define fake_make_parameter_variable_no_color_length 8 + #define fake_make_parameter_variable_process_length 7 + #define fake_make_parameter_variable_quiet_length 5 + #define fake_make_parameter_variable_return_length 6 + #define fake_make_parameter_variable_settings_length 8 + #define fake_make_parameter_variable_sources_length 7 + #define fake_make_parameter_variable_verbose_length 7 + #define fake_make_parameter_variable_work_length 4 typedef struct { f_string_dynamics_t build; @@ -699,6 +699,8 @@ extern "C" { * * @param data * The program data. + * @param return_code + * The return code to process. * @param data_make * All make related setting data, including data from the fakefile and optionally build settings file. * @param status diff --git a/level_3/fake/data/build/fakefile b/level_3/fake/data/build/fakefile index bfcb395..369f0db 100644 --- a/level_3/fake/data/build/fakefile +++ b/level_3/fake/data/build/fakefile @@ -14,7 +14,4 @@ settings: main: - #build - - print beginning - print return = 'parameter:"return"' (This needs to be fixed, always set return value after each line is operated). + build diff --git a/level_3/fake/documents/fakefile.txt b/level_3/fake/documents/fakefile.txt index 839bcee..c9f6c38 100644 --- a/level_3/fake/documents/fakefile.txt +++ b/level_3/fake/documents/fakefile.txt @@ -306,3 +306,20 @@ Fakefile Documentation: The first Content must be either "file" or "directory". The remaining Content must be a path to the file. + + The IKI vocabulary context is supported and is further clarified as follows\: + - define\: + The define object represents environment variables passed to the program or created by the program. + The value represents the environment variable name and is case-sensitive. + This IKI variable gets substituted with the environment variable's value or NULL if not defined. + The "settings" list supports declaring custom environment variables (which overwrite any existing environment variable with the same name). + + - parameter\: + The parameter object represents a variable that is to be substituted. + The value represents the variable name and is case-sensitive. + This IKI variable gets substituted with the value defined in the "settings" list or NULL if not defined. + + The following are reserved parameter variable names\: + - return\: + This variable holds the return status from a previously run user-space applications, which happens with the "run" and "shell" section operations. + This does not represent the return code for each line, just only those lines that run user-space applications. diff --git a/level_3/fake/specifications/fakefile.txt b/level_3/fake/specifications/fakefile.txt index e28b929..51a74a5 100644 --- a/level_3/fake/specifications/fakefile.txt +++ b/level_3/fake/specifications/fakefile.txt @@ -17,16 +17,8 @@ Fakefile Specification: The reserved Settings Section does not support IKI variable substitution. The IKI-0002 vocabulary context is further clarified as follows\: - - define\: - The define object represents environment variables passed to the program or created by the program. - The value represents the environment variable name and is case-sensitive. - This IKI variable gets substituted with the environment variable's value or NULL if not defined. - The "settings" list supports declaring custom environment variables (which overwrite any existing environment variable with the same name). - - - parameter\: - The parameter object represents a variable that is to be substituted. - The value represents the variable name and is case-sensitive. - This IKI variable gets substituted with the value defined in the "settings" list or NULL if not defined. + - define: the value must be a case-sensitive valid environment variable name (alpha-numeric or underscore, but no leading digits). + - parameter: the value is a case-sensitive variable name. The reserved Section Objects are\: - settings: contains a list of Settings Objects and Content in FSS-0001 (Extended) format.