From: Kevin Day Date: Fri, 22 Jul 2022 00:02:59 +0000 (-0500) Subject: Update: Improve user experience by defaulting specified fakefile and build settings... X-Git-Tag: 0.6.0~28 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=713fed1f9755f48164eb00f8b3d1572943bb2c9d;p=fll Update: Improve user experience by defaulting specified fakefile and build settings file to present working directory. Change the behavior to search the present working directory first. If the file exists, then use it. If not, then check the data/build/ directory. This is done only for fakefile and build settings file that are not specified using a directory separator. --- diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index a1223c9..6c8f973 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -71,12 +71,13 @@ extern "C" { fl_print_format(" of 'fll_monolithic' is specified, build libraries from both 'build_libraries' and 'build_libraries-fll_monolithic' are used (but not 'build_libraries-fll_level').%r%r", file.stream, f_string_eol_s, f_string_eol_s); fl_print_format(" When specifying the %[%r%] or the %[%r%]", file.stream, context.set.notable, fake_make_parameter_variable_fakefile_s, context.set.notable, context.set.notable, fake_make_parameter_variable_settings_s, context.set.notable); - fl_print_format(" parameters, the filenames are relative to the data build directory, unless a path is used.%r", file.stream, f_string_eol_s); + fl_print_format(" parameters, the project root is seached first and then the build data director is searched when the given file does not contain a directory separator.%r", file.stream, f_string_eol_s); fl_print_format(" For example, with '%[%r%r my_fakefile%]' the fakefile at", file.stream, context.set.notable, f_console_symbol_long_enable_s, fake_long_fakefile_s, context.set.notable); - fl_print_format(" '%[./%r%rmy_fakefile%]' would be used, however with", file.stream, context.set.notable, fake_default_path_data_s, fake_default_path_build_s, context.set.notable); - fl_print_format(" '%[%r%r ./my_fakefile%]' the fakefile at", file.stream, context.set.notable, f_console_symbol_long_enable_s, fake_long_fakefile_s, context.set.notable); - fl_print_format(" '%[./my_fakefile%]' would be used.%r%r", file.stream, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); + fl_print_format(" '%[./my_fakefile%]' is used if found, but if it is not found then", file.stream, context.set.notable, context.set.notable); + fl_print_format(" '%[./%r%rmy_fakefile%]' is used if found.%r", file.stream, context.set.notable, fake_default_path_data_s, fake_default_path_build_s, context.set.notable, f_string_eol_s); + fl_print_format(" For example, with '%[%r%r ./my_fakefile%]' the fakefile at", file.stream, context.set.notable, f_console_symbol_long_enable_s, fake_long_fakefile_s, context.set.notable); + fl_print_format(" '%[./my_fakefile%]' is used if found, but if it is not found then no other paths are attempted.%r%r", file.stream, context.set.notable, context.set.notable, f_string_eol_s, f_string_eol_s); fl_print_format(" When piping data to this program, the piped data is treated as a %[%r%].%r", file.stream, context.set.notable, fake_make_parameter_variable_fakefile_s, context.set.notable, f_string_eol_s); fl_print_format(" Only the %[%r%] operation is supported when using piped data.%r%r", file.stream, context.set.notable, fake_other_operation_make_s, context.set.notable, f_string_eol_s, f_string_eol_s); diff --git a/level_3/fake/c/private-fake-path_generate.c b/level_3/fake/c/private-fake-path_generate.c index 43ccb35..aeab508 100644 --- a/level_3/fake/c/private-fake-path_generate.c +++ b/level_3/fake/c/private-fake-path_generate.c @@ -170,14 +170,13 @@ extern "C" { } // When custom fakefile or settings are used and they are paths to a file, remove the default path. - if (f_path_is(data->fakefile) == F_true) { + if (data->main->process_pipe || f_path_is(data->fakefile) == F_true || f_file_exists(data->fakefile, F_true) == F_true) { data->file_data_build_fakefile.used = 0; } - if (f_path_is(data->settings) == F_true) { + if (data->main->process_pipe || f_path_is(data->settings) == F_true || f_file_exists(data->settings, F_true) == F_true) { data->file_data_build_settings.used = 0; } - { const f_string_static_t parameters_source[] = { fake_path_part_script_s, diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 7b6ef8b..17b7b10 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -556,9 +556,7 @@ extern "C" { f_status_t fake_validate_parameter_paths(fake_data_t * const data) { // Only perform these checks when not a pipe. - if (data->main->process_pipe) { - return F_none; - } + if (data->main->process_pipe) return F_none; if (fll_program_standard_signal_received(data->main)) { fake_print_signal_received(data); @@ -584,6 +582,8 @@ extern "C" { F_false, }; + f_status_t status = F_none; + // Check only expected operations (fake_operation_clean_e and fake_operation_skeleton_e should not call this function). if (data->operation == fake_operation_make_e) { @@ -594,6 +594,13 @@ extern "C" { if (f_path_is_absolute(data->main->parameters.arguments.array[index]) == F_true || f_path_is_relative_current(data->main->parameters.arguments.array[index]) == F_true) { parameters_required[1] = F_none; } + else { + status = f_file_exists(data->main->parameters.arguments.array[index], F_true); + + if (F_status_is_error_not(status) && status == F_true) { + parameters_required[1] = F_none; + } + } } } else if (data->operation == fake_operation_build_e) { @@ -605,11 +612,17 @@ extern "C" { if (f_path_is_absolute(data->main->parameters.arguments.array[index]) == F_true || f_path_is_relative_current(data->main->parameters.arguments.array[index]) == F_true) { parameters_required[1] = F_none; } + else { + status = f_file_exists(data->main->parameters.arguments.array[index], F_true); + + if (F_status_is_error_not(status) && status == F_true) { + parameters_required[1] = F_none; + } + } } } struct stat directory_stat; - f_status_t status = F_none; for (uint8_t i = 0; i < 3; ++i) {