Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 1 | @echo off
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 2 | goto Run
|
| 3 | :Usage
|
| 4 | echo.%~nx0 [flags and arguments] [quoted MSBuild options]
|
| 5 | echo.
|
| 6 | echo.Build CPython from the command line. Requires the appropriate
|
| 7 | echo.version(s) of Microsoft Visual Studio to be installed (see readme.txt).
|
| 8 | echo.Also requires Subversion (svn.exe) to be on PATH if the '-e' flag is
|
| 9 | echo.given.
|
| 10 | echo.
|
| 11 | echo.After the flags recognized by this script, up to 9 arguments to be passed
|
| 12 | echo.directly to MSBuild may be passed. If the argument contains an '=', the
|
| 13 | echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`)
|
| 14 | echo.
|
| 15 | echo.Available flags:
|
| 16 | echo. -h Display this help message
|
| 17 | echo. -V Display version information for the current build
|
| 18 | echo. -r Target Rebuild instead of Build
|
| 19 | echo. -d Set the configuration to Debug
|
| 20 | echo. -e Build external libraries fetched by get_externals.bat
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 21 | echo. Extension modules that depend on external libraries will not attempt
|
| 22 | echo. to build if this flag is not present
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 23 | echo. -m Enable parallel build (enabled by default)
|
| 24 | echo. -M Disable parallel build
|
| 25 | echo. -v Increased output messages
|
| 26 | echo. -k Attempt to kill any running Pythons before building (usually done
|
| 27 | echo. automatically by the pythoncore project)
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 28 | echo. --pgo Build with Profile-Guided Optimization. This flag
|
| 29 | echo. overrides -c and -d
|
| 30 | echo. --test-marker Enable the test marker within the build.
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 31 | echo.
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 32 | echo.Available flags to avoid building certain modules.
|
| 33 | echo.These flags have no effect if '-e' is not given:
|
| 34 | echo. --no-ssl Do not attempt to build _ssl
|
| 35 | echo. --no-tkinter Do not attempt to build Tkinter
|
| 36 | echo.
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 37 | echo.Available arguments:
|
| 38 | echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
|
| 39 | echo. Set the configuration (default: Release)
|
| 40 | echo. -p x64 ^| Win32
|
| 41 | echo. Set the platform (default: Win32)
|
| 42 | echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
|
| 43 | echo. Set the target manually
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 44 | echo. --pgo-job The job to use for PGO training; implies --pgo
|
| 45 | echo. (default: "-m test --pgo")
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 46 | exit /b 127
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 47 |
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 48 | :Run
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 49 | setlocal
|
| 50 | set platf=Win32
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 51 | set vs_platf=x86
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 52 | set conf=Release
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 53 | set target=Build
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 54 | set dir=%~dp0
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 55 | set parallel=/m
|
| 56 | set verbose=/nologo /v:m
|
Zachary Ware | 6250df8 | 2015-06-09 23:16:52 -0500 | [diff] [blame] | 57 | set kill=
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 58 | set do_pgo=
|
| 59 | set pgo_job=-m test --pgo
|
| 60 | set on_64_bit=true
|
| 61 |
|
| 62 | rem This may not be 100% accurate, but close enough.
|
| 63 | if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 64 |
|
| 65 | :CheckOpts
|
Zachary Ware | 6732343 | 2015-09-02 13:21:19 -0500 | [diff] [blame] | 66 | if "%~1"=="-h" goto Usage
|
Steve Dower | e1f6805 | 2015-07-20 21:34:45 -0700 | [diff] [blame] | 67 | if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
|
| 68 | if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
|
| 69 | if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
|
| 70 | if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
|
| 71 | if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
|
Steve Dower | e1f6805 | 2015-07-20 21:34:45 -0700 | [diff] [blame] | 72 | if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
|
| 73 | if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
|
| 74 | if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
|
| 75 | if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 76 | if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts
|
| 77 | if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts
|
Steve Dower | 940f6a8 | 2015-10-31 12:17:11 -0700 | [diff] [blame] | 78 | if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
|
Steve Dower | e1f6805 | 2015-07-20 21:34:45 -0700 | [diff] [blame] | 79 | if "%~1"=="-V" shift & goto Version
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 80 | rem These use the actual property names used by MSBuild. We could just let
|
| 81 | rem them in through the environment, but we specify them on the command line
|
| 82 | rem anyway for visibility so set defaults after this
|
Zachary Ware | a6deff2 | 2015-09-04 01:10:23 -0500 | [diff] [blame] | 83 | if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 84 | if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
|
| 85 | if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
|
| 86 |
|
| 87 | if "%IncludeExternals%"=="" set IncludeExternals=false
|
| 88 | if "%IncludeSSL%"=="" set IncludeSSL=true
|
| 89 | if "%IncludeTkinter%"=="" set IncludeTkinter=true
|
Zachary Ware | 4c9c848 | 2015-04-13 11:59:54 -0500 | [diff] [blame] | 90 |
|
Zachary Ware | a6deff2 | 2015-09-04 01:10:23 -0500 | [diff] [blame] | 91 | if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
|
| 92 |
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 93 | if "%platf%"=="x64" (
|
| 94 | if "%on_64_bit%"=="true" (
|
| 95 | rem This ought to always be correct these days...
|
| 96 | set vs_platf=amd64
|
| 97 | ) else (
|
| 98 | if "%do_pgo%"=="true" (
|
| 99 | echo.ERROR: Cannot cross-compile with PGO
|
| 100 | echo. 32bit operating system detected, if this is incorrect,
|
| 101 | echo. make sure the ProgramFiles(x86^) environment variable is set
|
| 102 | exit /b 1
|
| 103 | )
|
| 104 | set vs_platf=x86_amd64
|
| 105 | )
|
| 106 | )
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 107 |
|
| 108 | rem Setup the environment
|
| 109 | call "%dir%env.bat" %vs_platf% >nul
|
| 110 |
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 111 | if "%kill%"=="true" call :Kill
|
Zachary Ware | 6250df8 | 2015-06-09 23:16:52 -0500 | [diff] [blame] | 112 |
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 113 | if "%do_pgo%"=="true" (
|
| 114 | set conf=PGInstrument
|
| 115 | call :Build
|
| 116 | del /s "%dir%\*.pgc"
|
| 117 | del /s "%dir%\..\Lib\*.pyc"
|
| 118 | echo on
|
| 119 | call "%dir%\..\python.bat" %pgo_job%
|
| 120 | @echo off
|
| 121 | call :Kill
|
| 122 | set conf=PGUpdate
|
| 123 | )
|
| 124 | goto Build
|
| 125 |
|
| 126 | :Kill
|
| 127 | echo on
|
| 128 | msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
|
| 129 | /p:Configuration=%conf% /p:Platform=%platf%^
|
| 130 | /p:KillPython=true
|
| 131 |
|
| 132 | @echo off
|
| 133 | goto :eof
|
| 134 |
|
| 135 | :Build
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 136 | rem Call on MSBuild to do the work, echo the command.
|
| 137 | rem Passing %1-9 is not the preferred option, but argument parsing in
|
| 138 | rem batch is, shall we say, "lackluster"
|
| 139 | echo on
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 140 | msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
|
| 141 | /p:Configuration=%conf% /p:Platform=%platf%^
|
| 142 | /p:IncludeExternals=%IncludeExternals%^
|
| 143 | /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
|
Steve Dower | 940f6a8 | 2015-10-31 12:17:11 -0700 | [diff] [blame] | 144 | /p:UseTestMarker=%UseTestMarker%^
|
Zachary Ware | b27f3c3 | 2015-09-03 23:43:54 -0500 | [diff] [blame] | 145 | %1 %2 %3 %4 %5 %6 %7 %8 %9
|
Steve Dower | 4943749 | 2015-07-08 20:18:44 -0700 | [diff] [blame] | 146 |
|
Zachary Ware | bed30c3 | 2016-01-12 01:26:50 -0600 | [diff] [blame^] | 147 | @echo off
|
| 148 | goto :eof
|
Steve Dower | 4943749 | 2015-07-08 20:18:44 -0700 | [diff] [blame] | 149 |
|
| 150 | :Version
|
| 151 | rem Display the current build version information
|
| 152 | msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9
|