updates to fix bundler on win32
[feisty_meow.git] / nucleus / applications / bundler / bundle_creator.cpp
index 5a6722a942344107ea3fca8306d91b5f5a7b3132..9313883f0fd0c4c0998f4e3f5241b49beb70f45d 100644 (file)
@@ -45,9 +45,9 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <zlib.h>
-#ifdef __WIN32__
-  #include <io.h>
-#endif
+//#ifdef __WIN32__
+  //#include <io.h>
+//#endif
 
 using namespace application;
 using namespace basis;
@@ -103,7 +103,7 @@ public:
   bundle_creator()
       : application_shell(),
         _app_name(filename(_global_argv[0]).basename()),
-        _bundle(NIL), _stub_size(0), _keyword() {}
+        _bundle(NULL_POINTER), _stub_size(0), _keyword() {}
 
   virtual ~bundle_creator() {
     WHACK(_bundle);
@@ -192,6 +192,9 @@ int bundle_creator::execute()
   BASE_LOG(astring("starting file bundling at ") + time_stamp::notarize(false));
 
   command_line cmds(_global_argc, _global_argv);
+
+//BASE_LOG(astring("before starting, cmds has: ") + parser_bits::platform_eol_to_chars() + cmds.text_form());
+
   astring temp;
   if (cmds.get_value('?', temp)) return print_instructions();
   if (cmds.get_value("?", temp)) return print_instructions();
@@ -239,6 +242,10 @@ Abandoning bundling process.\n", _app_name.s()));
   environment::set("DLL_START", "");
   environment::set("DLL_END", ".dll");
 #endif
+  // specify a target variable on the source side so that we can operate in there,
+  // even if the bundle doesn't specify one.  otherwise we can't run source side commands
+  // properly if the paths are based on TARGET (like TMP often is).
+  environment::set("TARGET", environment::TMP());
 
   int ret = 0;
   if ( (ret = read_manifest()) ) FAIL_RETURN(ret, "reading manifest");
@@ -324,7 +331,7 @@ int bundle_creator::add_files_here(directory &dirndl, const astring &source,
 int bundle_creator::recurse_into_dir(const astring &source,
     const astring &target, int manifest_index)
 {
-//  FUNCDEF("recurse_into_dir");
+  FUNCDEF("recurse_into_dir");
 //LOG(astring("src=") + source + " dest=" + target);
 
   // we won't include the subversion folder.
@@ -362,7 +369,7 @@ int bundle_creator::recurse_into_dir(const astring &source,
 int bundle_creator::patch_recursive_target(const astring &source,
     const astring &target, int manifest_index)
 {
-//  FUNCDEF("patch_recursive_target");
+  FUNCDEF("patch_recursive_target");
 //LOG(astring("patch recurs src=") + source + " targ=" + target);
   return recurse_into_dir(source, target, manifest_index);
 }
@@ -370,7 +377,7 @@ int bundle_creator::patch_recursive_target(const astring &source,
 int bundle_creator::patch_wildcard_target(const astring &source,
     const astring &target, int manifest_index)
 {
-//  FUNCDEF("patch_wildcard_target");
+  FUNCDEF("patch_wildcard_target");
   // find the last slash.  the rest is our wildcard component.
   int src_end = source.end();
   int slash_indy = source.find('/', src_end, true);
@@ -744,7 +751,7 @@ astring bundle_creator::determine_stub_file_and_validate()
 #ifdef __WIN32__
   astring stub_filename("unpacker_stub.exe");
 #endif
-  astring repo_dir = "$PRODUCTION_DIR";
+  astring repo_dir = "$RUNTIME_PATH";
   astring stub_file = parser_bits::substitute_env_vars
       (repo_dir + "/binaries/" + stub_filename, false);
   if (!filename(stub_file).exists()) {
@@ -918,7 +925,7 @@ int bundle_creator::finalize_file()
 
 int bundle_creator::write_offset()
 {
-//  FUNCDEF("write_offset");
+  FUNCDEF("write_offset");
   byte_filer bun(_output_file, "r+b");  // open the file for updating.
 
   astring magic_string("muftiloc");  // our sentinel string.