From 0b344c25102e37a5a57e48d839de3d078d8112a5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 4 Nov 2020 00:32:04 -0600 Subject: [PATCH] Bugfix: Fake building monolithic FLL is not compiling due to header directory structure problems. The header directory structure is being preserved by the bootstrap.sh but not by Fake. Introduce a new setting, 'path_headers_preserve' as a yes/no boolean. This designates that the path for headers should be preserved or not. In the case of the monolithic build, path_headers_preserve must be 'yes'. Provide a new function fl_directory_create() to make it easy to create an entire directory tree. Fake is now aware of this new 'path_headers_preserve', setting. When supplied, it will make sure to preserve the directory tree, such as 'level_0/' in the monolithic build header file 'level_0/color.h'. Both Fake and the bootstrap script should now behave the same in this respect. The changes in this commit have been quickly thrown together. This will need additional reviewing. --- build/level_0/settings | 1 + build/level_1/settings | 1 + build/level_2/settings | 1 + build/monolithic/settings | 1 + build/scripts/bootstrap.sh | 74 +++++++++++----------- level_0/f_account/data/build/settings | 1 + level_0/f_color/data/build/settings | 1 + level_0/f_console/data/build/settings | 1 + level_0/f_conversion/data/build/settings | 1 + level_0/f_directory/data/build/settings | 1 + level_0/f_environment/data/build/settings | 1 + level_0/f_file/data/build/settings | 1 + level_0/f_fss/data/build/settings | 1 + level_0/f_iki/data/build/settings | 1 + level_0/f_memory/data/build/settings | 1 + level_0/f_path/data/build/settings | 1 + level_0/f_pipe/data/build/settings | 1 + level_0/f_print/data/build/settings | 1 + level_0/f_serialize/data/build/settings | 1 + level_0/f_signal/data/build/settings | 1 + level_0/f_socket/data/build/settings | 1 + level_0/f_status/data/build/settings | 1 + level_0/f_string/data/build/settings | 1 + level_0/f_type/data/build/settings | 1 + level_0/f_utf/data/build/settings | 1 + level_1/fl_color/data/build/settings | 1 + level_1/fl_console/data/build/settings | 1 + level_1/fl_conversion/data/build/settings | 1 + level_1/fl_directory/c/directory.c | 44 +++++++++++++ level_1/fl_directory/c/directory.h | 39 ++++++++++++ level_1/fl_directory/data/build/settings | 1 + level_1/fl_environment/data/build/settings | 1 + level_1/fl_fss/data/build/settings | 1 + level_1/fl_iki/data/build/settings | 1 + level_1/fl_print/data/build/settings | 1 + level_1/fl_status/data/build/settings | 1 + level_1/fl_string/data/build/settings | 1 + level_1/fl_utf/data/build/settings | 1 + level_1/fl_utf_file/data/build/settings | 1 + level_2/fll_error/data/build/settings | 1 + level_2/fll_execute/data/build/settings | 1 + level_2/fll_file/data/build/settings | 1 + level_2/fll_fss/data/build/settings | 1 + level_2/fll_iki/data/build/settings | 1 + level_2/fll_path/data/build/settings | 1 + level_2/fll_program/data/build/settings | 1 + level_2/fll_status/data/build/settings | 1 + level_3/byte_dump/data/build/settings | 1 + level_3/fake/c/private-build.c | 74 +++++++++++++++++++--- level_3/fake/c/private-build.h | 17 ++++- level_3/fake/data/build/settings | 1 + level_3/firewall/data/build/settings | 1 + level_3/fss_basic_list_read/data/build/settings | 1 + level_3/fss_basic_list_write/data/build/settings | 1 + level_3/fss_basic_read/data/build/settings | 1 + level_3/fss_basic_write/data/build/settings | 1 + level_3/fss_extended_list_read/data/build/settings | 1 + .../fss_extended_list_write/data/build/settings | 1 + level_3/fss_extended_read/data/build/settings | 1 + level_3/fss_extended_write/data/build/settings | 1 + level_3/fss_status_code/data/build/settings | 1 + level_3/iki_read/data/build/settings | 1 + level_3/iki_write/data/build/settings | 1 + level_3/init/data/build/settings | 1 + level_3/status_code/data/build/settings | 1 + 65 files changed, 260 insertions(+), 48 deletions(-) diff --git a/build/level_0/settings b/build/level_0/settings index 0b71dfb..00f7d65 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/build/level_1/settings b/build/level_1/settings index 421c2f7..3530295 100644 --- a/build/level_1/settings +++ b/build/level_1/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/build/level_2/settings b/build/level_2/settings index 9aca52c..d6c04fc 100644 --- a/build/level_2/settings +++ b/build/level_2/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/build/monolithic/settings b/build/monolithic/settings index 2d1f4a2..2ae883a 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers +path_headers_preserve yes path_library_script script path_library_shared shared path_library_static static diff --git a/build/scripts/bootstrap.sh b/build/scripts/bootstrap.sh index 9a6ae00..792b43e 100644 --- a/build/scripts/bootstrap.sh +++ b/build/scripts/bootstrap.sh @@ -449,40 +449,41 @@ bootstrap_id() { "modes_default") echo -n 22;; "path_language") echo -n 23;; "path_headers") echo -n 24;; - "path_library_script") echo -n 25;; - "path_library_shared") echo -n 26;; - "path_library_static") echo -n 27;; - "path_program_script") echo -n 28;; - "path_program_shared") echo -n 29;; - "path_program_static") echo -n 30;; - "path_sources") echo -n 31;; - "path_standard") echo -n 32;; - "process_post") echo -n 33;; - "process_pre") echo -n 34;; - "project_name") echo -n 35;; - "search_exclusive") echo -n 36;; - "search_shared") echo -n 37;; - "search_static") echo -n 38;; - "version_major") echo -n 39;; - "version_micro") echo -n 40;; - "version_minor") echo -n 41;; - "version_target") echo -n 42;; - - "build_libraries-$mode") echo -n 43;; - "build_sources_headers-$mode") echo -n 44;; - "build_sources_library-$mode") echo -n 45;; - "build_sources_program-$mode") echo -n 46;; - "build_sources_setting-$mode") echo -n 47;; - "build_sources_script-$mode") echo -n 48;; - "defines_all-$mode") echo -n 49;; - "defines_shared-$mode") echo -n 50;; - "defines_static-$mode") echo -n 51;; - "environment-$mode") echo -n 52;; - "flags_all-$mode") echo -n 53;; - "flags_library-$mode") echo -n 54;; - "flags_program-$mode") echo -n 55;; - "flags_shared-$mode") echo -n 56;; - "flags_static-$mode") echo -n 57;; + "path_headers_preserve") echo -n 25;; + "path_library_script") echo -n 26;; + "path_library_shared") echo -n 27;; + "path_library_static") echo -n 28;; + "path_program_script") echo -n 29;; + "path_program_shared") echo -n 30;; + "path_program_static") echo -n 31;; + "path_sources") echo -n 32;; + "path_standard") echo -n 33;; + "process_post") echo -n 34;; + "process_pre") echo -n 35;; + "project_name") echo -n 36;; + "search_exclusive") echo -n 37;; + "search_shared") echo -n 38;; + "search_static") echo -n 39;; + "version_major") echo -n 40;; + "version_micro") echo -n 41;; + "version_minor") echo -n 42;; + "version_target") echo -n 43;; + + "build_libraries-$mode") echo -n 44;; + "build_sources_headers-$mode") echo -n 45;; + "build_sources_library-$mode") echo -n 46;; + "build_sources_program-$mode") echo -n 47;; + "build_sources_setting-$mode") echo -n 48;; + "build_sources_script-$mode") echo -n 49;; + "defines_all-$mode") echo -n 50;; + "defines_shared-$mode") echo -n 51;; + "defines_static-$mode") echo -n 52;; + "environment-$mode") echo -n 53;; + "flags_all-$mode") echo -n 54;; + "flags_library-$mode") echo -n 55;; + "flags_program-$mode") echo -n 56;; + "flags_shared-$mode") echo -n 57;; + "flags_static-$mode") echo -n 58;; esac } @@ -509,7 +510,7 @@ bootstrap_load_settings() { return 1 fi - for i in build_compiler build_indexer build_language build_libraries build_script build_shared build_sources_headers build_sources_library build_sources_program build_sources_setting build_sources_script build_static defines_all defines_shared defines_static environment flags_all flags_library flags_program flags_shared flags_static modes modes_default path_language path_headers path_library_script path_library_shared path_library_static path_program_script path_program_shared path_program_static path_sources path_standard process_post process_pre project_name search_exclusive search_shared search_static version_major version_micro version_minor ; do + for i in build_compiler build_indexer build_language build_libraries build_script build_shared build_sources_headers build_sources_library build_sources_program build_sources_setting build_sources_script build_static defines_all defines_shared defines_static environment flags_all flags_library flags_program flags_shared flags_static modes modes_default path_language path_headers path_headers_preserve path_library_script path_library_shared path_library_static path_program_script path_program_shared path_program_static path_sources path_standard process_post process_pre project_name search_exclusive search_shared search_static version_major version_micro version_minor ; do variables[$(bootstrap_id $i)]=$(grep -s -o "^[[:space:]]*$i[[:space:]].*\$" $settings_file | sed -e "s|^[[:space:]]*$i\>||" -e 's|^[[:space:]]*||') done } @@ -581,6 +582,7 @@ bootstrap_operation_build() { local alt=$1 local directory= local path_headers=${variables[$(bootstrap_id path_headers)]} + local path_headers_preserve=${variables[$(bootstrap_id path_headers_preserve)]} if [[ $target == "" ]] ; then target="major" @@ -831,7 +833,7 @@ bootstrap_operation_build() { for i in $sources_headers ; do directory=$(dirname $i) - if [[ $directory == "." ]] ; then + if [[ $directory == "." || $path_headers_preserve != "yes" ]] ; then cp $verbose -f $path_c$i ${path_build}includes/ || failure=1 else mkdir $verbose -p ${path_build}includes/$directory || failure=1 diff --git a/level_0/f_account/data/build/settings b/level_0/f_account/data/build/settings index 667135c..8813f2d 100644 --- a/level_0/f_account/data/build/settings +++ b/level_0/f_account/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_color/data/build/settings b/level_0/f_color/data/build/settings index 7ed5f0c..3ad9dd7 100644 --- a/level_0/f_color/data/build/settings +++ b/level_0/f_color/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_console/data/build/settings b/level_0/f_console/data/build/settings index 0b74059..3519b3d 100644 --- a/level_0/f_console/data/build/settings +++ b/level_0/f_console/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_conversion/data/build/settings b/level_0/f_conversion/data/build/settings index af2b4c2..42317c6 100644 --- a/level_0/f_conversion/data/build/settings +++ b/level_0/f_conversion/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_directory/data/build/settings b/level_0/f_directory/data/build/settings index 8d8af5a..5d9863a 100644 --- a/level_0/f_directory/data/build/settings +++ b/level_0/f_directory/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_environment/data/build/settings b/level_0/f_environment/data/build/settings index c53f36e..de1c56d 100644 --- a/level_0/f_environment/data/build/settings +++ b/level_0/f_environment/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_file/data/build/settings b/level_0/f_file/data/build/settings index 7d25b53..bf8362b 100644 --- a/level_0/f_file/data/build/settings +++ b/level_0/f_file/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_fss/data/build/settings b/level_0/f_fss/data/build/settings index 8d7f125..bb45799 100644 --- a/level_0/f_fss/data/build/settings +++ b/level_0/f_fss/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_iki/data/build/settings b/level_0/f_iki/data/build/settings index 15844d0..b126df5 100644 --- a/level_0/f_iki/data/build/settings +++ b/level_0/f_iki/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_memory/data/build/settings b/level_0/f_memory/data/build/settings index 67731dd..17aab4e 100644 --- a/level_0/f_memory/data/build/settings +++ b/level_0/f_memory/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_path/data/build/settings b/level_0/f_path/data/build/settings index 0ed3d6e..35a58ec 100644 --- a/level_0/f_path/data/build/settings +++ b/level_0/f_path/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_pipe/data/build/settings b/level_0/f_pipe/data/build/settings index 86780d4..b101892 100644 --- a/level_0/f_pipe/data/build/settings +++ b/level_0/f_pipe/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_print/data/build/settings b/level_0/f_print/data/build/settings index d5227b2..e719414 100644 --- a/level_0/f_print/data/build/settings +++ b/level_0/f_print/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_serialize/data/build/settings b/level_0/f_serialize/data/build/settings index b2599bf..8b76774 100644 --- a/level_0/f_serialize/data/build/settings +++ b/level_0/f_serialize/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_signal/data/build/settings b/level_0/f_signal/data/build/settings index 7f405be..22514cb 100644 --- a/level_0/f_signal/data/build/settings +++ b/level_0/f_signal/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_socket/data/build/settings b/level_0/f_socket/data/build/settings index 2f98ab7..ac713d1 100644 --- a/level_0/f_socket/data/build/settings +++ b/level_0/f_socket/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_status/data/build/settings b/level_0/f_status/data/build/settings index 0010e52..280f6f5 100644 --- a/level_0/f_status/data/build/settings +++ b/level_0/f_status/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_string/data/build/settings b/level_0/f_string/data/build/settings index ea9140b..1e91f5d 100644 --- a/level_0/f_string/data/build/settings +++ b/level_0/f_string/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_type/data/build/settings b/level_0/f_type/data/build/settings index 07d5ed7..358b08c 100644 --- a/level_0/f_type/data/build/settings +++ b/level_0/f_type/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_0/f_utf/data/build/settings b/level_0/f_utf/data/build/settings index d7f82d4..4e9894b 100644 --- a/level_0/f_utf/data/build/settings +++ b/level_0/f_utf/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_0 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_color/data/build/settings b/level_1/fl_color/data/build/settings index df814a4..700d112 100644 --- a/level_1/fl_color/data/build/settings +++ b/level_1/fl_color/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_console/data/build/settings b/level_1/fl_console/data/build/settings index 009d2fb..d328a27 100644 --- a/level_1/fl_console/data/build/settings +++ b/level_1/fl_console/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_conversion/data/build/settings b/level_1/fl_conversion/data/build/settings index 35b3266..ffa7202 100644 --- a/level_1/fl_conversion/data/build/settings +++ b/level_1/fl_conversion/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_directory/c/directory.c b/level_1/fl_directory/c/directory.c index 916ffc1..a77ee62 100644 --- a/level_1/fl_directory/c/directory.c +++ b/level_1/fl_directory/c/directory.c @@ -5,6 +5,50 @@ extern "C" { #endif +#ifndef _di_fl_directory_create_ + f_return_status fl_directory_create(const f_string_t path, const f_string_length_t length, const mode_t mode) { + #ifndef _di_level_1_parameter_checking_ + if (!path) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!length) { + return F_data_not; + } + + f_status_t status = f_directory_exists(path); + + if (F_status_is_error(status)) return status; + if (status == F_true) return F_directory_found; + + { + f_string_length_t at_tree = 0; + f_string_length_t at_path = 0; + + char tree[length]; + + for (; path[at_path]; ++at_path) { + + if (at_path && path[at_path] == f_path_separator[0]) { + memcpy(tree, path + at_tree, at_path - at_tree); + tree[at_path] = 0; + + status = f_directory_exists(tree); + if (F_status_is_error(status)) return status; + + if (status == F_false) { + status = f_directory_create(tree, mode); + if (F_status_is_error(status)) return status; + } + + at_tree = at_path; + } + } // for + } + + return f_directory_create(path, mode); + } +#endif // _di_fl_directory_create_ + #ifndef _di_fl_directory_clone_ f_return_status fl_directory_clone(const f_string_t source, const f_string_t destination, const f_string_length_t source_length, const f_string_length_t destination_length, const bool role, const fl_directory_recurse_t recurse) { #ifndef _di_level_1_parameter_checking_ diff --git a/level_1/fl_directory/c/directory.h b/level_1/fl_directory/c/directory.h index c42df55..e5a7a3e 100644 --- a/level_1/fl_directory/c/directory.h +++ b/level_1/fl_directory/c/directory.h @@ -87,6 +87,45 @@ extern "C" { #endif // _di_fl_directory_recurse_t_ /** + * Create all directories at the given path. + * + * The paths must not contain NULL except for the terminating NULL. + * The paths must be NULL terminated. + * + * @param path + * The file path to the directory. + * @param length + * The length of the path string. + * @param mode + * The directory mode to use when creating. + * This is applied to all created directories. + * + * @return + * F_none on success. + * F_data_not on success, but there was no string to process (length is 0). + * F_directory_found on success, but the directory already exists. + * F_access_denied (with error bit) on access denied. + * F_directory (with error bit) if a supposed directory in path is not actually a directory. + * F_directory_link_max (with error bit) max links limit reached or exceeded. + * F_file_found (with error bit) of a directory aleady exists at the path. + * F_file_found_not (with error bit) if a file within the path is not found (such as a broken symbolic link). + * F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted. + * F_loop (with error bit) on loop error. + * F_memory_out (with error bit) if out of memory. + * F_name (with error bit) on path name error. + * F_parameter (with error bit) if a parameter is invalid. + * F_prohibited (with error bit) if filesystem does not allow for removing. + * F_read_only (with error bit) if file is read-only. + * F_space_not (with error bit) if filesystem is out of space (or filesystem quota is reached). + * F_failure (with error bit) for any other error. + * + * @see f_directory_create() + */ +#ifndef _di_fl_directory_create_ + extern f_return_status fl_directory_create(const f_string_t path, const f_string_length_t length, const mode_t mode); +#endif // _di_fl_directory_create_ + +/** * Copy a directory and its contents, as well as its file mode and possibly the owner and group. * * The paths must not contain NULL except for the terminating NULL. diff --git a/level_1/fl_directory/data/build/settings b/level_1/fl_directory/data/build/settings index 4b2a577..67d09a8 100644 --- a/level_1/fl_directory/data/build/settings +++ b/level_1/fl_directory/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_environment/data/build/settings b/level_1/fl_environment/data/build/settings index fe254d0..7449c3e 100644 --- a/level_1/fl_environment/data/build/settings +++ b/level_1/fl_environment/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_fss/data/build/settings b/level_1/fl_fss/data/build/settings index 594af86..3910c90 100644 --- a/level_1/fl_fss/data/build/settings +++ b/level_1/fl_fss/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_iki/data/build/settings b/level_1/fl_iki/data/build/settings index ff1dbf2..9870d7c 100644 --- a/level_1/fl_iki/data/build/settings +++ b/level_1/fl_iki/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_print/data/build/settings b/level_1/fl_print/data/build/settings index 5d1b1ff..a9bad59 100644 --- a/level_1/fl_print/data/build/settings +++ b/level_1/fl_print/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_status/data/build/settings b/level_1/fl_status/data/build/settings index 3553e5d..b6d9a5f 100644 --- a/level_1/fl_status/data/build/settings +++ b/level_1/fl_status/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_string/data/build/settings b/level_1/fl_string/data/build/settings index aa8397d..27b6217 100644 --- a/level_1/fl_string/data/build/settings +++ b/level_1/fl_string/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_utf/data/build/settings b/level_1/fl_utf/data/build/settings index 40b5d5a..bfdc970 100644 --- a/level_1/fl_utf/data/build/settings +++ b/level_1/fl_utf/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_1/fl_utf_file/data/build/settings b/level_1/fl_utf_file/data/build/settings index e22ef88..194b731 100644 --- a/level_1/fl_utf_file/data/build/settings +++ b/level_1/fl_utf_file/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_1 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_error/data/build/settings b/level_2/fll_error/data/build/settings index 5975a30..f6dac97 100644 --- a/level_2/fll_error/data/build/settings +++ b/level_2/fll_error/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_execute/data/build/settings b/level_2/fll_execute/data/build/settings index bee8328..aec0966 100644 --- a/level_2/fll_execute/data/build/settings +++ b/level_2/fll_execute/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_file/data/build/settings b/level_2/fll_file/data/build/settings index 9f2a17e..2aea06b 100644 --- a/level_2/fll_file/data/build/settings +++ b/level_2/fll_file/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_fss/data/build/settings b/level_2/fll_fss/data/build/settings index 7a8f602..c98f4e2 100644 --- a/level_2/fll_fss/data/build/settings +++ b/level_2/fll_fss/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_iki/data/build/settings b/level_2/fll_iki/data/build/settings index f5292c6..0a6a786 100644 --- a/level_2/fll_iki/data/build/settings +++ b/level_2/fll_iki/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_path/data/build/settings b/level_2/fll_path/data/build/settings index 0443978..8d9f957 100644 --- a/level_2/fll_path/data/build/settings +++ b/level_2/fll_path/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_program/data/build/settings b/level_2/fll_program/data/build/settings index 3263070..0463423 100644 --- a/level_2/fll_program/data/build/settings +++ b/level_2/fll_program/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_2/fll_status/data/build/settings b/level_2/fll_status/data/build/settings index 982858c..bfa8914 100644 --- a/level_2/fll_status/data/build/settings +++ b/level_2/fll_status/data/build/settings @@ -30,6 +30,7 @@ build_shared yes build_static yes path_headers level_2 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/byte_dump/data/build/settings b/level_3/byte_dump/data/build/settings index 92c7e2e..24b64fe 100644 --- a/level_3/byte_dump/data/build/settings +++ b/level_3/byte_dump/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index f0d86db..309bfaf 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -164,7 +164,7 @@ extern "C" { #endif // _di_fake_build_arguments_standard_add_ #ifndef _di_fake_build_copy_ - void fake_build_copy(const fake_data_t data, const f_mode_t mode, const f_string_t label, const f_string_static_t source, const f_string_static_t destination, const f_string_statics_t files, const f_string_static_t file_stage, f_status_t *status) { + void fake_build_copy(const fake_data_t data, const f_mode_t mode, const f_string_t label, const f_string_static_t source, const f_string_static_t destination, const f_string_statics_t files, const f_string_static_t file_stage, const f_string_length_t preserve, f_status_t *status) { if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true) return; if (fake_signal_received(data)) { @@ -175,6 +175,7 @@ extern "C" { f_directory_statuss_t failures = f_directory_statuss_t_initialize; f_string_dynamic_t path_source = f_string_dynamic_t_initialize; f_string_dynamic_t destination_file = f_string_dynamic_t_initialize; + f_string_dynamic_t destination_directory = f_string_dynamic_t_initialize; if (data.error.verbosity != f_console_verbosity_quiet) { fprintf(data.output.stream, "%c", f_string_eol[0]); @@ -255,6 +256,7 @@ extern "C" { } else if (*status == F_false) { destination_file.used = 0; + destination_directory.used = 0; *status = fl_string_dynamic_append_nulless(destination, &destination_file); @@ -263,11 +265,49 @@ extern "C" { break; } - *status = f_file_name_base(path_source.string, path_source.used, &destination_file); + if (preserve && preserve < path_source.used) { + *status = fl_string_dynamic_append_nulless(destination, &destination_directory); - if (F_status_is_error(*status)) { - fll_error_print(data.error, F_status_set_fine(*status), "f_file_name_base", F_true); - break; + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true); + break; + } + + *status = f_file_name_directory(path_source.string + preserve, path_source.used - preserve, &destination_directory); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "f_file_name_directory", F_true); + break; + } + + *status = fl_string_dynamic_terminate_after(&destination_directory); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_string_dynamic_terminate_after", F_true); + break; + } + + *status = fl_directory_create(destination_directory.string, destination_directory.used, f_file_mode_all_rwx); + + if (F_status_is_error(*status)) { + fll_error_file_print(data.error, F_status_set_fine(*status), "fl_directory_create", F_true, destination_directory.string, "create", fll_error_file_type_directory); + break; + } + + *status = fl_string_append(path_source.string + preserve, path_source.used - preserve, &destination_file); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_string_append", F_true); + break; + } + } + else { + *status = f_file_name_base(path_source.string, path_source.used, &destination_file); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "f_file_name_base", F_true); + break; + } } *status = fl_string_dynamic_terminate_after(&destination_file); @@ -304,6 +344,7 @@ extern "C" { f_macro_directory_statuss_t_delete_simple(failures); f_macro_string_dynamic_t_delete_simple(path_source); f_macro_string_dynamic_t_delete_simple(destination_file); + f_macro_string_dynamic_t_delete_simple(destination_directory); if (F_status_is_error_not(*status)) { fake_build_touch(data, file_stage, status); @@ -1414,6 +1455,7 @@ extern "C" { fake_build_setting_name_modes, fake_build_setting_name_modes_default, fake_build_setting_name_path_headers, + fake_build_setting_name_path_headers_preserve, fake_build_setting_name_path_language, fake_build_setting_name_path_library_script, fake_build_setting_name_path_library_shared, @@ -1460,6 +1502,7 @@ extern "C" { fake_build_setting_name_modes_length, fake_build_setting_name_modes_default_length, fake_build_setting_name_path_headers_length, + fake_build_setting_name_path_headers_preserve_length, fake_build_setting_name_path_language_length, fake_build_setting_name_path_library_script_length, fake_build_setting_name_path_library_shared_length, @@ -1488,6 +1531,7 @@ extern "C" { f_string_dynamics_t build_shared = f_string_dynamics_t_initialize; f_string_dynamics_t build_static = f_string_dynamics_t_initialize; f_string_dynamics_t path_headers = f_string_dynamics_t_initialize; + f_string_dynamics_t path_headers_preserve = f_string_dynamics_t_initialize; f_string_dynamics_t path_language = f_string_dynamics_t_initialize; f_string_dynamics_t path_library_script = f_string_dynamics_t_initialize; f_string_dynamics_t path_library_shared = f_string_dynamics_t_initialize; @@ -1533,6 +1577,7 @@ extern "C" { &setting->modes, &setting->modes_default, &path_headers, + &path_headers_preserve, &path_language, &path_library_script, &path_library_shared, @@ -1661,6 +1706,7 @@ extern "C" { fake_build_setting_name_build_shared, fake_build_setting_name_build_static, fake_build_setting_name_path_headers, + fake_build_setting_name_path_headers_preserve, fake_build_setting_name_path_language, fake_build_setting_name_path_library_script, fake_build_setting_name_path_library_shared, @@ -1690,6 +1736,7 @@ extern "C" { &build_shared, &build_static, &path_headers, + &path_headers_preserve, &path_language, &path_library_script, &path_library_shared, @@ -1719,6 +1766,7 @@ extern "C" { &setting->build_shared, &setting->build_static, 0, + &setting->path_headers_preserve, 0, 0, 0, @@ -1744,6 +1792,7 @@ extern "C" { 0, 0, &setting->path_headers, + 0, &setting->path_language, &setting->path_library_script, &setting->path_library_shared, @@ -1796,6 +1845,7 @@ extern "C" { 0, 0, 0, + 0, &setting->version_target, }; @@ -1808,6 +1858,7 @@ extern "C" { 1, 1, 2, + 1, 2, 2, 2, @@ -1829,7 +1880,7 @@ extern "C" { 5, }; - for (f_array_length_t i = 0; i < 26; i++) { + for (f_array_length_t i = 0; i < 27; i++) { if (!settings_single_source[i]->used) continue; if (settings_single_source[i]->used > 1) { @@ -1967,6 +2018,7 @@ extern "C" { f_macro_string_dynamics_t_delete_simple(build_shared); f_macro_string_dynamics_t_delete_simple(build_static); f_macro_string_dynamics_t_delete_simple(path_headers); + f_macro_string_dynamics_t_delete_simple(path_headers_preserve); f_macro_string_dynamics_t_delete_simple(path_language); f_macro_string_dynamics_t_delete_simple(path_library_script); f_macro_string_dynamics_t_delete_simple(path_library_shared); @@ -2517,7 +2569,7 @@ extern "C" { fake_build_execute_process_script(data, data_build, data_build.setting.process_pre, stage.file_process_pre, &status); - fake_build_copy(data, mode, "setting files", data.path_data_settings, data.path_build_settings, data_build.setting.build_sources_setting, stage.file_sources_settings, &status); + fake_build_copy(data, mode, "setting files", data.path_data_settings, data.path_build_settings, data_build.setting.build_sources_setting, stage.file_sources_settings, 0, &status); if (data_build.setting.build_language == fake_build_language_type_bash) { fake_build_libraries_script(data, data_build, mode, stage.file_libraries_script, &status); @@ -2525,7 +2577,7 @@ extern "C" { fake_build_programs_script(data, data_build, mode, stage.file_programs_script, &status); if (data_build.setting.build_script) { - fake_build_copy(data, mode, "scripts", data.path_sources_script, data.path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, &status); + fake_build_copy(data, mode, "scripts", data.path_sources_script, data.path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); } } else { @@ -2543,6 +2595,8 @@ extern "C" { path_sources = &data_build.setting.path_sources; } + const f_string_length_t path_sources_base_length = path_sources->used; + f_string_static_t path_headers = f_string_static_t_initialize; f_string_length_t directory_headers_length = data.path_build_includes.used + data_build.setting.path_headers.used; @@ -2568,7 +2622,7 @@ extern "C" { path_headers.size = directory_headers_length + 1; } - fake_build_copy(data, mode, "header files", *path_sources, path_headers, data_build.setting.build_sources_headers, stage.file_sources_headers, &status); + fake_build_copy(data, mode, "header files", *path_sources, path_headers, data_build.setting.build_sources_headers, stage.file_sources_headers, data_build.setting.path_headers_preserve ? path_sources_base_length : 0, &status); } if (data_build.setting.build_shared) { @@ -2586,7 +2640,7 @@ extern "C" { } if (data_build.setting.build_script) { - fake_build_copy(data, mode, "scripts", data.path_sources_script, data.path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, &status); + fake_build_copy(data, mode, "scripts", data.path_sources_script, data.path_build_programs_script, data_build.setting.build_sources_script, stage.file_sources_script, 0, &status); } } diff --git a/level_3/fake/c/private-build.h b/level_3/fake/c/private-build.h index 1060e1e..c88a2b4 100644 --- a/level_3/fake/c/private-build.h +++ b/level_3/fake/c/private-build.h @@ -23,6 +23,7 @@ extern "C" { bool build_static; bool path_standard; + bool path_headers_preserve; bool search_exclusive; bool search_shared; @@ -75,6 +76,7 @@ extern "C" { F_true, \ F_true, \ F_true, \ + F_true, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ f_string_dynamic_t_initialize, \ @@ -171,6 +173,7 @@ extern "C" { #define fake_build_setting_name_modes "modes" #define fake_build_setting_name_modes_default "modes_default" #define fake_build_setting_name_path_headers "path_headers" + #define fake_build_setting_name_path_headers_preserve "path_headers_preserve" #define fake_build_setting_name_path_language "path_language" #define fake_build_setting_name_path_library_script "path_library_script" #define fake_build_setting_name_path_library_shared "path_library_shared" @@ -215,6 +218,7 @@ extern "C" { #define fake_build_setting_name_modes_length 5 #define fake_build_setting_name_modes_default_length 13 #define fake_build_setting_name_path_headers_length 12 + #define fake_build_setting_name_path_headers_preserve_length 21 #define fake_build_setting_name_path_language_length 13 #define fake_build_setting_name_path_library_script_length 19 #define fake_build_setting_name_path_library_shared_length 19 @@ -235,7 +239,7 @@ extern "C" { #define fake_build_setting_name_version_minor_length 13 #define fake_build_setting_name_version_target_length 14 - #define fake_build_setting_total 43 + #define fake_build_setting_total 44 #define fake_build_setting_default_version "0" @@ -422,6 +426,15 @@ extern "C" { * The files to copy from source to destination. * @param file_stage * The specific stage file path. + * @param perserve + * When a positive number, this represents the amount of characters at the front of each file to ignore. + * Everything after that is preserved, and the directory is created if necessary. + * + * This is always treated as 0 for any file that is a directory type. + * Set to 0 to disable. + * + * Example: 'sources/c/level_0/fss.h' with a preseve of 10, would result in the path of 'level_0/fss.h' being preserved. + * Whereas a preserve of 0 would result in a path of 'fss.h' being used (the 'level_0/' directory is not preserved). * @param status * The return status. * @@ -431,7 +444,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_build_copy_ - extern void fake_build_copy(const fake_data_t data, const f_mode_t mode, const f_string_t label, const f_string_static_t source, const f_string_static_t destination, const f_string_statics_t files, const f_string_static_t file_stage, f_status_t *status) f_gcc_attribute_visibility_internal; + extern void fake_build_copy(const fake_data_t data, const f_mode_t mode, const f_string_t label, const f_string_static_t source, const f_string_static_t destination, const f_string_statics_t files, const f_string_static_t file_stage, const f_string_length_t preserve, f_status_t *status) f_gcc_attribute_visibility_internal; #endif // _di_fake_build_copy_ /** diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index ad955d7..062134d 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/firewall/data/build/settings b/level_3/firewall/data/build/settings index e01a332..12603ca 100644 --- a/level_3/firewall/data/build/settings +++ b/level_3/firewall/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_basic_list_read/data/build/settings b/level_3/fss_basic_list_read/data/build/settings index a3a7d69..87dd4dc 100644 --- a/level_3/fss_basic_list_read/data/build/settings +++ b/level_3/fss_basic_list_read/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_basic_list_write/data/build/settings b/level_3/fss_basic_list_write/data/build/settings index 8b7e63d..906aa1f 100644 --- a/level_3/fss_basic_list_write/data/build/settings +++ b/level_3/fss_basic_list_write/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_basic_read/data/build/settings b/level_3/fss_basic_read/data/build/settings index adb4ea2..a9bb147 100644 --- a/level_3/fss_basic_read/data/build/settings +++ b/level_3/fss_basic_read/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_basic_write/data/build/settings b/level_3/fss_basic_write/data/build/settings index 851c939..6635285 100644 --- a/level_3/fss_basic_write/data/build/settings +++ b/level_3/fss_basic_write/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_extended_list_read/data/build/settings b/level_3/fss_extended_list_read/data/build/settings index f351f90..f2ed020 100644 --- a/level_3/fss_extended_list_read/data/build/settings +++ b/level_3/fss_extended_list_read/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_extended_list_write/data/build/settings b/level_3/fss_extended_list_write/data/build/settings index bd37022..08f0016 100644 --- a/level_3/fss_extended_list_write/data/build/settings +++ b/level_3/fss_extended_list_write/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_extended_read/data/build/settings b/level_3/fss_extended_read/data/build/settings index 9c03d08..3af122f 100644 --- a/level_3/fss_extended_read/data/build/settings +++ b/level_3/fss_extended_read/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_extended_write/data/build/settings b/level_3/fss_extended_write/data/build/settings index 5050311..810c1ac 100644 --- a/level_3/fss_extended_write/data/build/settings +++ b/level_3/fss_extended_write/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/fss_status_code/data/build/settings b/level_3/fss_status_code/data/build/settings index aaed02b..01e1b20 100644 --- a/level_3/fss_status_code/data/build/settings +++ b/level_3/fss_status_code/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/iki_read/data/build/settings b/level_3/iki_read/data/build/settings index d55a35a..f177e53 100644 --- a/level_3/iki_read/data/build/settings +++ b/level_3/iki_read/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/iki_write/data/build/settings b/level_3/iki_write/data/build/settings index c04f8e7..b56c5fa 100644 --- a/level_3/iki_write/data/build/settings +++ b/level_3/iki_write/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings index 39f8c8e..8118e46 100644 --- a/level_3/init/data/build/settings +++ b/level_3/init/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static diff --git a/level_3/status_code/data/build/settings b/level_3/status_code/data/build/settings index 875584f..8dd1161 100644 --- a/level_3/status_code/data/build/settings +++ b/level_3/status_code/data/build/settings @@ -32,6 +32,7 @@ build_shared yes build_static yes path_headers level_3 +path_headers_preserve no path_library_script script path_library_shared shared path_library_static static -- 1.8.3.1