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 34 35:: Find msbuild.exe. (The batch file sets %MSBUILD%.) 36call %PYTHON_SRC%\PCbuild\find_msbuild.bat 37if %ERRORLEVEL% neq 0 goto :end 38 39:: Avoid calling PCbuild\build.bat directly because that script either downloads externals or 40:: disables them, and we need to specify their locations. The batch file mostly reduces to this one 41:: msbuild invocation. 42echo ## Building python... 43%MSBUILD% "%PYTHON_SRC%\PCbuild\pcbuild.proj" ^ 44 -target:Build -maxCpuCount -nologo -verbosity:minimal -clp:summary ^ 45 -property:Configuration=Release ^ 46 -property:Platform=x64 ^ 47 -property:IncludeExternals=true ^ 48 -property:IncludeCTypes=true ^ 49 -property:IncludeSSL=false ^ 50 -property:IncludeTkinter=false ^ 51 -property:UseTestMarker= ^ 52 -property:GIT=git.exe 53if %ERRORLEVEL% neq 0 goto :end 54 55echo ## Packaging python... 56set OUT_ARCHIVE=%DEST%\python3-windows-%KOKORO_BUILD_ID%.zip 57PCBuild\amd64\python.exe PC\layout --zip %OUT_ARCHIVE% --include-dev 58if %ERRORLEVEL% neq 0 goto :end 59 60:: Linux/Darwin Python puts the LICENSE.txt file in lib/pythonX.Y with the Python libraries. For 61:: consistency, move LICENSE.txt into Lib, which has the Python libraries on Windows. 62echo ## Moving LICENSE.txt to Lib\LICENSE.txt... 637z rn %OUT_ARCHIVE% LICENSE.txt Lib\LICENSE.txt 64 65:end 66exit /b %ERRORLEVEL% 67