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 2013, CMake, Ninja, SVN, GNUWin32,
12REM   NSIS with the strlen_8192 patch,
13REM   Visual Studio 2013 SDK (for the clang-format plugin).
14
15
16REM You may need to modify the paths below:
17set vcdir=c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
18set PATH=%PATH%;c:\gnuwin32\bin
19
20set revision=%1
21set branch=trunk
22set package_version=3.8.0-r%revision%
23set clang_format_vs_version=3.8.0.%revision%
24set build_dir=llvm_package_%revision%
25
26echo Branch: %branch%
27echo Revision: %revision%
28echo Package version: %package_version%
29echo Clang format plugin version: %clang_format_vs_version%
30echo Build dir: %build_dir%
31echo.
32pause
33
34mkdir %build_dir%
35cd %build_dir%
36
37echo Checking out %branch% at r%revision%...
38svn.exe export -r %revision% http://llvm.org/svn/llvm-project/llvm/%branch% llvm || exit /b
39svn.exe export -r %revision% http://llvm.org/svn/llvm-project/cfe/%branch% llvm/tools/clang || exit /b
40svn.exe export -r %revision% http://llvm.org/svn/llvm-project/clang-tools-extra/%branch% llvm/tools/clang/tools/extra || exit /b
41svn.exe export -r %revision% http://llvm.org/svn/llvm-project/lld/%branch% llvm/tools/lld || exit /b
42svn.exe export -r %revision% http://llvm.org/svn/llvm-project/compiler-rt/%branch% llvm/projects/compiler-rt || exit /b
43
44
45set cmake_flags=-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DLLVM_USE_CRT_RELEASE=MT -DCLANG_FORMAT_VS_VERSION=%clang_format_vs_version% -DPACKAGE_VERSION=%package_version%
46
47REM TODO: Run all tests, including lld and compiler-rt.
48
49call "%vcdir%/vcvarsall.bat" x86
50set CC=
51set CXX=
52mkdir build32_stage0
53cd build32_stage0
54cmake -GNinja %cmake_flags% ..\llvm || exit /b
55ninja all || exit /b
56ninja check || exit /b
57ninja check-clang || exit /b
58cd..
59
60mkdir build32
61cd build32
62set CC=..\build32_stage0\bin\clang-cl
63set CXX=..\build32_stage0\bin\clang-cl
64cmake -GNinja %cmake_flags% -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON ..\llvm || exit /b
65ninja all || exit /b
66ninja check || exit /b
67ninja check-clang || exit /b
68copy ..\llvm\tools\clang\tools\clang-format-vs\ClangFormat\bin\Release\ClangFormat.vsix ClangFormat-r%revision%.vsix
69ninja package || exit /b
70cd ..
71
72
73call "%vcdir%/vcvarsall.bat" amd64
74set CC=
75set CXX=
76mkdir build64_stage0
77cd build64_stage0
78cmake -GNinja %cmake_flags%  ..\llvm || exit /b
79ninja all || exit /b
80ninja check || exit /b
81ninja check-clang || exit /b
82cd..
83
84mkdir build64
85cd build64
86set CC=..\build64_stage0\bin\clang-cl
87set CXX=..\build64_stage0\bin\clang-cl
88cmake -GNinja %cmake_flags% ..\llvm || exit /b
89ninja all || exit /b
90ninja check || exit /b
91ninja check-clang || exit /b
92ninja package || exit /b
93cd ..
94