1@echo off 2setlocal 3 4REM Script for building the LLVM installer on Windows, 5REM used for the the weekly snapshots at http://www.llvm.org/builds. 6REM 7REM Usage: build_llvm_package.bat <revision> 8 9REM Prerequisites: 10REM 11REM Visual Studio 2019, CMake, Ninja, GNUWin32, SWIG, Python 3, 12REM NSIS with the strlen_8192 patch, 13REM Visual Studio 2019 SDK and Nuget (for the clang-format plugin), 14REM Perl (for the OpenMP run-time), 7Zip. 15REM 16REM 17REM For LLDB, SWIG version <= 3.0.8 needs to be used to work around 18REM https://github.com/swig/swig/issues/769 19 20 21REM You need to modify the paths below: 22set vsdevcmd=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat 23 24set python32_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36-32 25set python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36 26 27for /f "usebackq" %%i in (`PowerShell ^(Get-Date^).ToString^('yyyyMMdd'^)`) do set datestamp=%%i 28 29set revision=%1 30set package_version=10.0.1-%revision% 31set clang_format_vs_version=10.0.1.%datestamp% 32set build_dir=llvm_package_%revision% 33 34echo Revision: %revision% 35echo Package version: %package_version% 36echo Clang format plugin version: %clang_format_vs_version% 37echo Build dir: %build_dir% 38echo. 39pause 40 41mkdir %build_dir% 42cd %build_dir% 43 44echo Checking out %revision% 45curl -L https://github.com/llvm/llvm-project/archive/%revision%.zip -o src.zip || exit /b 467z x src.zip || exit /b 47mv llvm-project-* llvm-project || exit /b 48 49REM Setting CMAKE_CL_SHOWINCLUDES_PREFIX to work around PR27226. 50set cmake_flags=^ 51 -DCMAKE_BUILD_TYPE=Release ^ 52 -DLLVM_ENABLE_ASSERTIONS=ON ^ 53 -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON ^ 54 -DLLVM_BUILD_LLVM_C_DYLIB=ON ^ 55 -DCMAKE_INSTALL_UCRT_LIBRARIES=ON ^ 56 -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% ^ 57 -DPACKAGE_VERSION=%package_version% ^ 58 -DLLDB_RELOCATABLE_PYTHON=1 ^ 59 -DLLDB_TEST_COMPILER=%cd%\build32_stage0\bin\clang.exe ^ 60 -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " ^ 61 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;compiler-rt;openmp;lldb" 62 63REM TODO: Run the "check-all" tests. 64 65set "VSCMD_START_DIR=%CD%" 66call "%vsdevcmd%" -arch=x86 67set CC= 68set CXX= 69mkdir build32_stage0 70cd build32_stage0 71cmake -GNinja %cmake_flags% -DPYTHON_HOME=%python32_dir% -DPYTHON_EXECUTABLE=%python32_dir%\python.exe ..\llvm-project\llvm || exit /b 72ninja all || ninja all || ninja all || exit /b 73ninja check || ninja check || ninja check || exit /b 74ninja check-clang || ninja check-clang || ninja check-clang || exit /b 75ninja check-lld || ninja check-lld || ninja check-lld || exit /b 76ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 77ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 78ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 79cd.. 80 81mkdir build32 82cd build32 83set CC=..\build32_stage0\bin\clang-cl 84set CXX=..\build32_stage0\bin\clang-cl 85cmake -GNinja %cmake_flags% -DPYTHON_HOME=%python32_dir% -DPYTHON_EXECUTABLE=%python32_dir%\python.exe ..\llvm-project\llvm || exit /b 86ninja all || ninja all || ninja all || exit /b 87ninja check || ninja check || ninja check || exit /b 88ninja check-clang || ninja check-clang || ninja check-clang || exit /b 89ninja check-lld || ninja check-lld || ninja check-lld || exit /b 90ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 91ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 92ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 93ninja package || exit /b 94 957z x LLVM-%package_version%-win32.exe -orepack 96rmdir /s /q repack\$PLUGINSDIR 97del repack\Uninstall.exe 987z a LLVM-%package_version%-win32.zip .\repack\* -mx9 99cd .. 100 101 102REM The plug-in is built separately as it uses a statically linked clang-format.exe. 103mkdir build_vsix 104cd build_vsix 105REM Having VSSDKINSTALL set makes devenv *not* find the SDK for some reason. 106set VSSDKINSTALL= 107set CC=..\build32_stage0\bin\clang-cl 108set CXX=..\build32_stage0\bin\clang-cl 109cmake -GNinja %cmake_flags% -DLLVM_USE_CRT_RELEASE=MT -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DPYTHON_HOME=%python32_dir% -DPYTHON_EXECUTABLE=%python32_dir%\python.exe ..\llvm-project\llvm || exit /b 110ninja clang_format_vsix || exit /b 111copy ..\llvm-project\llvm\tools\clang\tools\clang-format-vs\ClangFormat\bin\Release\ClangFormat.vsix ClangFormat-r%revision%.vsix 112cd .. 113 114 115set "VSCMD_START_DIR=%CD%" 116call "%vsdevcmd%" -arch=amd64 117set CC= 118set CXX= 119mkdir build64_stage0 120cd build64_stage0 121cmake -GNinja %cmake_flags% -DPYTHON_HOME=%python64_dir% -DPYTHON_EXECUTABLE=%python64_dir%\python.exe ..\llvm-project\llvm || exit /b 122ninja all || ninja all || ninja all || exit /b 123ninja check || ninja check || ninja check || exit /b 124ninja check-clang || ninja check-clang || ninja check-clang || exit /b 125ninja check-lld || ninja check-lld || ninja check-lld || exit /b 126ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 127ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 128ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 129cd.. 130 131mkdir build64 132cd build64 133set CC=..\build64_stage0\bin\clang-cl 134set CXX=..\build64_stage0\bin\clang-cl 135cmake -GNinja %cmake_flags% -DPYTHON_HOME=%python64_dir% -DPYTHON_EXECUTABLE=%python64_dir%\python.exe ..\llvm-project\llvm || exit /b 136ninja all || ninja all || ninja all || exit /b 137ninja check || ninja check || ninja check || exit /b 138ninja check-clang || ninja check-clang || ninja check-clang || exit /b 139ninja check-lld || ninja check-lld || ninja check-lld || exit /b 140ninja check-sanitizer || ninja check-sanitizer || ninja check-sanitizer || exit /b 141ninja check-clang-tools || ninja check-clang-tools || ninja check-clang-tools || exit /b 142ninja check-clangd || ninja check-clangd || ninja check-clangd || exit /b 143ninja package || exit /b 144 1457z x LLVM-%package_version%-win64.exe -orepack 146rmdir /s /q repack\$PLUGINSDIR 147del repack\Uninstall.exe 1487z a LLVM-%package_version%-win64.zip .\repack\* -mx9 149cd .. 150