]> Kevux Git Server - fll/commitdiff
Progress: featureless make.
authorKevin Day <thekevinday@gmail.com>
Tue, 8 Sep 2020 04:15:00 +0000 (23:15 -0500)
committerKevin Day <thekevinday@gmail.com>
Tue, 8 Sep 2020 04:15:00 +0000 (23:15 -0500)
Seems I completely forgot some basic section operations:
- copy
- move

This prepares foo implementing a copy, a clone, and a move.

It seems that there is no directory_move or file_move function, so these need to be implemented.

level_3/fake/c/private-make.c
level_3/fake/c/private-make.h
level_3/fake/documents/fakefile.txt
level_3/fake/specifications/fakefile.txt

index 8e9fcb169445df17e0792e88017fef35bfb11d28..bf5fc571463c160b77eccd090acd1d3937861190 100644 (file)
@@ -1430,6 +1430,7 @@ extern "C" {
       f_macro_string_static_t_initialize(fake_make_operation_build, fake_make_operation_build_length),
       f_macro_string_static_t_initialize(fake_make_operation_clean, fake_make_operation_clean_length),
       f_macro_string_static_t_initialize(fake_make_operation_compile, fake_make_operation_compile_length),
+      f_macro_string_static_t_initialize(fake_make_operation_copy, fake_make_operation_copy_length),
       f_macro_string_static_t_initialize(fake_make_operation_define, fake_make_operation_define_length),
       f_macro_string_static_t_initialize(fake_make_operation_delete, fake_make_operation_delete_length),
       f_macro_string_static_t_initialize(fake_make_operation_deletes, fake_make_operation_deletes_length),
@@ -1443,6 +1444,7 @@ extern "C" {
       f_macro_string_static_t_initialize(fake_make_operation_link, fake_make_operation_link_length),
       f_macro_string_static_t_initialize(fake_make_operation_mode, fake_make_operation_mode_length),
       f_macro_string_static_t_initialize(fake_make_operation_modes, fake_make_operation_modes_length),
+      f_macro_string_static_t_initialize(fake_make_operation_move, fake_make_operation_move_length),
       f_macro_string_static_t_initialize(fake_make_operation_operate, fake_make_operation_operate_length),
       f_macro_string_static_t_initialize(fake_make_operation_owner, fake_make_operation_owner_length),
       f_macro_string_static_t_initialize(fake_make_operation_owners, fake_make_operation_owners_length),
@@ -1461,6 +1463,7 @@ extern "C" {
       f_macro_string_range_initialize(fake_make_operation_build_length),
       f_macro_string_range_initialize(fake_make_operation_clean_length),
       f_macro_string_range_initialize(fake_make_operation_compile_length),
+      f_macro_string_range_initialize(fake_make_operation_copy_length),
       f_macro_string_range_initialize(fake_make_operation_define_length),
       f_macro_string_range_initialize(fake_make_operation_delete_length),
       f_macro_string_range_initialize(fake_make_operation_deletes_length),
@@ -1474,6 +1477,7 @@ extern "C" {
       f_macro_string_range_initialize(fake_make_operation_link_length),
       f_macro_string_range_initialize(fake_make_operation_mode_length),
       f_macro_string_range_initialize(fake_make_operation_modes_length),
+      f_macro_string_range_initialize(fake_make_operation_move_length),
       f_macro_string_range_initialize(fake_make_operation_operate_length),
       f_macro_string_range_initialize(fake_make_operation_owner_length),
       f_macro_string_range_initialize(fake_make_operation_owners_length),
@@ -1492,6 +1496,7 @@ extern "C" {
       fake_make_operation_type_build,
       fake_make_operation_type_clean,
       fake_make_operation_type_compile,
+      fake_make_operation_type_copy,
       fake_make_operation_type_define,
       fake_make_operation_type_delete,
       fake_make_operation_type_deletes,
@@ -1505,6 +1510,7 @@ extern "C" {
       fake_make_operation_type_link,
       fake_make_operation_type_mode,
       fake_make_operation_type_modes,
+      fake_make_operation_type_move,
       fake_make_operation_type_operate,
       fake_make_operation_type_owner,
       fake_make_operation_type_owners,
@@ -1780,6 +1786,29 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_clone) {
+      const f_array_length_t total = arguments.used -1;
+      f_status_t status_file = F_none;
+
+      for (f_array_length_t i = 0; i < total; i++) {
+        status_file = f_directory_is(arguments.array[i].string);
+
+        if (status_file == F_true) {
+          // @todo: *status = fl_directory_clone();
+        }
+        else if (status_file == F_true) {
+          // @todo: *status = f_file_clone();
+        }
+        else if (F_status_is_error(status_file)) {
+          // @todo
+          *status = F_status_set_error(F_failure);
+          break;
+        }
+      } // for
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_compile) {
       int return_code = fake_execute(data, data_make->environment, data_make->setting_build.build_compiler, arguments, status);
 
@@ -1793,6 +1822,29 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_copy) {
+      const f_array_length_t total = arguments.used -1;
+      f_status_t status_file = F_none;
+
+      for (f_array_length_t i = 0; i < total; i++) {
+        status_file = f_directory_is(arguments.array[i].string);
+
+        if (status_file == F_true) {
+          // @todo: *status = fl_directory_copy();
+        }
+        else if (status_file == F_true) {
+          // @todo: *status = f_file_copy();
+        }
+        else if (F_status_is_error(status_file)) {
+          // @todo
+          *status = F_status_set_error(F_failure);
+          break;
+        }
+      } // for
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_define) {
 
       if (arguments.used > 1) {
@@ -2582,6 +2634,29 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_move) {
+      const f_array_length_t total = arguments.used -1;
+      f_status_t status_file = F_none;
+
+      for (f_array_length_t i = 0; i < total; i++) {
+        status_file = f_directory_is(arguments.array[i].string);
+
+        if (status_file == F_true) {
+          // @todo: *status = fl_directory_copy();
+        }
+        else if (status_file == F_true) {
+          // @todo: *status = f_file_copy();
+        }
+        else if (F_status_is_error(status_file)) {
+          // @todo
+          *status = F_status_set_error(F_failure);
+          break;
+        }
+      } // for
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_operate) {
       f_array_length_t id_section = 0;
 
@@ -3210,6 +3285,84 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_clone) {
+      if (arguments.used > 1) {
+        for (f_array_length_t i = 0; i < arguments.used; i++) {
+          *status = fake_make_assure_inside_project(data, arguments.array[i], data_make);
+
+          if (F_status_is_error(*status)) {
+            fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string, data_make->print);
+
+            if (F_status_set_fine(*status) == F_false) {
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        } // for
+
+        for (f_array_length_t i = 0; i < arguments.used - 1; i++) {
+          if (f_file_exists(arguments.array[i].string) != F_true) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[i].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+        } // for
+
+        if (arguments.used > 2) {
+          // the last file must be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
+
+          if (status_file == F_false || status_file == F_file_found_not) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+          else if (F_status_is_error(status_file)) {
+            fake_print_message_file(data, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true, data_make->print);
+            *status = F_status_set_error(F_failure);
+          }
+        }
+        else {
+          // when the first file is a directory, then the second, if it exists, must also be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[0].string);
+
+          if (status_file == F_true) {
+            status_file = f_directory_is(arguments.array[1].string);
+
+            if (status_file == F_false) {
+              if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+                printf("%c", f_string_eol[0]);
+                fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+                fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+                fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+              }
+
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        }
+      }
+      else {
+        if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+          printf("%c", f_string_eol[0]);
+          fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix);
+        }
+
+        *status = F_status_set_error(F_failure);
+      }
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_compile) {
       if (arguments.used == 0) {
         if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
@@ -3233,6 +3386,84 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_copy) {
+      if (arguments.used > 1) {
+        for (f_array_length_t i = 0; i < arguments.used; i++) {
+          *status = fake_make_assure_inside_project(data, arguments.array[i], data_make);
+
+          if (F_status_is_error(*status)) {
+            fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string, data_make->print);
+
+            if (F_status_set_fine(*status) == F_false) {
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        } // for
+
+        for (f_array_length_t i = 0; i < arguments.used - 1; i++) {
+          if (f_file_exists(arguments.array[i].string) != F_true) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[i].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+        } // for
+
+        if (arguments.used > 2) {
+          // the last file must be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
+
+          if (status_file == F_false || status_file == F_file_found_not) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+          else if (F_status_is_error(status_file)) {
+            fake_print_message_file(data, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true, data_make->print);
+            *status = F_status_set_error(F_failure);
+          }
+        }
+        else {
+          // when the first file is a directory, then the second, if it exists, must also be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[0].string);
+
+          if (status_file == F_true) {
+            status_file = f_directory_is(arguments.array[1].string);
+
+            if (status_file == F_false) {
+              if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+                printf("%c", f_string_eol[0]);
+                fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+                fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+                fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+              }
+
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        }
+      }
+      else {
+        if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+          printf("%c", f_string_eol[0]);
+          fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix);
+        }
+
+        *status = F_status_set_error(F_failure);
+      }
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_delete || operation == fake_make_operation_type_deletes) {
       if (arguments.used) {
         for (f_array_length_t i = 0; i < arguments.used; i++) {
@@ -3866,6 +4097,84 @@ extern "C" {
       return;
     }
 
+    if (operation == fake_make_operation_type_move) {
+      if (arguments.used > 1) {
+        for (f_array_length_t i = 0; i < arguments.used; i++) {
+          *status = fake_make_assure_inside_project(data, arguments.array[i], data_make);
+
+          if (F_status_is_error(*status)) {
+            fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string, data_make->print);
+
+            if (F_status_set_fine(*status) == F_false) {
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        } // for
+
+        for (f_array_length_t i = 0; i < arguments.used - 1; i++) {
+          if (f_file_exists(arguments.array[i].string) != F_true) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[i].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+        } // for
+
+        if (arguments.used > 2) {
+          // the last file must be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
+
+          if (status_file == F_false || status_file == F_file_found_not) {
+            if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+              printf("%c", f_string_eol[0]);
+              fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+              fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+              fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+            }
+
+            *status = F_status_set_error(F_failure);
+          }
+          else if (F_status_is_error(status_file)) {
+            fake_print_message_file(data, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true, data_make->print);
+            *status = F_status_set_error(F_failure);
+          }
+        }
+        else {
+          // when the first file is a directory, then the second, if it exists, must also be a directory.
+          f_status_t status_file = f_directory_is(arguments.array[0].string);
+
+          if (status_file == F_true) {
+            status_file = f_directory_is(arguments.array[1].string);
+
+            if (status_file == F_false) {
+              if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+                printf("%c", f_string_eol[0]);
+                fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The last file '", data_make->print.prefix);
+                fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[arguments.used - 1].string);
+                fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a valid directory.");
+              }
+
+              *status = F_status_set_error(F_failure);
+            }
+          }
+        }
+      }
+      else {
+        if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
+          printf("%c", f_string_eol[0]);
+          fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix);
+        }
+
+        *status = F_status_set_error(F_failure);
+      }
+
+      return;
+    }
+
     if (operation == fake_make_operation_type_operate) {
       if (arguments.used > 1) {
         if (data.verbosity != fake_verbosity_quiet && data_make->print.to) {
index 5baa17f2a50b1512cb351349f8187cb7909a9a90..62247d1df24193b2fc113b0d49f5f389ffc48f26 100644 (file)
@@ -63,7 +63,9 @@ extern "C" {
   #define fake_make_operation_build    "build"
   #define fake_make_operation_break    "break"
   #define fake_make_operation_clean    "clean"
+  #define fake_make_operation_clone    "clone"
   #define fake_make_operation_compile  "compile"
+  #define fake_make_operation_copy     "copy"
   #define fake_make_operation_define   "define"
   #define fake_make_operation_delete   "delete"
   #define fake_make_operation_deletes  "deletes"
@@ -77,6 +79,7 @@ extern "C" {
   #define fake_make_operation_link     "link"
   #define fake_make_operation_mode     "mode"
   #define fake_make_operation_modes    "modes"
+  #define fake_make_operation_move     "move"
   #define fake_make_operation_operate  "operate"
   #define fake_make_operation_owner    "owner"
   #define fake_make_operation_owners   "owners"
@@ -93,7 +96,9 @@ extern "C" {
   #define fake_make_operation_break_length    5
   #define fake_make_operation_build_length    5
   #define fake_make_operation_clean_length    5
+  #define fake_make_operation_clone_length    5
   #define fake_make_operation_compile_length  7
+  #define fake_make_operation_copy_length     4
   #define fake_make_operation_define_length   6
   #define fake_make_operation_delete_length   6
   #define fake_make_operation_deletes_length  7
@@ -106,6 +111,7 @@ extern "C" {
   #define fake_make_operation_link_length     4
   #define fake_make_operation_mode_length     4
   #define fake_make_operation_modes_length    5
+  #define fake_make_operation_move_length     4
   #define fake_make_operation_operate_length  7
   #define fake_make_operation_owner_length    5
   #define fake_make_operation_owners_length   6
@@ -122,7 +128,9 @@ extern "C" {
     fake_make_operation_type_break = 1,
     fake_make_operation_type_build,
     fake_make_operation_type_clean,
+    fake_make_operation_type_clone,
     fake_make_operation_type_compile,
+    fake_make_operation_type_copy,
     fake_make_operation_type_define,
     fake_make_operation_type_delete,
     fake_make_operation_type_deletes,
@@ -136,6 +144,7 @@ extern "C" {
     fake_make_operation_type_link,
     fake_make_operation_type_mode,
     fake_make_operation_type_modes,
+    fake_make_operation_type_move,
     fake_make_operation_type_operate,
     fake_make_operation_type_owner,
     fake_make_operation_type_owners,
@@ -149,7 +158,7 @@ extern "C" {
     fake_make_operation_type_touch,
   };
 
-  #define fake_make_operation_total 28
+  #define fake_make_operation_total 31
 
   #define fake_make_operation_argument_environment "environment"
   #define fake_make_operation_argument_failure     "failure"
index b985a92ab208fc42fcae13d4691056fce0951877..e22b4c5907093776e3df8a83f0f5c5da5211bc48 100644 (file)
@@ -83,11 +83,25 @@ Fakefile Documentation:
       Run the fake clean operation as if "fake clean" was run instead of "fake make".
       Command line arguments are automatically passed to the fake build operation.
 
+    - clone\:
+      Copy all files (and directories), preserving all propeties, into the last content.
+      If there are more than one file (or directory) being copied, then the final path must be a directory.
+
+      All Content, except last, represents the files to clone.
+      The last Content represents the destination file (or directory) to clone to.
+
     - compile\:
       Execute the compiler program, such as "gcc".
 
       All Content are passed as arguments to the respective "gcc" program.
 
+    - copy\:
+      Copy all files (and directories) into the last content.
+      If there are more than one file (or directory) being copied, then the final path must be a directory.
+
+      All Content, except last, represents the files to copy.
+      The last Content represents the destination file (or directory) to copy to.
+
     - define\:
       This represents an environment variable to define on run.
       The environment variable name is case-sensitive.
@@ -231,6 +245,13 @@ Fakefile Documentation:
     - modes\:
       Identical to mode operation, except this will recursively apply the mode to all files within the given file, if that file is a directory file path.
 
+    - move\:
+      Move all files (and directories) into the last content.
+      If there are more than one file (or directory) being copied, then the final path must be a directory.
+
+      All Content, except last, represents the files to move.
+      The last Content represents the destination file (or directory) to move to.
+
     - operate\:
       Begin execution of another Section.
 
index 38e185f90cb5af9b7d6bea2a1d83822c0abeb3de..4954e278ae32561c6c3eb2179af1f81f524998dc 100644 (file)
@@ -39,7 +39,9 @@ Fakefile Specification:
   - break: Zero or One Content. If specified, First content must be one of "success" or "failure".
   - build: Zero or One Content. First Content represents file name of the settings file to use.
   - clean: Zero Content.
+  - clone: Two or more Content representing paths to files.
   - compile: One or more Content as parameters to compiler.
+  - copy: Two or more Content representing paths to files.
   - define: Two or more Content.
   - delete: One or more Content representing paths to files.
   - deletes: One or more Content representing paths to files.
@@ -53,6 +55,7 @@ Fakefile Specification:
   - link: Two Content. First Content is the link target file and second Content is the pointer file (the link).
   - mode: Two or more Content. First Content is the mode, remaining Content are paths to files.
   - modes: Two or more Content. First Content is the mode, remaining Content are paths to files.
+  - move: Two or more Content representing paths to files.
   - operate: One Content. First Content is the name of a valid Section Object, except for the reserved Section Objects.
   - owner: Two or more Content. First Content is group name or number, remaining Content are paths to files.
   - owners: Two or more Content. First Content is group name or number, remaining Content are paths to files.