]> Kevux Git Server - fll/commitdiff
Progress: continue work on fake (Featureless Make)
authorKevin Day <thekevinday@gmail.com>
Sun, 10 May 2020 05:50:56 +0000 (00:50 -0500)
committerKevin Day <thekevinday@gmail.com>
Sun, 10 May 2020 05:50:56 +0000 (00:50 -0500)
level_3/fake/c/fake.c
level_3/fake/c/fake.h
level_3/fake/c/private-build.c
level_3/fake/c/private-build.h
level_3/fake/c/private-fake.c
level_3/fake/c/private-fake.h
level_3/fake/data/build/process_post.sh
level_3/fake/data/build/process_pre.sh

index b7adac57acc56516d20ca112a0645cbb9e0d99a6..5dc796129c2f03653ce3110bef3a93cb0170d334 100644 (file)
@@ -73,7 +73,7 @@ extern "C" {
     fl_color_print(f_standard_output, context.notable, context.reset, "%s", fake_long_mode);
     printf(" of 'fll_monolithic' is specified, build libaries from both 'build_libraries' and 'build_libraries-fll_monolithic' are used (but not 'build_libraries-fll_level').");
 
-    printf("%c", f_string_eol);
+    printf("%c%c", f_string_eol, f_string_eol);
 
     return f_none;
   }
