1:: Copyright 2021 The Android Open Source Project 2:: 3:: Licensed under the Apache License, Version 2.0 (the "License"); 4:: you may not use this file except in compliance with the License. 5:: You may obtain a copy of the License at 6:: 7:: http://www.apache.org/licenses/LICENSE-2.0 8:: 9:: Unless required by applicable law or agreed to in writing, software 10:: distributed under the License is distributed on an "AS IS" BASIS, 11:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12:: See the License for the specific language governing permissions and 13:: limitations under the License. 14 15:: Expected arguments: 16:: %1 = python_src 17:: %2 = dest_dir 18 19setlocal 20set PYTHON_SRC=%1 21set DEST=%2 22 23cd %PYTHON_SRC% 24rmdir /s/q %DEST% 2>NUL 25md %DEST% 26if %ERRORLEVEL% neq 0 goto :end 27 28:: Deletes Android.bp or it will be packaged. 29del Lib\Android.bp 30if %ERRORLEVEL% neq 0 goto :end 31 32echo ## Running prepare_windows_externals.py to configure XML files and build libffi... 33py -3 %PYTHON_SRC%\kokoro\prepare_windows_externals.py 34if %ERRORLEVEL% neq 0 goto :end 35 36:: Find msbuild.exe. (The batch file sets %MSBUILD%.) 37call %PYTHON_SRC%\PCbuild\find_msbuild.bat 38if %ERRORLEVEL% neq 0 goto :end 39 40:: Avoid calling PCbuild\build.bat directly because that script either downloads externals or 41:: disables them, and we need to specify their locations. The batch file mostly reduces to this one 42:: msbuild invocation. 43echo ## Building python... 44%MSBUILD% "%PYTHON_SRC%\PCbuild\pcbuild.proj" ^ 45 -target:Build -maxCpuCount -nologo -verbosity:minimal -clp:summary ^ 46 -property:Configuration=Release ^ 47 -property:Platform=x64 ^ 48 -property:IncludeExternals=true ^ 49 -property:IncludeCTypes=true ^ 50 -property:IncludeSSL=false ^ 51 -property:IncludeTkinter=false ^ 52 -property:UseTestMarker= ^ 53 -property:GIT=git.exe ^ 54 -property:PythonForBuild=python.exe 55if %ERRORLEVEL% neq 0 goto :end 56 57echo ## Packaging python... 58set OUT_ARCHIVE=%DEST%\python3-windows-%KOKORO_BUILD_ID%.zip 59PCBuild\amd64\python.exe PC\layout --zip %OUT_ARCHIVE% --include-dev 60if %ERRORLEVEL% neq 0 goto :end 61 62:: Linux/Darwin Python puts the LICENSE.txt file in lib/pythonX.Y with the Python libraries. For 63:: consistency, move LICENSE.txt into Lib, which has the Python libraries on Windows. 64echo ## Moving LICENSE.txt to Lib\LICENSE.txt... 657z rn %OUT_ARCHIVE% LICENSE.txt Lib\LICENSE.txt 66 67:end 68exit /b %ERRORLEVEL% 69