Commits

Anonymous committed 8b515da

Improve the scons.bat script. (Alex Jacques)

Comments (0)

Files changed (5)

HOWTO/release.txt

 			   cd scons-{version}
 			   python setup.py install
 			   cd scons-src-{version}
-			   python runtest.py -a -x C:\Python15\scons.bat
+			   python runtest.py -a -X -x C:\Python20\scons.bat
 
 			3) scons-{verson}.win32.exe
 			   cd scons-src-{version}
-			   python runtest.py -a -x C:\Python15\scons.bat
+			   python runtest.py -a -X -x C:\Python20\scons.bat
 
 	Read through the README and src/README.txt files for any updates
 
 import os
 import os.path
 import string
+import sys
+
 import TestCmd
 
 class TestFailed(Exception):
 	is not necessary.
 	"""
 	if not kw.has_key('program'):
-	    if os.path.exists('scons'):
-		kw['program'] = 'scons'
-	    else:
-		kw['program'] = 'scons.py'
-	if not kw.has_key('interpreter'):
-	    kw['interpreter'] = 'python'
+            kw['program'] = os.environ.get('SCONS')
+            if not kw['program']:
+                if os.path.exists('scons'):
+                    kw['program'] = 'scons'
+                else:
+                    kw['program'] = 'scons.py'
+	if not kw.has_key('interpreter') and not os.environ.get('SCONS_EXEC'):
+	    kw['interpreter'] = sys.executable
 	if not kw.has_key('match'):
 	    kw['match'] = TestCmd.match_exact
 	if not kw.has_key('workdir'):
 #			debugger (pdb.py) so you don't have to
 #			muck with PYTHONPATH yourself.
 #
+#	-p package	Test against the specified package.
+#
 #	-q		Quiet.  By default, runtest.py prints the
 #			command line it will execute before
 #			executing it.  This suppresses that print.
 #
-#	-p package	Test against the specified package.
+#	-X		The scons "script" is an executable; don't
+#			feed it to Python.
+#
+#       -x scons        The scons script to use for tests.
 #
 # (Note:  There used to be a -v option that specified the SCons
 # version to be tested, when we were installing in a version-specific
 tests = []
 printcmd = 1
 package = None
+scons = None
+scons_exec = None
 
 if sys.platform == 'win32':
     lib_dir = os.path.join(sys.exec_prefix, "lib")
 else:
     lib_dir = os.path.join(sys.exec_prefix, "lib", "python" + sys.version[0:3])
 
-opts, tests = getopt.getopt(sys.argv[1:], "adqp:",
-			    ['all', 'debug', 'quiet', 'package='])
+opts, tests = getopt.getopt(sys.argv[1:], "adqp:Xx:",
+			    ['all', 'debug', 'exec=', 'quiet', 'package='])
 
 for o, a in opts:
     if o == '-a' or o == '--all': all = 1
     elif o == '-d' or o == '--debug': debug = os.path.join(lib_dir, "pdb.py")
     elif o == '-q' or o == '--quiet': printcmd = 0
     elif o == '-p' or o == '--package': package = a
+    elif o == '-X': scons_exec = 1
+    elif o == '-x' or o == '--exec': scons = a
 
 cwd = os.getcwd()
 
                            os.pathsep + \
                            os.path.join(cwd, 'etc')
 
+if scons:
+    os.environ['SCONS'] = scons
+
+if scons_exec:
+    os.environ['SCONS_EXEC'] = '1'
+
 os.chdir(scons_dir)
 
 fail = []
   - Fix for relative CPPPATH directories in subsidiary SConscript files
     (broken in 0.06).
 
+  From Alex Jacques:
+
+  - Create a better scons.bat file from a py2bat.py script on the Python
+    mailing list two years ago (modeled after pl2bat.pl).
+
   From Steven Knight:
 
   - Fix so that -c -n does *not* remove the targets!
   - Support building a PDF file directly from a TeX or LaTeX file
     using pdftex or pdflatex.
 
+  - Add a -x option to runtest.py to specify the script being tested.
+    A -X option indicates it's an executable, not a script to feed
+    to the Python interpreter.
+
   From Steve Leblanc:
 
   - Add the SConscriptChdir() method.

src/script/scons.bat

-@rem __FILE__ __REVISION__ __DATE__ __DEVELOPER__
-@python -c "import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
+@echo off
+if "%OS%" == "Windows_NT" goto WinNT
+REM for 9x/Me you better not have more than 9 args
+python -c "import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
+REM no way to set exit status of this script for 9x/Me
+goto endscons
+:WinNT
+python -c "import SCons.Script; SCons.Script.main()" %*
+if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endscons
+if errorlevel 9009 echo you do not have python in your PATH
+REM color 00 causes this script to exit with non-zero exit status
+if errorlevel 1 color 00
+:endscons