From: Kevin Day Date: Sat, 9 May 2020 04:31:22 +0000 (-0500) Subject: Progress: continue work on fake X-Git-Tag: 0.5.0~276 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=23b9ecb0e98277affcad7c82c52a7a24780bbda6;p=fll Progress: continue work on fake --- diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 8ae5443..981f78e 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -216,30 +216,16 @@ extern "C" { return f_status_set_error(status); } - status = fake_load_settings_data(*data, &data->settings_data); - - if (f_status_is_error(status)) { - fake_delete_data(data); - return f_status_set_error(status); - } - for (uint8_t i = 0; i < fake_operations_total && operations[i]; i++) { data->operation = operations[i]; if (operations[i] == fake_operation_build) { - status = fake_build_execute_process_script(*data, data->settings_data.process_pre); - if (f_status_is_error(status)) { - // @todo handle errors. - break; - } - - 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", fake_other_operation_build); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is not yet implemented."); + status = fake_build_operate(*data); - status = fake_build_execute_process_script(*data, data->settings_data.process_post); if (f_status_is_error(status)) { - // @todo handle errors. + 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", fake_other_operation_clean); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' failed."); break; } } @@ -296,8 +282,6 @@ extern "C" { f_macro_string_dynamic_delete_simple(data->path_source_licenses); f_macro_string_dynamic_delete_simple(data->path_source_settings); - fake_macro_settings_data_delete_simple(data->settings_data); - fl_macro_color_context_delete_simple(data->context); return f_none; diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 2a3a251..cd69025 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -9,7 +9,7 @@ * * This program is intented only to build source code into binaries. * It specifically does not install, test, or package some project. - * It does provide the built binaries and scripts in a consistent location for other programs to operate on. + * It does provide the built binaries and scripts in a consistent range for other programs to operate on. * * This currently only supports a few select languages. * Additional languages can be provided via explicit operations. @@ -55,11 +55,17 @@ * "build_sources_headers" * "build_sources_library" * "build_sources_program" - * "build_sources_settings" + * "build_sources_setting" * "build_sources_shell" * * "build_static" * + * "path_headers" + * "path_library_shared" + * "path_library_static" + * "path_program_shared" + * "path_program_static" + * * "defines_all" * "defines_shared" * "defines_static" @@ -120,7 +126,7 @@ // fll-2 includes #include #include -#include +#include #include // Temporary include, remove this. @@ -215,235 +221,6 @@ extern "C" { #define fake_default_language_shell_length 6 #endif // _di_fake_defaults_ -#ifndef _di_settings_data_ - typedef struct { - f_string_dynamic build_compiler; - f_string_dynamic build_libraries; - f_string_dynamic build_linker; - f_string_dynamic build_shared; - f_string_dynamic build_sources_headers; - f_string_dynamic build_sources_library; - f_string_dynamic build_sources_program; - f_string_dynamic build_sources_settings; - f_string_dynamic build_sources_shell; - f_string_dynamic build_static; - f_string_dynamic defines_all; - f_string_dynamic defines_shared; - f_string_dynamic defines_static; - f_string_dynamic flags_all; - f_string_dynamic flags_library; - f_string_dynamic flags_program; - f_string_dynamic flags_shared; - f_string_dynamic flags_static; - f_string_dynamic path_language; - f_string_dynamic process_post; - f_string_dynamic process_pre; - f_string_dynamic project_level; - f_string_dynamic project_name; - f_string_dynamic version_major; - f_string_dynamic version_micro; - f_string_dynamic version_minor; - } fake_settings_data; - - #define fake_settings_data_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, 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 } - - #define fake_macro_settings_build_clear(settings_data) \ - f_macro_string_dynamic_clear(settings_data.build_compiler) \ - f_macro_string_dynamic_clear(settings_data.build_libraries) \ - f_macro_string_dynamic_clear(settings_data.build_linker) \ - f_macro_string_dynamic_clear(settings_data.build_shared) \ - f_macro_string_dynamic_clear(settings_data.build_sources_headers) \ - f_macro_string_dynamic_clear(settings_data.build_sources_library) \ - f_macro_string_dynamic_clear(settings_data.build_sources_program) \ - f_macro_string_dynamic_clear(settings_data.build_sources_settings) \ - f_macro_string_dynamic_clear(settings_data.build_sources_shell) \ - f_macro_string_dynamic_clear(settings_data.build_static) \ - f_macro_string_dynamic_clear(settings_data.defines_all) \ - f_macro_string_dynamic_clear(settings_data.defines_shared) \ - f_macro_string_dynamic_clear(settings_data.defines_static) \ - f_macro_string_dynamic_clear(settings_data.flags_all) \ - f_macro_string_dynamic_clear(settings_data.flags_library) \ - f_macro_string_dynamic_clear(settings_data.flags_program) \ - f_macro_string_dynamic_clear(settings_data.flags_shared) \ - f_macro_string_dynamic_clear(settings_data.flags_static) \ - f_macro_string_dynamic_clear(settings_data.path_language) \ - f_macro_string_dynamic_clear(settings_data.process_post) \ - f_macro_string_dynamic_clear(settings_data.process_pre) \ - f_macro_string_dynamic_clear(settings_data.project_level) \ - f_macro_string_dynamic_clear(settings_data.project_name) \ - f_macro_string_dynamic_clear(settings_data.version_major) \ - f_macro_string_dynamic_clear(settings_data.version_micro) \ - f_macro_string_dynamic_clear(settings_data.version_minor) - - #define fake_macro_settings_data_delete(status, settings_data) \ - f_macro_string_dynamic_delete(status, settings_data.build_compiler) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_libraries) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_linker) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_shared) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_sources_headers) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_sources_library) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_sources_program) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_sources_settings) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_sources_shell) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.build_static) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.defines_all) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.defines_shared) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.defines_static) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.flags_all) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.flags_library) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.flags_program) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.flags_shared) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.flags_static) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.path_language) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.process_post) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.process_pre) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.project_level) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.project_name) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.version_major) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.version_micro) \ - if (status == f_none) f_macro_string_dynamic_delete(status, settings_data.version_minor) - - #define fake_macro_settings_data_destroy(status, settings_data, length) \ - f_macro_string_dynamic_delete(status, settings_data.build_compiler) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_libraries) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_linker) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_shared) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_sources_headers) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_sources_library) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_sources_program) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_sources_settings) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_sources_shell) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.build_static) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.defines_all) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.defines_shared) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.defines_static) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.flags_all) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.flags_library) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.flags_program) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.flags_shared) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.flags_static) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.path_language) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.process_post) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.process_pre) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.project_level) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.project_name) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.version_major) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.version_micro) \ - if (status == f_none) f_macro_string_dynamic_destroy(status, settings_data.version_minor) - - #define fake_macro_settings_data_delete_simple(settings_data) \ - f_macro_string_dynamic_delete_simple(settings_data.build_compiler) \ - f_macro_string_dynamic_delete_simple(settings_data.build_libraries) \ - f_macro_string_dynamic_delete_simple(settings_data.build_linker) \ - f_macro_string_dynamic_delete_simple(settings_data.build_shared) \ - f_macro_string_dynamic_delete_simple(settings_data.build_sources_headers) \ - f_macro_string_dynamic_delete_simple(settings_data.build_sources_library) \ - f_macro_string_dynamic_delete_simple(settings_data.build_sources_program) \ - f_macro_string_dynamic_delete_simple(settings_data.build_sources_settings) \ - f_macro_string_dynamic_delete_simple(settings_data.build_sources_shell) \ - f_macro_string_dynamic_delete_simple(settings_data.build_static) \ - f_macro_string_dynamic_delete_simple(settings_data.defines_all) \ - f_macro_string_dynamic_delete_simple(settings_data.defines_shared) \ - f_macro_string_dynamic_delete_simple(settings_data.defines_static) \ - f_macro_string_dynamic_delete_simple(settings_data.flags_all) \ - f_macro_string_dynamic_delete_simple(settings_data.flags_library) \ - f_macro_string_dynamic_delete_simple(settings_data.flags_program) \ - f_macro_string_dynamic_delete_simple(settings_data.flags_shared) \ - f_macro_string_dynamic_delete_simple(settings_data.flags_static) \ - f_macro_string_dynamic_delete_simple(settings_data.path_language) \ - f_macro_string_dynamic_delete_simple(settings_data.process_post) \ - f_macro_string_dynamic_delete_simple(settings_data.process_pre) \ - f_macro_string_dynamic_delete_simple(settings_data.project_level) \ - f_macro_string_dynamic_delete_simple(settings_data.project_name) \ - f_macro_string_dynamic_delete_simple(settings_data.version_major) \ - f_macro_string_dynamic_delete_simple(settings_data.version_micro) \ - f_macro_string_dynamic_delete_simple(settings_data.version_minor) - - #define fake_macro_settings_data_destroy_simple(settings_data, length) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_compiler) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_libraries) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_linker) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_shared) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_sources_headers) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_sources_library) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_sources_program) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_sources_settings) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_sources_shell) \ - f_macro_string_dynamic_destroy_simple(settings_data.build_static) \ - f_macro_string_dynamic_destroy_simple(settings_data.defines_all) \ - f_macro_string_dynamic_destroy_simple(settings_data.defines_shared) \ - f_macro_string_dynamic_destroy_simple(settings_data.defines_static) \ - f_macro_string_dynamic_destroy_simple(settings_data.flags_all) \ - f_macro_string_dynamic_destroy_simple(settings_data.flags_library) \ - f_macro_string_dynamic_destroy_simple(settings_data.flags_program) \ - f_macro_string_dynamic_destroy_simple(settings_data.flags_shared) \ - f_macro_string_dynamic_destroy_simple(settings_data.flags_static) \ - f_macro_string_dynamic_destroy_simple(settings_data.path_language) \ - f_macro_string_dynamic_destroy_simple(settings_data.process_post) \ - f_macro_string_dynamic_destroy_simple(settings_data.process_pre) \ - f_macro_string_dynamic_destroy_simple(settings_data.project_level) \ - f_macro_string_dynamic_destroy_simple(settings_data.project_name) \ - f_macro_string_dynamic_destroy_simple(settings_data.version_major) \ - f_macro_string_dynamic_destroy_simple(settings_data.version_micro) \ - f_macro_string_dynamic_destroy_simple(settings_data.version_minor) - - #define fake_settings_name_build_compiler "build_compiler" - #define fake_settings_name_build_libraries "build_libraries" - #define fake_settings_name_build_linker "build_linker" - #define fake_settings_name_build_shared "build_shared" - #define fake_settings_name_build_sources_headers "build_sources_headers" - #define fake_settings_name_build_sources_library "build_sources_library" - #define fake_settings_name_build_sources_program "build_sources_program" - #define fake_settings_name_build_sources_settings "build_sources_settings" - #define fake_settings_name_build_sources_shell "build_sources_shell" - #define fake_settings_name_build_static "build_static" - #define fake_settings_name_defines_all "defines_all" - #define fake_settings_name_defines_shared "defines_shared" - #define fake_settings_name_defines_static "defines_static" - #define fake_settings_name_flags_all "flags_all" - #define fake_settings_name_flags_library "flags_library" - #define fake_settings_name_flags_program "flags_program" - #define fake_settings_name_flags_shared "flags_shared" - #define fake_settings_name_flags_static "flags_static" - #define fake_settings_name_path_language "path_language" - #define fake_settings_name_process_post "process_post" - #define fake_settings_name_process_pre "process_pre" - #define fake_settings_name_project_level "project_level" - #define fake_settings_name_project_name "project_name" - #define fake_settings_name_version_major "version_major" - #define fake_settings_name_version_micro "version_micro" - #define fake_settings_name_version_minor "version_minor" - - #define fake_settings_name_build_compiler_length 14 - #define fake_settings_name_build_libraries_length 15 - #define fake_settings_name_build_linker_length 12 - #define fake_settings_name_build_shared_length 12 - #define fake_settings_name_build_sources_headers_length 21 - #define fake_settings_name_build_sources_library_length 21 - #define fake_settings_name_build_sources_program_length 21 - #define fake_settings_name_build_sources_settings_length 22 - #define fake_settings_name_build_sources_shell_length 19 - #define fake_settings_name_build_static_length 12 - #define fake_settings_name_defines_all_length 11 - #define fake_settings_name_defines_shared_length 14 - #define fake_settings_name_defines_static_length 14 - #define fake_settings_name_flags_all_length 9 - #define fake_settings_name_flags_library_length 13 - #define fake_settings_name_flags_program_length 13 - #define fake_settings_name_flags_shared_length 12 - #define fake_settings_name_flags_static_length 12 - #define fake_settings_name_path_language_length 13 - #define fake_settings_name_process_post_length 12 - #define fake_settings_name_process_pre_length 11 - #define fake_settings_name_project_level_length 13 - #define fake_settings_name_project_name_length 12 - #define fake_settings_name_version_major_length 13 - #define fake_settings_name_version_micro_length 13 - #define fake_settings_name_version_minor_length 13 - - #define fake_settings_total 26 -#endif // _di_settings_data_ - #ifndef _di_fake_build_language_ enum { fake_build_language_c = 1, @@ -653,8 +430,6 @@ extern "C" { f_string_dynamic path_source_licenses; f_string_dynamic path_source_settings; - fake_settings_data settings_data; - fl_color_context context; } fake_data; @@ -677,7 +452,6 @@ extern "C" { f_string_dynamic_initialize, \ f_string_dynamic_initialize, \ f_string_dynamic_initialize, \ - fake_settings_data_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 f334345..cc8f167 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -6,8 +6,313 @@ extern "C" { #endif +#ifndef _di_fake_build_load_settings_ + f_return_status fake_build_load_settings(const fake_data data, fake_build_settings *settings) { + 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, 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); + + if (status == f_true) { + name_function = "f_file_open"; + status = f_file_open(&file, path.string); + + if (status == f_none) { + name_function = "fl_file_read_position"; + status = fl_file_read(&file, &buffer); + + f_file_close(&file); + } + } + else if (status == f_false) { + status = f_status_set_error(f_file_not_found); + } + + if (f_status_is_error(status)) { + fake_print_error_file(data.context, f_status_set_fine(status), name_function, path.string, "file", f_true); + + f_macro_string_dynamic_delete_simple(buffer); + f_macro_string_dynamic_delete_simple(path); + return status; + } + } + + if (buffer.used > 0) { + f_fss_objects objects = f_fss_objects_initialize; + f_fss_contents contents = f_fss_contents_initialize; + f_string_range range = f_string_range_initialize; + + range.start = 0; + range.stop = buffer.used - 1; + + status = fll_fss_extended_read(&buffer, &range, &objects, &contents); + + if (f_status_is_error(status)) { + f_macro_fss_objects_delete_simple(objects); + f_macro_fss_contents_delete_simple(contents); + f_macro_string_dynamic_delete_simple(buffer); + + if (status == f_status_set_error(f_incomplete_utf_on_stop)) { + 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_line(f_standard_error, data.context.error, data.context.reset, "')."); + } + else if (status == f_status_set_error(f_incomplete_utf_on_stop)) { + 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_line(f_standard_error, data.context.error, data.context.reset, "')."); + } + else { + fake_print_error(data.context, f_status_set_fine(status), "fll_fss_extended_read", true); + } + + 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; + } + + { + const f_string setting_names[] = { + fake_build_settings_name_build_compiler, + fake_build_settings_name_build_libraries, + fake_build_settings_name_build_linker, + fake_build_settings_name_build_shared, + fake_build_settings_name_build_sources_headers, + fake_build_settings_name_build_sources_library, + fake_build_settings_name_build_sources_program, + fake_build_settings_name_build_sources_settings, + fake_build_settings_name_build_sources_shell, + fake_build_settings_name_build_static, + fake_build_settings_name_defines_all, + fake_build_settings_name_defines_shared, + fake_build_settings_name_defines_static, + fake_build_settings_name_flags_all, + fake_build_settings_name_flags_library, + fake_build_settings_name_flags_program, + fake_build_settings_name_flags_shared, + fake_build_settings_name_flags_static, + fake_build_settings_name_path_language, + fake_build_settings_name_path_headers, + fake_build_settings_name_path_library_shared, + fake_build_settings_name_path_library_static, + fake_build_settings_name_path_program_shared, + fake_build_settings_name_path_program_static, + fake_build_settings_name_process_post, + fake_build_settings_name_process_pre, + fake_build_settings_name_project_level, + fake_build_settings_name_project_name, + fake_build_settings_name_version_major, + fake_build_settings_name_version_micro, + fake_build_settings_name_version_minor, + }; + + const f_string_length setting_lengths[] = { + fake_build_settings_name_build_compiler_length, + fake_build_settings_name_build_libraries_length, + fake_build_settings_name_build_linker_length, + fake_build_settings_name_build_shared_length, + fake_build_settings_name_build_sources_headers_length, + fake_build_settings_name_build_sources_library_length, + fake_build_settings_name_build_sources_program_length, + fake_build_settings_name_build_sources_settings_length, + fake_build_settings_name_build_sources_shell_length, + fake_build_settings_name_build_static_length, + fake_build_settings_name_defines_all_length, + fake_build_settings_name_defines_shared_length, + fake_build_settings_name_defines_static_length, + fake_build_settings_name_flags_all_length, + fake_build_settings_name_flags_library_length, + fake_build_settings_name_flags_program_length, + fake_build_settings_name_flags_shared_length, + fake_build_settings_name_flags_static_length, + fake_build_settings_name_path_language_length, + fake_build_settings_name_path_headers_length, + fake_build_settings_name_path_library_shared_length, + fake_build_settings_name_path_library_static_length, + fake_build_settings_name_path_program_shared_length, + fake_build_settings_name_path_program_static_length, + fake_build_settings_name_process_post_length, + fake_build_settings_name_process_pre_length, + fake_build_settings_name_project_level_length, + fake_build_settings_name_project_name_length, + fake_build_settings_name_version_major_length, + fake_build_settings_name_version_micro_length, + fake_build_settings_name_version_minor_length, + }; + + f_string_dynamic *setting_values[] = { + &settings->build_compiler, + &settings->build_libraries, + &settings->build_linker, + &settings->build_shared, + &settings->build_sources_headers, + &settings->build_sources_library, + &settings->build_sources_program, + &settings->build_sources_setting, + &settings->build_sources_shell, + &settings->build_static, + &settings->defines_all, + &settings->defines_shared, + &settings->defines_static, + &settings->flags_all, + &settings->flags_library, + &settings->flags_program, + &settings->flags_shared, + &settings->flags_static, + &settings->path_language, + &settings->path_headers, + &settings->path_library_shared, + &settings->path_library_static, + &settings->path_program_shared, + &settings->path_program_static, + &settings->process_post, + &settings->process_pre, + &settings->project_level, + &settings->project_name, + &settings->version_major, + &settings->version_micro, + &settings->version_minor, + }; + + // @todo change this to use fll_fss_snatch_apart() so that each string can be a distinct argument for fll_execute functions. + status = fll_fss_snatch_mash_together(buffer, objects, contents, setting_names, setting_lengths, setting_values, fake_build_settings_total, " ", 1); + + if (status == f_none) { + for (f_array_length i = 0; i < data.mode.used; i++) { + f_string_dynamic settings_mode_name_dynamic[fake_build_settings_total]; + f_string settings_mode_names[fake_build_settings_total]; + f_string_length setting_mode_lengths[fake_build_settings_total]; + + memset(&settings_mode_name_dynamic, 0, sizeof(f_string_dynamic) * fake_build_settings_total); + memset(&settings_mode_names, 0, sizeof(f_string) * fake_build_settings_total); + + for (f_string_length j = 0; j < fake_build_settings_total; j++) { + setting_mode_lengths[j] = setting_lengths[j] + 1 + data.mode.array[i].used; + + f_macro_string_dynamic_new(status, settings_mode_name_dynamic[j], setting_mode_lengths[j]); + if (f_status_is_error(status)) break; + + memcpy(settings_mode_name_dynamic[j].string, setting_names[j], setting_lengths[j]); + memcpy(settings_mode_name_dynamic[j].string + setting_lengths[j] + 1, data.mode.array[i].string, data.mode.array[i].used); + settings_mode_name_dynamic[j].string[setting_lengths[j]] = '-'; + + settings_mode_names[j] = settings_mode_name_dynamic[j].string; + } // for + + if (status == f_none) { + status = fll_fss_snatch_mash_together(buffer, objects, contents, settings_mode_names, setting_mode_lengths, setting_values, fake_build_settings_total, " ", 1); + } + + for (f_string_length j = 0; j < fake_build_settings_total; j++) { + f_macro_string_dynamic_delete_simple(settings_mode_name_dynamic[j]); + } // for + + if (f_status_is_error(status)) break; + } // for + + if (f_status_is_error(status)) { + fake_print_error(data.context, f_status_set_fine(status), "f_macro_string_dynamic_new", f_true); + + 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; + } + } + + if (f_status_is_error(status)) { + if (status == f_status_set_error(f_string_too_large)) { + 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_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); + } + else { + fake_print_error(data.context, f_status_set_fine(status), "fl_string_dynamic_partial_mash", f_true); + } + } + } + + 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); + + // @todo: perform validation of values, such as "shared" and "static", at least one must be "yes". + + return status; + } +#endif // _di_fake_build_load_settings_ + +#ifndef _di_fake_build_operate_ + f_return_status fake_build_operate(const fake_data data) { + f_status status = f_none; + fake_build_settings settings = fake_build_settings_initialize; + + status = fake_build_load_settings(data, &settings); + + if (f_status_is_error(status)) { + fake_macro_build_settings_delete_simple(settings); + return f_status_set_error(status); + } + + status = fake_build_execute_process_script(data, settings, settings.process_pre); + if (f_status_is_error(status)) { + // @todo handle errors. + } + + // @todo: may have to process all data intended to be used in parameters, exploding them into console parameters. + // Steps: + // 1) copy sources settings to build settings + // 2) copy sources headers to build headers + // 3) if shared=yes and library sources exist, compile shared libraries and make links. + // 4) if shared=yes and program sources exist, compile shared programs. + // 5) if static=yes and library sources exist, compile static objects. + // 6) if static=yes and library sources exist, link static objects into static library (appending objects to path for static programs to compile against). + // 7) if static=yes and program sources exist, compile static programs (include any static objects). + // 8) touch build file designating that build fully completed. + + status = fake_build_execute_process_script(data, settings, settings.process_post); + if (f_status_is_error(status)) { + // @todo handle errors. + } + + fake_macro_build_settings_delete_simple(settings); + + return status; + } +#endif // _di_fake_build_operate_ + #ifndef _di_fake_build_execute_process_script_ - f_return_status fake_build_execute_process_script(const fake_data data, const f_string_dynamic process_script) { + f_return_status fake_build_execute_process_script(const fake_data data, const fake_build_settings settings, const f_string_dynamic process_script) { if (process_script.used == 0) return f_none; f_status status = f_none; diff --git a/level_3/fake/c/private-build.h b/level_3/fake/c/private-build.h index 492012b..1104cc6 100644 --- a/level_3/fake/c/private-build.h +++ b/level_3/fake/c/private-build.h @@ -12,21 +12,323 @@ extern "C" { #endif +#ifndef _di_fake_build_settings_ + typedef struct { + f_string_dynamic build_compiler; + f_string_dynamic build_libraries; + f_string_dynamic build_linker; + f_string_dynamic build_shared; + f_string_dynamic build_sources_headers; + f_string_dynamic build_sources_library; + f_string_dynamic build_sources_program; + f_string_dynamic build_sources_setting; + f_string_dynamic build_sources_shell; + f_string_dynamic build_static; + f_string_dynamic defines_all; + f_string_dynamic defines_shared; + f_string_dynamic defines_static; + f_string_dynamic flags_all; + f_string_dynamic flags_library; + f_string_dynamic flags_program; + f_string_dynamic flags_shared; + f_string_dynamic flags_static; + f_string_dynamic path_language; + f_string_dynamic path_headers; + f_string_dynamic path_library_shared; + f_string_dynamic path_library_static; + f_string_dynamic path_program_shared; + f_string_dynamic path_program_static; + f_string_dynamic process_post; + f_string_dynamic process_pre; + f_string_dynamic project_level; + f_string_dynamic project_name; + f_string_dynamic version_major; + f_string_dynamic version_micro; + f_string_dynamic version_minor; + } fake_build_settings; + + #define fake_build_settings_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, 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 } + + #define fake_macro_settings_build_clear(settings) \ + f_macro_string_dynamic_clear(settings.build_compiler) \ + f_macro_string_dynamic_clear(settings.build_libraries) \ + f_macro_string_dynamic_clear(settings.build_linker) \ + f_macro_string_dynamic_clear(settings.build_shared) \ + f_macro_string_dynamic_clear(settings.build_sources_headers) \ + f_macro_string_dynamic_clear(settings.build_sources_library) \ + f_macro_string_dynamic_clear(settings.build_sources_program) \ + f_macro_string_dynamic_clear(settings.build_sources_setting) \ + f_macro_string_dynamic_clear(settings.build_sources_shell) \ + f_macro_string_dynamic_clear(settings.build_static) \ + f_macro_string_dynamic_clear(settings.defines_all) \ + f_macro_string_dynamic_clear(settings.defines_shared) \ + f_macro_string_dynamic_clear(settings.defines_static) \ + f_macro_string_dynamic_clear(settings.flags_all) \ + f_macro_string_dynamic_clear(settings.flags_library) \ + f_macro_string_dynamic_clear(settings.flags_program) \ + f_macro_string_dynamic_clear(settings.flags_shared) \ + f_macro_string_dynamic_clear(settings.flags_static) \ + f_macro_string_dynamic_clear(settings.path_language) \ + f_macro_string_dynamic_clear(settings.path_headers) \ + f_macro_string_dynamic_clear(settings.path_libary_shared) \ + f_macro_string_dynamic_clear(settings.path_library_static) \ + f_macro_string_dynamic_clear(settings.path_program_shared) \ + f_macro_string_dynamic_clear(settings.path_program_static) \ + f_macro_string_dynamic_clear(settings.process_post) \ + f_macro_string_dynamic_clear(settings.process_pre) \ + f_macro_string_dynamic_clear(settings.project_level) \ + f_macro_string_dynamic_clear(settings.project_name) \ + f_macro_string_dynamic_clear(settings.version_major) \ + f_macro_string_dynamic_clear(settings.version_micro) \ + f_macro_string_dynamic_clear(settings.version_minor) + + #define fake_macro_build_settings_delete(status, settings) \ + f_macro_string_dynamic_delete(status, settings.build_compiler) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_libraries) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_linker) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_shared) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_sources_headers) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_sources_library) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_sources_program) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_sources_setting) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_sources_shell) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.build_static) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.defines_all) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.defines_shared) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.defines_static) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.flags_all) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.flags_library) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.flags_program) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.flags_shared) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.flags_static) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_language) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_headers) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_library_shared) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_library_static) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_library_shared) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.path_library_static) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.process_post) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.process_pre) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.project_level) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.project_name) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.version_major) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.version_micro) \ + if (status == f_none) f_macro_string_dynamic_delete(status, settings.version_minor) + + #define fake_macro_build_settings_destroy(status, settings, length) \ + f_macro_string_dynamic_delete(status, settings.build_compiler) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_libraries) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_linker) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_shared) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_sources_headers) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_sources_library) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_sources_program) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_sources_setting) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_sources_shell) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.build_static) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.defines_all) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.defines_shared) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.defines_static) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.flags_all) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.flags_library) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.flags_program) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.flags_shared) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.flags_static) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_language) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_headers) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_library_shared) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_library_static) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_program_shared) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.path_program_static) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.process_post) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.process_pre) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.project_level) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.project_name) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.version_major) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.version_micro) \ + if (status == f_none) f_macro_string_dynamic_destroy(status, settings.version_minor) + + #define fake_macro_build_settings_delete_simple(settings) \ + f_macro_string_dynamic_delete_simple(settings.build_compiler) \ + f_macro_string_dynamic_delete_simple(settings.build_libraries) \ + f_macro_string_dynamic_delete_simple(settings.build_linker) \ + f_macro_string_dynamic_delete_simple(settings.build_shared) \ + f_macro_string_dynamic_delete_simple(settings.build_sources_headers) \ + f_macro_string_dynamic_delete_simple(settings.build_sources_library) \ + f_macro_string_dynamic_delete_simple(settings.build_sources_program) \ + f_macro_string_dynamic_delete_simple(settings.build_sources_setting) \ + f_macro_string_dynamic_delete_simple(settings.build_sources_shell) \ + f_macro_string_dynamic_delete_simple(settings.build_static) \ + f_macro_string_dynamic_delete_simple(settings.defines_all) \ + f_macro_string_dynamic_delete_simple(settings.defines_shared) \ + f_macro_string_dynamic_delete_simple(settings.defines_static) \ + f_macro_string_dynamic_delete_simple(settings.flags_all) \ + f_macro_string_dynamic_delete_simple(settings.flags_library) \ + f_macro_string_dynamic_delete_simple(settings.flags_program) \ + f_macro_string_dynamic_delete_simple(settings.flags_shared) \ + f_macro_string_dynamic_delete_simple(settings.flags_static) \ + f_macro_string_dynamic_delete_simple(settings.path_language) \ + f_macro_string_dynamic_delete_simple(settings.path_headers) \ + f_macro_string_dynamic_delete_simple(settings.path_library_shared) \ + f_macro_string_dynamic_delete_simple(settings.path_library_static) \ + f_macro_string_dynamic_delete_simple(settings.path_program_shared) \ + f_macro_string_dynamic_delete_simple(settings.path_program_static) \ + f_macro_string_dynamic_delete_simple(settings.process_post) \ + f_macro_string_dynamic_delete_simple(settings.process_pre) \ + f_macro_string_dynamic_delete_simple(settings.project_level) \ + f_macro_string_dynamic_delete_simple(settings.project_name) \ + f_macro_string_dynamic_delete_simple(settings.version_major) \ + f_macro_string_dynamic_delete_simple(settings.version_micro) \ + f_macro_string_dynamic_delete_simple(settings.version_minor) + + #define fake_macro_build_settings_destroy_simple(settings, length) \ + f_macro_string_dynamic_destroy_simple(settings.build_compiler) \ + f_macro_string_dynamic_destroy_simple(settings.build_libraries) \ + f_macro_string_dynamic_destroy_simple(settings.build_linker) \ + f_macro_string_dynamic_destroy_simple(settings.build_shared) \ + f_macro_string_dynamic_destroy_simple(settings.build_sources_headers) \ + f_macro_string_dynamic_destroy_simple(settings.build_sources_library) \ + f_macro_string_dynamic_destroy_simple(settings.build_sources_program) \ + f_macro_string_dynamic_destroy_simple(settings.build_sources_setting) \ + f_macro_string_dynamic_destroy_simple(settings.build_sources_shell) \ + f_macro_string_dynamic_destroy_simple(settings.build_static) \ + f_macro_string_dynamic_destroy_simple(settings.defines_all) \ + f_macro_string_dynamic_destroy_simple(settings.defines_shared) \ + f_macro_string_dynamic_destroy_simple(settings.defines_static) \ + f_macro_string_dynamic_destroy_simple(settings.flags_all) \ + f_macro_string_dynamic_destroy_simple(settings.flags_library) \ + f_macro_string_dynamic_destroy_simple(settings.flags_program) \ + f_macro_string_dynamic_destroy_simple(settings.flags_shared) \ + f_macro_string_dynamic_destroy_simple(settings.flags_static) \ + f_macro_string_dynamic_destroy_simple(settings.path_language) \ + f_macro_string_dynamic_destroy_simple(settings.path_headers) \ + f_macro_string_dynamic_destroy_simple(settings.path_library_shared) \ + f_macro_string_dynamic_destroy_simple(settings.path_library_static) \ + f_macro_string_dynamic_destroy_simple(settings.path_program_shared) \ + f_macro_string_dynamic_destroy_simple(settings.path_program_static) \ + f_macro_string_dynamic_destroy_simple(settings.process_post) \ + f_macro_string_dynamic_destroy_simple(settings.process_pre) \ + f_macro_string_dynamic_destroy_simple(settings.project_level) \ + f_macro_string_dynamic_destroy_simple(settings.project_name) \ + f_macro_string_dynamic_destroy_simple(settings.version_major) \ + f_macro_string_dynamic_destroy_simple(settings.version_micro) \ + f_macro_string_dynamic_destroy_simple(settings.version_minor) + + #define fake_build_settings_name_build_compiler "build_compiler" + #define fake_build_settings_name_build_libraries "build_libraries" + #define fake_build_settings_name_build_linker "build_linker" + #define fake_build_settings_name_build_shared "build_shared" + #define fake_build_settings_name_build_sources_headers "build_sources_headers" + #define fake_build_settings_name_build_sources_library "build_sources_library" + #define fake_build_settings_name_build_sources_program "build_sources_program" + #define fake_build_settings_name_build_sources_settings "build_sources_setting" + #define fake_build_settings_name_build_sources_shell "build_sources_shell" + #define fake_build_settings_name_build_static "build_static" + #define fake_build_settings_name_defines_all "defines_all" + #define fake_build_settings_name_defines_shared "defines_shared" + #define fake_build_settings_name_defines_static "defines_static" + #define fake_build_settings_name_flags_all "flags_all" + #define fake_build_settings_name_flags_library "flags_library" + #define fake_build_settings_name_flags_program "flags_program" + #define fake_build_settings_name_flags_shared "flags_shared" + #define fake_build_settings_name_flags_static "flags_static" + #define fake_build_settings_name_path_language "path_language" + #define fake_build_settings_name_path_headers "path_headers" + #define fake_build_settings_name_path_library_shared "path_library_shared" + #define fake_build_settings_name_path_library_static "path_library_static" + #define fake_build_settings_name_path_program_shared "path_program_shared" + #define fake_build_settings_name_path_program_static "path_program_static" + #define fake_build_settings_name_process_post "process_post" + #define fake_build_settings_name_process_pre "process_pre" + #define fake_build_settings_name_project_level "project_level" + #define fake_build_settings_name_project_name "project_name" + #define fake_build_settings_name_version_major "version_major" + #define fake_build_settings_name_version_micro "version_micro" + #define fake_build_settings_name_version_minor "version_minor" + + #define fake_build_settings_name_build_compiler_length 14 + #define fake_build_settings_name_build_libraries_length 15 + #define fake_build_settings_name_build_linker_length 12 + #define fake_build_settings_name_build_shared_length 12 + #define fake_build_settings_name_build_sources_headers_length 21 + #define fake_build_settings_name_build_sources_library_length 21 + #define fake_build_settings_name_build_sources_program_length 21 + #define fake_build_settings_name_build_sources_settings_length 22 + #define fake_build_settings_name_build_sources_shell_length 19 + #define fake_build_settings_name_build_static_length 12 + #define fake_build_settings_name_defines_all_length 11 + #define fake_build_settings_name_defines_shared_length 14 + #define fake_build_settings_name_defines_static_length 14 + #define fake_build_settings_name_flags_all_length 9 + #define fake_build_settings_name_flags_library_length 13 + #define fake_build_settings_name_flags_program_length 13 + #define fake_build_settings_name_flags_shared_length 12 + #define fake_build_settings_name_flags_static_length 12 + #define fake_build_settings_name_path_language_length 13 + #define fake_build_settings_name_path_headers_length 12 + #define fake_build_settings_name_path_library_shared_length 19 + #define fake_build_settings_name_path_library_static_length 19 + #define fake_build_settings_name_path_program_shared_length 19 + #define fake_build_settings_name_path_program_static_length 19 + #define fake_build_settings_name_process_post_length 12 + #define fake_build_settings_name_process_pre_length 11 + #define fake_build_settings_name_project_level_length 13 + #define fake_build_settings_name_project_name_length 12 + #define fake_build_settings_name_version_major_length 13 + #define fake_build_settings_name_version_micro_length 13 + #define fake_build_settings_name_version_minor_length 13 + + #define fake_build_settings_total 31 +#endif // _di_fake_build_settings_ + +/** + * Find the build settings file, load it, validate it, and process it. + * + * @param data + * The program data. + * @param settings + * All build related settings data from the build settings file are loaded into this. + * These settings will have any specified mode property applied. + * + * @return + * f_none on success. + * Status codes (with error bit) are returned on any problem. + */ +#ifndef _di_fake_build_load_settings_ + extern f_return_status fake_build_load_settings(const fake_data data, fake_build_settings *settings) f_gcc_attribute_visibility_internal; +#endif // _di_fake_build_load_settings_ + +/** + * Execute the build operation. + * + * @param data + * The program data. + * + * @return + * f_none on success. + * Status codes (with error bit) are returned on any problem. + */ +#ifndef _di_fake_build_operate_ + extern f_return_status fake_build_operate(const fake_data data) f_gcc_attribute_visibility_internal; +#endif // _di_fake_build_operate_ + /** * Execute the Pre-Process or Post-pocess build script. * * @param data * The program data. + * @param settings + * All build related settings data from the build settings file. * @param process_script * The setting_data file name fo the appropriate process script. - * This is expected to be eithe data.settings_data.process_pre or data.settings_data.process_post. + * This is expected to be either settings.process_pre or settings.process_post. * * @return * f_none on success. * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_build_execute_process_script_ - extern f_return_status fake_build_execute_process_script(const fake_data data, const f_string_dynamic process_script) f_gcc_attribute_visibility_internal; + extern f_return_status fake_build_execute_process_script(const fake_data data, const fake_build_settings settings, const f_string_dynamic process_script) f_gcc_attribute_visibility_internal; #endif // _di_fake_build_execute_process_script_ #ifdef __cplusplus diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 126e798..5da80bc 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -5,254 +5,6 @@ extern "C" { #endif -#ifndef _di_fake_load_settings_data_ - f_return_status fake_load_settings_data(const fake_data data, fake_settings_data *settings_data) { - 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, 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); - - if (status == f_true) { - name_function = "f_file_open"; - status = f_file_open(&file, path.string); - - if (status == f_none) { - name_function = "fl_file_read_position"; - status = fl_file_read(&file, &buffer); - - f_file_close(&file); - } - } - else if (status == f_false) { - status = f_status_set_error(f_file_not_found); - } - - if (f_status_is_error(status)) { - fake_print_error_file(data.context, f_status_set_fine(status), name_function, path.string, "file", f_true); - - f_macro_string_dynamic_delete_simple(buffer); - f_macro_string_dynamic_delete_simple(path); - return status; - } - } - - if (buffer.used > 0) { - f_fss_objects objects = f_fss_objects_initialize; - f_fss_contents contents = f_fss_contents_initialize; - f_string_location location = f_string_location_initialize; - - location.start = 0; - location.stop = buffer.used - 1; - - status = fll_fss_basic_read(&buffer, &location, &objects, &contents); - - if (f_status_is_error(status)) { - f_macro_fss_objects_delete_simple(objects); - f_macro_fss_contents_delete_simple(contents); - f_macro_string_dynamic_delete_simple(buffer); - - if (status == f_status_set_error(f_incomplete_utf_on_stop)) { - 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", location.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_line(f_standard_error, data.context.error, data.context.reset, "')."); - } - else if (status == f_status_set_error(f_incomplete_utf_on_stop)) { - 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", location.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_line(f_standard_error, data.context.error, data.context.reset, "')."); - } - else { - fake_print_error(data.context, f_status_set_fine(status), "fll_fss_basic_read", true); - } - - 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; - } - - { - const f_string setting_names[] = { - fake_settings_name_build_compiler, - fake_settings_name_build_libraries, - fake_settings_name_build_linker, - fake_settings_name_build_shared, - fake_settings_name_build_sources_headers, - fake_settings_name_build_sources_library, - fake_settings_name_build_sources_program, - fake_settings_name_build_sources_settings, - fake_settings_name_build_sources_shell, - fake_settings_name_build_static, - fake_settings_name_defines_all, - fake_settings_name_defines_shared, - fake_settings_name_defines_static, - fake_settings_name_flags_all, - fake_settings_name_flags_library, - fake_settings_name_flags_program, - fake_settings_name_flags_shared, - fake_settings_name_flags_static, - fake_settings_name_path_language, - fake_settings_name_process_post, - fake_settings_name_process_pre, - fake_settings_name_project_level, - fake_settings_name_project_name, - fake_settings_name_version_major, - fake_settings_name_version_micro, - fake_settings_name_version_minor, - }; - - const f_string_length setting_lengths[] = { - fake_settings_name_build_compiler_length, - fake_settings_name_build_libraries_length, - fake_settings_name_build_linker_length, - fake_settings_name_build_shared_length, - fake_settings_name_build_sources_headers_length, - fake_settings_name_build_sources_library_length, - fake_settings_name_build_sources_program_length, - fake_settings_name_build_sources_settings_length, - fake_settings_name_build_sources_shell_length, - fake_settings_name_build_static_length, - fake_settings_name_defines_all_length, - fake_settings_name_defines_shared_length, - fake_settings_name_defines_static_length, - fake_settings_name_flags_all_length, - fake_settings_name_flags_library_length, - fake_settings_name_flags_program_length, - fake_settings_name_flags_shared_length, - fake_settings_name_flags_static_length, - fake_settings_name_path_language_length, - fake_settings_name_process_post_length, - fake_settings_name_process_pre_length, - fake_settings_name_project_level_length, - fake_settings_name_project_name_length, - fake_settings_name_version_major_length, - fake_settings_name_version_micro_length, - fake_settings_name_version_minor_length, - }; - - f_string_dynamic *setting_values[] = { - &settings_data->build_compiler, - &settings_data->build_libraries, - &settings_data->build_linker, - &settings_data->build_shared, - &settings_data->build_sources_headers, - &settings_data->build_sources_library, - &settings_data->build_sources_program, - &settings_data->build_sources_settings, - &settings_data->build_sources_shell, - &settings_data->build_static, - &settings_data->defines_all, - &settings_data->defines_shared, - &settings_data->defines_static, - &settings_data->flags_all, - &settings_data->flags_library, - &settings_data->flags_program, - &settings_data->flags_shared, - &settings_data->flags_static, - &settings_data->path_language, - &settings_data->process_post, - &settings_data->process_pre, - &settings_data->project_level, - &settings_data->project_name, - &settings_data->version_major, - &settings_data->version_micro, - &settings_data->version_minor, - }; - - status = fll_fss_snatch_mash_together(buffer, objects, contents, setting_names, setting_lengths, setting_values, fake_settings_total, " ", 1); - - if (status == f_none) { - for (f_array_length i = 0; i < data.mode.used; i++) { - f_string_dynamic settings_mode_name_dynamic[fake_settings_total]; - f_string settings_mode_names[fake_settings_total]; - f_string_length setting_mode_lengths[fake_settings_total]; - - memset(&settings_mode_name_dynamic, 0, sizeof(f_string_dynamic) * fake_settings_total); - memset(&settings_mode_names, 0, sizeof(f_string) * fake_settings_total); - - for (f_string_length j = 0; j < fake_settings_total; j++) { - setting_mode_lengths[j] = setting_lengths[j] + 1 + data.mode.array[i].used; - - f_macro_string_dynamic_new(status, settings_mode_name_dynamic[j], setting_mode_lengths[j]); - if (f_status_is_error(status)) break; - - memcpy(settings_mode_name_dynamic[j].string, setting_names[j], setting_lengths[j]); - memcpy(settings_mode_name_dynamic[j].string + setting_lengths[j] + 1, data.mode.array[i].string, data.mode.array[i].used); - settings_mode_name_dynamic[j].string[setting_lengths[j]] = '-'; - - settings_mode_names[j] = settings_mode_name_dynamic[j].string; - } // for - - if (status == f_none) { - status = fll_fss_snatch_mash_together(buffer, objects, contents, settings_mode_names, setting_mode_lengths, setting_values, fake_settings_total, " ", 1); - } - - for (f_string_length j = 0; j < fake_settings_total; j++) { - f_macro_string_dynamic_delete_simple(settings_mode_name_dynamic[j]); - } // for - - if (f_status_is_error(status)) break; - } // for - - if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "f_macro_string_dynamic_new", f_true); - - 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; - } - } - - if (f_status_is_error(status)) { - if (status == f_status_set_error(f_string_too_large)) { - 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_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); - } - else { - fake_print_error(data.context, f_status_set_fine(status), "fl_string_dynamic_partial_mash", f_true); - } - } - } - - 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; - } -#endif // _di_fake_load_settings_data_ - #ifndef _di_fake_print_error_ f_return_status fake_print_error(const fl_color_context context, const f_status status, const f_string function, const bool fallback) { diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 47a0cbf..ad7543d 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -13,23 +13,6 @@ extern "C" { #endif /** - * Find the build settings file, load it, validate it, and process it. - * - * @param data - * The program data. - * @param settings_data - * All settings data from the build settings file are loaded into this. - * These settings will have any specified mode property applied. - * - * @return - * f_none on success. - * Status codes (with error bit) are returned on any problem. - */ -#ifndef _di_fake_load_settings_data_ - extern f_return_status fake_load_settings_data(const fake_data data, fake_settings_data *settings_data) f_gcc_attribute_visibility_internal; -#endif // _di_fake_load_settings_data_ - -/** * Print generic error messages. * * @param context diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index eb339c4..83922a0 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -3,8 +3,8 @@ project_name fake project_level 3 -process_pre ./process_pre.sh -process_post ./process_post.sh +process_pre process_pre.sh +process_post process_post.sh version_major 0 version_minor 5 @@ -19,11 +19,17 @@ build_libraries_fll-monolithic -lfll build_sources_library fake.c private-fake.c private-clean.c private-build.c private-make.c private-skeleton.c build_sources_program main.c build_sources_headers fake.h -build_sources_bash -build_sources_settings +build_sources_setting +build_sources_shell build_shared yes build_static yes +path_headers level_3 +path_library_shared shared +path_library_static static +path_poogram_shared shared +path_poogram_static static + defines_all defines_static defines_shared