From: Kevin Day Date: Tue, 15 Feb 2022 06:47:20 +0000 (-0600) Subject: Update: The build setting path_sources is not being properly used and improve skeleto... X-Git-Tag: 0.5.8~50 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=3efd461a2c934ec90c42473fe71968e7232581be;p=fll Update: The build setting path_sources is not being properly used and improve skeleton process. Resolve the fixme regarding the path_sources_object and similar. Consolidate the static source build into functions. The fake_build_setting_name_preserve_path_headers_s is in the wrong location, resulting in the incorrect loading of build settings data. Provide default for path_sources. Make the main->path_sources a prefix path where all sources exist (there will likely need to be a follow up commit to address this in bootstrap.sh). Get rid of the path_source_* forr bash, c, and other custom paths. Get rid of the redundant version default assignment in fake_build_load_setting_defaults(). Rename fake_build_load_setting_defaults() to fake_build_load_setting_override(). Update the skeleton generation. Add "specifications" directory creation. Add "sources/script" directory creation. --- diff --git a/level_3/fake/c/common.c b/level_3/fake/c/common.c index 9ee2b2b..f76ccc8 100644 --- a/level_3/fake/c/common.c +++ b/level_3/fake/c/common.c @@ -37,6 +37,7 @@ extern "C" { const f_string_static_t fake_path_part_script_s = macro_f_string_static_t_initialize(FAKE_path_part_script_s, 0, FAKE_path_part_script_s_length); const f_string_static_t fake_path_part_settings_s = macro_f_string_static_t_initialize(FAKE_path_part_settings_s, 0, FAKE_path_part_settings_s_length); const f_string_static_t fake_path_part_shared_s = macro_f_string_static_t_initialize(FAKE_path_part_shared_s, 0, FAKE_path_part_shared_s_length); + const f_string_static_t fake_path_part_specifications_s = macro_f_string_static_t_initialize(FAKE_path_part_specifications_s, 0, FAKE_path_part_specifications_s_length); const f_string_static_t fake_path_part_stage_s = macro_f_string_static_t_initialize(FAKE_path_part_stage_s, 0, FAKE_path_part_stage_s_length); const f_string_static_t fake_path_part_static_s = macro_f_string_static_t_initialize(FAKE_path_part_static_s, 0, FAKE_path_part_static_s_length); #endif // _di_fake_path_ @@ -154,16 +155,6 @@ extern "C" { f_string_dynamic_resize(0, &main->path_licenses); f_string_dynamic_resize(0, &main->path_sources); - f_string_dynamic_resize(0, &main->path_sources_bash); - f_string_dynamic_resize(0, &main->path_sources_c); - f_string_dynamic_resize(0, &main->path_sources_cpp); - f_string_dynamic_resize(0, &main->path_sources_script); - - f_string_dynamic_resize(0, &main->path_sources_object); - f_string_dynamic_resize(0, &main->path_sources_object_bash); - f_string_dynamic_resize(0, &main->path_sources_object_c); - f_string_dynamic_resize(0, &main->path_sources_object_cpp); - f_string_dynamic_resize(0, &main->path_sources_object_script); f_string_dynamic_resize(0, &main->path_work); f_string_dynamic_resize(0, &main->path_work_includes); diff --git a/level_3/fake/c/common.h b/level_3/fake/c/common.h index 0088f4a..7fa7a5e 100644 --- a/level_3/fake/c/common.h +++ b/level_3/fake/c/common.h @@ -84,41 +84,43 @@ extern "C" { * These structures are hard-coded by their individual pieces to be constructed later on. */ #ifndef _di_fake_path_ - #define FAKE_path_part_bash_s "bash" F_path_separator_s - #define FAKE_path_part_build_s "build" F_path_separator_s - #define FAKE_path_part_c_s "c" F_path_separator_s - #define FAKE_path_part_cpp_s "c++" F_path_separator_s - #define FAKE_path_part_data_s "data" F_path_separator_s - #define FAKE_path_part_documents_s "documents" F_path_separator_s - #define FAKE_path_part_includes_s "includes" F_path_separator_s - #define FAKE_path_part_libraries_s "libraries" F_path_separator_s - #define FAKE_path_part_licenses_s "licenses" F_path_separator_s - #define FAKE_path_part_objects_s "objects" F_path_separator_s - #define FAKE_path_part_process_s "process" F_path_separator_s - #define FAKE_path_part_programs_s "programs" F_path_separator_s - #define FAKE_path_part_script_s "script" F_path_separator_s - #define FAKE_path_part_settings_s "settings" F_path_separator_s - #define FAKE_path_part_shared_s "shared" F_path_separator_s - #define FAKE_path_part_stage_s "stage" F_path_separator_s - #define FAKE_path_part_static_s "static" F_path_separator_s - - #define FAKE_path_part_bash_s_length 5 + F_path_separator_s_length - #define FAKE_path_part_build_s_length 6 + F_path_separator_s_length - #define FAKE_path_part_c_s_length 2 + F_path_separator_s_length - #define FAKE_path_part_cpp_s_length 4 + F_path_separator_s_length - #define FAKE_path_part_data_s_length 5 + F_path_separator_s_length - #define FAKE_path_part_documents_s_length 10 + F_path_separator_s_length - #define FAKE_path_part_includes_s_length 9 + F_path_separator_s_length - #define FAKE_path_part_libraries_s_length 10 + F_path_separator_s_length - #define FAKE_path_part_licenses_s_length 9 + F_path_separator_s_length - #define FAKE_path_part_objects_s_length 8 + F_path_separator_s_length - #define FAKE_path_part_process_s_length 8 + F_path_separator_s_length - #define FAKE_path_part_programs_s_length 9 + F_path_separator_s_length - #define FAKE_path_part_script_s_length 7 + F_path_separator_s_length - #define FAKE_path_part_settings_s_length 9 + F_path_separator_s_length - #define FAKE_path_part_shared_s_length 7 + F_path_separator_s_length - #define FAKE_path_part_stage_s_length 6 + F_path_separator_s_length - #define FAKE_path_part_static_s_length 7 + F_path_separator_s_length + #define FAKE_path_part_bash_s "bash" F_path_separator_s + #define FAKE_path_part_build_s "build" F_path_separator_s + #define FAKE_path_part_c_s "c" F_path_separator_s + #define FAKE_path_part_cpp_s "c++" F_path_separator_s + #define FAKE_path_part_data_s "data" F_path_separator_s + #define FAKE_path_part_documents_s "documents" F_path_separator_s + #define FAKE_path_part_includes_s "includes" F_path_separator_s + #define FAKE_path_part_libraries_s "libraries" F_path_separator_s + #define FAKE_path_part_licenses_s "licenses" F_path_separator_s + #define FAKE_path_part_objects_s "objects" F_path_separator_s + #define FAKE_path_part_process_s "process" F_path_separator_s + #define FAKE_path_part_programs_s "programs" F_path_separator_s + #define FAKE_path_part_script_s "script" F_path_separator_s + #define FAKE_path_part_settings_s "settings" F_path_separator_s + #define FAKE_path_part_shared_s "shared" F_path_separator_s + #define FAKE_path_part_specifications_s "specifications" F_path_separator_s + #define FAKE_path_part_stage_s "stage" F_path_separator_s + #define FAKE_path_part_static_s "static" F_path_separator_s + + #define FAKE_path_part_bash_s_length 4 + F_path_separator_s_length + #define FAKE_path_part_build_s_length 5 + F_path_separator_s_length + #define FAKE_path_part_c_s_length 1 + F_path_separator_s_length + #define FAKE_path_part_cpp_s_length 3 + F_path_separator_s_length + #define FAKE_path_part_data_s_length 4 + F_path_separator_s_length + #define FAKE_path_part_documents_s_length 9 + F_path_separator_s_length + #define FAKE_path_part_includes_s_length 8 + F_path_separator_s_length + #define FAKE_path_part_libraries_s_length 9 + F_path_separator_s_length + #define FAKE_path_part_licenses_s_length 8 + F_path_separator_s_length + #define FAKE_path_part_objects_s_length 7 + F_path_separator_s_length + #define FAKE_path_part_process_s_length 7 + F_path_separator_s_length + #define FAKE_path_part_programs_s_length 8 + F_path_separator_s_length + #define FAKE_path_part_script_s_length 6 + F_path_separator_s_length + #define FAKE_path_part_settings_s_length 8 + F_path_separator_s_length + #define FAKE_path_part_shared_s_length 6 + F_path_separator_s_length + #define FAKE_path_part_specifications_s_length 14 + F_path_separator_s_length + #define FAKE_path_part_stage_s_length 5 + F_path_separator_s_length + #define FAKE_path_part_static_s_length 6 + F_path_separator_s_length extern const f_string_static_t fake_path_part_bash_s; extern const f_string_static_t fake_path_part_build_s; @@ -135,6 +137,7 @@ extern "C" { extern const f_string_static_t fake_path_part_script_s; extern const f_string_static_t fake_path_part_settings_s; extern const f_string_static_t fake_path_part_shared_s; + extern const f_string_static_t fake_path_part_specifications_s; extern const f_string_static_t fake_path_part_stage_s; extern const f_string_static_t fake_path_part_static_s; #endif // _di_fake_path_ @@ -507,16 +510,6 @@ extern "C" { f_string_dynamic_t path_licenses; f_string_dynamic_t path_sources; - f_string_dynamic_t path_sources_bash; - f_string_dynamic_t path_sources_c; - f_string_dynamic_t path_sources_cpp; - f_string_dynamic_t path_sources_script; - - f_string_dynamic_t path_sources_object; - f_string_dynamic_t path_sources_object_bash; - f_string_dynamic_t path_sources_object_c; - f_string_dynamic_t path_sources_object_cpp; - f_string_dynamic_t path_sources_object_script; f_string_dynamic_t path_work; f_string_dynamic_t path_work_includes; @@ -599,15 +592,6 @@ extern "C" { f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ - f_string_dynamic_t_initialize, \ f_string_dynamics_t_initialize, \ f_string_dynamics_t_initialize, \ f_color_context_t_initialize, \ diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index f52b7a5..f3a33de 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -304,7 +304,7 @@ extern "C" { } if (F_status_is_error_not(status)) { - status = fake_build_operate(f_string_empty_s, main); + status = fake_build_operate(main, f_string_empty_s); } } else if (main->operation == fake_operation_clean_e) { diff --git a/level_3/fake/c/private-build-load.c b/level_3/fake/c/private-build-load.c index f21edc8..c4ef952 100644 --- a/level_3/fake/c/private-build-load.c +++ b/level_3/fake/c/private-build-load.c @@ -173,7 +173,7 @@ extern "C" { } } - fake_build_load_setting_defaults(main, setting, status); + fake_build_load_setting_override(main, setting, status); } #endif // _di_fake_build_load_setting_ @@ -292,7 +292,6 @@ extern "C" { fake_build_setting_name_modes_s, fake_build_setting_name_modes_default_s, fake_build_setting_name_path_headers_s, - fake_build_setting_name_preserve_path_headers_s, fake_build_setting_name_path_language_s, fake_build_setting_name_path_library_script_s, fake_build_setting_name_path_library_shared_s, @@ -305,6 +304,7 @@ extern "C" { fake_build_setting_name_path_program_static_s, fake_build_setting_name_path_sources_s, fake_build_setting_name_path_sources_object_s, + fake_build_setting_name_preserve_path_headers_s, fake_build_setting_name_process_post_s, fake_build_setting_name_process_pre_s, fake_build_setting_name_search_exclusive_s, @@ -834,7 +834,7 @@ extern "C" { fake_path_part_script_s, // path_program_script fake_path_part_shared_s, // path_program_shared fake_path_part_static_s, // path_program_static - f_string_empty_s, // path_sources + fake_default_path_sources_s, // path_sources f_string_empty_s, // path_sources_object f_string_empty_s, // preserve_path_headers f_string_empty_s, // process_post @@ -1299,53 +1299,29 @@ extern "C" { } #endif // _di_fake_build_load_setting_process_ -#ifndef _di_fake_build_load_setting_defaults_ - void fake_build_load_setting_defaults(fake_main_t * const main, fake_build_setting_t * const setting, f_status_t * const status) { +#ifndef _di_fake_build_load_setting_override_ + void fake_build_load_setting_override(fake_main_t * const main, fake_build_setting_t * const setting, f_status_t * const status) { if (F_status_is_error(*status)) return; - if (fake_signal_received(main)) { - *status = F_status_set_error(F_interrupt); - - return; - } + if (main->parameters.array[fake_parameter_path_sources_e].result == f_console_result_additional_e && main->path_sources.used) { + *status = f_string_dynamic_append_assure(f_path_separator_s, &main->path_sources); - { - const f_string_static_t sources[] = { - fake_build_setting_default_version_s, - fake_build_setting_default_version_s, - fake_build_setting_default_version_s, - }; - - f_string_dynamic_t * const destinations[] = { - &setting->version_major, - &setting->version_minor, - &setting->version_micro, - }; - - for (uint8_t i = 0; i < 3; ++i) { - - if (destinations[i]->used) continue; + if (F_status_is_error(*status)) { + fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_append_assure", F_true); - *status = f_string_dynamic_append_assure(sources[i], destinations[i]); + return; + } - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_append_assure", F_true); - break; - } + *status = f_string_dynamic_terminate_after(&main->path_sources); - *status = f_string_dynamic_terminate_after(destinations[i]); + if (F_status_is_error(*status)) { + fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_terminate_after", F_true); - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_terminate_after", F_true); - break; - } - } // for + return; + } } - if (F_status_is_error(*status)) return; - - // Override setting file when any of these are specified in the command line. if (main->parameters.array[fake_parameter_shared_disabled_e].result == f_console_result_found_e) { if (main->parameters.array[fake_parameter_shared_enabled_e].result == f_console_result_found_e) { if (main->parameters.array[fake_parameter_shared_enabled_e].location > main->parameters.array[fake_parameter_shared_disabled_e].location) { @@ -1436,7 +1412,7 @@ extern "C" { } } } -#endif // _di_fake_build_load_setting_defaults_ +#endif // _di_fake_build_load_setting_override_ #ifndef _di_fake_build_load_stage_ void fake_build_load_stage(fake_main_t * const main, const f_string_static_t settings_file, fake_build_stage_t * const stage, f_status_t * const status) { diff --git a/level_3/fake/c/private-build-load.h b/level_3/fake/c/private-build-load.h index c70c1a3..43acce2 100644 --- a/level_3/fake/c/private-build-load.h +++ b/level_3/fake/c/private-build-load.h @@ -36,7 +36,7 @@ extern "C" { #endif // _di_fake_build_load_setting_ /** - * Assign build setting defaults. + * Override build settings based on command line arguments. * * @param main * The main program data. @@ -55,9 +55,9 @@ extern "C" { * * Status codes (with error bit) are returned on any problem. */ -#ifndef _di_fake_build_load_setting_defaults_ - extern void fake_build_load_setting_defaults(fake_main_t * const main, fake_build_setting_t * const setting, f_status_t * const status) F_attribute_visibility_internal_d; -#endif // _di_fake_build_load_setting_defaults_ +#ifndef _di_fake_build_load_setting_override_ + extern void fake_build_load_setting_override(fake_main_t * const main, fake_build_setting_t * const setting, f_status_t * const status) F_attribute_visibility_internal_d; +#endif // _di_fake_build_load_setting_override_ /** * Load and process the setting buffer. diff --git a/level_3/fake/c/private-build-objects.c b/level_3/fake/c/private-build-objects.c index 7610c05..60d450c 100644 --- a/level_3/fake/c/private-build-objects.c +++ b/level_3/fake/c/private-build-objects.c @@ -37,21 +37,8 @@ extern "C" { f_string_static_t destination = f_string_static_t_initialize; f_string_static_t source = f_string_static_t_initialize; - const f_string_static_t *path_sources = &main->path_sources; - int result = main->child; - if (data_build->setting.has_path_standard) { - path_sources = &main->path_sources_c; - - if (data_build->setting.build_language == fake_build_language_type_cpp_e) { - path_sources = &main->path_sources_cpp; - } - } - else if (main->parameters.array[fake_parameter_path_sources_e].result != f_console_result_additional_e) { - path_sources = &data_build->setting.path_sources; - } - const f_string_dynamics_t *sources[2] = { &data_build->setting.build_sources_library, &data_build->setting.build_sources_library_static, @@ -67,14 +54,17 @@ extern "C" { file_name.used = 0; destination_path.used = 0; - source.used = path_sources->used + sources[i]->array[j].used; - char source_string[source.used + 1]; + fake_build_path_source_length(main, data_build, &data_build->setting.path_sources_object, &source); + + char source_string[source.used + sources[i]->array[j].used + 1]; source.string = source_string; - source_string[source.used] = 0; - memcpy(source_string, path_sources->string, path_sources->used); - memcpy(source_string + path_sources->used, sources[i]->array[j].string, sources[i]->array[j].used); + fake_build_path_source_string(main, data_build, &data_build->setting.path_sources_object, &source); + + memcpy(source_string + source.used, sources[i]->array[j].string, sources[i]->array[j].used); + source.used += sources[i]->array[j].used; + source.string[source.used] = 0; *status = fake_build_get_file_name_without_extension(main, sources[i]->array[j], &file_name); diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 9f0e4ae..2ebff22 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -864,7 +864,7 @@ extern "C" { #endif // _di_fake_build_objects_add_ #ifndef _di_fake_build_operate_ - f_status_t fake_build_operate(const f_string_static_t setting_file, fake_main_t *main) { + f_status_t fake_build_operate(fake_main_t * const main, const f_string_static_t setting_file) { if (fake_signal_received(main)) { return F_status_set_error(F_interrupt); @@ -910,23 +910,32 @@ extern "C" { fake_build_program_script(main, &data_build, mode, stage.file_program_script, &status); if (data_build.setting.build_script) { - fake_build_copy(main, mode, fake_build_scripts_s, main->path_sources_script, main->path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); + f_string_static_t source = f_string_static_t_initialize; + + fake_build_path_source_length(main, &data_build, &data_build.setting.path_sources, &source); + + char source_string[source.used + fake_path_part_script_s.used + 1]; + source.string = source_string; + + fake_build_path_source_string(main, &data_build, &data_build.setting.path_sources, &source); + + memcpy(source_string + source.used, fake_path_part_script_s.string, fake_path_part_script_s.used); + source.used += fake_path_part_script_s.used; + source.string[source.used] = 0; + + fake_build_copy(main, mode, fake_build_scripts_s, source, main->path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); } } else { if (data_build.setting.build_sources_headers.used) { - f_string_static_t path_sources = main->path_sources; + f_string_static_t source = f_string_static_t_initialize; - if (data_build.setting.has_path_standard) { - path_sources = main->path_sources_c; + fake_build_path_source_length(main, &data_build, &data_build.setting.path_sources, &source); - if (data_build.setting.build_language == fake_build_language_type_cpp_e) { - path_sources = main->path_sources_cpp; - } - } - else if (main->parameters.array[fake_parameter_path_sources_e].result != f_console_result_additional_e) { - path_sources = data_build.setting.path_sources; - } + char source_string[source.used + 1]; + source.string = source_string; + + fake_build_path_source_string(main, &data_build, &data_build.setting.path_sources, &source); f_string_static_t path_headers = f_string_static_t_initialize; path_headers.used = main->path_build_includes.used + data_build.setting.path_headers.used; @@ -942,14 +951,14 @@ extern "C" { path_headers_string[path_headers.used] = 0; - fake_build_copy(main, mode, fake_build_header_files_s, path_sources, path_headers, data_build.setting.build_sources_headers, stage.file_sources_headers, data_build.setting.preserve_path_headers ? path_sources.used : 0, &status); + fake_build_copy(main, mode, fake_build_header_files_s, source, path_headers, data_build.setting.build_sources_headers, stage.file_sources_headers, data_build.setting.preserve_path_headers ? source.used : 0, &status); if (data_build.setting.build_shared) { - fake_build_copy(main, mode, fake_build_header_files_shared_s, path_sources, path_headers, data_build.setting.build_sources_headers_shared, stage.file_sources_headers, data_build.setting.preserve_path_headers ? path_sources.used : 0, &status); + fake_build_copy(main, mode, fake_build_header_files_shared_s, source, path_headers, data_build.setting.build_sources_headers_shared, stage.file_sources_headers, data_build.setting.preserve_path_headers ? source.used : 0, &status); } if (data_build.setting.build_static) { - fake_build_copy(main, mode, fake_build_header_files_static_s, path_sources, path_headers, data_build.setting.build_sources_headers_static, stage.file_sources_headers, data_build.setting.preserve_path_headers ? path_sources.used : 0, &status); + fake_build_copy(main, mode, fake_build_header_files_static_s, source, path_headers, data_build.setting.build_sources_headers_static, stage.file_sources_headers, data_build.setting.preserve_path_headers ? source.used : 0, &status); } } @@ -972,7 +981,20 @@ extern "C" { } if (data_build.setting.build_script) { - fake_build_copy(main, mode, fake_build_scripts_s, main->path_sources_script, main->path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); + f_string_static_t source = f_string_static_t_initialize; + + fake_build_path_source_length(main, &data_build, &data_build.setting.path_sources, &source); + + char source_string[source.used + fake_path_part_script_s.used + 1]; + source.string = source_string; + + fake_build_path_source_string(main, &data_build, &data_build.setting.path_sources, &source); + + memcpy(source_string + source.used, fake_path_part_script_s.string, fake_path_part_script_s.used); + source.used += fake_path_part_script_s.used; + source.string[source.used] = 0; + + fake_build_copy(main, mode, fake_build_scripts_s, source, main->path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); } } @@ -985,6 +1007,64 @@ extern "C" { } #endif // _di_fake_build_operate_ +#ifndef _di_fake_build_path_source_length_ + void fake_build_path_source_length(fake_main_t * const main, fake_build_data_t * const data_build, f_string_static_t * const setting_path_source, f_string_static_t * const source) { + + source->used = main->path_sources.used; + + if (setting_path_source->used) { + source->used += setting_path_source->used; + } + + if (data_build->setting.has_path_standard) { + if (data_build->setting.build_language == fake_build_language_type_c_e) { + source->used += fake_build_language_c_s.used; + } + else if (data_build->setting.build_language == fake_build_language_type_cpp_e) { + source->used += fake_build_language_cpp_s.used; + } + else if (data_build->setting.build_language == fake_build_language_type_bash_e) { + source->used += fake_build_language_bash_s.used; + } + + source->used += f_path_separator_s.used; + } + } +#endif // _di_fake_build_path_source_length_ + +#ifndef _di_fake_build_path_source_string_ + void fake_build_path_source_string(fake_main_t * const main, fake_build_data_t * const data_build, f_string_static_t * const setting_path_source, f_string_static_t * const source) { + + source->used = 0; + + memcpy(source->string, main->path_sources.string, main->path_sources.used); + source->used += main->path_sources.used; + + memcpy(source->string + source->used, setting_path_source->string, setting_path_source->used); + source->used += setting_path_source->used; + + if (data_build->setting.has_path_standard) { + if (data_build->setting.build_language == fake_build_language_type_c_e) { + memcpy(source->string + source->used, fake_build_language_c_s.string, fake_build_language_c_s.used); + source->used += fake_build_language_c_s.used; + } + else if (data_build->setting.build_language == fake_build_language_type_cpp_e) { + memcpy(source->string + source->used, fake_build_language_cpp_s.string, fake_build_language_cpp_s.used); + source->used += fake_build_language_cpp_s.used; + } + else if (data_build->setting.build_language == fake_build_language_type_bash_e) { + memcpy(source->string + source->used, fake_build_language_bash_s.string, fake_build_language_bash_s.used); + source->used += fake_build_language_bash_s.used; + } + + memcpy(source->string + source->used, f_path_separator_s.string, f_path_separator_s.used); + source->used += f_path_separator_s.used; + } + + source->string[source->used] = 0; + } +#endif // _di_fake_build_path_source_string_ + #ifndef _di_fake_build_sources_add_ f_status_t fake_build_sources_add(fake_main_t * const main, fake_build_data_t * const data_build, const f_string_statics_t *generic, const f_string_statics_t *specific, f_string_dynamics_t *arguments) { @@ -992,26 +1072,12 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - f_string_static_t source = f_string_static_t_initialize; - - // @fixme review this, these paths (like path_sources_object) need to be build on a per-settings basis rather than using a global value. - f_string_dynamic_t *path_sources = &main->path_sources; const f_string_statics_t *sources[2] = { generic, specific, }; - if (data_build->setting.has_path_standard) { - if (data_build->setting.build_language == fake_build_language_type_c_e) { - path_sources = &main->path_sources_c; - } - else { - path_sources = &main->path_sources_cpp; - } - } - else if (main->parameters.array[fake_parameter_path_sources_e].result != f_console_result_additional_e) { - path_sources = &data_build->setting.path_sources; - } + f_string_static_t source = f_string_static_t_initialize; for (; i < 2; ++i) { @@ -1019,14 +1085,16 @@ extern "C" { if (!sources[i]->array[j].used) continue; - source.used = path_sources->used + sources[i]->array[j].used; + fake_build_path_source_length(main, data_build, &data_build->setting.path_sources, &source); - char source_string[source.used + 1]; + char source_string[source.used + sources[i]->array[j].used + 1]; source.string = source_string; - source_string[source.used] = 0; - memcpy(source_string, path_sources->string, path_sources->used); - memcpy(source_string + path_sources->used, sources[i]->array[j].string, sources[i]->array[j].used); + fake_build_path_source_string(main, data_build, &data_build->setting.path_sources, &source); + + memcpy(source_string + source.used, sources[i]->array[j].string, sources[i]->array[j].used); + source.used += sources[i]->array[j].used; + source.string[source.used] = 0; status = fll_execute_arguments_add(source, arguments); if (F_status_is_error(status)) return status; @@ -1042,45 +1110,34 @@ extern "C" { if (!generic->used && !specific->used) return F_none; - f_status_t status = F_none; - f_string_static_t source = f_string_static_t_initialize; - f_string_dynamic_t *path_sources = &main->path_sources_object; - // @fixme review this, these paths (like path_sources_object) need to be build on a per-settings basis rather than using a global value. - if (data_build->setting.has_path_standard) { - if (data_build->setting.build_language == fake_build_language_type_c_e) { - path_sources = &main->path_sources_object_c; - } - else { - path_sources = &main->path_sources_object_cpp; - } - } - else if (main->parameters.array[fake_parameter_path_sources_e].result != f_console_result_additional_e) { - path_sources = &data_build->setting.path_sources_object; - } + fake_build_path_source_length(main, data_build, &data_build->setting.path_sources_object, &source); if (specific->used) { - source.used = path_sources->used + specific->used; + source.used += specific->used; } else { - source.used = path_sources->used + generic->used; + source.used += generic->used; } char source_string[source.used + 1]; source.string = source_string; - source_string[source.used] = 0; - memcpy(source_string, path_sources->string, path_sources->used); + fake_build_path_source_string(main, data_build, &data_build->setting.path_sources_object, &source); if (specific->used) { - memcpy(source_string + path_sources->used, specific->string, specific->used); + memcpy(source_string + source.used, specific->string, specific->used); + source.used += specific->used; } else { - memcpy(source_string + path_sources->used, generic->string, generic->used); + memcpy(source_string + source.used, generic->string, generic->used); + source.used += generic->used; } - status = fll_execute_arguments_add(source, arguments); + source_string[source.used] = 0; + + const f_status_t status = fll_execute_arguments_add(source, arguments); if (F_status_is_error(status)) return status; return F_none; diff --git a/level_3/fake/c/private-build.h b/level_3/fake/c/private-build.h index c8b9b38..27c9caa 100644 --- a/level_3/fake/c/private-build.h +++ b/level_3/fake/c/private-build.h @@ -178,15 +178,14 @@ extern "C" { extern f_status_t fake_build_objects_add(fake_main_t * const main, fake_build_data_t * const data_build, const f_string_static_t *path, const f_string_statics_t *generic, const f_string_statics_t *specific, f_string_dynamics_t *arguments) F_attribute_visibility_internal_d; #endif // _di_fake_build_objects_add_ - /** * Execute the build operation. * + * @param main + * The main program data. * @param setting_file * The name of the settings file to use. * If setting_file.used is 0, then the default or program parameter supplied file is used. - * @param main - * The main program data. * * @return * F_none on success. @@ -194,10 +193,48 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_build_operate_ - extern f_status_t fake_build_operate(const f_string_static_t setting_file, fake_main_t *main) F_attribute_visibility_internal_d; + extern f_status_t fake_build_operate(fake_main_t * const main, const f_string_static_t setting_file) F_attribute_visibility_internal_d; #endif // _di_fake_build_operate_ /** + * Calculate the length of the sources path so that it can be used to manually construct a static string. + * + * @param main + * The main program data. + * @param data_build + * The build data. + * @param setting_path_source + * The source path from the build settings file. + * @param source + * The static string. + * The path_sources.string is not expected to be defined at this point. + * The path_sources.used is updated. + * The path_sources.size is ignored. + */ +#ifndef _di_fake_build_path_source_length_ + extern void fake_build_path_source_length(fake_main_t * const main, fake_build_data_t * const data_build, f_string_static_t * const setting_path_source, f_string_static_t * const source) F_attribute_visibility_internal_d; +#endif // _di_fake_build_path_source_length_ + +/** + * Construct a static string array of the sources path. + * + * @param main + * The main program data. + * @param data_build + * The build data. + * @param setting_path_source + * The source path from the build settings file. + * @param source + * The static string. + * The path_sources.string is expected to be defined and set to a size from path_sources.used + 1. + * The path_sources.used is updated. + * The path_sources.size is ignored. + */ +#ifndef _di_fake_build_path_source_string_ + extern void fake_build_path_source_string(fake_main_t * const main, fake_build_data_t * const data_build, f_string_static_t * const setting_path_source, f_string_static_t * const source) F_attribute_visibility_internal_d; +#endif // _di_fake_build_path_source_string_ + +/** * Add the sources to the execute arguments array. * * @param main diff --git a/level_3/fake/c/private-fake-path_generate.c b/level_3/fake/c/private-fake-path_generate.c index d6ada65..f5fd737 100644 --- a/level_3/fake/c/private-fake-path_generate.c +++ b/level_3/fake/c/private-fake-path_generate.c @@ -20,15 +20,11 @@ extern "C" { const f_string_dynamic_t *parameters_source[] = { &main->path_build, &main->path_data, - &main->path_sources, - &main->path_sources_object, }; const uint8_t parameters_size[] = { 7, 2, - 4, - 4, }; f_string_dynamic_t *parameters_value_0[] = { @@ -46,28 +42,12 @@ extern "C" { &main->path_data_settings, }; - f_string_dynamic_t *parameters_value_2[] = { - &main->path_sources_bash, - &main->path_sources_c, - &main->path_sources_cpp, - &main->path_sources_script, - }; - - f_string_dynamic_t *parameters_value_3[] = { - &main->path_sources_object_bash, - &main->path_sources_object_c, - &main->path_sources_object_cpp, - &main->path_sources_object_script, - }; - f_string_dynamic_t **const parameters_value[] = { parameters_value_0, parameters_value_1, - parameters_value_2, - parameters_value_3, }; - for (i = 0; i < 4; ++i) { + for (i = 0; i < 2; ++i) { // Initialize all string lengths to 0. for (uint8_t j = 0; j < parameters_size[i]; ++j) { @@ -97,14 +77,6 @@ extern "C" { fake_path_part_settings_s, fake_path_part_documents_s, fake_path_part_licenses_s, - fake_path_part_bash_s, - fake_path_part_c_s, - fake_path_part_cpp_s, - fake_path_part_script_s, - fake_path_part_bash_s, - fake_path_part_c_s, - fake_path_part_cpp_s, - fake_path_part_script_s, }; f_string_dynamic_t * const parameters_value[] = { @@ -119,17 +91,9 @@ extern "C" { &main->path_data_settings, &main->path_documents, &main->path_licenses, - &main->path_sources_bash, - &main->path_sources_c, - &main->path_sources_cpp, - &main->path_sources_script, - &main->path_sources_object_bash, - &main->path_sources_object_c, - &main->path_sources_object_cpp, - &main->path_sources_object_script, }; - for (i = 0; i < 19; ++i) { + for (i = 0; i < 11; ++i) { status = f_string_dynamic_append_nulless(parameters_source[i], parameters_value[i]); @@ -408,11 +372,9 @@ extern "C" { &main->path_build_stage, &main->path_data_build, &main->path_data_settings, + &main->path_documents, &main->path_licenses, - &main->path_sources_bash, - &main->path_sources_c, - &main->path_sources_cpp, - &main->path_sources_script, + &main->path_sources, &main->path_work_includes, &main->path_work_libraries, &main->path_work_libraries_script, @@ -424,6 +386,8 @@ extern "C" { &main->path_work_programs_static, &main->file_data_build_defines, &main->file_data_build_dependencies, + &main->file_data_build_process_post_s, + &main->file_data_build_process_pre_s, &main->file_data_build_fakefile, &main->file_data_build_settings, &main->file_documents_readme, diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 0f1ca1c..89e94e0 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -334,32 +334,28 @@ extern "C" { const uint8_t parameters_id[] = { fake_parameter_path_build_e, fake_parameter_path_data_e, - fake_parameter_path_sources_e, fake_parameter_path_work_e, }; const f_string_static_t parameters_name[] = { fake_long_path_build_s, fake_long_path_data_s, - fake_long_path_sources_s, fake_long_path_work_s, }; const f_string_static_t parameter_defaults[] = { fake_default_path_build_s, fake_default_path_data_s, - fake_default_path_sources_s, fake_default_path_work_s, }; f_string_dynamic_t * const parameters_value[] = { &main->path_build, &main->path_data, - &main->path_sources, &main->path_work, }; - for (uint8_t i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 3; ++i) { if (main->parameters.array[parameters_id[i]].result == f_console_result_found_e) { fake_print_error_parameter_missing_value(main, parameters_name[i]); diff --git a/level_3/fake/c/private-make-operate_process.c b/level_3/fake/c/private-make-operate_process.c index 769c805..f051614 100644 --- a/level_3/fake/c/private-make-operate_process.c +++ b/level_3/fake/c/private-make-operate_process.c @@ -99,7 +99,7 @@ extern "C" { } if (state_process->operation == fake_make_operation_type_build_e) { - *status = fake_build_operate(arguments.used ? arguments.array[0] : f_string_empty_s, data_make->main); + *status = fake_build_operate(data_make->main, arguments.used ? arguments.array[0] : f_string_empty_s); if (F_status_set_fine(*status) == F_interrupt) { return 0; diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index bc843e7..47285cb 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -17,10 +17,44 @@ extern "C" { if (main->output.verbosity != f_console_verbosity_quiet_e) { fll_print_format("%rGenerating skeleton structure.%r", main->output.to.stream, f_string_eol_s, f_string_eol_s); + + if (main->output.verbosity == f_console_verbosity_verbose_e) { + fll_print_dynamic(f_string_eol_s, main->output.to.stream); + } } { - const f_string_dynamic_t *parameters_value[] = { + f_string_static_t sources = f_string_static_t_initialize; + f_string_static_t sources_bash = f_string_static_t_initialize; + f_string_static_t sources_c = f_string_static_t_initialize; + f_string_static_t sources_cpp = f_string_static_t_initialize; + f_string_static_t sources_script = f_string_static_t_initialize; + + fake_skeleton_path_source_length(main, &f_string_empty_s, &sources); + fake_skeleton_path_source_length(main, &fake_path_part_bash_s, &sources_bash); + fake_skeleton_path_source_length(main, &fake_path_part_c_s, &sources_c); + fake_skeleton_path_source_length(main, &fake_path_part_cpp_s, &sources_cpp); + fake_skeleton_path_source_length(main, &fake_path_part_script_s, &sources_script); + + char sources_string[sources.used + 1]; + char sources_bash_string[sources_bash.used + 1]; + char sources_c_string[sources_c.used + 1]; + char sources_cpp_string[sources_cpp.used + 1]; + char sources_script_string[sources_script.used + 1]; + + sources.string = sources_string; + sources_bash.string = sources_bash_string; + sources_c.string = sources_c_string; + sources_cpp.string = sources_cpp_string; + sources_script.string = sources_script_string; + + fake_skeleton_path_source_string(main, &f_string_empty_s, &sources); + fake_skeleton_path_source_string(main, &fake_path_part_bash_s, &sources_bash); + fake_skeleton_path_source_string(main, &fake_path_part_c_s, &sources_c); + fake_skeleton_path_source_string(main, &fake_path_part_cpp_s, &sources_cpp); + fake_skeleton_path_source_string(main, &fake_path_part_script_s, &sources_script); + + const f_string_static_t *parameters_value[] = { &main->path_build, &main->path_data, &main->path_data_build, @@ -28,9 +62,11 @@ extern "C" { &main->path_documents, &main->path_licenses, &main->path_sources, - &main->path_sources_bash, - &main->path_sources_c, - &main->path_sources_cpp, + &sources, + &sources_bash, + &sources_c, + &sources_cpp, + &sources_script, &main->path_work, &main->path_work_includes, &main->path_work_libraries, @@ -41,9 +77,10 @@ extern "C" { &main->path_work_programs_script, &main->path_work_programs_shared, &main->path_work_programs_static, + &fake_path_part_specifications_s, }; - for (uint8_t i = 0; i < 20; ++i) { + for (uint8_t i = 0; i < 23; ++i) { status = fake_skeleton_operate_directory_create(main, *parameters_value[i]); @@ -53,6 +90,10 @@ extern "C" { return status; } } // for + + if (main->output.verbosity == f_console_verbosity_verbose_e) { + fll_print_dynamic(f_string_eol_s, main->output.to.stream); + } } if (F_status_is_error_not(status)) { @@ -90,13 +131,11 @@ extern "C" { #endif // _di_fake_skeleton_operate_ #ifndef _di_fake_skeleton_operate_directory_create_ - f_status_t fake_skeleton_operate_directory_create(fake_main_t * const main, const f_string_dynamic_t path) { - - f_status_t status = F_none; + f_status_t fake_skeleton_operate_directory_create(fake_main_t * const main, const f_string_static_t path) { if (!path.used) return F_none; - status = f_directory_exists(path); + f_status_t status = f_directory_exists(path); if (status == F_true) { if (main->error.verbosity == f_console_verbosity_verbose_e) { @@ -154,7 +193,7 @@ extern "C" { #endif // _di_fake_skeleton_operate_directory_create_ #ifndef _di_fake_skeleton_operate_file_create_ - f_status_t fake_skeleton_operate_file_create(fake_main_t * const main, const f_string_dynamic_t path, const bool executable, const f_string_static_t content) { + f_status_t fake_skeleton_operate_file_create(fake_main_t * const main, const f_string_static_t path, const bool executable, const f_string_static_t content) { f_status_t status = F_none; @@ -240,6 +279,7 @@ extern "C" { fll_error_file_print(main->error, F_status_set_fine(status), "f_file_write", F_true, path, fake_common_file_populate_pre_s, fll_error_file_type_file_e); f_file_stream_close(F_true, &file); + return status; } @@ -260,6 +300,31 @@ extern "C" { } #endif // _di_fake_skeleton_operate_file_create_ +#ifndef _di_fake_skeleton_path_source_length_ + void fake_skeleton_path_source_length(fake_main_t * const main, const f_string_static_t *partial, f_string_static_t * const source) { + + source->used = main->path_sources.used + fake_default_path_sources_s.used + partial->used; + } +#endif // _di_fake_skeleton_path_source_length_ + +#ifndef _di_fake_skeleton_path_source_string_ + void fake_skeleton_path_source_string(fake_main_t * const main, const f_string_static_t *partial, f_string_static_t * const source) { + + source->used = 0; + + memcpy(source->string, main->path_sources.string, main->path_sources.used); + source->used += main->path_sources.used; + + memcpy(source->string, fake_default_path_sources_s.string, fake_default_path_sources_s.used); + source->used += fake_default_path_sources_s.used; + + memcpy(source->string + source->used, partial->string, partial->used); + source->used += partial->used; + + source->string[source->used] = 0; + } +#endif // _di_fake_skeleton_path_source_string_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-skeleton.h b/level_3/fake/c/private-skeleton.h index c786b1a..cf5dc21 100644 --- a/level_3/fake/c/private-skeleton.h +++ b/level_3/fake/c/private-skeleton.h @@ -44,7 +44,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_skeleton_operate_directory_create_ - extern f_status_t fake_skeleton_operate_directory_create(fake_main_t * const main, const f_string_dynamic_t path) F_attribute_visibility_internal_d; + extern f_status_t fake_skeleton_operate_directory_create(fake_main_t * const main, const f_string_static_t path) F_attribute_visibility_internal_d; #endif // _di_fake_skeleton_operate_directory_create_ /** @@ -67,9 +67,43 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_skeleton_operate_file_create_ - extern f_status_t fake_skeleton_operate_file_create(fake_main_t * const main, const f_string_dynamic_t path, const bool executable, const f_string_static_t content) F_attribute_visibility_internal_d; + extern f_status_t fake_skeleton_operate_file_create(fake_main_t * const main, const f_string_static_t path, const bool executable, const f_string_static_t content) F_attribute_visibility_internal_d; #endif // _di_fake_skeleton_operate_file_create_ +/** + * Calculate the length of the sources path so that it can be used to manually construct a static string. + * + * @param main + * The main program data. + * @param partial + * The partial path string, such as "bash". + * @param source + * The static string. + * The path_sources.string is not expected to be defined at this point. + * The path_sources.used is updated. + * The path_sources.size is ignored. + */ +#ifndef _di_fake_skeleton_path_source_length_ + extern void fake_skeleton_path_source_length(fake_main_t * const main, const f_string_static_t *partial, f_string_static_t * const source) F_attribute_visibility_internal_d; +#endif // _di_fake_skeleton_path_source_length_ + +/** + * Construct a static string array of the sources path. + * + * @param main + * The main program data. + * @param partial + * The partial path string, such as "bash". + * @param source + * The static string. + * The path_sources.string is expected to be defined and set to a size from path_sources.used + 1. + * The path_sources.used is updated. + * The path_sources.size is ignored. + */ +#ifndef _di_fake_skeleton_path_source_string_ + extern void fake_skeleton_path_source_string(fake_main_t * const main, const f_string_static_t *partial, f_string_static_t * const source) F_attribute_visibility_internal_d; +#endif // _di_fake_skeleton_path_source_string_ + #ifdef __cplusplus } // extern "C" #endif