You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/04/06 00:35:26 UTC

svn commit: r160235 - in gump/branches/Gump3: bin/PrintPath giraffe-settings.sh gump pygump/main.py pygump/python/gump/util/sysinfo.py

Author: leosimons
Date: Tue Apr  5 15:35:22 2005
New Revision: 160235

URL: http://svn.apache.org/viewcvs?view=rev&rev=160235
Log:
Make help|run|test targets work under windows w/ cygwin. See http://wiki.apache.org/gump/ for details. Basically, we needed to edit the shell scripts to know about cygwin and the required path munging. Also, some posix features obviously aren't available, so we need those disabled on windows.

Modified:
    gump/branches/Gump3/bin/PrintPath
    gump/branches/Gump3/giraffe-settings.sh
    gump/branches/Gump3/gump
    gump/branches/Gump3/pygump/main.py
    gump/branches/Gump3/pygump/python/gump/util/sysinfo.py

Modified: gump/branches/Gump3/bin/PrintPath
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/bin/PrintPath?view=diff&r1=160234&r2=160235
==============================================================================
--- gump/branches/Gump3/bin/PrintPath (original)
+++ gump/branches/Gump3/bin/PrintPath Tue Apr  5 15:35:22 2005
@@ -31,6 +31,28 @@
 #
 # This version found in Apache Portable Runtime CVS under "build"
 
+
+##
+# Hack to have at least some support for cygwin...
+##
+cygwin=false;
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+esac
+
+if $cygwin; then
+  for args in $*; do
+    case $args in
+	-s) echo="no";;
+	-p*) pathname="" ;;
+	*) programs="$programs $args" ;;
+    esac
+  done
+  echo `which $programs 2>/dev/null`
+  exit 0
+fi
+
+
 ##
 # Some "constants"
 ##

Modified: gump/branches/Gump3/giraffe-settings.sh
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/giraffe-settings.sh?view=diff&r1=160234&r2=160235
==============================================================================
--- gump/branches/Gump3/giraffe-settings.sh (original)
+++ gump/branches/Gump3/giraffe-settings.sh Tue Apr  5 15:35:22 2005
@@ -1 +1,10 @@
-export JAVA_HOME=/usr/lib/j2se/1.4
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+esac
+
+if $cygwin; then
+  export JAVA_HOME=/cygdrive/c/j2sdk1.4.2_08
+else
+  export JAVA_HOME=/usr/lib/j2se/1.4
+fi
+

Modified: gump/branches/Gump3/gump
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/gump?view=diff&r1=160234&r2=160235
==============================================================================
--- gump/branches/Gump3/gump (original)
+++ gump/branches/Gump3/gump Tue Apr  5 15:35:22 2005
@@ -289,6 +289,18 @@
   export GUMP_ENV_FILE="$GUMP_HOME/$GUMP_HOSTNAME-settings.sh"
 }
 
+# Determine whether we're running under cygwin
+function find_cygwin
+{
+  local cygwin=false
+  case "`uname`" in
+    CYGWIN*) cygwin=true ;;
+  esac
+  if $cygwin; then
+    export GUMP_CYGWIN=true
+  fi
+}
+
 # Determine the python command to use
 function find_python
 {
@@ -296,18 +308,18 @@
     return
   fi
 
-  local python=`which python2.4`
+  local python=`which python2.4 2>/dev/null`
   if [[ -z "$python" || "$python" == "no"* ]]; then
-    python=`which python2.3`
+    python=`which python2.3 2>/dev/null`
   fi
   if [[ -z "$python" || "$python" == "no"* ]]; then
-    python=`which python2.2`
+    python=`which python2.2 2>/dev/null`
   fi
   if [[ -z "$python" || "$python" == "no"* ]]; then
-    python=`which python2`
+    python=`which python2 2>/dev/null`
   fi
   if [[ -z "$python" || "$python" == "no"* ]]; then
-    python=`which python`
+    python=`which python 2>/dev/null`
   fi
   if [[ -z "$python" || "$python" == "no"* ]]; then
     python="python" # hope for the best...
@@ -327,7 +339,9 @@
   if [[ -f "$GUMP_ENV_FILE" ]]; then
     . "$GUMP_ENV_FILE"
   fi
-  
+
+
+  find_cygwin
   find_python
   find_workdir
 }
@@ -403,7 +417,11 @@
 except:
   print "error"
 ENDCOMMAND
-  local cmd=`$GUMP_PYTHON "$GUMP_HOME/pycmd.tmp.py"`
+  if $GUMP_CYGWIN; then
+    local cmd="$GUMP_PYTHON `cygpath -w $GUMP_HOME/pycmd.tmp.py`"
+  else
+    local cmd="$GUMP_PYTHON '$GUMP_HOME/pycmd.tmp.py'"
+  fi
   result=`$cmd`
   rm -f "$GUMP_HOME/pycmd.tmp.py"
 
