made the output file nicer, and time stamped it.
[feisty_meow.git] / scripts / generator / build_variables.sh
index 308fe88ee3603a4f5d33cd12deadce2d67efc027..571770098fa5ff4ede79c23704a3d297bd0117f1 100644 (file)
@@ -1,36 +1,36 @@
-###############################################################################
-#                                                                             #
-#  Name   : build variable calculator                                         #
-#  Author : Chris Koeritz                                                     #
-#                                                                             #
-#  Purpose:                                                                   #
-#                                                                             #
-#    This script sets up all the variables needed by the HOOPLE system for    #
-#  building the source code.  It can either be run as a bash script directly  #
-#  like so:                                                                   #
-#                                                                             #
-#      bash ~/feisty_meow/scripts/generator/build_variables.sh                #
-#                                                                             #
-#  which will establish a new shell containing all the variables, or you can  #
-#  'source' the script like so:                                               #
-#                                                                             #
-#      build_vars=~/feisty_meow/scripts/generator/build_variables.sh          #
-#      source $build_vars $build_vars                                         #
-#                                                                             #
-#  to set all of the variables in your current shell.  The full path is       #
-#  necessary in these commands to allow the script to easily find itself.     #
-#  The 'source' version needs to be fed the actual path to the script         #
-#  because bash 'source' commands cause the first parameter (called $0) to    #
-#  be set to just the path to bash itself.                                    #
-#                                                                             #
-###############################################################################
-# Copyright (c) 2004-$now By Author.  This program is free software; you can  #
-# redistribute it and/or modify it under the terms of the GNU General Public  #
-# License as published by the Free Software Foundation; either version 2 of   #
-# the License or (at your option) any later version.  This is online at:      #
-#     http://www.fsf.org/copyleft/gpl.html                                    #
-# Please send any updates to: fred@gruntose.com                               #
-###############################################################################
+##############
+#
+#  Name   : build variable calculator
+#  Author : Chris Koeritz
+#
+#  Purpose:
+#
+#    This script sets up all the variables needed by the HOOPLE system for
+#  building the source code.  It can either be run as a bash script directly
+#  like so:
+#
+#      bash ~/feisty_meow/scripts/generator/build_variables.sh
+#
+#  which will establish a new shell containing all the variables, or you can
+#  'source' the script like so:
+#
+#      build_vars=~/feisty_meow/scripts/generator/build_variables.sh
+#      source $build_vars $build_vars
+#
+#  to set all of the variables in your current shell.  The full path is
+#  necessary in these commands to allow the script to easily find itself.
+#  The 'source' version needs to be fed the actual path to the script
+#  because bash 'source' commands cause the first parameter (called $0) to
+#  be set to just the path to bash itself.
+#
+##############
+# Copyright (c) 2004-$now By Author.  This program is free software; you can
+# redistribute it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either version 2 of
+# the License or (at your option) any later version.  This is online at:
+#     http://www.fsf.org/copyleft/gpl.html
+# Please send any updates to: fred@gruntose.com
+##############
 
 # prerequisites for this script:
 #
