diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat --- a/llvm/utils/release/build_llvm_release.bat +++ b/llvm/utils/release/build_llvm_release.bat @@ -14,8 +14,10 @@ echo --help: display this help echo --x86: build and test x86 variant echo --x64: build and test x64 variant +echo --download-prerequisites: automatically download prerequisites needed echo. echo Note: At least one variant to build is required. +echo Note: For prerequisites, VS, python and perl must be installed manually. echo. echo Example: build_llvm_release.bat --version 15.0.0 --x86 --x64 exit /b 1 @@ -28,6 +30,7 @@ set help= set x86= set x64= +set download-prerequisites= call :parse_args %* if "%help%" NEQ "" goto usage @@ -45,7 +48,7 @@ ) ::============================================================================== -:: check prerequisites +:: check prerequisites (See download_prerequisites.bat script for details) REM Note: REM 7zip versions 21.x and higher will try to extract the symlinks in REM llvm's git archive, which requires running as administrator. @@ -70,18 +73,6 @@ ) ) -REM Prerequisites: -REM -REM Visual Studio 2019, CMake, Ninja, GNUWin32, SWIG, Python 3, -REM NSIS with the strlen_8192 patch, -REM Visual Studio 2019 SDK and Nuget (for the clang-format plugin), -REM Perl (for the OpenMP run-time). -REM -REM -REM For LLDB, SWIG version <= 3.0.8 needs to be used to work around -REM https://github.com/swig/swig/issues/769 -REM - :: Detect Visual Studio set vsdevcmd= set vs_2019_prefix=C:\Program Files (x86)\Microsoft Visual Studio\2019 @@ -97,6 +88,11 @@ ) echo Using VS devcmd: %vsdevcmd% +if "%download-prerequisites%" == "true" ( + call %~dp0\download_prerequisites.bat prerequisites || exit /b 1 + call prerequisites/activate.bat || exit /b 1 +) + ::============================================================================== :: start echoing what we do @echo on @@ -190,7 +186,7 @@ -DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^ -DPYTHON_HOME=%PYTHONHOME% ^ -DPython3_ROOT_DIR=%PYTHONHOME% ^ - -DLIBXML2_INCLUDE_DIRS=%libxmldir%/include/libxml2 ^ + -DLIBXML2_INCLUDE_DIR=%libxmldir%/include/libxml2 ^ -DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1 @@ -261,7 +257,7 @@ -DLLDB_TEST_COMPILER=%stage0_bin_dir%/clang.exe ^ -DPYTHON_HOME=%PYTHONHOME% ^ -DPython3_ROOT_DIR=%PYTHONHOME% ^ - -DLIBXML2_INCLUDE_DIRS=%libxmldir%/include/libxml2 ^ + -DLIBXML2_INCLUDE_DIR=%libxmldir%/include/libxml2 ^ -DLIBXML2_LIBRARIES=%libxmldir%/lib/libxml2s.lib cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1 diff --git a/llvm/utils/release/download_prerequisites.bat b/llvm/utils/release/download_prerequisites.bat new file mode 100644 --- /dev/null +++ b/llvm/utils/release/download_prerequisites.bat @@ -0,0 +1,171 @@ +@echo off + +if "%1" == "" ( + echo usage: ^ + echo. + echo This script downloads prerequisites needed to build LLVM. + echo In ^, an activate.bat script will be generated. + echo It can be called to override PATH. + echo + echo VS, Python and Perl installers are downloaded, but it's up to + echo you to install them. + exit /b 1 +) + +set out_folder=%1 +mkdir %out_folder% +pushd %out_folder% + +echo =========================================================== +call :get_msys2 || exit /b 1 +echo =========================================================== +call :get_7z || exit /b 1 +echo =========================================================== +call :get_ninja || exit /b 1 +echo =========================================================== +call :get_nsis || exit /b 1 +echo =========================================================== +call :get_swig || exit /b 1 +echo =========================================================== +:: Visual Studio 2019 SDK and Nuget (for the clang-format plugin) +call :get_nuget || exit /b 1 +echo =========================================================== +call :get_cmake || exit /b 1 +echo =========================================================== + +echo Those dependencies are just downloaded, and you can install them +echo system-wide manually +set url_vs2019=https://aka.ms/vs/16/release/vs_community.exe +call :download "VS2019 installer" %url_vs2019% vs_community_2019.exe || exit /b 1 +set url_vs2022=https://aka.ms/vs/17/release/vs_community.exe +call :download "VS2022 installer" %url_vs2022% vs_community_2022.exe || exit /b 1 +set url_pythonx86=https://www.python.org/ftp/python/3.10.5/python-3.10.5.exe +call :download "Python x86" %url_pythonx86% python310_x86.exe || exit /b 1 +set url_pythonx64=https://www.python.org/ftp/python/3.10.5/python-3.10.5.amd64.exe +call :download "Python x64" %url_pythonx64% python310_x64.exe || exit /b 1 +:: Perl (for the OpenMP run-time) +set url_perl=https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-64bit.msi +call :download "Perl" %url_perl% perl_setup.exe || exit /b 1 + +echo =========================================================== +echo To import dependencies in your PATH, call %cd%\activate.bat +popd +exit /b 0 + +::=============================================================== +:prepend_path +set added_relative_path=%1 +if not exist %added_relative_path% ( + echo %added_relative_path% can't be found under %out_folder% + exit /b 1 +) +:: update current PATH +set "PATH=%cd%/%added_relative_path%;%PATH%" +:: set activate.bat +echo set PATH=%%~dp0/%added_relative_path%;%%PATH%% >> activate.bat +exit /b 0 + +::=============================================================== +:download +set description=%~1 +set url=%2 +set out_file=%3 +echo Download %description% from %url% in %out_file% +curl -L %url% -o %out_file% || exit /b 1 +exit /b 0 + +::=============================================================== +:get_msys2 +mkdir msys2 && pushd msys2 +set url_msys2=https://github.com/msys2/msys2-installer/releases/download/2022-09-04/msys2-base-x86_64-20220904.sfx.exe +set msys2_packages=p7zip unzip diffutils +call :download "Msys2 self extracting installer" %url_msys2% msys2_setup.exe || exit /b 1 +msys2_setup.exe || exit /b 1 +popd +call :prepend_path msys2/msys64/usr/bin || exit /b 1 +:: initialize +bash.exe -c "pacman-key --init && pacman-key --populate msys2 && pacman -Sy" || exit /b 1 +bash.exe -c "echo 'SigLevel = Never' >> /etc/pacman.conf" || exit /b 1 +:: install some needed packages +bash.exe -c "yes | pacman -S %msys2_packages%" || exit /b 1 +:: may leave gpg-agent behind +taskkill /IM gpg-agent.exe /f +where 7z || exit /b 1 +exit /b 0 + +::=============================================================== +:get_7z +mkdir 7zip && pushd 7zip +set url_7zip=https://www.7-zip.org/a/7z2201-x64.exe +call :download "7zip" %url_7zip% 7zip_setup.exe || exit /b 1 +:: extract using msys2 7z +7z x 7zip_setup.exe || exit /b 1 +popd +call :prepend_path 7zip || exit /b 1 +where 7z || exit /b 1 +exit /b 0 + +::=============================================================== +:get_ninja +mkdir ninja && pushd ninja +set url_ninja=https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip +call :download "ninja" %url_ninja% ninja.zip || exit /b 1 +unzip ninja.zip || exit /b 1 +popd +call :prepend_path ninja || exit /b 1 +where ninja || exit /b 1 +exit /b 0 + +::=============================================================== +:get_nsis +mkdir nsis && pushd nsis +:: you can appreciate the double escape to allow %20 in url +set url_nsis=https://freefr.dl.sourceforge.net/project/nsis/NSIS%%%%203/3.08/nsis-3.08-setup.exe +set url_nsis_patch=https://freefr.dl.sourceforge.net/project/nsis/NSIS%%%%203/3.08/nsis-3.08-strlen_8192.zip +call :download "NSIS" "%url_nsis%" nsis_setup.exe || exit /b 1 +7z x nsis_setup.exe || exit /b 1 +call :download "NSIS" "%url_nsis_patch%" nsis_patch.zip || exit /b 1 +REM overwrite some files with patch +unzip -o nsis_patch.zip || exit /b 1 +popd +call :prepend_path nsis || exit /b 1 +where NSIS || exit /b 1 +exit /b 0 + +::=============================================================== +:get_swig +mkdir swig && pushd swig +REM For LLDB, SWIG version <= 3.0.8 or >= 4.0 needs to be used to work around +REM https://github.com/swig/swig/issues/769 +set swig_version=4.0.2 +set url_swig=https://freefr.dl.sourceforge.net/project/swig/swigwin/swigwin-%swig_version%/swigwin-%swig_version%.zip +call :download "SWIG" %url_swig% swig.zip || exit /b 1 +unzip -q swig.zip || exit /b 1 +mv swigwin-%swig_version%/* . || exit /b 1 +popd +call :prepend_path swig || exit /b 1 +where swig || exit /b 1 +exit /b 0 + +::=============================================================== +:get_nuget +mkdir nuget && pushd nuget +set url_nuget=https://dist.nuget.org/win-x86-commandline/v6.1.0/nuget.exe +call :download "nuget" %url_nuget% nuget.exe || exit /b 1 +popd +call :prepend_path nuget || exit /b 1 +where nuget || exit /b 1 +exit /b 0 + +::=============================================================== +:get_cmake +mkdir cmake && pushd cmake +set cmake_version=3.24.2 +set url_cmake=https://github.com/Kitware/CMake/releases/download/v%cmake_version%/cmake-%cmake_version%-windows-x86_64.zip +call :download "cmake" %url_cmake% cmake.zip || exit /b 1 +unzip -q cmake.zip || exit /b 1 +mv cmake-*/* . || exit /b 1 +popd +call :prepend_path cmake/bin || exit /b 1 +where cmake || exit /b 1 +exit /b 0