17db96d56Sopenharmony_ci@setlocal 27db96d56Sopenharmony_ci@echo off 37db96d56Sopenharmony_ci 47db96d56Sopenharmony_cirem This script is intended for building official releases of Python. 57db96d56Sopenharmony_cirem To use it to build alternative releases, you should clone this file 67db96d56Sopenharmony_cirem and modify the following three URIs. 77db96d56Sopenharmony_ci 87db96d56Sopenharmony_cirem These two will ensure that your release can be installed 97db96d56Sopenharmony_cirem alongside an official Python release, by modifying the GUIDs used 107db96d56Sopenharmony_cirem for all components. 117db96d56Sopenharmony_cirem 127db96d56Sopenharmony_cirem The following substitutions will be applied to the release URI: 137db96d56Sopenharmony_cirem Variable Description Example 147db96d56Sopenharmony_cirem {arch} architecture amd64, win32 157db96d56Sopenharmony_cirem Do not change the scheme to https. Otherwise, releases built with this 167db96d56Sopenharmony_cirem script will not be upgradable to/from official releases of Python. 177db96d56Sopenharmony_ciset RELEASE_URI=http://www.python.org/{arch} 187db96d56Sopenharmony_ci 197db96d56Sopenharmony_cirem This is the URL that will be used to download installation files. 207db96d56Sopenharmony_cirem The files available from the default URL *will* conflict with your 217db96d56Sopenharmony_cirem installer. Trust me, you don't want them, even if it seems like a 227db96d56Sopenharmony_cirem good idea. 237db96d56Sopenharmony_cirem 247db96d56Sopenharmony_cirem The following substitutions will be applied to the download URL: 257db96d56Sopenharmony_cirem Variable Description Example 267db96d56Sopenharmony_cirem {version} version number 3.5.0 277db96d56Sopenharmony_cirem {arch} architecture amd64, win32 287db96d56Sopenharmony_cirem {releasename} release name a1, b2, rc3 (or blank for final) 297db96d56Sopenharmony_cirem {msi} MSI filename core.msi 307db96d56Sopenharmony_ciset DOWNLOAD_URL=https://www.python.org/ftp/python/{version}/{arch}{releasename}/{msi} 317db96d56Sopenharmony_ci 327db96d56Sopenharmony_ciset D=%~dp0 337db96d56Sopenharmony_ciset PCBUILD=%D%..\..\PCbuild\ 347db96d56Sopenharmony_ciif NOT DEFINED Py_OutDir set Py_OutDir=%PCBUILD% 357db96d56Sopenharmony_ciset EXTERNALS=%D%..\..\externals\windows-installer\ 367db96d56Sopenharmony_ci 377db96d56Sopenharmony_ciset BUILDX86= 387db96d56Sopenharmony_ciset BUILDX64= 397db96d56Sopenharmony_ciset BUILDARM64= 407db96d56Sopenharmony_ciset TARGET=Rebuild 417db96d56Sopenharmony_ciset TESTTARGETDIR= 427db96d56Sopenharmony_ciset PGO=-m test -q --pgo 437db96d56Sopenharmony_ciset BUILDMSI=1 447db96d56Sopenharmony_ciset BUILDNUGET=1 457db96d56Sopenharmony_ciset BUILDZIP=1 467db96d56Sopenharmony_ci 477db96d56Sopenharmony_ci 487db96d56Sopenharmony_ci:CheckOpts 497db96d56Sopenharmony_ciif "%1" EQU "-h" goto Help 507db96d56Sopenharmony_ciif "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 517db96d56Sopenharmony_ciif "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 527db96d56Sopenharmony_ciif "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 537db96d56Sopenharmony_ciif "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 547db96d56Sopenharmony_ciif "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts 557db96d56Sopenharmony_ciif "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts 567db96d56Sopenharmony_ciif "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts 577db96d56Sopenharmony_ciif "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts 587db96d56Sopenharmony_ciif "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts 597db96d56Sopenharmony_ciif "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts 607db96d56Sopenharmony_ciif "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts 617db96d56Sopenharmony_ciif "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts 627db96d56Sopenharmony_ciif /I "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts 637db96d56Sopenharmony_ciif /I "%1" EQU "-Win32" (set BUILDX86=1) && shift && goto CheckOpts 647db96d56Sopenharmony_ciif /I "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts 657db96d56Sopenharmony_ciif /I "%1" EQU "-arm64" (set BUILDARM64=1) && shift && goto CheckOpts 667db96d56Sopenharmony_ciif "%1" EQU "--pgo" (set PGO=%~2) && shift && shift && goto CheckOpts 677db96d56Sopenharmony_ciif "%1" EQU "--skip-pgo" (set PGO=) && shift && goto CheckOpts 687db96d56Sopenharmony_ciif "%1" EQU "--skip-nuget" (set BUILDNUGET=) && shift && goto CheckOpts 697db96d56Sopenharmony_ciif "%1" EQU "--skip-zip" (set BUILDZIP=) && shift && goto CheckOpts 707db96d56Sopenharmony_ciif "%1" EQU "--skip-msi" (set BUILDMSI=) && shift && goto CheckOpts 717db96d56Sopenharmony_ci 727db96d56Sopenharmony_ciif "%1" NEQ "" echo Invalid option: "%1" && exit /B 1 737db96d56Sopenharmony_ci 747db96d56Sopenharmony_ciif not defined BUILDX86 if not defined BUILDX64 if not defined BUILDARM64 (set BUILDX86=1) && (set BUILDX64=1) 757db96d56Sopenharmony_ci 767db96d56Sopenharmony_ciif not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc" 777db96d56Sopenharmony_ciif not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1 787db96d56Sopenharmony_ci 797db96d56Sopenharmony_cicall "%D%get_externals.bat" 807db96d56Sopenharmony_cicall "%PCBUILD%find_msbuild.bat" %MSBUILD% 817db96d56Sopenharmony_ciif ERRORLEVEL 1 (echo Cannot locate MSBuild.exe on PATH or as MSBUILD variable & exit /b 2) 827db96d56Sopenharmony_ci 837db96d56Sopenharmony_ci:builddoc 847db96d56Sopenharmony_ciif "%SKIPBUILD%" EQU "1" goto skipdoc 857db96d56Sopenharmony_ciif "%SKIPDOC%" EQU "1" goto skipdoc 867db96d56Sopenharmony_ci 877db96d56Sopenharmony_cicall "%D%..\..\doc\make.bat" html 887db96d56Sopenharmony_ciif errorlevel 1 exit /B %ERRORLEVEL% 897db96d56Sopenharmony_ci:skipdoc 907db96d56Sopenharmony_ci 917db96d56Sopenharmony_ciif defined BUILDX86 ( 927db96d56Sopenharmony_ci call :build x86 937db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 947db96d56Sopenharmony_ci) 957db96d56Sopenharmony_ci 967db96d56Sopenharmony_ciif defined BUILDX64 ( 977db96d56Sopenharmony_ci call :build x64 "%PGO%" 987db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 997db96d56Sopenharmony_ci) 1007db96d56Sopenharmony_ci 1017db96d56Sopenharmony_ciif defined BUILDARM64 ( 1027db96d56Sopenharmony_ci call :build ARM64 1037db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1047db96d56Sopenharmony_ci) 1057db96d56Sopenharmony_ci 1067db96d56Sopenharmony_ciif defined TESTTARGETDIR ( 1077db96d56Sopenharmony_ci call "%D%testrelease.bat" -t "%TESTTARGETDIR%" 1087db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1097db96d56Sopenharmony_ci) 1107db96d56Sopenharmony_ci 1117db96d56Sopenharmony_ciexit /B 0 1127db96d56Sopenharmony_ci 1137db96d56Sopenharmony_ci:build 1147db96d56Sopenharmony_ci@setlocal 1157db96d56Sopenharmony_ci@echo off 1167db96d56Sopenharmony_ci 1177db96d56Sopenharmony_ciif "%1" EQU "x86" ( 1187db96d56Sopenharmony_ci set PGO= 1197db96d56Sopenharmony_ci set BUILD=%Py_OutDir%win32\ 1207db96d56Sopenharmony_ci set BUILD_PLAT=Win32 1217db96d56Sopenharmony_ci set OUTDIR_PLAT=win32 1227db96d56Sopenharmony_ci set OBJDIR_PLAT=x86 1237db96d56Sopenharmony_ci) else if "%1" EQU "x64" ( 1247db96d56Sopenharmony_ci set BUILD=%Py_OutDir%amd64\ 1257db96d56Sopenharmony_ci set PGO=%~2 1267db96d56Sopenharmony_ci set BUILD_PLAT=x64 1277db96d56Sopenharmony_ci set OUTDIR_PLAT=amd64 1287db96d56Sopenharmony_ci set OBJDIR_PLAT=x64 1297db96d56Sopenharmony_ci) else if "%1" EQU "ARM64" ( 1307db96d56Sopenharmony_ci set BUILD=%Py_OutDir%amd64\ 1317db96d56Sopenharmony_ci set PGO=%~2 1327db96d56Sopenharmony_ci set BUILD_PLAT=ARM64 1337db96d56Sopenharmony_ci set OUTDIR_PLAT=arm64 1347db96d56Sopenharmony_ci set OBJDIR_PLAT=arm64 1357db96d56Sopenharmony_ci) else ( 1367db96d56Sopenharmony_ci echo Unknown platform %1 1377db96d56Sopenharmony_ci exit /B 1 1387db96d56Sopenharmony_ci) 1397db96d56Sopenharmony_ci 1407db96d56Sopenharmony_ciif exist "%BUILD%en-us" ( 1417db96d56Sopenharmony_ci echo Deleting %BUILD%en-us 1427db96d56Sopenharmony_ci rmdir /q/s "%BUILD%en-us" 1437db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1447db96d56Sopenharmony_ci) 1457db96d56Sopenharmony_ci 1467db96d56Sopenharmony_ciif exist "%D%obj\Debug_%OBJDIR_PLAT%" ( 1477db96d56Sopenharmony_ci echo Deleting "%D%obj\Debug_%OBJDIR_PLAT%" 1487db96d56Sopenharmony_ci rmdir /q/s "%D%obj\Debug_%OBJDIR_PLAT%" 1497db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1507db96d56Sopenharmony_ci) 1517db96d56Sopenharmony_ci 1527db96d56Sopenharmony_ciif exist "%D%obj\Release_%OBJDIR_PLAT%" ( 1537db96d56Sopenharmony_ci echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" 1547db96d56Sopenharmony_ci rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" 1557db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1567db96d56Sopenharmony_ci) 1577db96d56Sopenharmony_ci 1587db96d56Sopenharmony_ciif not "%CERTNAME%" EQU "" ( 1597db96d56Sopenharmony_ci set CERTOPTS="/p:SigningCertificate=%CERTNAME%" 1607db96d56Sopenharmony_ci) else ( 1617db96d56Sopenharmony_ci set CERTOPTS= 1627db96d56Sopenharmony_ci) 1637db96d56Sopenharmony_ciif not "%PGO%" EQU "" ( 1647db96d56Sopenharmony_ci set PGOOPTS=--pgo-job "%PGO%" 1657db96d56Sopenharmony_ci) else ( 1667db96d56Sopenharmony_ci set PGOOPTS= 1677db96d56Sopenharmony_ci) 1687db96d56Sopenharmony_ciif not "%SKIPBUILD%" EQU "1" ( 1697db96d56Sopenharmony_ci @echo call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS% 1707db96d56Sopenharmony_ci @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS% 1717db96d56Sopenharmony_ci @if errorlevel 1 exit /B %ERRORLEVEL% 1727db96d56Sopenharmony_ci @rem build.bat turns echo back on, so we disable it again 1737db96d56Sopenharmony_ci @echo off 1747db96d56Sopenharmony_ci 1757db96d56Sopenharmony_ci @echo call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET% 1767db96d56Sopenharmony_ci @call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET% 1777db96d56Sopenharmony_ci @if errorlevel 1 exit /B %ERRORLEVEL% 1787db96d56Sopenharmony_ci @rem build.bat turns echo back on, so we disable it again 1797db96d56Sopenharmony_ci @echo off 1807db96d56Sopenharmony_ci) 1817db96d56Sopenharmony_ci 1827db96d56Sopenharmony_ciif "%OUTDIR_PLAT%" EQU "win32" ( 1837db96d56Sopenharmony_ci %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% 1847db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1857db96d56Sopenharmony_ci) else if not exist "%Py_OutDir%win32\en-us\launcher.msi" ( 1867db96d56Sopenharmony_ci %MSBUILD% "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% 1877db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1887db96d56Sopenharmony_ci) 1897db96d56Sopenharmony_ci 1907db96d56Sopenharmony_ciset BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% 1917db96d56Sopenharmony_ciif defined BUILDMSI ( 1927db96d56Sopenharmony_ci %MSBUILD% "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true 1937db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 1947db96d56Sopenharmony_ci) 1957db96d56Sopenharmony_ci 1967db96d56Sopenharmony_ciif defined BUILDZIP ( 1977db96d56Sopenharmony_ci if "%BUILD_PLAT%" EQU "ARM64" ( 1987db96d56Sopenharmony_ci echo Skipping embeddable ZIP generation for ARM64 platform 1997db96d56Sopenharmony_ci ) else ( 2007db96d56Sopenharmony_ci %MSBUILD% "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% /p:OutputPath="%BUILD%en-us" 2017db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 2027db96d56Sopenharmony_ci ) 2037db96d56Sopenharmony_ci) 2047db96d56Sopenharmony_ci 2057db96d56Sopenharmony_ciif defined BUILDNUGET ( 2067db96d56Sopenharmony_ci if "%BUILD_PLAT%" EQU "ARM64" ( 2077db96d56Sopenharmony_ci echo Skipping Nuget package generation for ARM64 platform 2087db96d56Sopenharmony_ci ) else ( 2097db96d56Sopenharmony_ci %MSBUILD% "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us" 2107db96d56Sopenharmony_ci if errorlevel 1 exit /B %ERRORLEVEL% 2117db96d56Sopenharmony_ci ) 2127db96d56Sopenharmony_ci) 2137db96d56Sopenharmony_ci 2147db96d56Sopenharmony_ciif not "%OUTDIR%" EQU "" ( 2157db96d56Sopenharmony_ci mkdir "%OUTDIR%\%OUTDIR_PLAT%" 2167db96d56Sopenharmony_ci mkdir "%OUTDIR%\%OUTDIR_PLAT%\binaries" 2177db96d56Sopenharmony_ci mkdir "%OUTDIR%\%OUTDIR_PLAT%\symbols" 2187db96d56Sopenharmony_ci robocopy "%BUILD%en-us" "%OUTDIR%\%OUTDIR_PLAT%" /XF "*.wixpdb" 2197db96d56Sopenharmony_ci robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\binaries" *.exe *.dll *.pyd /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" 2207db96d56Sopenharmony_ci robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\symbols" *.pdb /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" 2217db96d56Sopenharmony_ci) 2227db96d56Sopenharmony_ci 2237db96d56Sopenharmony_ciexit /B 0 2247db96d56Sopenharmony_ci 2257db96d56Sopenharmony_ci:Help 2267db96d56Sopenharmony_ciecho buildrelease.bat [--out DIR] [-x86] [-x64] [-arm64] [--certificate CERTNAME] [--build] [--pgo COMMAND] 2277db96d56Sopenharmony_ciecho [--skip-build] [--skip-doc] [--skip-nuget] [--skip-zip] [--skip-pgo] 2287db96d56Sopenharmony_ciecho [--download DOWNLOAD URL] [--test TARGETDIR] 2297db96d56Sopenharmony_ciecho [-h] 2307db96d56Sopenharmony_ciecho. 2317db96d56Sopenharmony_ciecho --out (-o) Specify an additional output directory for installers 2327db96d56Sopenharmony_ciecho -x86 Build x86 installers 2337db96d56Sopenharmony_ciecho -x64 Build x64 installers 2347db96d56Sopenharmony_ciecho -arm64 Build ARM64 installers 2357db96d56Sopenharmony_ciecho --build (-b) Incrementally build Python rather than rebuilding 2367db96d56Sopenharmony_ciecho --skip-build (-B) Do not build Python (just do the installers) 2377db96d56Sopenharmony_ciecho --skip-doc (-D) Do not build documentation 2387db96d56Sopenharmony_ciecho --pgo Specify PGO command for x64 installers 2397db96d56Sopenharmony_ciecho --skip-pgo Build x64 installers without using PGO 2407db96d56Sopenharmony_ciecho --skip-msi Do not build executable/MSI packages 2417db96d56Sopenharmony_ciecho --skip-nuget Do not build Nuget packages 2427db96d56Sopenharmony_ciecho --skip-zip Do not build embeddable package 2437db96d56Sopenharmony_ciecho --download Specify the full download URL for MSIs 2447db96d56Sopenharmony_ciecho --test Specify the test directory to run the installer tests 2457db96d56Sopenharmony_ciecho -h Display this help information 2467db96d56Sopenharmony_ciecho. 2477db96d56Sopenharmony_ciecho If no architecture is specified, all architectures will be built. 2487db96d56Sopenharmony_ciecho If --test is not specified, the installer tests are not run. 2497db96d56Sopenharmony_ciecho. 2507db96d56Sopenharmony_ciecho For the --pgo option, any Python command line can be used, or 'default' to 2517db96d56Sopenharmony_ciecho use the default task (-m test --pgo). 2527db96d56Sopenharmony_ciecho. 2537db96d56Sopenharmony_ciecho x86 and ARM64 builds will never use PGO. ARM64 builds will never generate 2547db96d56Sopenharmony_ciecho embeddable or Nuget packages. 2557db96d56Sopenharmony_ciecho. 2567db96d56Sopenharmony_ciecho The following substitutions will be applied to the download URL: 2577db96d56Sopenharmony_ciecho Variable Description Example 2587db96d56Sopenharmony_ciecho {version} version number 3.5.0 2597db96d56Sopenharmony_ciecho {arch} architecture amd64, win32 2607db96d56Sopenharmony_ciecho {releasename} release name a1, b2, rc3 (or blank for final) 2617db96d56Sopenharmony_ciecho {msi} MSI filename core.msi 262