@@ -69,11 +69,11 @@ function dos_to_msys_path() {
 #        of dos to msys etc live.
 # test suite for above functions.
 #echo this should go from msys to dos:
-#  prior='/c/bogart\dingle'
+#  prior='/c/bogart\dongle'
 #  latter=$(msys_to_dos_path "$prior")
 #  echo went from $prior to $latter
 #echo this should go from dos to msys:
-#  prior='D:\bogart\dingle'
+#  prior='D:\bogart\dongle'
 #  latter=$(dos_to_msys_path "$prior")
 #  echo went from $prior to $latter
 
@@ -84,16 +84,20 @@ if [ ! -z "$PARM_1" ]; then
   # use the first real parameter since this is probably the 'source' version.
   export BUILD_SCRIPTS_DIR="$(dirname "$PARM_1")"
   THIS_TOOL_NAME="$(basename "$PARM_1")"
+#echo sourced version buildscriptsdir is $BUILD_SCRIPTS_DIR
 else
   # use the zeroth parameter, since we know nothing more about our name.
   export BUILD_SCRIPTS_DIR="$(dirname "$PARM_0")"
   THIS_TOOL_NAME="$(basename "$PARM_0")"
+#echo bashed version buildscriptsdir is $BUILD_SCRIPTS_DIR
 fi
-BUILD_SCRIPTS_DIR="$(echo $BUILD_SCRIPTS_DIR | tr '\\\\' '/' )"
-echo buildsc is $BUILD_SCRIPTS_DIR
+BUILD_SCRIPTS_DIR="$(cd $(echo $BUILD_SCRIPTS_DIR | tr '\\\\' '/' ); \pwd)"
+#echo ">> buildscriptsdir is $BUILD_SCRIPTS_DIR"
+
 # figure out the other paths based on where we found this script.
 export BUILDING_HIERARCHY="$(echo "$BUILD_SCRIPTS_DIR" | sed -e 's/\(.*\)\/[^\/]*/\1/')"
-export CLAM_DIR="$BUILD_SCRIPTS_DIR/../clam"
+export CLAM_DIR="$(cd $BUILD_SCRIPTS_DIR/../clam ; \pwd)"
+#echo ">> clamdir is $CLAM_DIR"
 # synonym to make other builds happy.
 export BUILDER_DIR="$BUILDING_HIERARCHY"
 
@@ -117,47 +121,30 @@ if [ ! -z "$SHELL_DEBUG" ]; then
   echo "[OS is \"$OPERATING_SYSTEM\"]"
 fi
 
-# the impact of always redoing the repository directory below means that we
-# will always expect the build scripts to be located within the build they're
-# building.  that's fundamentally broken for some usages.
-# but just using the existing repository directory is fundamentally broken
-# too, since then the build variables will never re-adapt to the repository
-# you want.
-# maybe just documentation; if you are changing your repository and the build
-# scripts are in the right place, then you should unset REPOSITORY_DIR.
-# we at least check that the folder still exists now too, but that's not exact
-# knowledge that it's still the right directory.
-
-if [ -z "$REPOSITORY_DIR" -o ! -d "$REPOSITORY_DIR" ]; then
-  # we create the variable repository dir, but we keep the idiotic dos form of
-  # the path, because otherwise lots of bad things happens when passing the
-  # folders around to visual studio commands that don't allow a space after them.
-  if [ -d "$BUILDING_HIERARCHY/source" ]; then
-    # old style repository is same height as building hierarchy.
-    export REPOSITORY_DIR="$BUILDING_HIERARCHY"
-  else
-    # new style repository is a level above the build hierarchy.
-    export REPOSITORY_DIR="$(echo "$BUILDING_HIERARCHY" | sed -e 's/\(.*\)\/[^\/]*/\1/')"
-  fi
+#hmmm: all this stuff is highly questionable value now.
+# we create the variable FEISTY_MEOW_DIR, but we keep the dos form of
+# the path, because otherwise lots of bad things happens when passing the
+# folders around to visual studio commands that don't allow a space after them.
+if [ -d "$BUILDING_HIERARCHY/source" ]; then
+  # old style repository is same height as building hierarchy.
+  export FEISTY_MEOW_DIR="$BUILDING_HIERARCHY"
+else
+  # new style repository is a level above the build hierarchy.
+  export FEISTY_MEOW_DIR="$(echo "$BUILDING_HIERARCHY" | sed -e 's/\(.*\)\/[^\/]*/\1/')"
 fi
 
 if [ "$OPERATING_SYSTEM" = "WIN32" ]; then
   # make sure repository dir looks right on windoze.
-  export REPOSITORY_DIR="$(msys_to_dos_path "$REPOSITORY_DIR")"
+  export FEISTY_MEOW_DIR="$(msys_to_dos_path "$FEISTY_MEOW_DIR")"
 fi
 
 if [ ! -z "$SHELL_DEBUG" ]; then
-  echo "[REPOSITORY_DIR is $REPOSITORY_DIR]"
+  echo "[FEISTY_MEOW_DIR is $FEISTY_MEOW_DIR]"
 fi
 
 # new BUILD_TOP variable points at the utter top-most level of any files
 # in the building hierarchy.
-if [ -d "$REPOSITORY_DIR/../../build" ]; then
-  export BUILD_TOP="$REPOSITORY_DIR/../.."
-else
-  # this is actually just a guess.
-  export BUILD_TOP="$REPOSITORY_DIR"
-fi
+export BUILD_TOP="$FEISTY_MEOW_DIR"
 
 # this variable points at a folder where we store most of the generated products
 # of the build.  these tend to be the things that will be used for packaging into
@@ -183,7 +170,7 @@ function make()
 #echo scripts: $BUILD_SCRIPTS_DIR
 #echo build tools hier: $BUILDING_HIERARCHY
 #echo this tool: $THIS_TOOL_NAME
-#echo repository: $REPOSITORY_DIR
+#echo repository: $FEISTY_MEOW_DIR
 #echo clam: $CLAM_DIR
 #echo makeflags: $MAKEFLAGS
 
@@ -194,10 +181,10 @@ pushd / &>/dev/null # jump to the root so relative paths are caught.
 
 # first the scripts directory; do we find this script there?
 if [ ! -f "$BUILD_SCRIPTS_DIR/$THIS_TOOL_NAME" ]; then
-  echo "This script must be run using its full pathname.  This enables the script to"
-  echo "locate the proper build folders.  Please try again with the full path, e.g.:"
-  echo "    bash /home/fred/codeplex/scripts/generator/$THIS_TOOL_NAME"
-#  exit 1
+  echo "This script cannot locate the proper build folders.  The crucial path"
+  echo "variable seems to be '$BUILD_SCRIPTS_DIR', which"
+  echo "does not seem to contain '$THIS_TOOL_NAME' (this"
+  echo "script's apparent name)."
 fi
 
 # next the clam directory; is the main variables file present there?
@@ -205,17 +192,15 @@ if [ ! -f "$CLAM_DIR/variables.def" ]; then
   echo "The clam directory could not be located under our build tools hierarchy."
   echo "Please examine the configuration and make sure that this script is in a"
   echo "directory that resides at the same height as the 'clam' directory."
-#  exit 1
 fi
 
 # now compute some more paths with a bit of "heuristics" for where we can
 # find the source code.
-export TOOL_SOURCES="$REPOSITORY_DIR/core/tools"
+export TOOL_SOURCES="$FEISTY_MEOW_DIR/nucleus/tools"
 if [ ! -d "$TOOL_SOURCES/dependency_tool" -o ! -d "$TOOL_SOURCES/clam_tools" ]; then
   if [ ! -d "$TOOL_SOURCES/dependency_tool" -o ! -d "$TOOL_SOURCES/clam_tools" ]; then
     echo "This script cannot locate the tool source code folder.  This is where the"
     echo "dependency_tool and clam_tools folders are expected to be."
-#    exit 1
   fi
 fi
 
@@ -241,7 +226,6 @@ fi
 export BUILD_PARAMETER_FILE="$PRODUCTION_DIR/feisty_meow_config.ini"
 if [ ! -f "$BUILD_PARAMETER_FILE" ]; then
   echo "Cannot find a useful build configuration file."
-#  exit 1
 fi
 
 # pick the executable's file ending based on the platform.
@@ -249,9 +233,12 @@ if [ "$OPERATING_SYSTEM" == "UNIX" ]; then export EXE_ENDING=;
 elif [ "$OPERATING_SYSTEM" == "WIN32" ]; then export EXE_ENDING=.exe;
 else
   echo "The OPERATING_SYSTEM variable is unset or unknown.  Bailing out."
-#  exit 1
 fi
 
+# we should have established our internal variables now, so let's try
+# using them.
+export PATH=$BINARY_DIR:$PATH
+
 # load up the helper variables for visual studio on winders.
 if [ "$OPERATING_SYSTEM" == "WIN32" ]; then
   source "$BUILD_SCRIPTS_DIR/vis_stu_vars.sh"