f8c2a87de8e5616a8e7059c8a1b7940bdc277a53
[blender.git] / build_files / windows / configure_msbuild.cmd
1 if "%BUILD_ARCH%"=="x64" (
2         set MSBUILD_PLATFORM=x64
3 ) else if "%BUILD_ARCH%"=="x86" (
4         set MSBUILD_PLATFORM=win32
5         if "%WITH_CLANG%"=="1" (
6                 echo Clang not supported for X86
7                 exit /b 1
8         )
9 )
10
11 if "%WITH_CLANG%"=="1" (
12         set CLANG_CMAKE_ARGS=-T"LLVM-vs2017"
13         if "%WITH_ASAN%"=="1" (
14                 set ASAN_CMAKE_ARGS=-DWITH_COMPILER_ASAN=On
15         )
16 ) else (
17         if "%WITH_ASAN%"=="1" (
18                 echo ASAN is only supported with clang.
19                 exit /b 1 
20         )
21 )
22 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS% %CLANG_CMAKE_ARGS% %ASAN_CMAKE_ARGS%
23
24 if NOT EXIST %BUILD_DIR%\nul (
25         mkdir %BUILD_DIR%
26 )
27
28 if "%MUST_CLEAN%"=="1" (
29         echo Cleaning %BUILD_DIR%
30         msbuild ^
31                 %BUILD_DIR%\Blender.sln ^
32                 /target:clean ^
33                 /property:Configuration=%BUILD_TYPE% ^
34                 /verbosity:minimal ^
35                 /p:platform=%MSBUILD_PLATFORM%
36 )
37
38 if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
39 if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
40
41 if "%MUST_CONFIGURE%"=="1" (
42
43         if NOT "%verbose%" == "" (
44                 echo %CMAKE% %BUILD_CMAKE_ARGS% -H%BLENDER_DIR% -B%BUILD_DIR% 
45         )
46
47         cmake ^
48                 %BUILD_CMAKE_ARGS% ^
49                 -H%BLENDER_DIR% ^
50                 -B%BUILD_DIR% 
51
52         if %ERRORLEVEL% NEQ 0 (
53                 echo "Configuration Failed"
54                 exit /b 1
55         )
56 )
57
58 echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd
59 echo "%CMAKE%" . >> %BUILD_DIR%\rebuild.cmd
60 echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
61 echo msbuild ^
62         %BUILD_DIR%\Blender.sln ^
63         /target:build ^
64         /property:Configuration=%BUILD_TYPE% ^
65         /maxcpucount:2 ^
66         /verbosity:minimal ^
67         /p:platform=%MSBUILD_PLATFORM% ^
68         /flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log >> %BUILD_DIR%\rebuild.cmd
69 echo msbuild ^
70         %BUILD_DIR%\INSTALL.vcxproj ^
71         /property:Configuration=%BUILD_TYPE% ^
72         /verbosity:minimal ^
73         /p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd
74 echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd