Fix T49478: triangulate of face hangs Blender.
[blender.git] / make.bat
1 @echo off
2 REM This batch file does an out-of-source CMake build in ../build_windows
3 REM This is for users who like to configure & build Blender with a single command.
4
5 setlocal ENABLEEXTENSIONS
6 set BLENDER_DIR=%~dp0
7 set BUILD_DIR=%BLENDER_DIR%..\build_windows
8 set BUILD_TYPE=Release
9 set BUILD_CMAKE_ARGS=
10
11 :argv_loop
12 if NOT "%1" == "" (
13
14         REM Help Message
15         if "%1" == "help" (
16                 goto HELP
17         )
18
19         REM Build Types
20         if "%1" == "debug" (
21                 set BUILD_DIR=%BUILD_DIR%_debug
22                 set BUILD_TYPE=Debug
23
24         REM Build Configurations
25         ) else if "%1" == "full" (
26                 set TARGET_SET=1
27                 set BUILD_DIR=%BUILD_DIR%_full
28                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
29                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake"
30         ) else if "%1" == "lite" (
31                 set TARGET_SET=1
32                 set BUILD_DIR=%BUILD_DIR%_lite
33                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
34                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake"
35         ) else if "%1" == "cycles" (
36                 set TARGET_SET=1
37                 set BUILD_DIR=%BUILD_DIR%_cycles
38                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
39                     -C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake"
40         ) else if "%1" == "headless" (
41                 set TARGET_SET=1
42                 set BUILD_DIR=%BUILD_DIR%_headless
43                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
44                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake"
45         ) else if "%1" == "bpy" (
46                 set TARGET_SET=1
47                 set BUILD_DIR=%BUILD_DIR%_bpy
48                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
49                     -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
50         ) else if "%1" == "release" (
51                 set TARGET_SET=1
52                 if "%CUDA_PATH_V7_5%"=="" (
53                         echo Cuda 7.5 Not found, aborting!
54                         goto EOF
55                 )
56                 if "%CUDA_PATH_V8_0%"=="" (
57                         echo Cuda 8.0 Not found, aborting!
58                         goto EOF
59                 )
60                 set BUILD_DIR=%BUILD_DIR%_Release
61                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
62                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake" -DCUDA_NVCC_EXECUTABLE:FILEPATH=%CUDA_PATH_V7_5%/bin/nvcc.exe -DCUDA_NVCC8_EXECUTABLE:FILEPATH=%CUDA_PATH_V8_0%/bin/nvcc.exe  
63         )       else if "%1" == "x86" (
64                 set BUILD_ARCH=x86
65                 set BUILD_DIR=%BUILD_DIR%_x86
66         )       else if "%1" == "x64" (
67                 set BUILD_ARCH=x64
68                 set BUILD_DIR=%BUILD_DIR%_x64
69         )       else if "%1" == "2015" (
70         set BUILD_VS_VER=14
71         set BUILD_VS_YEAR=2015
72         )       else if "%1" == "2013" (
73         set BUILD_VS_VER=12
74         set BUILD_VS_YEAR=2013
75         )       else if "%1" == "packagename" (
76         set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
77         shift /1
78         )       else if "%1" == "nobuild" (
79         set NOBUILD=1
80         )       else if "%1" == "showhash" (
81                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Branch_hash=%%i
82                 cd release/datafiles/locale 
83                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Locale_hash=%%i
84                 cd %~dp0
85                 cd release/scripts/addons
86                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Addons_Hash=%%i
87                 cd %~dp0
88                 goto EOF
89         REM Non-Build Commands
90         ) else if "%1" == "update" (
91                 svn up ../lib/*
92                 git pull --rebase
93                 git submodule foreach git pull --rebase origin master
94                 goto EOF
95         ) else if "%1" == "clean" (
96                 set MUST_CLEAN=1
97         ) else (
98                 echo Command "%1" unknown, aborting!
99                 goto EOF
100         )
101
102         shift /1
103         goto argv_loop
104 )
105 if "%BUILD_ARCH%"=="" (
106         if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
107                 set WINDOWS_ARCH= Win64
108         ) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
109                 set WINDOWS_ARCH= Win64
110         ) else (
111                 set WINDOWS_ARCH=
112         )
113 ) else if "%BUILD_ARCH%"=="x64" (
114                 set WINDOWS_ARCH= Win64
115         ) else if "%BUILD_ARCH%"=="x86" (
116                 set WINDOWS_ARCH=
117         )
118
119 if "%BUILD_VS_VER%"=="" (
120         set BUILD_VS_VER=12
121         set BUILD_VS_YEAR=2013
122 )
123
124 set BUILD_DIR=%BUILD_DIR%_vc%BUILD_VS_VER%
125
126 REM Detect MSVC Installation
127 if DEFINED VisualStudioVersion goto msvc_detect_finally
128 set VALUE_NAME=ProductDir
129 REM Check 64 bits
130 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
131 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
132 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
133 REM Check 32 bits
134 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
135 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C
136 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
137 :msvc_detect_finally
138 if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat"
139
140 REM Sanity Checks
141 where /Q msbuild
142 if %ERRORLEVEL% NEQ 0 (
143         echo Error: "MSBuild" command not in the PATH.
144         echo You must have MSVC installed and run this from the "Developer Command Prompt"
145         echo ^(available from Visual Studio's Start menu entry^), aborting!
146         goto EOF
147 )
148 where /Q cmake
149 if %ERRORLEVEL% NEQ 0 (
150         echo Error: "CMake" command not in the PATH.
151         echo You must have CMake installed and added to your PATH, aborting!
152         goto EOF
153 )
154 if NOT EXIST %BLENDER_DIR%..\lib\nul (
155         echo Error: Path to libraries not found "%BLENDER_DIR%..\lib\"
156         echo This is needed for building, aborting!
157         goto EOF
158 )
159 if NOT "%TARGET_SET%"=="1" (
160         echo Error: Convenience target not set
161         echo This is required for building, aborting!
162         echo . 
163         goto HELP
164 )
165
166 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%"
167 if NOT EXIST %BUILD_DIR%\nul (
168         mkdir %BUILD_DIR%
169 )
170 if "%MUST_CLEAN%"=="1" (
171                 echo Cleaning %BUILD_DIR%
172                 msbuild ^
173                         %BUILD_DIR%\Blender.sln ^
174                         /target:clean ^
175                         /property:Configuration=%BUILD_TYPE% ^
176                         /verbosity:minimal
177                 if %ERRORLEVEL% NEQ 0 (
178                         echo Cleaned "%BUILD_DIR%"
179                 )
180                 goto EOF
181 )
182 REM Only configure on first run or when called with nobuild
183 if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
184 if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
185
186 if "%MUST_CONFIGURE%"=="1" (
187         cmake ^
188                 %BUILD_CMAKE_ARGS% ^
189                 -H%BLENDER_DIR% ^
190                 -B%BUILD_DIR% ^
191                 %BUILD_CMAKE_ARGS%
192
193         if %ERRORLEVEL% NEQ 0 (
194                 echo "Configuration Failed"
195                 goto EOF
196         )
197 )
198 if "%NOBUILD%"=="1" goto EOF
199
200 msbuild ^
201         %BUILD_DIR%\Blender.sln ^
202         /target:build ^
203         /property:Configuration=%BUILD_TYPE% ^
204         /maxcpucount ^
205         /verbosity:minimal
206
207 if %ERRORLEVEL% NEQ 0 (
208         echo "Build Failed"
209         goto EOF
210 )
211
212 msbuild ^
213         %BUILD_DIR%\INSTALL.vcxproj ^
214         /property:Configuration=%BUILD_TYPE% ^
215         /verbosity:minimal
216
217 echo.
218 echo At any point you can optionally modify your build configuration by editing:
219 echo "%BUILD_DIR%\CMakeCache.txt", then run "make" again to build with the changes applied.
220 echo.
221 echo Blender successfully built, run from: "%BUILD_DIR%\bin\%BUILD_TYPE%"
222 echo.
223 goto EOF
224 :HELP
225                 echo.
226                 echo Convenience targets
227                 echo - release 
228                 echo - debug
229                 echo - full
230                 echo - lite
231                 echo - headless
232                 echo - cycles
233                 echo - bpy
234                 echo.
235                 echo Utilities ^(not associated with building^)
236                 echo - clean ^(Target must be set^)
237                 echo - update
238                 echo - nobuild ^(only generate project files^)
239                 echo - showhash ^(Show git hashes of source tree^)
240                 echo.
241                 echo Configuration options
242                 echo - packagename [newname] ^(override default cpack package name^)
243                 echo - x86 ^(override host autodetect and build 32 bit code^)
244                 echo - x64 ^(override host autodetect and build 64 bit code^)
245                 echo - 2013 ^(build with visual studio 2013^)
246                 echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
247                 echo.
248
249 :EOF
250