From 6807ca8f3ee0ca98c27b02d7ece2523a1e327038 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 16 May 2020 22:06:16 -0500 Subject: [PATCH] Progress: featureless make --- level_3/fake/c/fake.c | 2 +- level_3/fake/c/fake.h | 40 ++++++++--------- level_3/fake/c/private-build.c | 97 ++++++++++++++++++++++++++++++++++++++-- level_3/fake/c/private-fake.c | 8 ++-- level_3/fake/c/private-fake.h | 4 +- level_3/fake/c/private-make.c | 1 - level_3/fake/data/build/settings | 4 +- 7 files changed, 123 insertions(+), 33 deletions(-) diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 656ba06..8a77888 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -330,7 +330,7 @@ extern "C" { fprintf(f_standard_error, "%c", f_string_eol); } else { - fprintf(f_standard_output, "%c", f_string_eol); + fprintf(f_standard_output, "%cAll operations complete.%c%c", f_string_eol, f_string_eol, f_string_eol); } } } diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index ca20d8a..447bd51 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -179,23 +179,23 @@ extern "C" { #define fake_path_part_sources "sources" f_path_separator #define fake_path_part_static "static" f_path_separator - #define fake_path_part_bash_length (4 + f_path_separator_length) - #define fake_path_part_build_length (5 + f_path_separator_length) - #define fake_path_part_c_length (1 + f_path_separator_length) - #define fake_path_part_cpp_length (3 + f_path_separator_length) - #define fake_path_part_data_length (4 + f_path_separator_length) - #define fake_path_part_documents_length (9 + f_path_separator_length) - #define fake_path_part_includes_length (8 + f_path_separator_length) - #define fake_path_part_libraries_length (9 + f_path_separator_length) - #define fake_path_part_licenses_length (8 + f_path_separator_length) - #define fake_path_part_objects_length (7 + f_path_separator_length) - #define fake_path_part_process_length (7 + f_path_separator_length) - #define fake_path_part_programs_length (8 + f_path_separator_length) - #define fake_path_part_script_length (6 + f_path_separator_length) - #define fake_path_part_settings_length (8 + f_path_separator_length) - #define fake_path_part_shared_length (6 + f_path_separator_length) - #define fake_path_part_sources_length (7 + f_path_separator_length) - #define fake_path_part_static_length (6 + f_path_separator_length) + #define fake_path_part_bash_length 5 + #define fake_path_part_build_length 6 + #define fake_path_part_c_length 2 + #define fake_path_part_cpp_length 4 + #define fake_path_part_data_length 5 + #define fake_path_part_documents_length 10 + #define fake_path_part_includes_length 9 + #define fake_path_part_libraries_length 10 + #define fake_path_part_licenses_length 9 + #define fake_path_part_objects_length 8 + #define fake_path_part_process_length 8 + #define fake_path_part_programs_length 9 + #define fake_path_part_script_length 7 + #define fake_path_part_settings_length 9 + #define fake_path_part_shared_length 7 + #define fake_path_part_sources_length 8 + #define fake_path_part_static_length 7 #endif // _di_fake_path_ #ifndef _di_fake_file_ @@ -223,9 +223,9 @@ extern "C" { #define fake_default_path_sources "sources" f_path_separator #define fake_default_path_work "" - #define fake_default_path_build_length (5 + f_path_separator_length) - #define fake_default_path_data_length (4 + f_path_separator_length) - #define fake_default_path_sources_length (7 + f_path_separator_length) + #define fake_default_path_build_length 6 + #define fake_default_path_data_length 5 + #define fake_default_path_sources_length 8 #define fake_default_path_work_length 0 #define fake_default_defines "" diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 5897e3b..8afe26b 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -154,9 +154,96 @@ extern "C" { } { + f_string_dynamics environment_names = f_string_dynamics_initialize; + f_string_dynamics environment_values = f_string_dynamics_initialize; + + // @todo add support for allowing specific environment variables + const f_string variables_name[] = { + f_path_environment, + f_path_present_working + }; + + const f_string_length variables_length[] = { + f_path_environment_length, + f_path_present_working_length + }; + + f_string_dynamic variable_name = f_string_dynamic_initialize; + f_string_dynamic variable_value = f_string_dynamic_initialize; + + for (uint8_t i = 0; i < 2; i++) { + status = f_environment_get(variables_name[i], &variable_value); + if (f_status_is_error(status)) { + status = f_status_set_fine(status); + + if (status == f_error_reallocation) { + fake_print_error(data.context, data.verbosity, status, "f_environment_get", f_true); + + f_macro_string_dynamic_delete_simple(variable_name); + f_macro_string_dynamic_delete_simple(variable_value); + f_macro_string_dynamic_delete_simple(path); + f_macro_string_dynamics_delete_simple(environment_names); + f_macro_string_dynamics_delete_simple(environment_values); + f_macro_string_dynamics_delete_simple(arguments); + return status; + } + } + + if (environment_names.used + 1 > environment_names.size) { + f_macro_string_dynamics_resize(status, environment_names, environment_names.size + f_memory_default_allocation_step); + + if (!f_status_is_error(status)) { + f_macro_string_dynamics_resize(status, environment_values, environment_values.size + f_memory_default_allocation_step); + } + + if (f_status_is_error(status)) { + fake_print_error(data.context, data.verbosity, status, "f_macro_string_dynamics_resize", f_true); + + f_macro_string_dynamic_delete_simple(variable_name); + f_macro_string_dynamic_delete_simple(variable_value); + f_macro_string_dynamic_delete_simple(path); + f_macro_string_dynamics_delete_simple(environment_names); + f_macro_string_dynamics_delete_simple(environment_values); + f_macro_string_dynamics_delete_simple(arguments); + return status; + } + } + + status = fl_string_append(variables_name[i], variables_length[i], &variable_name); + + if (f_status_is_error(status)) { + fake_print_error(data.context, data.verbosity, status, "fl_string_append", f_true); + + f_macro_string_dynamic_delete_simple(variable_name); + f_macro_string_dynamic_delete_simple(variable_value); + f_macro_string_dynamic_delete_simple(path); + f_macro_string_dynamics_delete_simple(environment_names); + f_macro_string_dynamics_delete_simple(environment_values); + f_macro_string_dynamics_delete_simple(arguments); + return status; + } + + environment_names.array[environment_names.used].string = variable_name.string; + environment_names.array[environment_names.used].used = variable_name.used; + environment_names.array[environment_names.used].size = variable_name.size; + environment_names.used++; + + environment_values.array[environment_values.used].string = variable_value.string; + environment_values.array[environment_values.used].used = variable_value.used; + environment_values.array[environment_values.used].size = variable_value.size; + environment_values.used++; + + f_macro_string_dynamic_clear(variable_name); + f_macro_string_dynamic_clear(variable_value); + } + int result = 0; - status = fll_execute_path(path.string, arguments, &result); + status = fll_execute_path_environment(path.string, arguments, environment_names, environment_values, &result); + + f_macro_string_dynamics_delete_simple(environment_names); + f_macro_string_dynamics_delete_simple(environment_values); + f_macro_string_dynamics_delete_simple(arguments); } if (f_status_is_error(status)) { @@ -169,12 +256,11 @@ extern "C" { } } else { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_path", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_path_environment", f_true); } } f_macro_string_dynamic_delete_simple(path); - f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -182,6 +268,11 @@ extern "C" { #ifndef _di_fake_build_operate_ f_return_status fake_build_operate(const fake_data data) { + if (data.verbosity != fake_verbosity_quiet) { + printf("%c", f_string_eol); + fl_color_print_line(f_standard_output, data.context.important, data.context.reset, "Building project."); + } + f_status status = f_none; fake_build_settings settings = fake_build_settings_initialize; diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 51b5d4b..2243032 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -398,11 +398,11 @@ extern "C" { #endif // _di_fake_path_generate_ #ifndef _di_fake_path_generate_string_dynamic_ - f_return_status fake_path_generate_string_dynamic(fake_data *data, const f_string_dynamic source, f_string_dynamic *value[], const uint8_t length) { + f_return_status fake_path_generate_string_dynamic(fake_data *data, const f_string_dynamic source, f_string_dynamic *destination[], const uint8_t length) { f_status status = f_none; for (uint8_t i = 0; i < length; i++) { - status = fl_string_dynamic_append_nulless(source, value[i]); + status = fl_string_dynamic_append_nulless(source, destination[i]); if (f_status_is_error(status)) return status; } // for @@ -469,7 +469,7 @@ extern "C" { if (status == f_invalid_parameter) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ", function, name); + fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling "); fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); fl_color_print(f_standard_error, context.error, context.reset, "() for the %s '", file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); @@ -689,7 +689,7 @@ extern "C" { } f_string_length location = data->parameters[parameters_id[i]].additional.array[0]; - f_string_length length = strnlen(arguments.argv[location], f_console_max_size); + f_string_length length = strnlen(arguments.argv[location], f_console_length_size); if (length > 0) { status = fl_string_append(arguments.argv[location], length, parameters_value[i]); diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 82692be..f22f5b9 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -33,7 +33,7 @@ extern "C" { * The program data. * @param source * The string to copy from. - * @param value + * @param destination * An array of pointers to the strings to append onto. * @param length * The size of the values. @@ -43,7 +43,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_path_generate_string_dynamic_ - extern f_return_status fake_path_generate_string_dynamic(fake_data *data, const f_string_dynamic source, f_string_dynamic *value[], const uint8_t size) f_gcc_attribute_visibility_internal; + extern f_return_status fake_path_generate_string_dynamic(fake_data *data, const f_string_dynamic source, f_string_dynamic *destination[], const uint8_t size) f_gcc_attribute_visibility_internal; #endif // _di_fake_path_generate_string_dynamic_ /** diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index ff48fa6..cc70223 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -6,7 +6,6 @@ extern "C" { #endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index 7a7f600..e9c26ec 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -16,10 +16,10 @@ modes_default individual build_compiler gcc build_linker ar build_libraries -lc -build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_utf -lfl_string -lfl_file -lfl_fss -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_environment -lf_file -lf_conversion -lf_console -lf_memory +build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_utf -lfl_string -lfl_file -lfl_fss -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_path -lf_environment -lf_file -lf_conversion -lf_console -lf_memory build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0 build_libraries_fll-monolithic -lfll -build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_utf -lfl_string -lfl_file -lfl_fss -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_environment -lf_file -lf_conversion -lf_console -lf_memory +build_libraries-individual -lfll_program -lfll_fss -lfll_execute -lfl_utf -lfl_string -lfl_file -lfl_fss -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_path -lf_environment -lf_file -lf_conversion -lf_console -lf_memory build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fake.c private-fake.c private-clean.c private-build.c private-make.c private-skeleton.c -- 1.8.3.1