From: Kevin Day Date: Thu, 14 May 2020 04:24:19 +0000 (-0500) Subject: Progress: Featureless Make X-Git-Tag: 0.5.0~257 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ab8d413608c5f245fe7dcd2d333c8c2fed149a55;p=fll Progress: Featureless Make Implement skeleton operation. Simplify parameters and enforce a more standard structure on 'build'. The "make" operation with its "fakefile"s can be used for more flexible project structures (at least once it is written). --- diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 9f8f0f7..4532740 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -23,22 +23,17 @@ extern "C" { printf("%c", f_string_eol); - fll_program_print_help_option(context, fake_short_path_build, fake_long_path_build, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom build directory."); fll_program_print_help_option(context, fake_short_defines, fake_long_defines, f_console_symbol_short_enable, f_console_symbol_long_enable, " Override custom defines with these defines."); fll_program_print_help_option(context, fake_short_mode, fake_long_mode, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use this mode when processing the build settings."); fll_program_print_help_option(context, fake_short_process, fake_long_process, f_console_symbol_short_enable, f_console_symbol_long_enable, " Process name for storing build states."); fll_program_print_help_option(context, fake_short_settings, fake_long_settings, f_console_symbol_short_enable, f_console_symbol_long_enable, "Use this settings file, from within the source settings directory."); - fll_program_print_help_option(context, fake_short_path_work, fake_long_path_work, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use includes/libraries from this directory instead of system."); printf("%c", f_string_eol); - fll_program_print_help_option(context, fake_short_path_source_build, fake_long_path_source_build, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the build source files."); - fll_program_print_help_option(context, fake_short_path_source_codes, fake_long_path_source_codes, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the compiled source files, such as c."); - fll_program_print_help_option(context, fake_short_path_source_common, fake_long_path_source_common, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the common source files."); - fll_program_print_help_option(context, fake_short_path_source_data, fake_long_path_source_data, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the data source files."); - fll_program_print_help_option(context, fake_short_path_source_documents, fake_long_path_source_documents, f_console_symbol_short_enable, f_console_symbol_long_enable, "Custom path to the documents source files."); - fll_program_print_help_option(context, fake_short_path_source_licenses, fake_long_path_source_licenses, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the license source files."); - fll_program_print_help_option(context, fake_short_path_source_settings, fake_long_path_source_settings, f_console_symbol_short_enable, f_console_symbol_long_enable, " Custom path to the settings source files."); + fll_program_print_help_option(context, fake_short_path_build, fake_long_path_build, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom build directory."); + fll_program_print_help_option(context, fake_short_path_data, fake_long_path_data, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the data files."); + fll_program_print_help_option(context, fake_short_path_sources, fake_long_path_sources, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a custom path to the source files."); + fll_program_print_help_option(context, fake_short_path_work, fake_long_path_work, f_console_symbol_short_enable, f_console_symbol_long_enable, " Use includes/libraries/programs from this directory instead of system."); printf("%c%c", f_string_eol, f_string_eol); @@ -341,6 +336,7 @@ extern "C" { } else { if (data->verbosity != fake_verbosity_quiet) { + fprintf(f_standard_error, "%c", f_string_eol); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify an operation."); fprintf(f_standard_error, "%c", f_string_eol); } @@ -384,13 +380,32 @@ extern "C" { f_macro_string_dynamic_delete_simple(data->path_build_settings); f_macro_string_dynamic_delete_simple(data->path_work); - f_macro_string_dynamic_delete_simple(data->path_source_build); - f_macro_string_dynamic_delete_simple(data->path_source_common); - f_macro_string_dynamic_delete_simple(data->path_source_data); - f_macro_string_dynamic_delete_simple(data->path_source_documents); - f_macro_string_dynamic_delete_simple(data->path_source_codes); - f_macro_string_dynamic_delete_simple(data->path_source_licenses); - f_macro_string_dynamic_delete_simple(data->path_source_settings); + f_macro_string_dynamic_delete_simple(data->path_data); + f_macro_string_dynamic_delete_simple(data->path_data_build); + + f_macro_string_dynamic_delete_simple(data->path_documents); + + f_macro_string_dynamic_delete_simple(data->path_licenses); + + f_macro_string_dynamic_delete_simple(data->path_sources); + f_macro_string_dynamic_delete_simple(data->path_sources_bash); + f_macro_string_dynamic_delete_simple(data->path_sources_c); + f_macro_string_dynamic_delete_simple(data->path_sources_cpp); + + f_macro_string_dynamic_delete_simple(data->path_work); + f_macro_string_dynamic_delete_simple(data->path_work_includes); + f_macro_string_dynamic_delete_simple(data->path_work_libraries); + f_macro_string_dynamic_delete_simple(data->path_work_libraries_script); + f_macro_string_dynamic_delete_simple(data->path_work_libraries_shared); + f_macro_string_dynamic_delete_simple(data->path_work_libraries_static); + f_macro_string_dynamic_delete_simple(data->path_work_programs); + f_macro_string_dynamic_delete_simple(data->path_work_programs_script); + f_macro_string_dynamic_delete_simple(data->path_work_programs_shared); + f_macro_string_dynamic_delete_simple(data->path_work_programs_static); + + f_macro_string_dynamic_delete_simple(data->file_data_build_dependencies); + f_macro_string_dynamic_delete_simple(data->file_data_build_settings); + f_macro_string_dynamic_delete_simple(data->file_documents_readme); fl_macro_color_context_delete_simple(data->context); diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 61a030e..4d29261 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -157,77 +157,74 @@ extern "C" { #endif // _di_fake_default_allocation_step_ /** - * Fake paths are hard-coded paths that are generally generated into a full path based on runtime settings. - * - * For example path_build_documents will become "build/documents/" if the fake_default_path_build is used. + * The build operation utilizes pre-defined path structures. + * These structures are hard-coded by their individual pieces to be constructed later on. */ #ifndef _di_fake_path_ - #define fake_path_documents "documents" f_path_separator - #define fake_path_data "data" f_path_separator - #define fake_path_licenses "licenses" f_path_separator - #define fake_path_sources "sources" f_path_separator - - #define fake_path_documents_length 9 - #define fake_path_data_length 4 - #define fake_path_licenses_length 8 - #define fake_path_sources_length 7 - - #define fake_path_build_documents "documents" f_path_separator - #define fake_path_build_includes "includes" f_path_separator - #define fake_path_build_libraries "libraries" f_path_separator - #define fake_path_build_libraries_script "script" f_path_separator - #define fake_path_build_libraries_shared "shared" f_path_separator - #define fake_path_build_libraries_static "static" f_path_separator - #define fake_path_build_objects "objects" f_path_separator - #define fake_path_build_process "process" f_path_separator - #define fake_path_build_programs "programs" f_path_separator - #define fake_path_build_programs_script "script" f_path_separator - #define fake_path_build_programs_shared "shared" f_path_separator - #define fake_path_build_programs_static "static" f_path_separator - #define fake_path_build_settings "settings" f_path_separator - - #define fake_path_build_documents_length 10 - #define fake_path_build_includes_length 9 - #define fake_path_build_libraries_length 10 - #define fake_path_build_libraries_script_length 6 - #define fake_path_build_libraries_shared_length 6 - #define fake_path_build_libraries_static_length 6 - #define fake_path_build_objects_length 7 - #define fake_path_build_process_length 7 - #define fake_path_build_programs_length 9 - #define fake_path_build_programs_script_length 7 - #define fake_path_build_programs_shared_length 7 - #define fake_path_build_programs_static_length 7 - #define fake_path_build_settings_length 9 - - // these paths are suffixes to be appended onto the work directory, if the work directory is supplied. - #define fake_path_work_includes "includes" f_path_separator - #define fake_path_work_libraries "libraries" f_path_separator - #define fake_path_work_libraries_script "libraries" f_path_separator "script" f_path_separator - #define fake_path_work_libraries_shared "libraries" f_path_separator "shared" f_path_separator - #define fake_path_work_libraries_static "libraries" f_path_separator "static" f_path_separator - #define fake_path_work_programs "programs" f_path_separator - #define fake_path_work_programs_script "programs" f_path_separator "script" f_path_separator - #define fake_path_work_programs_shared "programs" f_path_separator "shared" f_path_separator - #define fake_path_work_programs_static "programs" f_path_separator "static" f_path_separator - - #define fake_path_work_includes_length 9 - #define fake_path_work_libraries_length 10 - #define fake_path_work_libraries_script_length 17 - #define fake_path_work_libraries_shared_length 17 - #define fake_path_work_libraries_static_length 17 - #define fake_path_work_programs_length 9 - #define fake_path_work_programs_script_length 16 - #define fake_path_work_programs_shared_length 16 - #define fake_path_work_programs_static_length 16 + #define fake_path_part_bash "bash" f_path_separator + #define fake_path_part_build "build" f_path_separator + #define fake_path_part_c "c" f_path_separator + #define fake_path_part_cpp "c++" f_path_separator + #define fake_path_part_data "data" f_path_separator + #define fake_path_part_documents "documents" f_path_separator + #define fake_path_part_includes "includes" f_path_separator + #define fake_path_part_libraries "libraries" f_path_separator + #define fake_path_part_licenses "licenses" f_path_separator + #define fake_path_part_objects "objects" f_path_separator + #define fake_path_part_process "process" f_path_separator + #define fake_path_part_programs "programs" f_path_separator + #define fake_path_part_script "script" f_path_separator + #define fake_path_part_settings "settings" f_path_separator + #define fake_path_part_shared "shared" f_path_separator + #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) #endif // _di_fake_path_ +#ifndef _di_fake_file_ + #define fake_file_dependencies "dependencies" + #define fake_file_process_post "process_post.sh" + #define fake_file_process_pre "process_pre.sh" + #define fake_file_readme "readme" + #define fake_file_settings "settings" + + #define fake_file_dependencies_length 12 + #define fake_file_process_post_length 15 + #define fake_file_process_pre_length 14 + #define fake_file_readme_length 6 + #define fake_file_settings_length 8 +#endif // _di_fake_file_ + +/** + * Provide default settings. + */ #ifndef _di_fake_defaults_ - #define fake_default_path_build "build" f_path_separator - #define fake_default_path_work "" + #define fake_default_path_build "build" f_path_separator + #define fake_default_path_data "data" f_path_separator + #define fake_default_path_sources "sources" f_path_separator + #define fake_default_path_work "" - #define fake_default_path_build_length 6 - #define fake_default_path_work_length 0 + #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_work_length 0 #define fake_default_defines "" #define fake_default_mode "" @@ -238,30 +235,6 @@ extern "C" { #define fake_default_mode_length 0 #define fake_default_process_length 0 #define fake_default_settings_length 8 - - #define fake_default_path_source_build "data" f_path_separator "build" f_path_separator - #define fake_default_path_source_codes "sources" f_path_separator - #define fake_default_path_source_common "data" f_path_separator "common" f_path_separator - #define fake_default_path_source_data "data" f_path_separator - #define fake_default_path_source_documents "data" f_path_separator "documents" f_path_separator - #define fake_default_path_source_licenses "licenses" f_path_separator - #define fake_default_path_source_settings "data" f_path_separator "build" f_path_separator - - #define fake_default_path_source_build_length 11 - #define fake_default_path_source_codes_length 8 - #define fake_default_path_source_common_length 12 - #define fake_default_path_source_data_length 5 - #define fake_default_path_source_documents_length 15 - #define fake_default_path_source_licenses_length 9 - #define fake_default_path_source_settings_length 11 - - #define fake_default_language_bash "bash" f_path_separator - #define fake_default_language_c "c" f_path_separator - #define fake_default_language_cpp "c++" f_path_separator - - #define fake_default_language_bash_length 5 - #define fake_default_language_c_length 2 - #define fake_default_language_cpp_length 4 #endif // _di_fake_defaults_ #ifndef _di_fake_build_language_ @@ -314,27 +287,15 @@ extern "C" { #define fake_file_extension_built_length 6 #define fake_file_extension_building_length 9 - #define fake_short_path_build "b" - #define fake_short_path_work "w" - - #define fake_short_path_build_length 1 - #define fake_short_path_work_length 1 - - #define fake_short_path_source_build "B" - #define fake_short_path_source_common "O" - #define fake_short_path_source_data "D" - #define fake_short_path_source_documents "M" - #define fake_short_path_source_codes "C" - #define fake_short_path_source_licenses "L" - #define fake_short_path_source_settings "S" + #define fake_short_path_build "b" + #define fake_short_path_data "D" + #define fake_short_path_sources "S" + #define fake_short_path_work "w" - #define fake_short_path_source_build_length 1 - #define fake_short_path_source_common_length 1 - #define fake_short_path_source_data_length 1 - #define fake_short_path_source_documents_length 1 - #define fake_short_path_source_codes_length 1 - #define fake_short_path_source_licenses_length 1 - #define fake_short_path_source_settings_length 1 + #define fake_short_path_build_length 1 + #define fake_short_path_data_length 1 + #define fake_short_path_sources_length 1 + #define fake_short_path_work_length 1 #define fake_long_defines "defines" #define fake_long_mode "mode" @@ -346,27 +307,15 @@ extern "C" { #define fake_long_process_length 7 #define fake_long_settings_length 8 - #define fake_long_path_build "build" - #define fake_long_path_work "work" + #define fake_long_path_build "build" + #define fake_long_path_data "data" + #define fake_long_path_sources "sources" + #define fake_long_path_work "work" - #define fake_long_path_build_length 5 - #define fake_long_path_work_length 4 - - #define fake_long_path_source_build "source_build" - #define fake_long_path_source_common "source_common" - #define fake_long_path_source_data "source_data" - #define fake_long_path_source_documents "source_documents" - #define fake_long_path_source_codes "source_codes" - #define fake_long_path_source_licenses "source_licenses" - #define fake_long_path_source_settings "source_settings" - - #define fake_long_path_source_build_length 12 - #define fake_long_path_source_common_length 13 - #define fake_long_path_source_data_length 11 - #define fake_long_path_source_documents_length 16 - #define fake_long_path_source_codes_length 12 - #define fake_long_path_source_licenses_length 15 - #define fake_long_path_source_settings_length 15 + #define fake_long_path_build_length 5 + #define fake_long_path_data_length 4 + #define fake_long_path_sources_length 7 + #define fake_long_path_work_length 4 // these special parameters are provided in such a way that they mimic the traditional ./configure script. #define fake_long_documents_disabled "disable-doc" @@ -409,16 +358,10 @@ extern "C" { fake_parameter_settings, fake_parameter_path_build, + fake_parameter_path_data, + fake_parameter_path_sources, fake_parameter_path_work, - fake_parameter_path_source_build, - fake_parameter_path_source_common, - fake_parameter_path_source_data, - fake_parameter_path_source_documents, - fake_parameter_path_source_codes, - fake_parameter_path_source_licenses, - fake_parameter_path_source_settings, - fake_parameter_documents_disabled, fake_parameter_documents_enabled, fake_parameter_shared_disabled, @@ -447,14 +390,9 @@ extern "C" { f_console_parameter_initialize(fake_short_process, fake_long_process, 0, 1, f_console_type_normal), \ f_console_parameter_initialize(fake_short_settings, fake_long_settings, 0, 1, f_console_type_normal), \ f_console_parameter_initialize(fake_short_path_build, fake_long_path_build, 0, 1, f_console_type_normal), \ + f_console_parameter_initialize(fake_short_path_data, fake_long_path_data, 0, 1, f_console_type_normal), \ + f_console_parameter_initialize(fake_short_path_sources, fake_long_path_sources, 0, 1, f_console_type_normal), \ f_console_parameter_initialize(fake_short_path_work, fake_long_path_work, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_build, fake_long_path_source_build, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_common, fake_long_path_source_common, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_data, fake_long_path_source_data, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_documents, fake_long_path_source_documents, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_codes, fake_long_path_source_codes, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_licenses, fake_long_path_source_licenses, 0, 1, f_console_type_normal), \ - f_console_parameter_initialize(fake_short_path_source_settings, fake_long_path_source_settings, 0, 1, f_console_type_normal), \ f_console_parameter_initialize(0, fake_long_documents_disabled, 0, 0, f_console_type_normal), \ f_console_parameter_initialize(0, fake_long_documents_enabled, 0, 0, f_console_type_normal), \ f_console_parameter_initialize(0, fake_long_shared_disabled, 0, 0, f_console_type_normal), \ @@ -467,7 +405,7 @@ extern "C" { f_console_parameter_initialize(0, 0, fake_other_operation_skeleton, 0, f_console_type_other), \ } - #define fake_total_parameters 31 + #define fake_total_parameters 26 #endif // _di_fake_defines_ #ifndef _di_fake_data_ @@ -499,15 +437,33 @@ extern "C" { f_string_dynamic path_build_programs_shared; f_string_dynamic path_build_programs_static; f_string_dynamic path_build_settings; - f_string_dynamic path_work; - f_string_dynamic path_source_build; - f_string_dynamic path_source_common; - f_string_dynamic path_source_data; - f_string_dynamic path_source_documents; - f_string_dynamic path_source_codes; - f_string_dynamic path_source_licenses; - f_string_dynamic path_source_settings; + f_string_dynamic path_data; + f_string_dynamic path_data_build; + + f_string_dynamic path_documents; + + f_string_dynamic path_licenses; + + f_string_dynamic path_sources; + f_string_dynamic path_sources_bash; + f_string_dynamic path_sources_c; + f_string_dynamic path_sources_cpp; + + f_string_dynamic path_work; + f_string_dynamic path_work_includes; + f_string_dynamic path_work_libraries; + f_string_dynamic path_work_libraries_script; + f_string_dynamic path_work_libraries_shared; + f_string_dynamic path_work_libraries_static; + f_string_dynamic path_work_programs; + f_string_dynamic path_work_programs_script; + f_string_dynamic path_work_programs_shared; + f_string_dynamic path_work_programs_static; + + f_string_dynamic file_data_build_dependencies; + f_string_dynamic file_data_build_settings; + f_string_dynamic file_documents_readme; fl_color_context context; } fake_data; @@ -545,6 +501,19 @@ extern "C" { f_string_dynamic_initialize, \ f_string_dynamic_initialize, \ f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ + f_string_dynamic_initialize, \ fl_color_context_initialize, \ } #endif // _di_fake_data_ diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 42e026a..2b7a1ab 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -11,97 +11,6 @@ extern "C" { if (process_script.used == 0) return f_none; f_status status = f_none; - - const f_string parameter_prefixs[] = { - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - f_console_symbol_short_enable, - }; - - const f_string_length parameter_prefixs_length[] = { - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - f_console_symbol_short_enable_length, - }; - - const f_string parameter_names[] = { - fake_short_defines, - fake_short_process, - fake_short_settings, - fake_short_path_build, - fake_short_path_work, - fake_short_path_source_build, - fake_short_path_source_common, - fake_short_path_source_data, - fake_short_path_source_documents, - fake_short_path_source_codes, - fake_short_path_source_licenses, - fake_short_path_source_settings, - }; - - const f_string_length parameter_names_length[] = { - fake_short_defines_length, - fake_short_process_length, - fake_short_settings_length, - fake_short_path_build_length, - fake_short_path_work_length, - fake_short_path_source_build_length, - fake_short_path_source_common_length, - fake_short_path_source_data_length, - fake_short_path_source_documents_length, - fake_short_path_source_codes_length, - fake_short_path_source_licenses_length, - fake_short_path_source_settings_length, - }; - - const f_string parameter_values[] = { - data.defines.string, - data.process.string, - data.settings.string, - data.path_build.string, - data.path_work.string, - data.path_source_build.string, - data.path_source_common.string, - data.path_source_data.string, - data.path_source_documents.string, - data.path_source_codes.string, - data.path_source_licenses.string, - data.path_source_settings.string, - }; - - const f_string_length parameter_values_length[] = { - data.defines.used, - data.process.used, - data.settings.used, - data.path_build.used, - data.path_work.used, - data.path_source_build.used, - data.path_source_common.used, - data.path_source_data.used, - data.path_source_documents.used, - data.path_source_codes.used, - data.path_source_licenses.used, - data.path_source_settings.used, - }; - f_string_dynamics arguments = f_string_dynamics_initialize; status = fll_execute_arguments_add(fake_other_operation_build, fake_other_operation_build_length, &arguments); @@ -147,30 +56,101 @@ extern "C" { return status; } - status = fll_execute_arguments_add_parameter_set(parameter_prefixs, parameter_prefixs_length, parameter_names, parameter_names_length, parameter_values, parameter_values_length, 12, &arguments); + { + const f_string parameters_prefix[] = { + f_console_symbol_short_enable, + f_console_symbol_short_enable, + f_console_symbol_short_enable, + f_console_symbol_short_enable, + f_console_symbol_short_enable, + f_console_symbol_short_enable, + f_console_symbol_short_enable, + }; + + const f_string_length parameters_prefix_length[] = { + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + f_console_symbol_short_enable_length, + }; + + const f_string parameters_name[] = { + fake_short_defines, + fake_short_process, + fake_short_settings, + fake_short_path_build, + fake_short_path_data, + fake_short_path_sources, + fake_short_path_work, + }; + + const f_string_length parameters_name_length[] = { + fake_short_defines_length, + fake_short_process_length, + fake_short_settings_length, + fake_short_path_build_length, + fake_short_path_data_length, + fake_short_path_sources_length, + fake_short_path_work_length, + }; + + const f_string parameters_value[] = { + data.defines.string, + data.process.string, + data.settings.string, + data.path_build.string, + data.path_data.string, + data.path_sources.string, + data.path_work.string, + }; + + const f_string_length parameters_value_length[] = { + data.defines.used, + data.process.used, + data.settings.used, + data.path_build.used, + data.path_data.used, + data.path_sources.used, + data.path_work.used, + }; + + status = fll_execute_arguments_add_parameter_set(parameters_prefix, parameters_prefix_length, parameters_name, parameters_name_length, parameters_value, parameters_value_length, 7, &arguments); - if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_arguments_add_parameter_set", f_true); + if (f_status_is_error(status)) { + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_arguments_add_parameter_set", f_true); - f_macro_string_dynamics_delete_simple(arguments); - return status; + f_macro_string_dynamics_delete_simple(arguments); + return status; + } } f_string_dynamic path = f_string_dynamic_initialize; - if (process_script.string[0] != '/') { - status = fl_string_dynamic_append(data.path_source_settings, &path); - } + { + f_string function = "fl_string_dynamic_append_nulless"; - if (!f_status_is_error(status)) { - status = fl_string_dynamic_append(process_script, &path); - } + if (process_script.string[0] != '/') { + status = fl_string_dynamic_append_nulless(data.path_data_build, &path); + } - if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_append", f_true); + if (!f_status_is_error(status)) { + status = fl_string_dynamic_append_nulless(process_script, &path); + } - f_macro_string_dynamic_delete_simple(path); - return status; + if (!f_status_is_error(status)) { + function = "fl_string_dynamic_terminate"; + status = fl_string_dynamic_terminate(&path); + } + + if (f_status_is_error(status)) { + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), function, f_true); + + f_macro_string_dynamic_delete_simple(path); + return status; + } } int results = 0; @@ -187,7 +167,7 @@ extern "C" { } } else { - fake_print_error(data.context, data.verbosity != fake_verbosity_quiet, 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", f_true); } } @@ -207,7 +187,7 @@ extern "C" { if (f_status_is_error(status)) { fake_macro_build_settings_delete_simple(settings); - return f_status_set_error(status); + return status; } status = fake_build_execute_process_script(data, settings, settings.process_pre); @@ -242,30 +222,16 @@ extern "C" { f_status status = f_none; f_file file = f_file_initialize; f_string_dynamic buffer = f_string_dynamic_initialize; - f_string_dynamic path = f_string_dynamic_initialize; - - status = fl_string_dynamic_append(data.path_source_settings, &path); - - if (!f_status_is_error(status)) { - status = fl_string_dynamic_append(data.settings, &path); - } - - if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_append", f_true); - - f_macro_string_dynamic_delete_simple(path); - return status; - } { f_string name_function = f_string_initialize; name_function = "f_file_exists"; - status = f_file_exists(path.string); + status = f_file_exists(data.file_data_build_settings.string); if (status == f_true) { name_function = "f_file_open"; - status = f_file_open(&file, path.string); + status = f_file_open(&file, data.file_data_build_settings.string); if (status == f_none) { name_function = "fl_file_read_position"; @@ -279,10 +245,9 @@ extern "C" { } if (f_status_is_error(status)) { - fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), name_function, path.string, f_true, f_true); + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), name_function, data.file_data_build_settings.string, "create", f_true, f_true); f_macro_string_dynamic_delete_simple(buffer); - f_macro_string_dynamic_delete_simple(path); return status; } } @@ -308,7 +273,7 @@ extern "C" { fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); } } @@ -318,7 +283,7 @@ extern "C" { fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings.string); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); } } @@ -329,7 +294,6 @@ extern "C" { f_macro_fss_objects_delete_simple(objects); f_macro_fss_contents_delete_simple(contents); f_macro_string_dynamic_delete_simple(buffer); - f_macro_string_dynamic_delete_simple(path); return status; } @@ -479,7 +443,6 @@ extern "C" { f_macro_fss_objects_delete_simple(objects); f_macro_fss_contents_delete_simple(contents); f_macro_string_dynamic_delete_simple(buffer); - f_macro_string_dynamic_delete_simple(path); return status; } } @@ -489,7 +452,7 @@ extern "C" { if (data.verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: a setting in the build settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", data.file_data_build_settings); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); } } @@ -504,7 +467,6 @@ extern "C" { } f_macro_string_dynamic_delete_simple(buffer); - f_macro_string_dynamic_delete_simple(path); // @todo: perform validation of values, such as "shared" and "static", at least one must be "yes". diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 31f799f..93aa2c1 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -8,31 +8,22 @@ extern "C" { #ifndef _di_fake_path_generate_ f_return_status fake_path_generate(fake_data *data) { f_status status = f_none; - f_string function = "fl_string_dynamic_append"; uint8_t i = 0; { - const f_string parameter_strings[] = { - fake_path_build_documents, - fake_path_build_includes, - fake_path_build_libraries, - fake_path_build_objects, - fake_path_build_process, - fake_path_build_programs, - fake_path_build_settings, - }; - - const f_string_length parameter_strings_lengths[] = { - fake_path_build_documents_length, - fake_path_build_includes_length, - fake_path_build_libraries_length, - fake_path_build_objects_length, - fake_path_build_process_length, - fake_path_build_programs_length, - fake_path_build_settings_length, - }; - - f_string_dynamic *parameter_values[] = { + const f_string_dynamic *parameters_source[] = { + &data->path_build, + &data->path_data, + &data->path_sources, + }; + + const uint8_t parameters_length[] = { + 7, + 1, + 3, + }; + + f_string_dynamic *parameters_value_0[] = { &data->path_build_documents, &data->path_build_includes, &data->path_build_libraries, @@ -42,116 +33,378 @@ extern "C" { &data->path_build_settings, }; - for (i = 0; i < 7; i++) { - status = fl_string_dynamic_append_nulless(data->path_build, parameter_values[i]); - if (f_status_is_error(status)) break; + f_string_dynamic *parameters_value_1[] = { + &data->path_data_build, + }; + + f_string_dynamic *parameters_value_2[] = { + &data->path_sources_bash, + &data->path_sources_c, + &data->path_sources_cpp, + }; - status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]); - if (f_status_is_error(status)) break; + f_string_dynamic **parameters_value[] = { + parameters_value_0, + parameters_value_1, + parameters_value_2, + }; + + for (i = 0; i < 3; i++) { + status = fake_path_generate_string_dynamic(data, *parameters_source[i], parameters_value[i], parameters_length[i]); - status = fl_string_append_assure("/", 1, parameter_values[i]); if (f_status_is_error(status)) { - function = "fl_string_append_assure"; - break; + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fake_path_generate_string_dynamic", f_true); + return status; } + } // for + } + + { + const f_string parameters_source[] = { + fake_path_part_documents, + fake_path_part_includes, + fake_path_part_libraries, + fake_path_part_objects, + fake_path_part_process, + fake_path_part_programs, + fake_path_part_settings, + fake_path_part_build, + fake_path_part_documents, + fake_path_part_licenses, + fake_path_part_bash, + fake_path_part_c, + fake_path_part_cpp, + }; + + const f_string_length parameters_length[] = { + fake_path_part_documents_length, + fake_path_part_includes_length, + fake_path_part_libraries_length, + fake_path_part_objects_length, + fake_path_part_process_length, + fake_path_part_programs_length, + fake_path_part_settings_length, + fake_path_part_build_length, + fake_path_part_documents_length, + fake_path_part_licenses_length, + fake_path_part_bash_length, + fake_path_part_c_length, + fake_path_part_cpp_length, + }; + + f_string_dynamic *parameters_value[] = { + &data->path_build_documents, + &data->path_build_includes, + &data->path_build_libraries, + &data->path_build_objects, + &data->path_build_process, + &data->path_build_programs, + &data->path_build_settings, + &data->path_data_build, + &data->path_documents, + &data->path_licenses, + &data->path_sources_bash, + &data->path_sources_c, + &data->path_sources_cpp, + }; + + for (i = 0; i < 13; i++) { + status = fl_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); - status = fl_string_dynamic_terminate(parameter_values[i]); if (f_status_is_error(status)) { - function = "fl_string_dynamic_terminate"; - break; + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_append_nulless", f_true); + return status; } } // for } - if (!f_status_is_error(status)) { - const f_string parameter_strings[] = { - fake_path_build_libraries_script, - fake_path_build_libraries_shared, - fake_path_build_libraries_static, + { + const f_string_dynamic *parameters_source[] = { + &data->path_build_libraries, + &data->path_build_programs, + &data->path_data_build, + &data->path_documents, }; - const f_string_length parameter_strings_lengths[] = { - fake_path_build_libraries_script_length, - fake_path_build_libraries_shared_length, - fake_path_build_libraries_static_length, + const uint8_t parameters_length[] = { + 3, + 3, + 2, + 1, }; - f_string_dynamic *parameter_values[] = { + f_string_dynamic *parameters_value_0[] = { &data->path_build_libraries_script, &data->path_build_libraries_shared, &data->path_build_libraries_static, }; - for (i = 0; i < 3; i++) { - status = fl_string_dynamic_append_nulless(data->path_build_libraries, parameter_values[i]); - if (f_status_is_error(status)) break; + f_string_dynamic *parameters_value_1[] = { + &data->path_build_programs_script, + &data->path_build_programs_shared, + &data->path_build_programs_static, + }; - status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]); - if (f_status_is_error(status)) break; + f_string_dynamic *parameters_value_2[] = { + &data->file_data_build_dependencies, + &data->file_data_build_settings, + }; - status = fl_string_append_assure("/", 1, parameter_values[i]); - if (f_status_is_error(status)) { - function = "fl_string_append_assure"; - break; - } + f_string_dynamic *parameters_value_3[] = { + &data->file_documents_readme, + }; + + f_string_dynamic **parameters_value[] = { + parameters_value_0, + parameters_value_1, + parameters_value_2, + parameters_value_3, + }; + + for (i = 0; i < 4; i++) { + status = fake_path_generate_string_dynamic(data, *parameters_source[i], parameters_value[i], parameters_length[i]); - status = fl_string_dynamic_terminate(parameter_values[i]); if (f_status_is_error(status)) { - function = "fl_string_dynamic_terminate"; - break; + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fake_path_generate_string_dynamic", f_true); + return status; } } // for } { - const f_string parameter_strings[] = { - fake_path_build_programs_script, - fake_path_build_programs_shared, - fake_path_build_programs_static, + const f_string parameters_source[] = { + fake_path_part_script, + fake_path_part_shared, + fake_path_part_static, + fake_path_part_script, + fake_path_part_shared, + fake_path_part_static, + fake_file_dependencies, + fake_file_settings, + fake_file_readme, }; - const f_string_length parameter_strings_lengths[] = { - fake_path_build_programs_script_length, - fake_path_build_programs_shared_length, - fake_path_build_programs_static_length, + const f_string_length parameters_length[] = { + fake_path_part_script_length, + fake_path_part_shared_length, + fake_path_part_static_length, + fake_path_part_script_length, + fake_path_part_shared_length, + fake_path_part_static_length, + fake_file_dependencies_length, + fake_file_settings_length, + fake_file_readme_length, }; - f_string_dynamic *parameter_values[] = { + f_string_dynamic *parameters_value[] = { + &data->path_build_libraries_script, + &data->path_build_libraries_shared, + &data->path_build_libraries_static, &data->path_build_programs_script, &data->path_build_programs_shared, &data->path_build_programs_static, + &data->file_data_build_dependencies, + &data->file_data_build_settings, + &data->file_documents_readme, }; - for (i = 0; i < 3; i++) { - status = fl_string_dynamic_append_nulless(data->path_build_programs, parameter_values[i]); - if (f_status_is_error(status)) break; - - status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]); - if (f_status_is_error(status)) break; + for (i = 0; i < 9; i++) { + status = fl_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); - status = fl_string_append_assure("/", 1, parameter_values[i]); if (f_status_is_error(status)) { - function = "fl_string_append_assure"; - break; + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_append_nulless", f_true); + return status; } + } // for + } + + if (data->path_work.used > 0) { + { + f_string_dynamic *parameters_value[] = { + &data->path_work_includes, + &data->path_work_libraries, + &data->path_work_programs, + }; + + for (i = 0; i < 3; i++) { + status = fl_string_dynamic_append_nulless(data->path_work, parameters_value[i]); + + if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_dynamic_append_nulless", f_true); + return status; + } + } // for + } + + { + const f_string parameters_source[] = { + fake_path_part_includes, + fake_path_part_libraries, + fake_path_part_programs, + }; + + const f_string_length parameters_length[] = { + fake_path_part_includes_length, + fake_path_part_libraries_length, + fake_path_part_programs_length, + }; + + f_string_dynamic *parameters_value[] = { + &data->path_work_includes, + &data->path_work_libraries, + &data->path_work_programs, + }; + + for (i = 0; i < 3; i++) { + status = fl_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); + + if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_append_nulless", f_true); + return status; + } + } // for + } + + { + const f_string_dynamic *parameters_source[] = { + &data->path_work_libraries, + &data->path_work_programs, + }; + + const uint8_t parameters_length[] = { + 3, + 3, + }; + + f_string_dynamic *parameters_value_0[] = { + &data->path_work_libraries_script, + &data->path_work_libraries_shared, + &data->path_work_libraries_static, + }; + + f_string_dynamic *parameters_value_1[] = { + &data->path_work_programs_script, + &data->path_work_programs_shared, + &data->path_work_programs_static, + }; + + f_string_dynamic **parameters_value[] = { + parameters_value_0, + parameters_value_1, + }; + + for (i = 0; i < 2; i++) { + status = fake_path_generate_string_dynamic(data, *parameters_source[i], parameters_value[i], parameters_length[i]); + + if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fake_path_generate_string_dynamic", f_true); + return status; + } + } // for + } + + { + const f_string parameters_source[] = { + fake_path_part_script, + fake_path_part_shared, + fake_path_part_static, + fake_path_part_script, + fake_path_part_shared, + fake_path_part_static, + }; + + const f_string_length parameters_length[] = { + fake_path_part_script_length, + fake_path_part_shared_length, + fake_path_part_static_length, + fake_path_part_script_length, + fake_path_part_shared_length, + fake_path_part_static_length, + }; + + f_string_dynamic *parameters_value[] = { + &data->path_work_libraries_script, + &data->path_work_libraries_shared, + &data->path_work_libraries_static, + &data->path_work_programs_script, + &data->path_work_programs_shared, + &data->path_work_programs_static, + }; + + for (i = 0; i < 6; i++) { + status = fl_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); + + if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_append_nulless", f_true); + return status; + } + } // for + } + } + + { + f_string_dynamic *parameters_value[] = { + &data->path_build_documents, + &data->path_build_includes, + &data->path_build_libraries, + &data->path_build_libraries_script, + &data->path_build_libraries_shared, + &data->path_build_libraries_static, + &data->path_build_objects, + &data->path_build_process, + &data->path_build_programs, + &data->path_build_programs_script, + &data->path_build_programs_shared, + &data->path_build_programs_static, + &data->path_build_settings, + &data->path_data_build, + &data->path_licenses, + &data->path_sources_bash, + &data->path_sources_c, + &data->path_sources_cpp, + &data->path_work_includes, + &data->path_work_libraries, + &data->path_work_libraries_script, + &data->path_work_libraries_shared, + &data->path_work_libraries_static, + &data->path_work_programs, + &data->path_work_programs_script, + &data->path_work_programs_shared, + &data->path_work_programs_static, + &data->file_data_build_dependencies, + &data->file_data_build_settings, + &data->file_documents_readme, + }; + + for (i = 0; i < 30; i++) { + if (parameters_value[i]->used == 0) continue; + + status = fl_string_dynamic_terminate(parameters_value[i]); - status = fl_string_dynamic_terminate(parameter_values[i]); if (f_status_is_error(status)) { - function = "fl_string_dynamic_terminate"; - break; + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_dynamic_terminate", f_true); + return status; } } // for } - if (f_status_is_error(status)) { - fake_print_error(data->context, data->verbosity, f_status_set_fine(status), function, f_true); - return status; - } - return f_none; } #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_status status = f_none; + + for (uint8_t i = 0; i < length; i++) { + status = fl_string_dynamic_append_nulless(source, value[i]); + if (f_status_is_error(status)) return status; + } // for + + return f_none; + } +#endif // _di_fake_path_generate_string_dynamic_ + #ifndef _di_fake_print_error_ f_return_status fake_print_error(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const bool fallback) { @@ -191,7 +444,7 @@ extern "C" { #endif // _di_fake_print_error_ #ifndef _di_fake_print_error_file_ - f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string name, const bool is_file, const bool fallback) { + f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) { f_string file_or_directory = 0; if (is_file) file_or_directory = "file"; @@ -235,7 +488,7 @@ extern "C" { if (status == f_out_of_memory) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -246,7 +499,7 @@ extern "C" { if (status == f_number_overflow) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -257,7 +510,7 @@ extern "C" { if (status == f_invalid_directory) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -268,7 +521,7 @@ extern "C" { if (status == f_access_denied) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -279,7 +532,7 @@ extern "C" { if (status == f_loop) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -288,25 +541,24 @@ extern "C" { } if (is_file) { - } - else { if (status == f_directory_not_found) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print_line(f_standard_error, context.error, context.reset, "' due to an invalid directory in the path."); } return f_none; } - - if (status == f_no_data) { + } + else { + if (status == f_directory_not_found) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: could not find %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + fl_color_print_line(f_standard_error, context.error, context.reset, "' due to an invalid directory in the path."); } return f_none; @@ -315,7 +567,7 @@ extern "C" { if (status == f_failure) { if (verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to read the %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -328,7 +580,7 @@ extern "C" { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); - fl_color_print(f_standard_error, context.error, context.reset, ") occurred for %s '", file_or_directory); + fl_color_print(f_standard_error, context.error, context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); fl_color_print(f_standard_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_standard_error, context.error, context.reset, "'."); } @@ -366,14 +618,14 @@ extern "C" { // @todo move as many of the inline error printing code into more general functions where possible to provide more accurate error reporting. { - const uint8_t parameter_ids[] = { + const uint8_t parameters_id[] = { fake_parameter_operation_build, fake_parameter_operation_clean, fake_parameter_operation_make, fake_parameter_operation_skeleton, }; - const f_string parameter_names[] = { + const f_string parameters_name[] = { fake_other_operation_build, fake_other_operation_clean, fake_other_operation_make, @@ -381,11 +633,11 @@ extern "C" { }; for (uint8_t i = 0; i < 4; i++) { - if (data->parameters[parameter_ids[i]].total > 1) { + if (data->parameters[parameters_id[i]].total > 1) { if (data->verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", parameter_names[i]); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", parameters_name[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' specified too many times."); } @@ -395,12 +647,12 @@ extern "C" { } { - const uint8_t parameter_ids[] = { + const uint8_t parameters_id[] = { fake_parameter_process, fake_parameter_settings, }; - const f_string parameter_names[] = { + const f_string parameters_name[] = { fake_long_process, fake_long_settings, }; @@ -415,34 +667,34 @@ extern "C" { fake_default_settings_length, }; - f_string_dynamic *parameter_values[] = { + f_string_dynamic *parameters_value[] = { &data->process, &data->settings, }; for (uint8_t i = 0; i < 2; i++) { - if (data->parameters[parameter_ids[i]].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, data->verbosity, parameter_names[i]); + if (data->parameters[parameters_id[i]].result == f_console_result_found) { + fake_print_error_parameter_missing_value(data->context, data->verbosity, parameters_name[i]); return f_status_set_error(f_invalid_parameter); } - else if (data->parameters[parameter_ids[i]].result == f_console_result_additional) { - if (data->parameters[parameter_ids[i]].total > 1) { - fake_print_error_parameter_too_many(data->context, data->verbosity, parameter_names[i]); + else if (data->parameters[parameters_id[i]].result == f_console_result_additional) { + if (data->parameters[parameters_id[i]].total > 1) { + fake_print_error_parameter_too_many(data->context, data->verbosity, parameters_name[i]); return f_status_set_error(f_invalid_parameter); } - f_string_length location = data->parameters[parameter_ids[i]].additional.array[0]; + f_string_length location = data->parameters[parameters_id[i]].additional.array[0]; f_string_length length = strnlen(arguments.argv[location], f_console_max_size); if (length > 0) { - status = fl_string_append(arguments.argv[location], length, parameter_values[i]); + status = fl_string_append(arguments.argv[location], length, parameters_value[i]); if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { if (data->verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); } } @@ -461,21 +713,21 @@ extern "C" { if (data->verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' must not be empty and must not contain only whitespace."); } } } else if (parameter_default_lengths[i] > 0) { - f_macro_string_dynamic_resize(status, (*parameter_values[i]), parameter_default_lengths[i]); + f_macro_string_dynamic_resize(status, (*parameters_value[i]), parameter_default_lengths[i]); if (f_status_is_error(status)) { fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_macro_string_dynamic_resize", f_true); return status; } - memcpy(parameter_values[i]->string, parameter_defaults[i], parameter_default_lengths[i]); - parameter_values[i]->used = parameter_default_lengths[i]; + memcpy(parameters_value[i]->string, parameter_defaults[i], parameter_default_lengths[i]); + parameters_value[i]->used = parameter_default_lengths[i]; } } // for } @@ -486,84 +738,59 @@ extern "C" { } { - const uint8_t parameter_ids[] = { + const uint8_t parameters_id[] = { fake_parameter_path_build, - fake_parameter_path_source_build, - fake_parameter_path_source_codes, - fake_parameter_path_source_common, - fake_parameter_path_source_data, - fake_parameter_path_source_documents, - fake_parameter_path_source_licenses, - fake_parameter_path_source_settings, + fake_parameter_path_data, + fake_parameter_path_sources, fake_parameter_path_work, }; - const f_string parameter_names[] = { + const f_string parameters_name[] = { fake_long_path_build, - fake_long_path_source_build, - fake_long_path_source_codes, - fake_long_path_source_common, - fake_long_path_source_data, - fake_long_path_source_documents, - fake_long_path_source_licenses, - fake_long_path_source_settings, + fake_long_path_data, + fake_long_path_sources, fake_long_path_work, }; const f_string parameter_defaults[] = { fake_default_path_build, - fake_default_path_source_build, - fake_default_path_source_codes, - fake_default_path_source_common, - fake_default_path_source_data, - fake_default_path_source_documents, - fake_default_path_source_licenses, - fake_default_path_source_settings, + fake_default_path_data, + fake_default_path_sources, fake_default_path_work, }; const f_string_length parameter_default_lengths[] = { fake_default_path_build_length, - fake_default_path_source_build_length, - fake_default_path_source_codes_length, - fake_default_path_source_common_length, - fake_default_path_source_data_length, - fake_default_path_source_documents_length, - fake_default_path_source_licenses_length, - fake_default_path_source_settings_length, + fake_default_path_data_length, + fake_default_path_sources_length, fake_default_path_work_length, }; - f_string_dynamic *parameter_values[] = { + f_string_dynamic *parameters_value[] = { &data->path_build, - &data->path_source_build, - &data->path_source_codes, - &data->path_source_common, - &data->path_source_data, - &data->path_source_documents, - &data->path_source_licenses, - &data->path_source_settings, + &data->path_data, + &data->path_sources, &data->path_work, }; - for (uint8_t i = 0; i < 9; i++) { - if (data->parameters[parameter_ids[i]].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, data->verbosity, parameter_names[i]); + for (uint8_t i = 0; i < 4; i++) { + if (data->parameters[parameters_id[i]].result == f_console_result_found) { + fake_print_error_parameter_missing_value(data->context, data->verbosity, parameters_name[i]); return f_status_set_error(f_invalid_parameter); } - else if (data->parameters[parameter_ids[i]].result == f_console_result_additional) { - if (data->parameters[parameter_ids[i]].additional.used > 1) { - fake_print_error_parameter_too_many(data->context, data->verbosity, parameter_names[i]); + else if (data->parameters[parameters_id[i]].result == f_console_result_additional) { + if (data->parameters[parameters_id[i]].additional.used > 1) { + fake_print_error_parameter_too_many(data->context, data->verbosity, parameters_name[i]); return f_status_set_error(f_invalid_parameter); } - status = fl_console_parameter_to_string_dynamic_directory(arguments.argv[data->parameters[parameter_ids[i]].additional.array[0]], parameter_values[i]); + status = fl_console_parameter_to_string_dynamic_directory(arguments.argv[data->parameters[parameters_id[i]].additional.array[0]], parameters_value[i]); if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); } @@ -571,21 +798,21 @@ extern "C" { } } else if (parameter_default_lengths[i] > 0) { - f_macro_string_dynamic_new(status, (*parameter_values[i]), parameter_default_lengths[i]); + f_macro_string_dynamic_new(status, (*parameters_value[i]), parameter_default_lengths[i]); if (f_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_macro_string_dynamic_new", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to load default for the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); } return status; } - memcpy(parameter_values[i]->string, parameter_defaults[i], parameter_default_lengths[i]); - parameter_values[i]->used = parameter_default_lengths[i]; + memcpy(parameters_value[i]->string, parameter_defaults[i], parameter_default_lengths[i]); + parameters_value[i]->used = parameter_default_lengths[i]; } } // for } @@ -671,92 +898,55 @@ extern "C" { #ifndef _di_fake_validate_directories_ f_return_status fake_validate_parameter_directories(const f_console_arguments arguments, const fake_data data) { - const uint8_t parameter_ids[] = { - fake_parameter_path_build, - fake_parameter_path_source_build, - fake_parameter_path_source_codes, - fake_parameter_path_source_common, - fake_parameter_path_source_data, - fake_parameter_path_source_documents, - fake_parameter_path_source_licenses, - fake_parameter_path_source_settings, - fake_parameter_path_work, - }; - - const f_string parameter_names[] = { + const f_string parameters_name[] = { fake_long_path_build, - fake_long_path_source_build, - fake_long_path_source_codes, - fake_long_path_source_common, - fake_long_path_source_data, - fake_long_path_source_documents, - fake_long_path_source_licenses, - fake_long_path_source_settings, + fake_long_path_data, + fake_long_path_sources, fake_long_path_work, }; const f_string parameter_defaults[] = { fake_default_path_build, - fake_default_path_source_build, - fake_default_path_source_codes, - fake_default_path_source_common, - fake_default_path_source_data, - fake_default_path_source_documents, - fake_default_path_source_licenses, - fake_default_path_source_settings, + fake_default_path_data, + fake_default_path_sources, fake_default_path_work, }; const f_string_length parameter_default_lengths[] = { fake_default_path_build_length, - fake_default_path_source_build_length, - fake_default_path_source_codes_length, - fake_default_path_source_common_length, - fake_default_path_source_data_length, - fake_default_path_source_documents_length, - fake_default_path_source_licenses_length, - fake_default_path_source_settings_length, + fake_default_path_data_length, + fake_default_path_sources_length, fake_default_path_work_length, }; + const f_string_dynamic *parameters_value[] = { + &data.path_build, + &data.path_data, + &data.path_sources, + &data.path_work, + }; + const bool parameters_required[] = { f_true, f_true, f_true, f_false, - f_true, - f_false, - f_false, - f_false, - f_false, - }; - - const f_string_dynamic *parameter_values[] = { - &data.path_build, - &data.path_source_build, - &data.path_source_codes, - &data.path_source_common, - &data.path_source_data, - &data.path_source_documents, - &data.path_source_licenses, - &data.path_source_settings, - &data.path_work, }; struct stat directory_stat; f_status status = f_none; - for (uint8_t i = 0; i < 9; i++) { - if (parameter_values[i]->used > 0) { + for (uint8_t i = 0; i < 4; i++) { + if (parameters_value[i]->used > 0) { memset(&directory_stat, 0, sizeof(struct stat)); - status = f_file_stat(parameter_values[i]->string, &directory_stat); + status = f_file_stat(parameters_value[i]->string, &directory_stat); if (status == f_status_set_error(f_file_not_found)) status = f_status_set_error(f_directory_not_found); if (f_status_is_error(status)) { if (f_status_set_fine(status) != f_directory_not_found || parameters_required[i]) { - fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_file_stat", parameter_values[i]->string, f_false, f_true); + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_file_stat", parameters_value[i]->string, "access", f_false, f_true); return status; } } @@ -764,7 +954,7 @@ extern "C" { else if (parameters_required[i]) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: No valid path for the (required) directory parameter '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameters_name[i]); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' was found."); return f_status_set_error(f_directory_not_found); diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 4b34936..82692be 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -27,6 +27,26 @@ extern "C" { #endif // _di_fake_path_generate_ /** + * Generate all appropriate paths based on runtime information from dynamic strings. + * + * @param data + * The program data. + * @param source + * The string to copy from. + * @param value + * An array of pointers to the strings to append onto. + * @param length + * The size of the values. + * + * @return + * f_none on success. + * 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; +#endif // _di_fake_path_generate_string_dynamic_ + +/** * Print generic error messages. * * @param context @@ -61,6 +81,8 @@ extern "C" { * The function call that returned the error. * @param name * The name of the file or directory. + * @param operation + * The operation that failes, such as 'create' or 'access'. * @param is_file * Set to TRUE if this is a file and FALSE if this is a directory. * @param fallback @@ -71,7 +93,7 @@ extern "C" { * f_unknown is returned if the status code has no print message. */ #ifndef _di_fake_print_error_file_ - extern f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string name, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal; + extern f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_error_file_ /** diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index 65879a4..b02740b 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -15,111 +15,66 @@ extern "C" { fl_color_print_line(f_standard_output, data.context.important, data.context.reset, "Generating skeleton structure."); } - status = fake_skeleton_operate_directory_create(data, fake_path_documents); - if (f_status_is_error(status)) return status; - - status = fake_skeleton_operate_directory_create(data, fake_path_data); - if (f_status_is_error(status)) return status; - - status = fake_skeleton_operate_directory_create(data, fake_path_licenses); - if (f_status_is_error(status)) return status; - - status = fake_skeleton_operate_directory_create(data, fake_path_sources); - if (f_status_is_error(status)) return status; - { - const f_string_static parameter_strings[] = { - data.path_build, - data.path_build_documents, - data.path_build_includes, - data.path_build_libraries, - data.path_build_libraries_script, - data.path_build_libraries_shared, - data.path_build_libraries_static, - data.path_build_objects, - data.path_build_process, - data.path_build_programs, - data.path_build_programs_script, - data.path_build_programs_shared, - data.path_build_programs_static, - data.path_build_settings, - data.path_work, - data.path_source_build, - data.path_source_common, - data.path_source_data, - data.path_source_documents, - data.path_source_codes, - data.path_source_licenses, - data.path_source_settings, + const f_string_dynamic *parameters_value[] = { + &data.path_build, + &data.path_data, + &data.path_data_build, + &data.path_documents, + &data.path_licenses, + &data.path_sources, + &data.path_sources_bash, + &data.path_sources_c, + &data.path_sources_cpp, + &data.path_work, + &data.path_work_includes, + &data.path_work_libraries, + &data.path_work_libraries_script, + &data.path_work_libraries_shared, + &data.path_work_libraries_static, + &data.path_work_programs, + &data.path_work_programs_script, + &data.path_work_programs_shared, + &data.path_work_programs_static, }; - // @todo this needs to create parent directories as well, for some paths. - for (f_array_length i = 0; i < 22; i++) { - if (parameter_strings[i].used == 0) continue; + for (uint8_t i = 0; i < 19; i++) { + status = fake_skeleton_operate_directory_create(data, *parameters_value[i]); - status = fake_skeleton_operate_directory_create(data, parameter_strings[i].string); - if (f_status_is_error(status)) return status; + if (f_status_is_error(status)) { + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fake_skeleton_operate_directory_create", f_true); + return status; + } } // for } - if (data.path_work.used > 0) { - const f_string parameter_strings[] = { - fake_path_work_includes, - fake_path_work_libraries, - fake_path_work_libraries_script, - fake_path_work_libraries_shared, - fake_path_work_libraries_static, - fake_path_work_programs, - fake_path_work_programs_script, - fake_path_work_programs_shared, - fake_path_work_programs_static, - }; - - const uint8_t parameter_strings_length[] = { - fake_path_work_includes_length, - fake_path_work_libraries_length, - fake_path_work_libraries_script_length, - fake_path_work_libraries_shared_length, - fake_path_work_libraries_static_length, - fake_path_work_programs_length, - fake_path_work_programs_script_length, - fake_path_work_programs_shared_length, - fake_path_work_programs_static_length, - }; - - f_string_dynamic path = f_string_dynamic_initialize; + f_string_dynamic file_data_build_process_post = f_string_dynamic_initialize; + f_string_dynamic file_data_build_process_pre = f_string_dynamic_initialize; - status = fl_string_dynamic_append_nulless(data.path_work, &path); - if (f_status_is_error(status)) { - f_macro_string_dynamic_delete_simple(path); - return status; - } + if (!f_status_is_error(status)) { + status = fake_skeleton_operate_file_create(data, data.file_data_build_dependencies, f_false); + } - for (f_array_length i = 0; i < 9; i++) { - path.used = data.path_work.used; + if (!f_status_is_error(status)) { + status = fake_skeleton_operate_file_create(data, file_data_build_process_post, f_true); + } - status = fl_string_append_nulless(parameter_strings[i], parameter_strings_length[i], &path); - if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_append_nulless", f_true); - f_macro_string_dynamic_delete_simple(path); - return status; - } + if (!f_status_is_error(status)) { + status = fake_skeleton_operate_file_create(data, file_data_build_process_pre, f_true); + } - status = fl_string_dynamic_terminate(&path); - if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_terminate", f_true); - f_macro_string_dynamic_delete_simple(path); - return status; - } + if (!f_status_is_error(status)) { + status = fake_skeleton_operate_file_create(data, data.file_data_build_settings, f_false); + } - status = fake_skeleton_operate_directory_create(data, path.string); - if (f_status_is_error(status)) { - f_macro_string_dynamic_delete_simple(path); - return status; - } - } // for + if (!f_status_is_error(status)) { + status = fake_skeleton_operate_file_create(data, data.file_documents_readme, f_false); + } - f_macro_string_dynamic_delete_simple(path); + if (f_status_is_error(status)) { + f_macro_string_dynamic_delete_simple(file_data_build_process_post); + f_macro_string_dynamic_delete_simple(file_data_build_process_pre); + return status; } return f_none; @@ -127,48 +82,53 @@ extern "C" { #endif // _di_fake_skeleton_operate_ #ifndef _di_fake_skeleton_operate_directory_create_ - f_return_status fake_skeleton_operate_directory_create(const fake_data data, const f_string path) { + f_return_status fake_skeleton_operate_directory_create(const fake_data data, const f_string_dynamic path) { f_status status = f_none; - status = f_directory_is(path); + if (path.used == 0) return f_none; + + status = f_directory_is(path.string); if (status == f_true) { if (data.verbosity == fake_verbosity_verbose) { - printf("Directory '%s' already exists.%c", path, f_string_eol); + printf("Directory '%s' already exists.%c", path.string, f_string_eol); } + + return f_none; } - else if (status == f_false) { + + if (status == f_false) { if (data.verbosity != fake_verbosity_quiet) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' exists but is not a directory."); } - return f_status_set_error(f_failure); + return f_status_set_warning(f_failure); } else if (status == f_file_not_found) { - status = f_directory_create(path, f_file_mode_all_rwx); + status = f_directory_create(path.string, f_file_mode_all_rwx); if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_file_not_found) { fprintf(f_standard_error, "%c", f_string_eol); fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); } else { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "f_directory_create", f_true); + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_directory_create", path.string, "create", f_false, f_true); } return status; } if (data.verbosity == fake_verbosity_verbose) { - printf("Directory '%s' created.%c", path, f_string_eol); + printf("Directory '%s' created.%c", path.string, f_string_eol); } } else if (f_status_is_error(status)) { - fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "f_directory_is", f_true); + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_directory_is", path.string, "create", f_false, f_true); return status; } @@ -176,6 +136,77 @@ extern "C" { } #endif // _di_fake_skeleton_operate_directory_create_ +#ifndef _di_fake_skeleton_operate_file_create_ + f_return_status fake_skeleton_operate_file_create(const fake_data data, const f_string_dynamic path, const bool executable) { + f_status status = f_none; + + if (path.used == 0) return f_none; + + status = f_file_is(path.string, f_file_type_file); + if (status == f_true) { + if (data.verbosity == fake_verbosity_verbose) { + printf("File '%s' already exists.%c", path.string, f_string_eol); + } + + return f_none; + } + + // symbolic links might also be fine. + if (status == f_false) { + status = f_file_is(path.string, f_file_type_link); + + if (status == f_true) { + if (data.verbosity == fake_verbosity_verbose) { + printf("File '%s' already exists (as a symbolic link).%c", path.string, f_string_eol); + } + + return f_none; + } + } + + if (status == f_false) { + if (data.verbosity == fake_verbosity_verbose) { + printf("File '%s' already exists but is not a regular file (or symbolic link).%c", path.string, f_string_eol); + } + + return f_status_set_warning(f_none); + } + else if (status == f_file_not_found) { + mode_t mode = f_file_mode_all_rw; + + if (executable) { + mode = f_file_mode_all_rwx; + } + + status = f_file_create(path.string, mode, true); + + if (f_status_is_error(status)) { + if (f_status_set_fine(status) == f_file_not_found) { + fprintf(f_standard_error, "%c", f_string_eol); + fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: The path '"); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' could not be created, a parent directory does not exist."); + } + else { + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_file_create", path.string, "create", f_true, f_true); + } + + return status; + } + + if (data.verbosity == fake_verbosity_verbose) { + printf("File '%s' created.%c", path.string, f_string_eol); + } + } + else if (f_status_is_error(status)) { + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), "f_file_is", path.string, "create", f_true, f_true); + return status; + } + + return f_none; + } +#endif // _di_fake_skeleton_operate_file_create_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-skeleton.h b/level_3/fake/c/private-skeleton.h index f078ed3..4ddeef7 100644 --- a/level_3/fake/c/private-skeleton.h +++ b/level_3/fake/c/private-skeleton.h @@ -24,10 +24,10 @@ extern "C" { */ #ifndef _di_fake_skeleton_operate_ extern f_return_status fake_skeleton_operate(const fake_data data) f_gcc_attribute_visibility_internal; -#endif // _di_fake_keleton_operate_ +#endif // _di_fake_skeleton_operate_ /** - * Create a directory if it does not exist, ignore it if it does, and error if path exists but is not a directory. + * Create a directory if it does not exist, ignore it if it does, and warn if path exists but is not a directory. * * @param data * The program data. @@ -36,12 +36,33 @@ extern "C" { * * @return * f_none on success. + * Status codes (with warning bit) are returned on certain problems that can be ignored. * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_skeleton_operate_directory_create_ - extern f_return_status fake_skeleton_operate_directory_create(const fake_data data, const f_string path) f_gcc_attribute_visibility_internal; + extern f_return_status fake_skeleton_operate_directory_create(const fake_data data, const f_string_dynamic path) f_gcc_attribute_visibility_internal; #endif // _di_fake_skeleton_operate_directory_create_ +/** + * Create a file if it does not exist, ignore it if it does, and warn if path exists but is not a file. + * + * @param data + * The program data. + * @param path + * The file path for the directory to create. + * @param executable + * Set to TRUE to make the file executable. + * Set to FALSE to not make the file executable. + * + * @return + * f_none on success. + * Status codes (with warning bit) are returned on certain problems that can be ignored. + * Status codes (with error bit) are returned on any problem. + */ +#ifndef _di_fake_skeleton_operate_file_create_ + extern f_return_status fake_skeleton_operate_file_create(const fake_data data, const f_string_dynamic path, const bool executable) f_gcc_attribute_visibility_internal; +#endif // _di_fake_skeleton_operate_file_create_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/data/build/process_post.sh b/level_3/fake/data/build/process_post.sh index 67b0497..2f70750 100755 --- a/level_3/fake/data/build/process_post.sh +++ b/level_3/fake/data/build/process_post.sh @@ -32,18 +32,35 @@ process_post_main(){ local process= local file_settings= local path_build= - local path_source_build= - local path_source_codes= - local path_source_common= - local path_source_data= - local path_source_documents= - local path_source_licenses= - local path_source_settings= + local path_data= + local path_sources= local path_work= local verbosity= - # standard settings paths. + # generated paths and standard paths. local path_directory_separator="/" + local path_data_build= + local path_documents="documents/" + local path_licenses="licenses/" + local path_sources_bash= + local path_sources_c= + local path_sources_cpp= + local path_work_includes= + local path_work_libraries= + local path_work_libraries_script= + local path_work_libraries_shared= + local path_work_libraries_static= + local path_work_programs= + local path_work_programs_script= + local path_work_programs_shared= + local path_work_programs_static= + + # generated file paths. + local file_data_build_dependencies= + local file_data_build_settings= + local file_documents_readme= + + # standard build paths. local path_build_documents= local path_build_includes= local path_build_libraries= @@ -81,20 +98,10 @@ process_post_main(){ grab_next="file_settings" elif [[ $p == "-b" ]] ; then grab_next="path_build" - elif [[ $p == "-B" ]] ; then - grab_next="path_source_build" - elif [[ $p == "-C" ]] ; then - grab_next="path_source_codes" - elif [[ $p == "-O" ]] ; then - grab_next="path_source_common" elif [[ $p == "-D" ]] ; then - grab_next="path_source_data" - elif [[ $p == "-M" ]] ; then - grab_next="path_source_documents" - elif [[ $p == "-L" ]] ; then - grab_next="path_source_licenses" + grab_next="path_data" elif [[ $p == "-S" ]] ; then - grab_next="path_source_settings" + grab_next="path_sources" elif [[ $p == "-w" ]] ; then grab_next="path_work" elif [[ $p == "+D" ]] ; then @@ -176,23 +183,45 @@ process_post_main(){ fi # update paths based on parameters. - path_build_documents=${path_build}documents$path_directory_separator - path_build_includes=${path_build}includes$path_directory_separator - path_build_libraries=${path_build}libraries$path_directory_separator - path_build_libraries_script=${path_build_libraries}script$path_directory_separator - path_build_libraries_shared=${path_build_libraries}shared$path_directory_separator - path_build_libraries_static=${path_build_libraries}static$path_directory_separator - path_build_objects=${path_build}objects$path_directory_separator - path_build_process=${path_build}process$path_directory_separator - path_build_programs=${path_build}programs$path_directory_separator - path_build_programs_script=${path_build_programs}script$path_directory_separator - path_build_programs_shared=${path_build_programs}shared$path_directory_separator - path_build_programs_static=${path_build_programs}static$path_directory_separator - path_build_settings=${path_build}settings$path_directory_separator + path_data_build="${path_data}build$path_directory_separator" + + path_sources_bash="${path_sources}bash$path_directory_separator" + path_sources_c="${path_sources}c$path_directory_separator" + path_sources_cpp="${path_sources}c++$path_directory_separator" + + path_build_documents="${path_build}documents$path_directory_separator" + path_build_includes="${path_build}includes$path_directory_separator" + path_build_libraries="${path_build}libraries$path_directory_separator" + path_build_libraries_script="${path_build_libraries}script$path_directory_separator" + path_build_libraries_shared="${path_build_libraries}shared$path_directory_separator" + path_build_libraries_static="${path_build_libraries}static$path_directory_separator" + path_build_objects="${path_build}objects$path_directory_separator" + path_build_process="${path_build}process$path_directory_separator" + path_build_programs="${path_build}programs$path_directory_separator" + path_build_programs_script="${path_build_programs}script$path_directory_separator" + path_build_programs_shared="${path_build_programs}shared$path_directory_separator" + path_build_programs_static="${path_build_programs}static$path_directory_separator" + path_build_settings="${path_build}settings$path_directory_separator" + + if [[ $path_work != "" ]] ; then + path_work_includes="${path_work}includes$path_directory_separator" + path_work_libraries="${path_work_libraries}libraries$path_directory_separator" + path_work_libraries_script="${path_work_libraries_script}script$path_directory_separator" + path_work_libraries_shared="${path_work_libraries_shared}shared$path_directory_separator" + path_work_libraries_static="${path_work_libraries_static}static$path_directory_separator" + path_work_programs="${path_work_programs}programs$path_directory_separator" + path_work_programs_script="${path_work_programs_script}script$path_directory_separator" + path_work_programs_shared="${path_work_programs_shared}shared$path_directory_separator" + path_work_programs_static="${path_work_programs_static}static$path_directory_separator" + fi + + file_data_build_dependencies="${path_data_build}dependencies" + file_data_build_settings="${path_data_build}settings" + file_documents_readme="${path_documents}readme" if [[ $verbosity != "quiet" ]] ; then echo - echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset" + echo -e "${c_title}Pre Processing Operation: $c_reset$c_notice$operation$c_reset" if [[ $modes != "" ]] ; then echo -e " Modes: $c_reset$c_notice$modes$c_reset" @@ -215,5 +244,5 @@ process_post_path_fix(){ echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } -# note: "$@" is necessary to preserve quoted arguments when passing though. +# note: "$@" is necessary to preserve quoted arguments when passing to function. process_post_main "$@" diff --git a/level_3/fake/data/build/process_pre.sh b/level_3/fake/data/build/process_pre.sh index baa0b6a..87e22ec 100755 --- a/level_3/fake/data/build/process_pre.sh +++ b/level_3/fake/data/build/process_pre.sh @@ -32,18 +32,35 @@ process_pre_main(){ local process= local file_settings= local path_build= - local path_source_build= - local path_source_codes= - local path_source_common= - local path_source_data= - local path_source_documents= - local path_source_licenses= - local path_source_settings= + local path_data= + local path_sources= local path_work= local verbosity= - # standard settings paths. + # generated paths and standard paths. local path_directory_separator="/" + local path_data_build= + local path_documents="documents/" + local path_licenses="licenses/" + local path_sources_bash= + local path_sources_c= + local path_sources_cpp= + local path_work_includes= + local path_work_libraries= + local path_work_libraries_script= + local path_work_libraries_shared= + local path_work_libraries_static= + local path_work_programs= + local path_work_programs_script= + local path_work_programs_shared= + local path_work_programs_static= + + # generated file paths. + local file_data_build_dependencies= + local file_data_build_settings= + local file_documents_readme= + + # standard build paths. local path_build_documents= local path_build_includes= local path_build_libraries= @@ -81,20 +98,10 @@ process_pre_main(){ grab_next="file_settings" elif [[ $p == "-b" ]] ; then grab_next="path_build" - elif [[ $p == "-B" ]] ; then - grab_next="path_source_build" - elif [[ $p == "-C" ]] ; then - grab_next="path_source_codes" - elif [[ $p == "-O" ]] ; then - grab_next="path_source_common" elif [[ $p == "-D" ]] ; then - grab_next="path_source_data" - elif [[ $p == "-M" ]] ; then - grab_next="path_source_documents" - elif [[ $p == "-L" ]] ; then - grab_next="path_source_licenses" + grab_next="path_data" elif [[ $p == "-S" ]] ; then - grab_next="path_source_settings" + grab_next="path_sources" elif [[ $p == "-w" ]] ; then grab_next="path_work" elif [[ $p == "+D" ]] ; then @@ -176,23 +183,45 @@ process_pre_main(){ fi # update paths based on parameters. - path_build_documents=${path_build}documents$path_directory_separator - path_build_includes=${path_build}includes$path_directory_separator - path_build_libraries=${path_build}libraries$path_directory_separator - path_build_libraries_script=${path_build_libraries}script$path_directory_separator - path_build_libraries_shared=${path_build_libraries}shared$path_directory_separator - path_build_libraries_static=${path_build_libraries}static$path_directory_separator - path_build_objects=${path_build}objects$path_directory_separator - path_build_process=${path_build}process$path_directory_separator - path_build_programs=${path_build}programs$path_directory_separator - path_build_programs_script=${path_build_programs}script$path_directory_separator - path_build_programs_shared=${path_build_programs}shared$path_directory_separator - path_build_programs_static=${path_build_programs}static$path_directory_separator - path_build_settings=${path_build}settings$path_directory_separator + path_data_build="${path_data}build$path_directory_separator" + + path_sources_bash="${path_sources}bash$path_directory_separator" + path_sources_c="${path_sources}c$path_directory_separator" + path_sources_cpp="${path_sources}c++$path_directory_separator" + + path_build_documents="${path_build}documents$path_directory_separator" + path_build_includes="${path_build}includes$path_directory_separator" + path_build_libraries="${path_build}libraries$path_directory_separator" + path_build_libraries_script="${path_build_libraries}script$path_directory_separator" + path_build_libraries_shared="${path_build_libraries}shared$path_directory_separator" + path_build_libraries_static="${path_build_libraries}static$path_directory_separator" + path_build_objects="${path_build}objects$path_directory_separator" + path_build_process="${path_build}process$path_directory_separator" + path_build_programs="${path_build}programs$path_directory_separator" + path_build_programs_script="${path_build_programs}script$path_directory_separator" + path_build_programs_shared="${path_build_programs}shared$path_directory_separator" + path_build_programs_static="${path_build_programs}static$path_directory_separator" + path_build_settings="${path_build}settings$path_directory_separator" + + if [[ $path_work != "" ]] ; then + path_work_includes="${path_work}includes$path_directory_separator" + path_work_libraries="${path_work_libraries}libraries$path_directory_separator" + path_work_libraries_script="${path_work_libraries_script}script$path_directory_separator" + path_work_libraries_shared="${path_work_libraries_shared}shared$path_directory_separator" + path_work_libraries_static="${path_work_libraries_static}static$path_directory_separator" + path_work_programs="${path_work_programs}programs$path_directory_separator" + path_work_programs_script="${path_work_programs_script}script$path_directory_separator" + path_work_programs_shared="${path_work_programs_shared}shared$path_directory_separator" + path_work_programs_static="${path_work_programs_static}static$path_directory_separator" + fi + + file_data_build_dependencies="${path_data_build}dependencies" + file_data_build_settings="${path_data_build}settings" + file_documents_readme="${path_documents}readme" if [[ $verbosity != "quiet" ]] ; then echo - echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset" + echo -e "${c_title}Post Processing Operation: $c_reset$c_notice$operation$c_reset" if [[ $modes != "" ]] ; then echo -e " Modes: $c_reset$c_notice$modes$c_reset" @@ -215,5 +244,5 @@ process_pre_path_fix(){ echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|" } -# note: "$@" is necessary to preserve quoted arguments when passing though. +# note: "$@" is necessary to preserve quoted arguments when passing to function. process_pre_main "$@"