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