@@ -246,6 +246,10 @@ extern "C" {
     else if (operations[0]) {
       status = fake_process_console_parameters(arguments, data);
 
+      if (!f_status_is_error(status)) {
+        status = fake_path_generate(data);
+      }
+
       if (f_status_is_error(status)) {
         fake_delete_data(data);
         return f_status_set_error(status);
@@ -307,6 +311,19 @@ extern "C" {
     f_macro_string_dynamic_delete_simple(data->settings);
 
     f_macro_string_dynamic_delete_simple(data->path_build);
+    f_macro_string_dynamic_delete_simple(data->path_build_documents);
+    f_macro_string_dynamic_delete_simple(data->path_build_includes);
+    f_macro_string_dynamic_delete_simple(data->path_build_libraries);
+    f_macro_string_dynamic_delete_simple(data->path_build_libraries_script);
+    f_macro_string_dynamic_delete_simple(data->path_build_libraries_shared);
+    f_macro_string_dynamic_delete_simple(data->path_build_libraries_static);
+    f_macro_string_dynamic_delete_simple(data->path_build_objects);
+    f_macro_string_dynamic_delete_simple(data->path_build_process);
+    f_macro_string_dynamic_delete_simple(data->path_build_programs);
+    f_macro_string_dynamic_delete_simple(data->path_build_programs_script);
+    f_macro_string_dynamic_delete_simple(data->path_build_programs_shared);
+    f_macro_string_dynamic_delete_simple(data->path_build_programs_static);
+    f_macro_string_dynamic_delete_simple(data->path_build_settings);
     f_macro_string_dynamic_delete_simple(data->path_work);
 
     f_macro_string_dynamic_delete_simple(data->path_source_build);
index c5d109d84e9910f80c34bb5feb63ead2f2250700..f4e35adcb5dd4f9db8d605a6399b7a145fb19c4f 100644 (file)
@@ -153,38 +153,49 @@ extern "C" {
   #define fake_default_allocation_step 4
 #endif // _di_fake_default_allocation_step_
 
+/**
+ * Fake paths are hard-coded paths that are generally generated into a full path based on runtime settings.
+ *
+ * For example path_build_documents will become "build/documents/" if the fake_default_path_build is used.
+ */
+#ifndef _di_fake_path_
+  #define fake_path_directory_separator "/" // @todo this should be provided by a f_path library.
+
+  #define fake_path_build_documents        "documents" fake_path_directory_separator
+  #define fake_path_build_includes         "includes"  fake_path_directory_separator
+  #define fake_path_build_libraries        "libraries" fake_path_directory_separator
+  #define fake_path_build_libraries_script "script"    fake_path_directory_separator
+  #define fake_path_build_libraries_shared "shared"    fake_path_directory_separator
+  #define fake_path_build_libraries_static "static"    fake_path_directory_separator
+  #define fake_path_build_objects          "objects"   fake_path_directory_separator
+  #define fake_path_build_process          "process"   fake_path_directory_separator
+  #define fake_path_build_programs         "programs"  fake_path_directory_separator
+  #define fake_path_build_programs_script  "script"    fake_path_directory_separator
+  #define fake_path_build_programs_shared  "shared"    fake_path_directory_separator
+  #define fake_path_build_programs_static  "static"    fake_path_directory_separator
+  #define fake_path_build_settings         "settings"  fake_path_directory_separator
+
+  #define fake_path_build_documents_length        10
+  #define fake_path_build_includes_length         9
+  #define fake_path_build_libraries_length        10
+  #define fake_path_build_libraries_script_length 6
+  #define fake_path_build_libraries_shared_length 6
+  #define fake_path_build_libraries_static_length 6
+  #define fake_path_build_objects_length          7
+  #define fake_path_build_process_length          7
+  #define fake_path_build_programs_length         9
+  #define fake_path_build_programs_script_length  7
+  #define fake_path_build_programs_shared_length  7
+  #define fake_path_build_programs_static_length  7
+  #define fake_path_build_settings_length         9
+#endif // _di_fake_path_
+
 #ifndef _di_fake_defaults_
-  #define fake_default_path_build                 "build/"
-  #define fake_default_path_build_documents       "build/documents/"
-  #define fake_default_path_build_includes        "build/includes/"
-  #define fake_default_path_build_libaries        "build/libaries/"
-  #define fake_default_path_build_libaries_script "build/libaries/script/"
-  #define fake_default_path_build_libaries_shared "build/libaries/shared/"
-  #define fake_default_path_build_libaries_static "build/libaries/static/"
-  #define fake_default_path_build_objects         "build/objects/"
-  #define fake_default_path_build_process         "build/process/"
-  #define fake_default_path_build_programs        "build/programs/"
-  #define fake_default_path_build_programs_script "build/programs/script/"
-  #define fake_default_path_build_programs_shared "build/programs/shared/"
-  #define fake_default_path_build_programs_static "build/programs/static/"
-  #define fake_default_path_build_settings        "build/settings/"
-  #define fake_default_path_work                  ""
-
-  #define fake_default_path_build_length                 6
-  #define fake_default_path_build_documents_length       16
-  #define fake_default_path_build_includes_length        15
-  #define fake_default_path_build_libaries_length        15
-  #define fake_default_path_build_libaries_script_length 22
-  #define fake_default_path_build_libaries_shared_length 22
-  #define fake_default_path_build_libaries_static_length 22
-  #define fake_default_path_build_objects_length         14
-  #define fake_default_path_build_process_length         14
-  #define fake_default_path_build_programs_length        15
-  #define fake_default_path_build_programs_script_length 22
-  #define fake_default_path_build_programs_shared_length 22
-  #define fake_default_path_build_programs_static_length 22
-  #define fake_default_path_build_settings_length        15
-  #define fake_default_path_work_length                  0
+  #define fake_default_path_build "build" fake_path_directory_separator
+  #define fake_default_path_work  ""
+
+  #define fake_default_path_build_length 6
+  #define fake_default_path_work_length  0
 
   #define fake_default_defines  ""
   #define fake_default_mode     ""
@@ -196,13 +207,13 @@ extern "C" {
   #define fake_default_process_length  0
   #define fake_default_settings_length 8
 
-  #define fake_default_path_source_build     "data/build/"
-  #define fake_default_path_source_codes     "sources/"
-  #define fake_default_path_source_common    "data/common/"
-  #define fake_default_path_source_data      "data/"
-  #define fake_default_path_source_documents "data/documents/"
-  #define fake_default_path_source_licenses  "licenses/"
-  #define fake_default_path_source_settings  "data/build/"
+  #define fake_default_path_source_build     "data" fake_path_directory_separator "build" fake_path_directory_separator
+  #define fake_default_path_source_codes     "sources" fake_path_directory_separator
+  #define fake_default_path_source_common    "data" fake_path_directory_separator "common" fake_path_directory_separator
+  #define fake_default_path_source_data      "data" fake_path_directory_separator
+  #define fake_default_path_source_documents "data" fake_path_directory_separator "documents" fake_path_directory_separator
+  #define fake_default_path_source_licenses  "licenses" fake_path_directory_separator
+  #define fake_default_path_source_settings  "data" fake_path_directory_separator "build" fake_path_directory_separator
 
   #define fake_default_path_source_build_length     11
   #define fake_default_path_source_codes_length     8
@@ -212,9 +223,9 @@ extern "C" {
   #define fake_default_path_source_licenses_length  9
   #define fake_default_path_source_settings_length  11
 
-  #define fake_default_language_c     "c/"
-  #define fake_default_language_cpp   "c++/"
-  #define fake_default_language_shell "shell/"
+  #define fake_default_language_c     "c" fake_path_directory_separator
+  #define fake_default_language_cpp   "c++" fake_path_directory_separator
+  #define fake_default_language_shell "shell" fake_path_directory_separator
 
   #define fake_default_language_c_length     2
   #define fake_default_language_cpp_length   4
@@ -261,6 +272,12 @@ extern "C" {
   #define fake_short_process_length  1
   #define fake_short_settings_length 1
 
+  #define fake_file_extension_built    ".built"
+  #define fake_file_extension_building ".building"
+
+  #define fake_file_extension_built_length    6
+  #define fake_file_extension_building_length 9
+
   #define fake_short_path_build "b"
   #define fake_short_path_work  "w"
 
@@ -433,6 +450,19 @@ extern "C" {
     f_string_dynamic settings;
 
     f_string_dynamic path_build;
+    f_string_dynamic path_build_documents;
+    f_string_dynamic path_build_includes;
+    f_string_dynamic path_build_libraries;
+    f_string_dynamic path_build_libraries_script;
+    f_string_dynamic path_build_libraries_shared;
+    f_string_dynamic path_build_libraries_static;
+    f_string_dynamic path_build_objects;
+    f_string_dynamic path_build_process;
+    f_string_dynamic path_build_programs;
+    f_string_dynamic path_build_programs_script;
+    f_string_dynamic path_build_programs_shared;
+    f_string_dynamic path_build_programs_static;
+    f_string_dynamic path_build_settings;
     f_string_dynamic path_work;
 
     f_string_dynamic path_source_build;
@@ -466,6 +496,19 @@ extern "C" {
       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, \
       fl_color_context_initialize, \
     }
 #endif // _di_fake_data_
index bc121749c0c9ac4746da798d2d763251bba5fc87..7f92034ff5b69b6895e9fc1c193ace16ebc00dc4 100644 (file)
@@ -318,11 +318,15 @@ extern "C" {
 #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 fake_build_settings settings, 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_static process_script) {
     if (process_script.used == 0) return f_none;
 
     f_status status = f_none;
 
+    //fake_file_extension_built
+
+    //if (fake_build_file_exists
+
     const f_string parameter_prefixs[] = {
       f_console_symbol_short_enable,
       f_console_symbol_short_enable,
index 1104cc6785bc6e125c25c1e5f76fc3943f36c8cc..5ccb37b320a269e32377cb2115a27ed26fab814c 100644 (file)
@@ -328,7 +328,7 @@ extern "C" {
  *   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 fake_build_settings settings, 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_static process_script) f_gcc_attribute_visibility_internal;
 #endif // _di_fake_build_execute_process_script_
 
 #ifdef __cplusplus
index 06aa54b5ae25c0aa10cbd98a8941a7eb61442cf7..b7a4d54bc9ed4684b386280055172674beddc4c3 100644 (file)
@@ -5,6 +5,159 @@
 extern "C" {
 #endif
 
+#ifndef _di_fake_path_generate_
+  f_return_status fake_path_generate(fake_data *data) {
+    f_status status = f_none;
+    f_string function = "fl_string_dynamic_append";
+    uint8_t i = 0;
+
+    {
+      const f_string parameter_strings[] = {
+        fake_path_build_documents,
+        fake_path_build_includes,
+        fake_path_build_libraries,
+        fake_path_build_objects,
+        fake_path_build_process,
+        fake_path_build_programs,
+        fake_path_build_settings,
+      };
+
+      const f_string_length parameter_strings_lengths[] = {
+        fake_path_build_documents_length,
+        fake_path_build_includes_length,
+        fake_path_build_libraries_length,
+        fake_path_build_objects_length,
+        fake_path_build_process_length,
+        fake_path_build_programs_length,
+        fake_path_build_settings_length,
+      };
+
+      f_string_dynamic *parameter_values[] = {
+        &data->path_build_documents,
+        &data->path_build_includes,
+        &data->path_build_libraries,
+        &data->path_build_objects,
+        &data->path_build_process,
+        &data->path_build_programs,
+        &data->path_build_settings,
+      };
+
+      const uint8_t total = 7;
+
+      for (i = 0; i < total; i++) {
+        status = fl_string_dynamic_append_nulless(data->path_build, parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append_assure("/", 1, parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_append_assure";
+          break;
+        }
+
+        status = fl_string_dynamic_terminate(parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_dynamic_terminate";
+          break;
+        }
+      } // for
+    }
+
+    if (!f_status_is_error(status)) {
+      const f_string parameter_strings[] = {
+        fake_path_build_libraries_script,
+        fake_path_build_libraries_shared,
+        fake_path_build_libraries_static,
+      };
+
+      const f_string_length parameter_strings_lengths[] = {
+        fake_path_build_libraries_script_length,
+        fake_path_build_libraries_shared_length,
+        fake_path_build_libraries_static_length,
+      };
+
+      f_string_dynamic *parameter_values[] = {
+        &data->path_build_libraries_script,
+        &data->path_build_libraries_shared,
+        &data->path_build_libraries_static,
+      };
+
+      const uint8_t total = 3;
+
+      for (i = 0; i < total; i++) {
+        status = fl_string_dynamic_append_nulless(data->path_build_libraries, parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append_assure("/", 1, parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_append_assure";
+          break;
+        }
+
+        status = fl_string_dynamic_terminate(parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_dynamic_terminate";
+          break;
+        }
+      } // for
+    }
+
+    {
+      const f_string parameter_strings[] = {
+        fake_path_build_programs_script,
+        fake_path_build_programs_shared,
+        fake_path_build_programs_static,
+      };
+
+      const f_string_length parameter_strings_lengths[] = {
+        fake_path_build_programs_script_length,
+        fake_path_build_programs_shared_length,
+        fake_path_build_programs_static_length,
+      };
+
+      f_string_dynamic *parameter_values[] = {
+        &data->path_build_programs_script,
+        &data->path_build_programs_shared,
+        &data->path_build_programs_static,
+      };
+
+      const uint8_t total = 3;
+
+      for (i = 0; i < total; i++) {
+        status = fl_string_dynamic_append_nulless(data->path_build_programs, parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append(parameter_strings[i], parameter_strings_lengths[i], parameter_values[i]);
+        if (f_status_is_error(status)) break;
+
+        status = fl_string_append_assure("/", 1, parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_append_assure";
+          break;
+        }
+
+        status = fl_string_dynamic_terminate(parameter_values[i]);
+        if (f_status_is_error(status)) {
+          function = "fl_string_dynamic_terminate";
+          break;
+        }
+      } // for
+    }
+
+    if (f_status_is_error(status)) {
+      fake_print_error(data->context, data->verbosity, f_status_set_fine(status), function, f_true);
+      return status;
+    }
+
+    return f_none;
+  }
+#endif // _di_fake_path_generate_
+
 #ifndef _di_fake_print_error_
   f_return_status fake_print_error(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const bool fallback) {
 
index 97cf9b674ca0c16c8ee0ea59a9d8b55858e76a2d..c88d08b207516f35ce98f88474a436f3b4408780 100644 (file)
@@ -13,6 +13,20 @@ extern "C" {
 #endif
 
 /**
+ * Generate all appropriate paths based on runtime information.
+ *
+ * @param data
+ *   The program data.
+ *
+ * @return
+ *   f_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ */
+#ifndef _di_fake_path_generate_
+  extern f_return_status fake_path_generate(fake_data *data) f_gcc_attribute_visibility_internal;
+#endif // _di_fake_path_generate_
+
+/**
  * Print generic error messages.
  *
  * @param context
index 435e9fe6ee96db417b688bbec2b5684da5b2b697..67b04978e83f67da3e140421f4d32f4c76fcbd1f 100755 (executable)
@@ -5,6 +5,8 @@
 # The purpose of this script is to provide an example for the post-process part of Fake.
 # Despite being an example, it is intended to be actually used when using fake to build the fake project.
 #
+# The dependencies of this script are: bash and sed.
+#
 process_post_main(){
   local grab_next=
   local do_color=normal
@@ -23,12 +25,39 @@ process_post_main(){
   local c_subtle="\\033[1;30m"
   local c_prefix="\\"
 
-  # the three supported parameters.
+  # the supported parameters.
   local operation=
-  local mode=
   local defines=
+  local modes=
+  local process=
+  local file_settings=
+  local path_build=
+  local path_source_build=
+  local path_source_codes=
+  local path_source_common=
+  local path_source_data=
+  local path_source_documents=
+  local path_source_licenses=
+  local path_source_settings=
+  local path_work=
   local verbosity=
 
+  # standard settings paths.
+  local path_directory_separator="/"
+  local path_build_documents=
+  local path_build_includes=
+  local path_build_libraries=
+  local path_build_libraries_script=
+  local path_build_libraries_shared=
+  local path_build_libraries_static=
+  local path_build_objects=
+  local path_build_process=
+  local path_build_programs=
+  local path_build_programs_script=
+  local path_build_programs_shared=
+  local path_build_programs_static=
+  local path_build_settings=
+
   # grab all supported parameters, ignoring duplicates.
   if [[ $# -gt 0 ]] ; then
     t=$#
@@ -42,36 +71,82 @@ process_post_main(){
           if [[ $operation == "" ]] ; then
             operation=$p
           fi
-        elif [[ $p == "-m" ]] ; then
-          grab_next="mode"
         elif [[ $p == "-d" ]] ; then
           grab_next="defines"
+        elif [[ $p == "-m" ]] ; then
+          grab_next="modes"
+        elif [[ $p == "-o" ]] ; then
+          grab_next="process"
+        elif [[ $p == "-s" ]] ; then
+          grab_next="file_settings"
+        elif [[ $p == "-b" ]] ; then
+          grab_next="path_build"
+        elif [[ $p == "-B" ]] ; then
+          grab_next="path_source_build"
+        elif [[ $p == "-C" ]] ; then
+          grab_next="path_source_codes"
+        elif [[ $p == "-O" ]] ; then
+          grab_next="path_source_common"
+        elif [[ $p == "-D" ]] ; then
+          grab_next="path_source_data"
+        elif [[ $p == "-M" ]] ; then
+          grab_next="path_source_documents"
+        elif [[ $p == "-L" ]] ; then
+          grab_next="path_source_licenses"
+        elif [[ $p == "-S" ]] ; then
+          grab_next="path_source_settings"
+        elif [[ $p == "-w" ]] ; then
+          grab_next="path_work"
+        elif [[ $p == "+D" ]] ; then
+          verbosity=debug
         elif [[ $p == "+q" ]] ; then
           verbosity=quiet
         elif [[ $p == "+V" ]] ; then
           verbosity=verbose
-        elif [[ $p == "+D" ]] ; then
-          verbosity=debug
-        elif [[ $p == "+n" ]] ; then
-          if [[ $do_color == "normal" ]] ; then
-            do_color=none
-          fi
         elif [[ $p == "+l" ]] ; then
           if [[ $do_color == "normal" ]] ; then
             do_color=light
           fi
+        elif [[ $p == "+n" ]] ; then
+          if [[ $do_color == "normal" ]] ; then
+            do_color=none
+          fi
         fi
       else
-        if [[ $grab_next == "mode" ]] ; then
-          if [[ $mode == "" ]] ; then
-            mode=$p
-          else
-            mode="$mode $p"
-          fi
-        elif [[ $grab_next == "defines" ]] ; then
+        if [[ $grab_next == "defines" ]] ; then
           if [[ $defines == "" ]] ; then
             defines=$p
+          else
+            defines="$defines $p"
+          fi
+        elif [[ $grab_next == "modes" ]] ; then
+          if [[ $modes == "" ]] ; then
+            modes=$p
+          else
+            modes="$modes $p"
           fi
+        elif [[ $grab_next == "process" ]] ; then
+          process=$p
+        elif [[ $grab_next == "file_settings" ]] ; then
+          file_settings=$p
+        elif [[ $grab_next == "path_build" ]] ; then
+          path_build=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_build" ]] ; then
+          path_source_build=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_codes" ]] ; then
+          path_source_codes=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_common" ]] ; then
+          path_source_common=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_data" ]] ; then
+          path_source_data=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_documents" ]] ; then
+          path_source_documents=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_licenses" ]] ; then
+          path_source_licenses=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_source_settings" ]] ; then
+          path_source_settings=$(process_post_path_fix $p)
+        elif [[ $grab_next == "path_work" ]] ; then
+          path_work=$(process_post_path_fix $p)
         fi
 
         grab_next=
@@ -100,12 +175,27 @@ process_post_main(){
     c_prefix=
   fi
 
+  # update paths based on parameters.
+  path_build_documents=${path_build}documents$path_directory_separator
+  path_build_includes=${path_build}includes$path_directory_separator
+  path_build_libraries=${path_build}libraries$path_directory_separator
+  path_build_libraries_script=${path_build_libraries}script$path_directory_separator
+  path_build_libraries_shared=${path_build_libraries}shared$path_directory_separator
+  path_build_libraries_static=${path_build_libraries}static$path_directory_separator
+  path_build_objects=${path_build}objects$path_directory_separator
+  path_build_process=${path_build}process$path_directory_separator
+  path_build_programs=${path_build}programs$path_directory_separator
+  path_build_programs_script=${path_build_programs}script$path_directory_separator
+  path_build_programs_shared=${path_build_programs}shared$path_directory_separator
+  path_build_programs_static=${path_build_programs}static$path_directory_separator
+  path_build_settings=${path_build}settings$path_directory_separator
+
   if [[ $verbosity != "quiet" ]] ; then
     echo
     echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset"
 
-    if [[ $mode != "" ]] ; then
-      echo -e "  Modes: $c_reset$c_notice$mode$c_reset"
+    if [[ $modes != "" ]] ; then
+      echo -e "  Modes: $c_reset$c_notice$modes$c_reset"
     fi
 
     if [[ $defines != "" ]] ; then
@@ -115,10 +205,15 @@ process_post_main(){
     echo
   fi
 
-  # cleanup and return
+  # cleanup and return.
   unset process_post_main
+  unset process_post_path_fix
   return 0
 }
 
+process_post_path_fix(){
+  echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|"
+}
+
 # note: "$@" is necessary to preserve quoted arguments when passing though.
 process_post_main "$@"
index 0b6cd4a397a54cb19ae931cf735e424e0cb89b3d..baa0b6a65276ccd222332965bdcfc2737367f075 100755 (executable)
@@ -5,6 +5,8 @@
 # The purpose of this script is to provide an example for the pre-process part of Fake.
 # Despite being an example, it is intended to be actually used when using fake to build the fake project.
 #
+# The dependencies of this script are: bash and sed.
+#
 process_pre_main(){
   local grab_next=
   local do_color=normal
@@ -23,12 +25,39 @@ process_pre_main(){
   local c_subtle="\\033[1;30m"
   local c_prefix="\\"
 
-  # the three supported parameters.
+  # the supported parameters.
   local operation=
-  local mode=
   local defines=
+  local modes=
+  local process=
+  local file_settings=
+  local path_build=
+  local path_source_build=
+  local path_source_codes=
+  local path_source_common=
+  local path_source_data=
+  local path_source_documents=
+  local path_source_licenses=
+  local path_source_settings=
+  local path_work=
   local verbosity=
 
+  # standard settings paths.
+  local path_directory_separator="/"
+  local path_build_documents=
+  local path_build_includes=
+  local path_build_libraries=
+  local path_build_libraries_script=
+  local path_build_libraries_shared=
+  local path_build_libraries_static=
+  local path_build_objects=
+  local path_build_process=
+  local path_build_programs=
+  local path_build_programs_script=
+  local path_build_programs_shared=
+  local path_build_programs_static=
+  local path_build_settings=
+
   # grab all supported parameters, ignoring duplicates.
   if [[ $# -gt 0 ]] ; then
     t=$#
@@ -42,36 +71,82 @@ process_pre_main(){
           if [[ $operation == "" ]] ; then
             operation=$p
           fi
-        elif [[ $p == "-m" ]] ; then
-          grab_next="mode"
         elif [[ $p == "-d" ]] ; then
           grab_next="defines"
+        elif [[ $p == "-m" ]] ; then
+          grab_next="modes"
+        elif [[ $p == "-o" ]] ; then
+          grab_next="process"
+        elif [[ $p == "-s" ]] ; then
+          grab_next="file_settings"
+        elif [[ $p == "-b" ]] ; then
+          grab_next="path_build"
+        elif [[ $p == "-B" ]] ; then
+          grab_next="path_source_build"
+        elif [[ $p == "-C" ]] ; then
+          grab_next="path_source_codes"
+        elif [[ $p == "-O" ]] ; then
+          grab_next="path_source_common"
+        elif [[ $p == "-D" ]] ; then
+          grab_next="path_source_data"
+        elif [[ $p == "-M" ]] ; then
+          grab_next="path_source_documents"
+        elif [[ $p == "-L" ]] ; then
+          grab_next="path_source_licenses"
+        elif [[ $p == "-S" ]] ; then
+          grab_next="path_source_settings"
+        elif [[ $p == "-w" ]] ; then
+          grab_next="path_work"
+        elif [[ $p == "+D" ]] ; then
+          verbosity=debug
         elif [[ $p == "+q" ]] ; then
           verbosity=quiet
         elif [[ $p == "+V" ]] ; then
           verbosity=verbose
-        elif [[ $p == "+D" ]] ; then
-          verbosity=debug
-        elif [[ $p == "+n" ]] ; then
-          if [[ $do_color == "normal" ]] ; then
-            do_color=none
-          fi
         elif [[ $p == "+l" ]] ; then
           if [[ $do_color == "normal" ]] ; then
             do_color=light
           fi
+        elif [[ $p == "+n" ]] ; then
+          if [[ $do_color == "normal" ]] ; then
+            do_color=none
+          fi
         fi
       else
-        if [[ $grab_next == "mode" ]] ; then
-          if [[ $mode == "" ]] ; then
-            mode=$p
-          else
-            mode="$mode $p"
-          fi
-        elif [[ $grab_next == "defines" ]] ; then
+        if [[ $grab_next == "defines" ]] ; then
           if [[ $defines == "" ]] ; then
             defines=$p
+          else
+            defines="$defines $p"
+          fi
+        elif [[ $grab_next == "modes" ]] ; then
+          if [[ $modes == "" ]] ; then
+            modes=$p
+          else
+            modes="$modes $p"
           fi
+        elif [[ $grab_next == "process" ]] ; then
+          process=$p
+        elif [[ $grab_next == "file_settings" ]] ; then
+          file_settings=$p
+        elif [[ $grab_next == "path_build" ]] ; then
+          path_build=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_build" ]] ; then
+          path_source_build=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_codes" ]] ; then
+          path_source_codes=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_common" ]] ; then
+          path_source_common=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_data" ]] ; then
+          path_source_data=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_documents" ]] ; then
+          path_source_documents=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_licenses" ]] ; then
+          path_source_licenses=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_source_settings" ]] ; then
+          path_source_settings=$(process_pre_path_fix $p)
+        elif [[ $grab_next == "path_work" ]] ; then
+          path_work=$(process_pre_path_fix $p)
         fi
 
         grab_next=
@@ -100,12 +175,27 @@ process_pre_main(){
     c_prefix=
   fi
 
+  # update paths based on parameters.
+  path_build_documents=${path_build}documents$path_directory_separator
+  path_build_includes=${path_build}includes$path_directory_separator
+  path_build_libraries=${path_build}libraries$path_directory_separator
+  path_build_libraries_script=${path_build_libraries}script$path_directory_separator
+  path_build_libraries_shared=${path_build_libraries}shared$path_directory_separator
+  path_build_libraries_static=${path_build_libraries}static$path_directory_separator
+  path_build_objects=${path_build}objects$path_directory_separator
+  path_build_process=${path_build}process$path_directory_separator
+  path_build_programs=${path_build}programs$path_directory_separator
+  path_build_programs_script=${path_build_programs}script$path_directory_separator
+  path_build_programs_shared=${path_build_programs}shared$path_directory_separator
+  path_build_programs_static=${path_build_programs}static$path_directory_separator
+  path_build_settings=${path_build}settings$path_directory_separator
+
   if [[ $verbosity != "quiet" ]] ; then
     echo
-    echo -e "${c_title}Begin Processing Operation: $c_reset$c_notice$operation$c_reset"
+    echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset"
 
-    if [[ $mode != "" ]] ; then
-      echo -e "  Modes: $c_reset$c_notice$mode$c_reset"
+    if [[ $modes != "" ]] ; then
+      echo -e "  Modes: $c_reset$c_notice$modes$c_reset"
     fi
 
     if [[ $defines != "" ]] ; then
@@ -115,10 +205,15 @@ process_pre_main(){
     echo
   fi
 
-  # cleanup and return
+  # cleanup and return.
   unset process_pre_main
+  unset process_pre_path_fix
   return 0
 }
 
+process_pre_path_fix(){
+  echo -n $* | sed -e "s|^${path_directory_separator}${path_directory_separator}*|${path_directory_separator}|" -e "s|${path_directory_separator}*$|${path_directory_separator}|"
+}
+
 # note: "$@" is necessary to preserve quoted arguments when passing though.
 process_pre_main "$@"