Browse Source

Added -d option to pass directory to the Python sqeezer

Dave Schuyler 22 years ago
parent
commit
9da45b6d81
2 changed files with 18 additions and 14 deletions
  1. 13 12
      direct/src/ffi/genPyCode
  2. 5 2
      direct/src/showbase/pandaSqueezer.py

+ 13 - 12
direct/src/ffi/genPyCode

@@ -58,13 +58,6 @@ pyDir=$DIRECT/lib/py
 extDir=$DIRECT/src/extensions
 pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py
 
-if [ `uname | grep CYGWIN` ]; then
-  install_dir="$(cygpath -aw $install_dir)"
-  pyDir="$(cygpath -w $pyDir)"
-  extDir="$(cygpath -w $extDir)"
-  pSqueezer="$(cygpath -w $pSqueezer)"
-fi
-
 if [ "$buildType" = "linux" ]; then
     cd $DIRECT/bin
     ppython -d generatePythonCode -v -d $pyDir -e $extDir -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
@@ -72,14 +65,22 @@ if [ "$buildType" = "linux" ]; then
 
 elif [ "$buildType" = "win-debug" ]; then
     cd $DIRECT/bin
+    pyDir="$(cygpath -w $pyDir)"
+    extDir="$(cygpath -w $extDir)"
+    pSqueezer="$(cygpath -w $pSqueezer)"
     ppython -d generatePythonCode -v -d $pyDir -e $extDir -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
 elif [ "$buildType" = "win-release" ]; then
     cd $DIRECT/bin
+    pyDir="$(cygpath -w $pyDir)"
+    extDir="$(cygpath -w $extDir)"
+    pSqueezer="$(cygpath -w $pSqueezer)"
     ppython generatePythonCode -v -d $pyDir -e $extDir -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
-
 elif [ "$buildType" = "win-publish" ]; then
     # no assertions, no comments, no docstrings
     cd $DIRECT/bin
+    pyDir="$(cygpath -w $pyDir)"
+    extDir="$(cygpath -w $extDir)"
+    pSqueezer="$(cygpath -w $pSqueezer)"
     ppython -OO generatePythonCode -O -v -d $pyDir -e $extDir -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
     optimizeFlag="-O"
     ppythonOptimizeFlag="-OO"
@@ -88,12 +89,13 @@ elif [ "$buildType" = "install" ]; then
     # Use relative paths; as installed on a machine without ctattach etc.
     pyDir=$install_dir/lib/py
     ppython=$install_dir/bin/ppython
+    pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py
     $ppython -d $install_dir/bin/generatePythonCode -O -v -d $pyDir -e $DIRECT/src/extensions -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
-
 elif [ "$buildType" = "release" ]; then
     # Use relative paths; as installed on a machine without ctattach etc.
     pyDir=$install_dir/lib/py
     ppython=$install_dir/bin/ppython
+    pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py
     $ppython $install_dir/bin/generatePythonCode -v -d $pyDir -e $DIRECT/src/extensions -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit
 else
     echo "Invalid parameter: $buildType"
@@ -102,9 +104,8 @@ fi
 
 if [ "$fSqueeze" = "squeezeMe" ]; then
     echo SQUEEZING PandaModules
-    cd $pyDir              || exit
-    rm -f PandaModules.py* || exit
-    $ppython $ppythonOptimizeFlag $pSqueezer $optimizeFlag || exit
+    rm -f $pyDir/PandaModules.py* || exit
+    $ppython $ppythonOptimizeFlag $pSqueezer $optimizeFlag -d $pyDir || exit
 else
     # renaming PandaModulesUnsqueezed.py to PandaModules.py
     cd $pyDir              || exit

+ 5 - 2
direct/src/showbase/pandaSqueezer.py

@@ -3,14 +3,15 @@ import sys
 import getopt
 import pandaSqueezeTool
 
-# Assumption: We will be squeezing the files from the current directory.
+# Assumption: We will be squeezing the files from the current directory or the -d directory.
 
 try:
-    opts, pargs = getopt.getopt(sys.argv[1:], 'O')
+    opts, pargs = getopt.getopt(sys.argv[1:], 'Od:')
 except Exception, e:
     # User passed in a bad option, print the error and the help, then exit
     print e
     print 'Usage: pass in -O for optimized'
+    print '       pass in -d directory'
     sys.exit()
 
 fOptimized = 0
@@ -20,6 +21,8 @@ for opt in opts:
     if (flag == '-O'):
         fOptimized = 1
         print 'Squeezing pyo files'
+    elif (flag == '-d'):
+        os.chdir(value)
 
 def getSqueezeableFiles():
     fileList = os.listdir(".")