]> Kevux Git Server - fll/commitdiff
Progress: featureless make
authorKevin Day <thekevinday@gmail.com>
Mon, 1 Jun 2020 04:02:50 +0000 (23:02 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 1 Jun 2020 04:02:50 +0000 (23:02 -0500)
Add stage files where stages are recorded to allow very basic build resuming.

Prepare the code for doing the build.

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

index d9ad36e151060b324af438ab4fde88cea9968646..25af6c7a1d66ee632e7f3999041a9ac4146c12ba 100644 (file)
@@ -379,6 +379,7 @@ extern "C" {
     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_build_stage);
     f_macro_string_dynamic_delete_simple(data->path_work);
 
     f_macro_string_dynamic_delete_simple(data->path_data);
index 7ccccec8a199865dd49af986a8cd2a6d6128df03..0d8e88a20d5d4bf129ebe2342ba0d604749342f5 100644 (file)
  *     - shared/
  *     - static/
  *   - settings/
+ *   - stage/
  *
  * The "data/" directory contains all file data, such as firmware or files commonly found under /usr/share in a standard GNU Linux system.
- * The "data/" directory may also contain build-time data.
  * The "documents/" directory contains all documentation after any build-time processing.
  * The "libraries/" and "programs/" directories contains the sub-directories "script/", "shared/", and "static/".
  * The "libraries/" directory will contain compiled libraries or library-like scripts in their respective sub-directories.
  * The "objects/" directory will contain any compile object files.
  * The "progams/" directory will contain compiled programs or program-like scripts in their respective sub-directories.
  * The "settings/" directory contains all configuration data, such as files commonly found under /etc in a standard GNU Linux system.
+ * The "stage/" directory will contain build-time data.
  *
  * @todo this will eventually support fakefile, which is akin to makefile.
  *       All of the setting data will be loaded and available for a fakefile.
@@ -117,6 +118,7 @@ extern "C" {
   #define fake_path_part_settings  "settings"  f_path_separator
   #define fake_path_part_shared    "shared"    f_path_separator
   #define fake_path_part_sources   "sources"   f_path_separator
+  #define fake_path_part_stage     "stage"     f_path_separator
   #define fake_path_part_static    "static"    f_path_separator
 
   #define fake_path_part_bash_length      5
@@ -135,6 +137,7 @@ extern "C" {
   #define fake_path_part_settings_length  9
   #define fake_path_part_shared_length    7
   #define fake_path_part_sources_length   8
+  #define fake_path_part_stage_length     6
   #define fake_path_part_static_length    7
 #endif // _di_fake_path_
 
@@ -380,6 +383,7 @@ extern "C" {
     f_string_dynamic path_build_programs_shared;
     f_string_dynamic path_build_programs_static;
     f_string_dynamic path_build_settings;
+    f_string_dynamic path_build_stage;
 
     f_string_dynamic path_data;
     f_string_dynamic path_data_build;
@@ -462,6 +466,7 @@ extern "C" {
       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 424c71ee7e10a22f1f62650dac6b663da8bf623e..04f5da7b9c06b8aed034b2bf397fd38a22351f5d 100644 (file)
@@ -133,13 +133,14 @@ extern "C" {
       &data.path_build_programs_shared,
       &data.path_build_programs_static,
       &data.path_build_settings,
+      &data.path_build_stage,
     };
 
     if (data.verbosity != fake_verbosity_quiet) {
       printf("%cCreating base build directories.%c", f_string_eol[0], f_string_eol[0]);
     }
 
-    for (uint8_t i = 0; i < 14; i++) {
+    for (uint8_t i = 0; i < 15; i++) {
       if (directorys[i]->used == 0) continue;
 
       status = f_directory_create(directorys[i]->string, mode);
@@ -505,69 +506,104 @@ extern "C" {
     }
 
     f_status status = F_none;
+    f_mode mode = f_mode_initialize;
+
     fake_build_setting setting = fake_build_setting_initialize;
+    fake_build_stage stage = fake_build_stage_initialize;
+
+    f_macro_mode_set_default_umask(mode, data.umask);
 
     status = fake_build_setting_load(data, &setting);
 
-    if (F_status_is_error(status)) {
-      fake_macro_build_settings_delete_simple(setting);
-      return status;
+    if (F_status_is_fine(status)) {
+      status = fake_build_stage_load(data, &stage);
     }
 
-    status = fake_build_execute_process_script(data, setting, setting.process_pre);
-    if (F_status_is_error(status)) {
-      fake_macro_build_settings_delete_simple(setting);
-      return status;
-    }
+    if (F_status_is_fine(status) && f_file_exists(stage.file_skeleton.string) != F_true) {
+      status = fake_build_skeleton(data, setting, mode.directory);
 
-    f_mode mode = f_mode_initialize;
+      fake_build_touch(data, stage.file_skeleton, mode, &status);
+    }
 
-    f_macro_mode_set_default_umask(mode, data.umask);
+    if (F_status_is_fine(status) && f_file_exists(stage.file_process_pre.string) != F_true) {
+      status = fake_build_execute_process_script(data, setting, setting.process_pre);
 
-    status = fake_build_skeleton(data, setting, mode.directory);
-    if (F_status_is_error(status)) {
-      fake_macro_build_settings_delete_simple(setting);
-      return status;
+      fake_build_touch(data, stage.file_process_pre, mode, &status);
     }
 
-    status = fake_build_copy(data, setting, mode, "source setting", data.path_data_settings, data.path_build_settings, setting.build_sources_setting);
-    if (F_status_is_error(status)) {
-      fake_macro_build_settings_delete_simple(setting);
-      return status;
+    if (F_status_is_fine(status) && f_file_exists(stage.file_sources_settings.string) != F_true) {
+      status = fake_build_copy(data, setting, mode, "setting files", data.path_data_settings, data.path_build_settings, setting.build_sources_setting);
+
+      fake_build_touch(data, stage.file_sources_settings, mode, &status);
     }
 
     if (setting.build_language == fake_build_language_type_bash) {
       // @todo
     }
-    else if (setting.build_language == fake_build_language_type_c) {
-      status = fake_build_copy(data, setting, mode, "header files", data.path_sources_c, data.path_build_includes, setting.build_sources_headers);
-      if (F_status_is_error(status)) {
-        fake_macro_build_settings_delete_simple(setting);
-        return status;
+    else {
+      const f_string_dynamic *path_sources = 0;
+
+      if (setting.build_language == fake_build_language_type_c) {
+        path_sources = &data.path_sources_c;
       }
-    }
-    else if (setting.build_language == fake_build_language_type_cpp) {
-      status = fake_build_copy(data, setting, mode, "header files", data.path_sources_cpp, data.path_build_includes, setting.build_sources_headers);
-      if (F_status_is_error(status)) {
-        fake_macro_build_settings_delete_simple(setting);
-        return status;
+      else if (setting.build_language == fake_build_language_type_cpp) {
+        path_sources = &data.path_sources_cpp;
+      }
+
+      if (F_status_is_fine(status) && f_file_exists(stage.file_sources_headers.string) != F_true) {
+        status = fake_build_copy(data, setting, mode, "header files", *path_sources, data.path_build_includes, setting.build_sources_headers);
+
+        fake_build_touch(data, stage.file_sources_headers, mode, &status);
+      }
+
+      if (setting.build_shared) {
+        if (F_status_is_fine(status) && f_file_exists(stage.file_libraries_shared.string) != F_true) {
+          // @todo
+          //status = fake_build_libraries_shared();
+
+          fake_build_touch(data, stage.file_libraries_shared, mode, &status);
+        }
+
+        if (F_status_is_fine(status) && f_file_exists(stage.file_programs_shared.string) != F_true) {
+          // @todo
+          //status = fake_build_programs_shared();
+
+          fake_build_touch(data, stage.file_programs_shared, mode, &status);
+        }
+      }
+
+      if (setting.build_static) {
+        if (F_status_is_fine(status) && f_file_exists(stage.file_objects_static.string) != F_true) {
+          // @todo
+          //status = fake_build_objects_static();
+
+          fake_build_touch(data, stage.file_objects_static, mode, &status);
+        }
+
+        if (F_status_is_fine(status) && f_file_exists(stage.file_libraries_static.string) != F_true) {
+          // @todo
+          //status = fake_build_libraries_static();
+
+          fake_build_touch(data, stage.file_libraries_static, mode, &status);
+        }
+
+        if (F_status_is_fine(status) && f_file_exists(stage.file_programs_static.string) != F_true) {
+          // @todo
+          //status = fake_build_programs_static();
+
+          fake_build_touch(data, stage.file_programs_static, mode, &status);
+        }
       }
     }
 
-    // @todo: may have to process all data intended to be used in parameters, exploding them into console parameters.
-    // Steps:
-    // 1) copy sources setting to build setting. done.
-    // 2) copy sources headers to build headers. done.
-    // 3) if shared=yes and library sources exist, compile shared libraries and make links.
-    // 4) if shared=yes and program sources exist, compile shared programs.
-    // 5) if static=yes and library sources exist, compile static objects.
-    // 6) if static=yes and library sources exist, link static objects into static library (appending objects to path for static programs to compile against).
-    // 7) if static=yes and program sources exist, compile static programs (include any static objects).
-    // 8) touch build file designating that build fully completed.
+    if (F_status_is_fine(status) && f_file_exists(stage.file_process_post.string) != F_true) {
+      status = fake_build_execute_process_script(data, setting, setting.process_post);
 
-    status = fake_build_execute_process_script(data, setting, setting.process_post);
+      fake_build_touch(data, stage.file_process_post, mode, &status);
+    }
 
     fake_macro_build_settings_delete_simple(setting);
+    fake_macro_build_stage_delete_simple(stage);
 
     return status;
   }
@@ -1094,6 +1130,85 @@ extern "C" {
   }
 #endif // _di_fake_build_setting_load_
 
+#ifndef _di_fake_build_stage_load_
+  f_return_status fake_build_stage_load(const fake_data data, fake_build_stage *stage) {
+    f_status status = F_none;
+
+    const f_string names[] = {
+      fake_build_stage_libraries_shared,
+      fake_build_stage_libraries_static,
+      fake_build_stage_objects_static,
+      fake_build_stage_process_post,
+      fake_build_stage_process_pre,
+      fake_build_stage_programs_shared,
+      fake_build_stage_programs_static,
+      fake_build_stage_skeleton,
+      fake_build_stage_sources_headers,
+      fake_build_stage_sources_settings,
+    };
+
+    const f_string_length lengths[] = {
+      fake_build_stage_libraries_shared_length,
+      fake_build_stage_libraries_static_length,
+      fake_build_stage_objects_static_length,
+      fake_build_stage_process_post_length,
+      fake_build_stage_process_pre_length,
+      fake_build_stage_programs_shared_length,
+      fake_build_stage_programs_static_length,
+      fake_build_stage_skeleton_length,
+      fake_build_stage_sources_headers_length,
+      fake_build_stage_sources_settings_length,
+    };
+
+    f_string_dynamic *values[] = {
+      &stage->file_libraries_shared,
+      &stage->file_libraries_static,
+      &stage->file_objects_static,
+      &stage->file_process_post,
+      &stage->file_process_pre,
+      &stage->file_programs_shared,
+      &stage->file_programs_static,
+      &stage->file_skeleton,
+      &stage->file_sources_headers,
+      &stage->file_sources_settings,
+    };
+
+    for (uint8_t i = 0; i < fake_build_stage_total; i++) {
+      status = fl_string_dynamic_append_nulless(data.path_build_stage, values[i]);
+      if (F_status_is_error(status)) {
+        fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "fl_string_dynamic_append_nulless", F_true);
+        break;
+      }
+
+      status = fl_string_append_nulless(names[i], lengths[i], values[i]);
+      if (F_status_is_error(status)) {
+        fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "fl_string_dynamic_append_nulless", F_true);
+        break;
+      }
+
+      status = fl_string_dynamic_terminate(values[i]);
+      if (F_status_is_error(status)) {
+        fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "fl_string_dynamic_terminate", F_true);
+        break;
+      }
+    } // for
+
+    return status;
+  }
+#endif // _di_fake_build_stage_load_
+
+#ifndef _di_fake_build_touch_
+  void fake_build_touch(const fake_data data, const f_string_dynamic file, const f_mode mode, f_status *status) {
+    if (F_status_is_fine(*status)) {
+      *status = f_file_touch(file.string, mode.regular, F_false);
+
+      if (F_status_is_error(*status)) {
+        fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "f_file_touch", F_true);
+      }
+    }
+  }
+#endif // _di_fake_build_touch_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index eb2b9340968275bb7aeaa0b1a9a348b412ba8ddc..e8248554c1108a68db813821aa75c1d5fa3fc195 100644 (file)
@@ -207,6 +207,70 @@ extern "C" {
   #define fake_build_setting_bool_no_length  2
 #endif // _di_fake_build_setting_
 
+#ifndef _di_fake_build_stage_
+  typedef struct {
+    f_string_dynamic file_libraries_shared;
+    f_string_dynamic file_libraries_static;
+    f_string_dynamic file_objects_static;
+    f_string_dynamic file_process_post;
+    f_string_dynamic file_process_pre;
+    f_string_dynamic file_programs_shared;
+    f_string_dynamic file_programs_static;
+    f_string_dynamic file_skeleton;
+    f_string_dynamic file_sources_headers;
+    f_string_dynamic file_sources_settings;
+  } fake_build_stage;
+
+  #define fake_build_stage_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, \
+  }
+
+  #define fake_build_stage_total 10
+
+  #define fake_macro_build_stage_delete_simple(stage) \
+    f_macro_string_dynamic_delete_simple(stage.file_libraries_shared) \
+    f_macro_string_dynamic_delete_simple(stage.file_libraries_static) \
+    f_macro_string_dynamic_delete_simple(stage.file_objects_static) \
+    f_macro_string_dynamic_delete_simple(stage.file_process_post) \
+    f_macro_string_dynamic_delete_simple(stage.file_process_pre) \
+    f_macro_string_dynamic_delete_simple(stage.file_programs_shared) \
+    f_macro_string_dynamic_delete_simple(stage.file_programs_static) \
+    f_macro_string_dynamic_delete_simple(stage.file_skeleton) \
+    f_macro_string_dynamic_delete_simple(stage.file_sources_headers) \
+    f_macro_string_dynamic_delete_simple(stage.file_sources_settings)
+
+  #define fake_build_stage_libraries_shared "libraries_shared.built"
+  #define fake_build_stage_libraries_static "libraries_static.built"
+  #define fake_build_stage_objects_static   "objects_static.built"
+  #define fake_build_stage_process_post     "process_post.built"
+  #define fake_build_stage_process_pre      "process_pre.built"
+  #define fake_build_stage_programs_shared  "programs_shared.built"
+  #define fake_build_stage_programs_static  "programs_static.built"
+  #define fake_build_stage_skeleton         "skeleton.built"
+  #define fake_build_stage_sources_headers  "sources_headers.built"
+  #define fake_build_stage_sources_settings "sources_settings.built"
+
+  #define fake_build_stage_libraries_shared_length 22
+  #define fake_build_stage_libraries_static_length 22
+  #define fake_build_stage_objects_static_length   20
+  #define fake_build_stage_process_post_length     18
+  #define fake_build_stage_process_pre_length      17
+  #define fake_build_stage_programs_shared_length  21
+  #define fake_build_stage_programs_static_length  21
+  #define fake_build_stage_skeleton_length         14
+  #define fake_build_stage_sources_headers_length  21
+  #define fake_build_stage_sources_settings_length 22
+#endif // _di_fake_build_stage_
+
 /**
  * Copy over the data settings files.
  *
@@ -301,6 +365,41 @@ extern "C" {
   extern f_return_status fake_build_setting_load(const fake_data data, fake_build_setting *settings) f_gcc_attribute_visibility_internal;
 #endif // _di_fake_build_setting_load_
 
+/**
+ * Load the stage file paths.
+ *
+ * @param data
+ *   The program data.
+ * @param stage
+ *   All stage file paths.
+ *
+ * @return
+ *   F_none on success.
+ *   Status codes (with error bit) are returned on any problem.
+ */
+#ifndef _di_fake_build_stage_load_
+  extern f_return_status fake_build_stage_load(const fake_data data, fake_build_stage *stage) f_gcc_attribute_visibility_internal;
+#endif // _di_fake_build_stage_load_
+
+/**
+ * Touch the given build stage file, but only if there are no current errors in status.
+ *
+ * @param data
+ *   The program data.
+ * @param file
+ *   The file path to touch.
+ * @param mode
+ *   The file mode to use.
+ * @param status
+ *   The return status.
+ *   This gets updated if f_file_touch() is executed.
+ *
+ * @see f_file_touch()
+ */
+#ifndef _di_fake_build_touch_
+  extern void fake_build_touch(const fake_data data, const f_string_dynamic file, const f_mode mode, f_status *status) f_gcc_attribute_visibility_internal;
+#endif // _di_fake_build_touch_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 5f152abc5a65331bad72272021a9a5bc23628e96..4b3849d8edee16516804f3ab934d0e7a39d6ab79 100644 (file)
@@ -19,7 +19,7 @@ extern "C" {
       };
 
       const uint8_t parameters_length[] = {
-        7,
+        8,
         2,
         3,
       };
@@ -32,6 +32,7 @@ extern "C" {
         &data->path_build_process,
         &data->path_build_programs,
         &data->path_build_settings,
+        &data->path_build_stage,
       };
 
       f_string_dynamic *parameters_value_1[] = {
@@ -70,6 +71,7 @@ extern "C" {
         fake_path_part_process,
         fake_path_part_programs,
         fake_path_part_settings,
+        fake_path_part_stage,
         fake_path_part_build,
         fake_path_part_settings,
         fake_path_part_documents,
@@ -87,6 +89,7 @@ extern "C" {
         fake_path_part_process_length,
         fake_path_part_programs_length,
         fake_path_part_settings_length,
+        fake_path_part_stage_length,
         fake_path_part_build_length,
         fake_path_part_settings_length,
         fake_path_part_documents_length,
@@ -104,6 +107,7 @@ extern "C" {
         &data->path_build_process,
         &data->path_build_programs,
         &data->path_build_settings,
+        &data->path_build_stage,
         &data->path_data_build,
         &data->path_data_settings,
         &data->path_documents,
@@ -113,7 +117,7 @@ extern "C" {
         &data->path_sources_cpp,
       };
 
-      for (i = 0; i < 14; i++) {
+      for (i = 0; i < 15; i++) {
         status = fl_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]);
 
         if (F_status_is_error(status)) {
@@ -366,6 +370,7 @@ extern "C" {
         &data->path_build_programs_shared,
         &data->path_build_programs_static,
         &data->path_build_settings,
+        &data->path_build_stage,
         &data->path_data_build,
         &data->path_data_settings,
         &data->path_licenses,
@@ -387,7 +392,7 @@ extern "C" {
         &data->file_documents_readme,
       };
 
-      for (i = 0; i < 32; i++) {
+      for (i = 0; i < 33; i++) {
         if (parameters_value[i]->used == 0) continue;
 
         status = fl_string_dynamic_terminate(parameters_value[i]);