@@ -421,7 +439,7 @@
 function check_environment
 {
   # PrintPath doesn't deal with absolute paths properly
-  check_command $GUMP_PYTHON "http://www.python.org/"
+  #check_command $GUMP_PYTHON "http://www.python.org/"
   #check_command "pkill" "http://sourceforge.net/projects/proctools"
   check_command "mysql" "http://www.mysql.com/"
   check_command "mysqladmin" "http://www.mysql.com/"
@@ -480,14 +498,26 @@
   find $GUMP_HOME/pygump -type f -name '*.pyc' | xargs rm -Rf
 
   # compile everything
-  $GUMP_PYTHON -c "import re; from compileall import compile_dir; compile_dir('$GUMP_HOME/pygump/python', 10, '$GUMP_HOME', False, re.compile('\.svn'), True)"
-
+  if $GUMP_CYGWIN; then
+    $GUMP_PYTHON -c "import re; import os; from compileall import compile_dir; compile_dir(os.path.join('`cygpath -w $GUMP_HOME`', 'pygump', 'python'), 10, '`cygpath -w $GUMP_HOME`', False, re.compile('\.svn'), True)"
+  else
+    $GUMP_PYTHON -c "import re; import os; from compileall import compile_dir; compile_dir(os.path.join('$GUMP_HOME', 'pygump', 'python'), 10, '$GUMP_HOME', False, re.compile('\.svn'), True)"
+  fi
+  
   # add pygump to python path
   local oldpythonpath="$PYTHONPATH"
   if [[ -z "$oldpythonpath" ]]; then
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    fi
   else
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`:$PYTHONPATH"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    fi
   fi
   
   # import all modules, one by one, to check syntax
@@ -513,20 +543,43 @@
   # add pygump to python path
   local oldpythonpath="$PYTHONPATH"
   if [[ -z "$oldpythonpath" ]]; then
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    fi
   else
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`:$PYTHONPATH"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    fi
   fi
-  
+
   local command="$1"
   shift
   
   # run pygump
   local current=`pwd`
-  cd "$GUMP_HOME/pygump"
   pycompile
 
+  if $GUMP_CYGWIN; then
+    local old_gump_home=$GUMP_HOME
+    local old_gump_workdir=$GUMP_WORKDIR
+    local old_java_home=$JAVA_HOME
+    export GUMP_HOME=`cygpath -w $GUMP_HOME`
+    export GUMP_WORKDIR=`cygpath -w $GUMP_WORKDIR`
+    export JAVA_HOME=`cygpath -w $JAVA_HOME`
+    cd "$GUMP_HOME\pygump"
+  else
+    cd "$GUMP_HOME/pygump"
+  fi
   $GUMP_PYTHON -c "$command" $@
+  if $GUMP_CYGWIN; then
+    export GUMP_HOME=$old_gump_home
+    export GUMP_WORKDIR=$old_gump_workdir
+    export JAVA_HOME=$old_java_home
+  fi
   cd "$current"
 
   # restore python path
@@ -584,20 +637,30 @@
   lock
   
   # add pygump to python path
-  local oldpythonpath="$PYTHONPATH"
   if [[ -z "$oldpythonpath" ]]; then
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump"
+    fi
   else
-    export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    if $GUMP_CYGWIN; then
+      export PYTHONPATH="`cygpath -w $GUMP_HOME/pygump/python`;`cygpath -w $GUMP_HOME/pygump`:$PYTHONPATH"
+    else
+      export PYTHONPATH="$GUMP_HOME/pygump/python:$GUMP_HOME/pygump:$PYTHONPATH"
+    fi
   fi
-  
 
   local current=`pwd`
   cd "$GUMP_HOME/pygump/python"
   pycompile
   
   # Run the pygump tests
-  $GUMP_PYTHON $GUMP_HOME/bin/testrunner.py -d $GUMP_HOME/pygump/python/gump/test $@
+  if $GUMP_CYGWIN; then
+    $GUMP_PYTHON `cygpath -w $GUMP_HOME/bin/testrunner.py` -d `cygpath -w $GUMP_HOME/pygump/python/gump/test` $@
+  else
+    $GUMP_PYTHON $GUMP_HOME/bin/testrunner.py -d $GUMP_HOME/pygump/python/gump/test $@
+  fi
   cd "$current"
   
   # restore python path

Modified: gump/branches/Gump3/pygump/main.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/main.py?view=diff&r1=160234&r2=160235
==============================================================================
--- gump/branches/Gump3/pygump/main.py (original)
+++ gump/branches/Gump3/pygump/main.py Tue Apr  5 15:35:22 2005
@@ -375,7 +375,7 @@
         _homedir   = os.environ["GUMP_HOME"]
         _hostname  = os.environ["GUMP_HOSTNAME"]
         try:
-            _workdir   = os.environ["GUMP_WORKDIR"]
+            _workdir = os.environ["GUMP_WORKDIR"]
         except:
             _workdir = os.path.join(_homedir, "pygump", "work")
             

Modified: gump/branches/Gump3/pygump/python/gump/util/sysinfo.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/util/sysinfo.py?view=diff&r1=160234&r2=160235
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/util/sysinfo.py (original)
+++ gump/branches/Gump3/pygump/python/gump/util/sysinfo.py Tue Apr  5 15:35:22 2005
@@ -20,12 +20,15 @@
 __copyright__ = "Copyright (c) 2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
+import sys
 from subprocess import Popen
 from subprocess import PIPE
 
 def amount_of_memory():
     """Returning an integer giving the amount of RAM memory in the system,
     in megabytes. Returns 0 if the amount of RAM cannot be determined."""
+    if sys.platform == "win32":
+        return 0
     amount = 0 # i.e., we don't know
     cat = Popen(["cat", "/proc/meminfo"], stdout=PIPE)
     if cat.wait():
@@ -42,6 +45,8 @@
 def amount_of_cpu_mhz():
     """Returning an integer giving the processor speed for this system,
     in MHz. Returns 0 if the processor speed cannot be determined."""
+    if sys.platform == "win32":
+        return 0
     amount = 0 # i.e., we don't know
     cat = Popen(["cat", "/proc/cpuinfo"], stdout=PIPE)
     if cat.wait():
@@ -61,6 +66,8 @@
 def number_of_cpus():
     """Returning an integer giving the number of CPUs in the system.
     Returns 0 if the number of CPUs cannot be determined."""
+    if sys.platform == "win32":
+        return 0
     amount = 0 # i.e., we don't know
     cat = Popen(["cat", "/proc/cpuinfo"], stdout=PIPE)
     if cat.wait():