build version move to generated store
[feisty_meow.git] / nucleus / tools / clam_tools / write_build_config.cpp
index 42914ebe6848fb84c24a9b599da778211852dc9c..b8bfd80c1ee8c8d647c0a3ffb16067fdf741bbca 100644 (file)
@@ -166,7 +166,7 @@ outcome write_build_config::output_decorated_macro(const astring &symbol_in,
 outcome write_build_config::output_definition_macro
     (const astring &embedded_value, astring &accumulator)
 {
-//  FUNCDEF("output_definition_macro");
+  FUNCDEF("output_definition_macro");
 //LOG(astring("into output def with: ") + embedded_value);
   variable_tokenizer t;
   t.parse(embedded_value);
@@ -208,10 +208,10 @@ if (read < 1) LOG("why is existing header contentless?");
     byte_filer build_header(filename, "wb");
     if (!build_header.good())
       non_continuable_error(static_class_name(), func, astring("failed to create "
-          "build header file in ") + build_header.filename());
+          "build header file in ") + build_header.name());
     build_header.write(new_contents);
     LOG(astring(static_class_name()) + ": wrote config to "
-        + build_header.filename());
+        + build_header.name());
   } else {
     // nothing has changed.
 //    LOG(astring(static_class_name()) + ": config already up to date in "
@@ -226,7 +226,7 @@ int write_build_config::execute()
   SETUP_CONSOLE_LOGGER;  // override the file_logger from app_shell.
 
   // find our build ini file.
-  astring repodir = environment::get("REPOSITORY_DIR");
+  astring repodir = environment::get("FEISTY_MEOW_APEX");
 
   // the below code should never be needed for a properly configured build.
 #ifdef __WIN32__
@@ -245,8 +245,8 @@ int write_build_config::execute()
   // find our storage area for the build headers.  we know a couple build
   // configurations by now, but this should really be coming out of a config
   // file instead.
-  astring library_directory = repodir + "/nucleus/library";
-  if (!filename(library_directory).good()) {
+  astring genstore_directory = environment::get("FEISTY_MEOW_GENERATED_STORE");
+  if (!filename(genstore_directory).good()) {
     non_continuable_error(static_class_name(), func,
         astring("failed to locate the library folder storing the generated files."));
   }
@@ -254,16 +254,14 @@ int write_build_config::execute()
   // these are very specific paths, but they really are where we expect to
   // see the headers.
 
-  astring cfg_header_filename = library_directory + "/"
-      "__build_configuration.h";
-  astring ver_header_filename = library_directory + "/"
-      "__build_version.h";
+  astring cfg_header_filename = genstore_directory + "/__build_configuration.h";
+  astring ver_header_filename = genstore_directory + "/__build_version.h";
 
   // open the ini file for reading.
   byte_filer ini(fname, "r");
   if (!ini.good())
     non_continuable_error(static_class_name(), func, astring("failed to open "
-        "build configuration file for reading at ") + ini.filename());
+        "build configuration file for reading at ") + ini.name());
 //hmmm: parameterize the build ini thing above!
 
   // now we build strings that represents the output files we want to create.
@@ -289,7 +287,7 @@ int write_build_config::execute()
   astring buffer;
   while (!ini.eof()) {
     int chars = ini.getline(buffer, MAX_LINE_SIZE);
-    if (!chars) continue;  // hmmm.
+    if (!chars) continue;  // hmmm: what does no chars mean?
     
     variable_tokenizer t;
     t.parse(buffer);
@@ -380,6 +378,17 @@ int write_build_config::execute()
     LOG(astring("failed writing output file ") + ver_header_filename);
   }
 
+  // now make a copy into the library folder, for when we release a production version.
+  astring library_directory = repodir + "/nucleus/library";
+  astring cfg_header_copy = library_directory + "/__build_configuration.h";
+  astring ver_header_copy = library_directory + "/__build_version.h";
+  if (!write_output_file(cfg_header_copy, cfg_accumulator)) {
+    LOG(astring("skipping copy due to read-only issue on output file: ") + cfg_header_copy);
+  }
+  if (!write_output_file(ver_header_copy, ver_accumulator)) {
+    LOG(astring("skipping copy due to read-only issue on output file: ") + ver_header_copy);
+  }
+
   return 0;
 }
 
@@ -389,9 +398,11 @@ HOOPLE_MAIN(write_build_config, )
   // static dependencies found by buildor_gen_deps.sh:
   #include <application/application_shell.cpp>
   #include <application/command_line.cpp>
+  #include <application/windoze_helper.cpp>
   #include <basis/astring.cpp>
   #include <basis/common_outcomes.cpp>
   #include <basis/environment.cpp>
+  #include <basis/guards.cpp>
   #include <basis/mutex.cpp>
   #include <basis/utf_conversion.cpp>
   #include <configuration/application_configuration.cpp>