Finish implementing -f/--fakefile and updating -s/--settings parameters.
This adds a new function f_path_is(), which is a dirt simple function for checking if the path separator exist in a given string.
}
#endif // _di_f_path_current_
+#ifndef _di_f_path_is_
+ f_return_status f_path_is(const f_string_t path, const f_string_length_t length) {
+ if (!path || !length) {
+ return F_false;
+ }
+
+ for (f_string_length_t i = 0; i < length; i++) {
+
+ if (path[i] == f_path_separator[0]) {
+ return F_true;
+ }
+ } // for
+
+ return F_false;
+ }
+#endif // _di_f_path_is_
+
#ifndef _di_f_path_real_
f_return_status f_path_real(const f_string_t path, f_string_dynamic_t *real) {
#ifndef _di_level_0_parameter_checking_
- if (real == 0) return F_status_set_error(F_parameter);
+ if (!real) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
return private_f_path_real(path, real);
* The path separator, intended to be represented as a single character.
* The path separator length must be a 1-byte wide character.
*
+ * The "current" path separator "." represents a part of the path that potentially may represent the current path.
+ * This is expected to be followed by a separator "/".
+ *
* The path variable separator is intended to represent the path separator used in the PATH environment variable.
* PATH="/bin:/usr/bin", the path variable separator is ':'.
* The path variable separator must be a 1-byte wide character.
*/
#ifndef _di_f_path_defines_
#define f_path_separator "/"
+ #define f_path_separator_current "."
#define f_path_separator_variable ":"
#define f_path_separator_length 1
+ #define f_path_separator_current_length 1
#define f_path_separator_variable_length 1
#define f_path_extension_separator "."
#endif // _di_f_path_current_
/**
+ * Identify whether or not a string represents a path string.
+ *
+ * A string without any path parts that could be a path is not considered a path by this function.
+ * That is to say "my_file.txt" is not a path string but "./my_file.txt" is a path string.
+ *
+ * @param path
+ * The string that may or may not represent a path..
+ * @param length
+ * Length of the path string.
+ *
+ * @return
+ * F_true if this string is a path string.
+ * F_false if this string is not a path string.
+ */
+#ifndef _di_f_path_is_
+ extern f_return_status f_path_is(const f_string_t path, const f_string_length_t length);
+#endif // _di_f_path_is_
+
+/**
* Get the real path for the given path.
*
* This does check to see if the path exists or not (path must exist).
f_macro_string_lengths_t_delete_simple(data->remaining);
f_macro_string_dynamics_t_delete_simple(data->define);
+ f_macro_string_dynamic_t_delete_simple(data->fakefile);
f_macro_string_dynamics_t_delete_simple(data->mode);
f_macro_string_dynamic_t_delete_simple(data->process);
f_macro_string_dynamic_t_delete_simple(data->settings);
#ifndef _di_fake_file_
#define fake_file_defines "defines"
#define fake_file_dependencies "dependencies"
- #define fake_file_fakefile "fakefile"
- #define fake_file_process_post "process_post.sh"
- #define fake_file_process_pre "process_pre.sh"
#define fake_file_readme "readme"
- #define fake_file_settings "settings"
#define fake_file_defines_length 7
#define fake_file_dependencies_length 12
- #define fake_file_fakefile_length 8
- #define fake_file_process_post_length 15
- #define fake_file_process_pre_length 14
#define fake_file_readme_length 6
- #define fake_file_settings_length 8
#endif // _di_fake_file_
/**
#define fake_default_path_work_length 0
#define fake_default_define ""
+ #define fake_default_fakefile "fakefile"
#define fake_default_mode ""
#define fake_default_process ""
#define fake_default_settings "settings"
#define fake_default_define_length 0
+ #define fake_default_fakefile_length 8
#define fake_default_mode_length 0
#define fake_default_process_length 0
#define fake_default_settings_length 8
uint8_t verbosity;
f_string_dynamics_t define;
+ f_string_dynamic_t fakefile;
f_string_dynamics_t mode;
f_string_dynamic_t process;
f_string_dynamic_t settings;
0, \
fake_verbosity_normal, \
f_string_dynamics_t_initialize, \
+ f_string_dynamic_t_initialize, \
f_string_dynamics_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
} // for
}
+ // When custom fakefile or settings are used and they are paths to a file, remove the default path.
+ if (f_path_is(data->fakefile.string, data->fakefile.used)) {
+ data->file_data_build_fakefile.used = 0;
+ }
+
+ if (f_path_is(data->settings.string, data->settings.used)) {
+ data->file_data_build_settings.used = 0;
+ }
+
{
const f_string_t parameters_source[] = {
fake_path_part_script,
fake_path_part_static,
fake_file_defines,
fake_file_dependencies,
- fake_file_fakefile,
+ data->fakefile.string,
data->settings.string,
fake_file_readme,
};
fake_path_part_static_length,
fake_file_defines_length,
fake_file_dependencies_length,
- fake_file_fakefile_length,
+ data->fakefile.used,
data->settings.used,
fake_file_readme_length,
};
}
}
- // @todo use fakefile and settings file if a custom path is provided by the command line instead of the default.
-
{
f_string_dynamic_t *parameters_value[] = {
&data->path_build_documents,
&data->path_work_programs_static,
&data->file_data_build_defines,
&data->file_data_build_dependencies,
+ &data->file_data_build_fakefile,
&data->file_data_build_settings,
&data->file_documents_readme,
};
- for (i = 0; i < 33; i++) {
+ for (i = 0; i < 34; i++) {
if (parameters_value[i]->used == 0) continue;
status = fl_string_dynamic_terminate_after(parameters_value[i]);
{
const uint8_t parameters_id[] = {
+ fake_parameter_fakefile,
fake_parameter_process,
fake_parameter_settings,
};
const f_string_t parameters_name[] = {
+ fake_long_fakefile,
fake_long_process,
fake_long_settings,
};
const f_string_t parameter_defaults[] = {
+ fake_default_fakefile,
fake_default_process,
fake_default_settings,
};
const f_string_length_t parameter_default_lengths[] = {
+ fake_default_fakefile_length,
fake_default_process_length,
fake_default_settings_length,
};
f_string_dynamic_t *parameters_value[] = {
+ &data->fakefile,
&data->process,
&data->settings,
};
bool parameters_validate_word[] = {
+ F_false,
F_true,
F_false,
};
- for (uint8_t i = 0; i < 2; i++) {
+ for (uint8_t i = 0; i < 3; i++) {
if (data->parameters[parameters_id[i]].result == f_console_result_found) {
fake_print_error_parameter_missing_value(*data, parameters_name[i]);
return F_status_set_error(F_parameter);
# 2) change into the extracted bzip2-1.0.8 directory.
# 3) create the directory path "data/build/" within this bzip2-1.0.8 directory.
# 4) copy the files fakefile-example-bzip2, settings-example-bzip2, and settings-example-bzip2recover) into the created directory path "data/build/".
-# 5) use the featureless make build operation to make, such as: "fake make".
+# 5) use the featureless make build operation to make, such as: "fake make -f fakefile-example-bzip2".
settings:
load_build no