diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2015-06-09 20:21:39 (GMT) |
---|---|---|
committer | Zachary Ware <zachary.ware@gmail.com> | 2015-06-09 20:21:39 (GMT) |
commit | e1076aa4e2fc164a908fc4a7e775ccf57c32c2c4 (patch) | |
tree | 5a9d7c6cb7681e961926a156b88a0a8ec3d5c5e0 /PCbuild | |
parent | 66f8d75ba8f16605fe6c3d12eb57410ed1027572 (diff) | |
download | cpython-e1076aa4e2fc164a908fc4a7e775ccf57c32c2c4.zip cpython-e1076aa4e2fc164a908fc4a7e775ccf57c32c2c4.tar.gz cpython-e1076aa4e2fc164a908fc4a7e775ccf57c32c2c4.tar.bz2 |
Clean up/refactor the batch scripts used for building on Windows.
This is mostly a backport of issue #21907, but also includes a few
extras necessary to make the bulidbot scripts as thin as possible.
Diffstat (limited to 'PCbuild')
-rw-r--r-- | PCbuild/build.bat | 109 | ||||
-rw-r--r-- | PCbuild/env.bat | 3 | ||||
-rw-r--r-- | PCbuild/get_externals.bat | 103 | ||||
-rw-r--r-- | PCbuild/rt.bat | 16 |
4 files changed, 212 insertions, 19 deletions
diff --git a/PCbuild/build.bat b/PCbuild/build.bat index fb25879..679aad5 100644 --- a/PCbuild/build.bat +++ b/PCbuild/build.bat @@ -1,18 +1,107 @@ @echo off
-rem A batch program to build or rebuild a particular configuration.
+rem A batch program to build or rebuild a particular configuration,
rem just for convenience.
+rem Arguments:
+rem -c Set the configuration (default: Release)
+rem -p Set the platform (x64 or Win32, default: Win32)
+rem -r Target Rebuild instead of Build
+rem -t Set the target manually (Build, Rebuild, or Clean)
+rem -d Set the configuration to Debug
+rem -e Pull in external libraries using get_externals.bat
+rem -k Attempt to kill any running Pythons before building
+
setlocal
set platf=Win32
+set vs_platf=x86
set conf=Release
-set build=
+set target=
+set dir=%~dp0
+set kill=
+set build_tkinter=
:CheckOpts
-if "%1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
-if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
-if "%1"=="-r" (set build=/rebuild) & shift & goto CheckOpts
-if "%1"=="-d" (set conf=Debug) & shift & goto CheckOpts
-
-set cmd=vcbuild /useenv pcbuild.sln %build% "%conf%|%platf%"
-echo %cmd%
-%cmd%
+if '%1'=='-c' (set conf=%2) & shift & shift & goto CheckOpts
+if '%1'=='-p' (set platf=%2) & shift & shift & goto CheckOpts
+if '%1'=='-r' (set target=/rebuild) & shift & goto CheckOpts
+if '%1'=='-t' (
+ if '%2'=='Clean' (set target=/clean) & shift & shift & goto CheckOpts
+ if '%2'=='Rebuild' (set target=/rebuild) & shift & shift & goto CheckOpts
+ if '%2'=='Build' (set target=) & shift & shift & goto CheckOpts
+ echo.Unknown target: %2 & goto :eof
+)
+if '%1'=='-d' (set conf=Debug) & shift & goto CheckOpts
+if '%1'=='-e' call "%dir%get_externals.bat" & (set build_tkinter=true) & shift & goto CheckOpts
+if '%1'=='-k' (set kill=true) & shift & goto CheckOpts
+
+if '%conf%'=='Debug' (set dbg_ext=_d) else (set dbg_ext=)
+if '%platf%'=='x64' (
+ set vs_platf=x86_amd64
+ set builddir=%dir%amd64\
+) else (
+ set builddir=%dir%
+)
+rem Can't use builddir until we're in a new command...
+if '%platf%'=='x64' (
+ rem Needed for buliding OpenSSL
+ set HOST_PYTHON=%builddir%python%dbg_ext%.exe
+)
+
+rem Setup the environment
+call "%dir%env.bat" %vs_platf%
+
+if '%kill%'=='true' (
+ vcbuild "%dir%kill_python.vcproj" "%conf%|%platf%" && "%builddir%kill_python%dbg_ext%.exe"
+)
+
+set externals_dir=%dir%..\externals
+if '%build_tkinter%'=='true' (
+ if '%platf%'=='x64' (
+ set tcltkdir=%externals_dir%\tcltk64
+ set machine=AMD64
+ ) else (
+ set tcltkdir=%externals_dir%\tcltk
+ set machine=IX86
+ )
+ if '%conf%'=='Debug' (
+ set tcl_dbg_ext=g
+ set debug_flag=1
+ ) else (
+ set tcl_dbg_ext=
+ set debug_flag=0
+ )
+ set tcldir=%externals_dir%\tcl-8.5.15.0
+ set tkdir=%externals_dir%\tk-8.5.15.0
+ set tixdir=%externals_dir%\tix-8.4.3.5
+)
+if '%build_tkinter%'=='true' (
+ if not exist "%tcltkdir%\bin\tcl85%tcl_dbg_ext%.dll" (
+ @rem all and install need to be separate invocations, otherwise nmakehlp is not found on install
+ pushd "%tcldir%\win"
+ nmake -f makefile.vc MACHINE=%machine% DEBUG=%debug_flag% INSTALLDIR="%tcltkdir%" clean all
+ nmake -f makefile.vc MACHINE=%machine% DEBUG=%debug_flag% INSTALLDIR="%tcltkdir%" install
+ popd
+ )
+
+ if not exist "%tcltkdir%\bin\tk85%tcl_dbg_ext%.dll" (
+ pushd "%tkdir%\win"
+ nmake -f makefile.vc MACHINE=%machine% DEBUG=%debug_flag% INSTALLDIR="%tcltkdir%" TCLDIR="%tcldir%" clean
+ nmake -f makefile.vc MACHINE=%machine% DEBUG=%debug_flag% INSTALLDIR="%tcltkdir%" TCLDIR="%tcldir%" all
+ nmake -f makefile.vc MACHINE=%machine% DEBUG=%debug_flag% INSTALLDIR="%tcltkdir%" TCLDIR="%tcldir%" install
+ popd
+ )
+
+ if not exist "%tcltkdir%\lib\tix8.4.3\tix84%tcl_dbg_ext%.dll" (
+ pushd "%tixdir%\win"
+ nmake -f python.mak DEBUG=%debug_flag% MACHINE=%machine% TCL_DIR="%tcldir%" TK_DIR="%tkdir%" INSTALL_DIR="%tcltkdir%" clean
+ nmake -f python.mak DEBUG=%debug_flag% MACHINE=%machine% TCL_DIR="%tcldir%" TK_DIR="%tkdir%" INSTALL_DIR="%tcltkdir%" all
+ nmake -f python.mak DEBUG=%debug_flag% MACHINE=%machine% TCL_DIR="%tcldir%" TK_DIR="%tkdir%" INSTALL_DIR="%tcltkdir%" install
+ popd
+ )
+)
+
+rem Call on VCBuild to do the work, echo the command.
+rem Passing %1-9 is not the preferred option, but argument parsing in
+rem batch is, shall we say, "lackluster"
+echo on
+vcbuild "%dir%pcbuild.sln" %target% "%conf%|%platf%" %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/PCbuild/env.bat b/PCbuild/env.bat index 1ba7b6d..57fc116 100644 --- a/PCbuild/env.bat +++ b/PCbuild/env.bat @@ -1,5 +1,4 @@ @echo off
-set VS9=%ProgramFiles%\Microsoft Visual Studio 9.0
echo Build environments: x86, ia64, amd64, x86_amd64, x86_ia64
echo.
-call "%VS9%\VC\vcvarsall.bat" %1
+call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" %*
diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat new file mode 100644 index 0000000..f81f58a --- /dev/null +++ b/PCbuild/get_externals.bat @@ -0,0 +1,103 @@ +@echo off
+setlocal
+rem Simple script to fetch source for external libraries
+
+if not exist "%~dp0..\externals" mkdir "%~dp0..\externals"
+pushd "%~dp0..\externals"
+
+if "%SVNROOT%"=="" set SVNROOT=http://svn.python.org/projects/external/
+
+rem Optionally clean up first. Be warned that this can be very destructive!
+if not "%1"=="" (
+ for %%c in (-c --clean --clean-only) do (
+ if "%1"=="%%c" goto clean
+ )
+ goto usage
+)
+goto fetch
+
+:clean
+echo.Cleaning up external libraries.
+for /D %%d in (
+ bzip2-*
+ db-*
+ nasm-*
+ openssl-*
+ tcl-*
+ tcltk*
+ tk-*
+ tix-*
+ sqlite-*
+ xz-*
+ ) do (
+ echo.Removing %%d
+ rmdir /s /q %%d
+)
+if "%1"=="--clean-only" (
+ goto end
+)
+
+:fetch
+rem Fetch current versions
+
+svn --version > nul 2>&1
+if ERRORLEVEL 9009 (
+ echo.svn.exe must be on your PATH.
+ echo.Try TortoiseSVN (http://tortoisesvn.net/^) and be sure to check the
+ echo.command line tools option.
+ popd
+ exit /b 1
+)
+
+echo.Fetching external libraries...
+
+for %%e in (
+ bzip2-1.0.6
+ db-4.7.25.0
+ nasm-2.11.06
+ openssl-1.0.2a
+ tcl-8.5.15.0
+ tk-8.5.15.0
+ tix-8.4.3.5
+ sqlite-3.6.21
+ ) do (
+ if exist %%e (
+ echo.%%e already exists, skipping.
+ ) else (
+ echo.Fetching %%e...
+ svn export %SVNROOT%%%e
+ )
+)
+
+goto end
+
+:usage
+echo.invalid argument: %1
+echo.usage: %~n0 [[ -c ^| --clean ] ^| --clean-only ]
+echo.
+echo.Pull all sources necessary for compiling optional extension modules
+echo.that rely on external libraries. Requires svn.exe to be on your PATH
+echo.and pulls sources from %SVNROOT%.
+echo.
+echo.Use the -c or --clean option to clean up all external library sources
+echo.before pulling in the current versions.
+echo.
+echo.Use the --clean-only option to do the same cleaning, without pulling in
+echo.anything new.
+echo.
+echo.Only the first argument is checked, all others are ignored.
+echo.
+echo.**WARNING**: the cleaning options unconditionally remove any directory
+echo.that is a child of
+echo. %CD%
+echo.and matches wildcard patterns beginning with bzip2-, db-, nasm-, openssl-,
+echo.tcl-, tcltk, tk-, tix-, sqlite-, or xz-, and as such has the potential
+echo.to be very destructive if you are not aware of what it is doing. Use with
+echo.caution!
+popd
+exit /b -1
+
+
+:end
+echo Finished.
+popd
diff --git a/PCbuild/rt.bat b/PCbuild/rt.bat index ebe88a2..31a8dc9 100644 --- a/PCbuild/rt.bat +++ b/PCbuild/rt.bat @@ -9,7 +9,8 @@ rem -q runs the tests just once, and without deleting .py[co] files. rem -x64 Run the 64-bit build of python (or python_d if -d was specified)
rem from the 'amd64' dir instead of the 32-bit build in this dir.
rem All leading instances of these switches are shifted off, and
-rem whatever remains is passed to regrtest.py. For example,
+rem whatever remains (up to 9 arguments) is passed to regrtest.py.
+rem For example,
rem rt -O -d -x test_thread
rem runs
rem python_d -O ../lib/test/regrtest.py -x test_thread
@@ -26,7 +27,8 @@ rem rt -u "network,largefile" setlocal
-set prefix=.\
+set pcbuild=%~dp0
+set prefix=%pcbuild%
set suffix=
set qmode=
set dashO=
@@ -36,15 +38,15 @@ set tcltk=tcltk if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts
if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts
if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts
-if "%1"=="-x64" (set prefix=amd64) & (set tcltk=tcltk64) & shift & goto CheckOpts
+if "%1"=="-x64" (set prefix=%prefix%amd64) & (set tcltk=tcltk64) & shift & goto CheckOpts
-PATH %PATH%;%~dp0..\externals\%tcltk%\bin
-set exe=%prefix%\python%suffix%
-set cmd=%exe% %dashO% -Wd -3 -E -tt ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9
+PATH %PATH%;%pcbuild%..\externals\%tcltk%\bin
+set exe="%prefix%\python%suffix%"
+set cmd=%exe% %dashO% -Wd -3 -E -tt "%pcbuild%\..\Lib\test\regrtest.py" %1 %2 %3 %4 %5 %6 %7 %8 %9
if defined qmode goto Qmode
echo Deleting .pyc/.pyo files ...
-%exe% rmpyc.py
+%exe% "%pcbuild%\rmpyc.py"
echo on
%cmd%
|