Merge branch 'release-2.140.136'
[feisty_meow.git] / scripts / generator / produce_feisty_meow.sh
index dbecd2637009bd8a0182397b5e9f7402f7e1f013..3985f0957d7a6336e74bc80bf982f4b13f48d662 100644 (file)
@@ -33,6 +33,7 @@ export INCLUDED_FROM_BOOTSTRAP=true
 export BUILD_SCRIPTS_PATH="$( \cd "$(\dirname "$0")" && /bin/pwd )"
 #echo build scripts dir initial value: $BUILD_SCRIPTS_PATH
 BUILD_SCRIPTS_PATH="$(echo $BUILD_SCRIPTS_PATH | tr '\\\\' '/' )"
+#hmmm: why four backslashes above?  trying two in our unix virtual root code below.
 #echo build scripts dir after chewing: $BUILD_SCRIPTS_PATH
 
 # load in feisty meow basic scripts, if not already loaded.
@@ -53,19 +54,86 @@ source "$BUILD_SCRIPTS_PATH/build_variables.sh" "$BUILD_SCRIPTS_PATH/build_varia
 ##############
 
 # creates the directory for our binaries and gives it a reasonable paths configuration.
-function prepare_binaries_dir()
+function prepare_clam_binaries_dir()
 {
   # we'll store binaries here from the bootstrap process.
   if [ ! -d "$CLAM_BINARIES" ]; then
-    echo "creating binary dir now in $CLAM_BINARIES"
+    echo "creating clam binary dir now in $CLAM_BINARIES"
     mkdir -p "$CLAM_BINARIES"
+    exit_on_error "creating clam binary directory in $CLAM_BINARIES"
   fi
   if [ ! -f "$CLAM_BINARIES/paths.ini" ]; then
-    echo "copied paths.ini to binary dir."
     cp "$PRODUCTION_STORE/paths.ini" "$CLAM_BINARIES"
+    exit_on_error "copying paths.ini to $CLAM_BINARIES"
+    echo "copied paths.ini to clam binary dir."
   fi
 }
 
+# fix the system helper header up by calling cygpath to determine the cygwin
+# root, if we are on windoze and cygwin.
+function update_system_helper_header()
+{
+  # create our main binaries directory if needed.
+  if [ ! -d "$FEISTY_MEOW_BINARIES" ]; then
+    echo "creating feisty meow binary folder now in $FEISTY_MEOW_BINARIES"
+    mkdir -p "$FEISTY_MEOW_BINARIES"
+    exit_on_error "creating feisty meow binary folder in $FEISTY_MEOW_BINARIES"
+  fi
+
+  # copy up the system helper template version into the binaries directory.
+  if [ ! -f "$FEISTY_MEOW_BINARIES/system_helper.h" ]; then
+    cp "$PRODUCTION_STORE/system_helper_template.h" "$FEISTY_MEOW_BINARIES/system_helper.h"
+    exit_on_error "creating system_helper header in $FEISTY_MEOW_BINARIES"
+    echo "copied system_helper header to feisty meow binary dir."
+  fi
+
+  # set the cygwin root path if we're on cygwin.
+  whichable cygpath &>/dev/null
+  if [ $? -eq 0 ]; then
+    # found cygpath, so run it now to get the dossy path of the root ('/' folder).
+    found_root="$(cygpath -w -m /)"
+    if [ $? -ne 0 ]; then
+      echo "Failure to find virtual Unix root folder with cygpath."
+      exit 1322
+    fi
+#echo "found root as '$found_root'"
+    # translate any backslashes to forward thinking slashes.    
+    found_root="$(echo $found_root | tr '\\' '/')"
+#echo "processed root is now: '$found_root'"
+    # edit the entry in place to correct the default path.
+    sed -i \
+        -e "s% *#define FEISTY_MEOW_VIRTUAL_UNIX_ROOT \".*$%#define FEISTY_MEOW_VIRTUAL_UNIX_ROOT \"$found_root\"%" \
+        "$FEISTY_MEOW_BINARIES/system_helper.h"
+    exit_on_error "updating system_helper header in $FEISTY_MEOW_BINARIES"
+#echo "system helper file now has:"
+#cat "$FEISTY_MEOW_BINARIES/system_helper.h"
+  fi
+}
+
+function make_code {
+  make $* $BE_NOISY ${BUILD_DEFAULTS[@]}
+  if [ $? != 0 ]; then
+    echo "Failed to make on: $*"
+    exit 2323
+  fi
+}
+
+# removes pcdos eol from any scripts.  that assumes that the bootstrap script
+# itself isn't polluted with them.
+function strip_cr {
+  ctrl_m=$'\015'
+  for i in $*; do
+    tempgrep="$(mktemp "$TEMPORARIES_PILE/tempgrep.XXXXXX")"
+    grep -l "$ctrl_m" "$i" >$tempgrep
+    if [ ! -z "$(cat $tempgrep)" ]; then
+      temp="$(mktemp "$TEMPORARIES_PILE/tempsed.XXXXXX")"
+      sed -e "s/$ctrl_m$//" <$i >$temp
+      mv -f $temp $i
+    fi
+    rm "$tempgrep"
+  done
+}
+
 ##############
 
 # turn off sounds to avoid running the sound player that's not been built yet.
@@ -78,9 +146,6 @@ echo "Build bootstrap process has started."
 
 # preconditions for the build process...
 
-# set up our output directories etc.
-prepare_binaries_dir
-
 # set a flag for this process so we can omit certain compilations as necessary.
 export BOOT_STRAPPING=true
 
@@ -99,30 +164,6 @@ declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=t" "OPTIMIZE=t" "REBUILD=t" "DEBUG="
   # noisy can be added to spew lots of text: "NOISY=t"
   #   this can help with compilation issues by showing all the flags.
 
-function make_code {
-  make $* $BE_NOISY ${BUILD_DEFAULTS[@]}
-  if [ $? != 0 ]; then
-    echo "Failed to make on: $*"
-    exit 2323
-  fi
-}
-
-# removes pcdos eol from any scripts.  that assumes that the bootstrap script
-# itself isn't polluted with them.
-function strip_cr {
-  ctrl_m=$'\015'
-  for i in $*; do
-    tempgrep="$(mktemp "$TEMPORARIES_PILE/tempgrep.XXXXXX")"
-    grep -l "$ctrl_m" "$i" >$tempgrep
-    if [ ! -z "$(cat $tempgrep)" ]; then
-      temp="$(mktemp "$TEMPORARIES_PILE/tempsed.XXXXXX")"
-      sed -e "s/$ctrl_m$//" <$i >$temp
-      mv -f $temp $i
-    fi
-    rm "$tempgrep"
-  done
-}
-
 # the promote function moves a file from the exe directory into the build's
 # bin directory.  it performs the copy step and makes the file executable.
 # the original name should just be the root of the filename without any
@@ -130,7 +171,7 @@ function strip_cr {
 # NOTE: this depends on the operating system having been chosen above!
 if [ "$OPERATING_SYSTEM" = "UNIX" ]; then
   function promote {
-    prepare_binaries_dir
+    prepare_clam_binaries_dir
 
     if [ ! -f "$INTERMEDIATE_STORE/$1" ]; then
       echo "Failed to build the application $1--quitting now."
@@ -142,7 +183,7 @@ if [ "$OPERATING_SYSTEM" = "UNIX" ]; then
   }
 elif [ "$OPERATING_SYSTEM" = "WIN32" ]; then
   function promote {
-    prepare_binaries_dir
+    prepare_clam_binaries_dir
 
     if [ ! -f "$INTERMEDIATE_STORE/$1.exe" ]; then
       echo "Failed to build the application $1.exe--quitting now."
@@ -166,6 +207,9 @@ source "$BUILD_SCRIPTS_PATH/build_variables.sh" "$BUILD_SCRIPTS_PATH/build_varia
 # clean out any current contents.
 bash "$BUILD_SCRIPTS_PATH/whack_build.sh" clean
 
+# set up our output directories etc.
+prepare_clam_binaries_dir
+
 # make this again so no one gets cranky.
 mkdir -p "$FEISTY_MEOW_LOGS"
 
@@ -179,13 +223,8 @@ if [ -z "$SAVE_BINARIES" ]; then
   done
 fi
 
-# make the clam shell scripts executable.
-#hmmm: why?  this should no longer be needed.
-#      and even if it's needed, the perms should be stored in the repo.
-#chmod 755 "$CLAM_SCRIPTS"/*.sh
-#chmod 755 "$CLAM_SCRIPTS"/cpp/*.sh
-#chmod 755 "$CLAM_SCRIPTS"/csharp/*.sh
-#chmod 755 "$FEISTY_MEOW_SCRIPTS/generator/wrapdoze.sh"
+# copy the system helper header.
+update_system_helper_header
 
 # rebuild the dependency tool.  needed by everything, pretty much, but
 # since it's from the xfree project, it doesn't need any of our libraries.
@@ -257,13 +296,15 @@ echo "The build binaries have been re-created (or were already present)."
 if [ -z "$JUST_BOOTSTRAP_APPS" ]; then
   echo Cleaning up the temporary files that were built.
   bash "$BUILD_SCRIPTS_PATH/whack_build.sh" 
-#wrong!  we don't want to whack it all. clean
 
   # recreate our useful junk directories...
   mkdir -p "$FEISTY_MEOW_GENERATED_STORE"
   mkdir -p "$TEMPORARIES_PILE"
   mkdir -p "$FEISTY_MEOW_LOGS"
 
+  # re-copy the system helper header.
+  update_system_helper_header
+
   echo Now starting a normal build of the repository source code.
   pushd "$FEISTY_MEOW_APEX" &>/dev/null
   unset BUILD_DEFAULTS