Cycles: rename displacement methods, default to displace, tweak panel layout.
[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 setlocal EnableDelayedExpansion
5 setlocal ENABLEEXTENSIONS
6 set BLENDER_DIR=%~dp0
7 set BLENDER_DIR_NOSPACES=%BLENDER_DIR: =%
8 for %%X in (svn.exe) do (set HAS_SVN=%%~$PATH:X)
9 if not "%BLENDER_DIR%"=="%BLENDER_DIR_NOSPACES%" (
10         echo There are spaces detected in the build path "%BLENDER_DIR%", this is currently not supported, exiting....
11         goto EOF
12 )
13 set BUILD_DIR=%BLENDER_DIR%..\build_windows
14 set BUILD_TYPE=Release
15 rem reset all variables so they do not get accidentally get carried over from previous builds
16 set BUILD_DIR_OVERRRIDE=
17 set BUILD_CMAKE_ARGS=
18 set BUILD_ARCH=
19 set BUILD_VS_VER=
20 set BUILD_VS_YEAR=
21 set BUILD_VS_LIBDIRPOST=
22 set BUILD_VS_LIBDIR=
23 set BUILD_VS_SVNDIR=
24 set BUILD_NGE=
25 set KEY_NAME=
26 set MSBUILD_PLATFORM=
27 set MUST_CLEAN=
28 set NOBUILD=
29 set TARGET=
30 set WINDOWS_ARCH=
31 set TESTS_CMAKE_ARGS=
32 :argv_loop
33 if NOT "%1" == "" (
34
35         REM Help Message
36         if "%1" == "help" (
37                 goto HELP
38         )
39
40         REM Build Types
41         if "%1" == "debug" (
42                 set BUILD_TYPE=Debug
43         REM Build Configurations
44         ) else if "%1" == "noge" (
45                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_GAMEENGINE=OFF -DWITH_PLAYER=OFF
46                 set BUILD_NGE=_noge
47         ) else if "%1" == "builddir" (
48                 set BUILD_DIR_OVERRRIDE="%BLENDER_DIR%..\%2"
49                 shift /1
50         ) else if "%1" == "with_tests" (
51                 set TESTS_CMAKE_ARGS=-DWITH_GTESTS=On
52         ) else if "%1" == "full" (
53                 set TARGET=Full
54                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
55                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake"
56         ) else if "%1" == "lite" (
57                 set TARGET=Lite
58                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
59                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake"
60         ) else if "%1" == "cycles" (
61                 set TARGET=Cycles
62                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
63                     -C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake"
64         ) else if "%1" == "headless" (
65                 set TARGET=Headless
66                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
67                     -C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake"
68         ) else if "%1" == "bpy" (
69                 set TARGET=Bpy
70                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
71                     -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake"
72         ) else if "%1" == "release" (
73                 set TARGET=Release
74         ) else if "%1" == "x86" (
75                 set BUILD_ARCH=x86
76         ) else if "%1" == "x64" (
77                 set BUILD_ARCH=x64
78         ) else if "%1" == "2017" (
79                 set BUILD_VS_VER=15
80                 set BUILD_VS_YEAR=2017
81                 set BUILD_VS_LIBDIRPOST=vc14
82         ) else if "%1" == "2015" (
83                 set BUILD_VS_VER=14
84                 set BUILD_VS_YEAR=2015
85                 set BUILD_VS_LIBDIRPOST=vc14
86         ) else if "%1" == "2013" (
87                 set BUILD_VS_VER=12
88                 set BUILD_VS_YEAR=2013
89                 set BUILD_VS_LIBDIRPOST=vc12
90         ) else if "%1" == "packagename" (
91                 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2"
92                 shift /1
93         ) else if "%1" == "nobuild" (
94                 set NOBUILD=1
95         ) else if "%1" == "showhash" (
96                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Branch_hash=%%i
97                 cd release/datafiles/locale
98                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Locale_hash=%%i
99                 cd %~dp0
100                 cd release/scripts/addons
101                 for /f "delims=" %%i in ('git rev-parse HEAD') do echo Addons_Hash=%%i
102                 cd %~dp0
103                 goto EOF
104         REM Non-Build Commands
105         ) else if "%1" == "update" (
106                 svn up ../lib/*
107                 git pull --rebase
108                 git submodule foreach git pull --rebase origin master
109                 goto EOF
110         ) else if "%1" == "clean" (
111                 set MUST_CLEAN=1
112         ) else (
113                 echo Command "%1" unknown, aborting!
114                 goto EOF
115         )
116
117         shift /1
118         goto argv_loop
119 )
120 if "%BUILD_ARCH%"=="" (
121         if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
122                 set WINDOWS_ARCH= Win64
123                 set BUILD_ARCH=x64
124         ) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
125                 set WINDOWS_ARCH= Win64
126                 set BUILD_ARCH=x64
127         ) else (
128                 set WINDOWS_ARCH=
129                 set BUILD_ARCH=x86
130         )
131 ) else if "%BUILD_ARCH%"=="x64" (
132         set WINDOWS_ARCH= Win64
133 ) else if "%BUILD_ARCH%"=="x86" (
134         set WINDOWS_ARCH=
135 )
136
137 if "%BUILD_VS_VER%"=="" (
138         set BUILD_VS_VER=12
139         set BUILD_VS_YEAR=2013
140         set BUILD_VS_LIBDIRPOST=vc12
141 )
142
143 if "%BUILD_ARCH%"=="x64" (
144         set MSBUILD_PLATFORM=x64
145 ) else if "%BUILD_ARCH%"=="x86" (
146         set MSBUILD_PLATFORM=win32
147 )
148
149
150 if "%target%"=="Release" (
151         rem for vc12 check for both cuda 7.5 and 8
152         if "%CUDA_PATH%"=="" (
153                 echo Cuda Not found, aborting!
154                 goto EOF
155         )
156         set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^
157         -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
158 )
159
160 :DetectMSVC
161 REM Detect MSVC Installation for 2013-2015
162 if DEFINED VisualStudioVersion goto msvc_detect_finally
163 set VALUE_NAME=ProductDir
164 REM Check 64 bits
165 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
166 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
167 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
168 REM Check 32 bits
169 set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
170 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
171 if DEFINED MSVC_VC_DIR goto msvc_detect_finally
172 :msvc_detect_finally
173 if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat"
174 if DEFINED MSVC_VC_DIR goto sanity_checks
175
176 rem MSVC Build environment 2017 and up.
177 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SXS\VS7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C
178 if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017
179 REM Check 32 bits
180 for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\sxs\vs7" /v %BUILD_VS_VER%.0 2^>nul`) DO set MSVC_VS_DIR=%%C
181 if DEFINED MSVC_VS_DIR goto msvc_detect_finally_2017
182 :msvc_detect_finally_2017
183 if DEFINED MSVC_VS_DIR call "%MSVC_VS_DIR%\Common7\Tools\VsDevCmd.bat"
184
185 :sanity_checks
186 REM Sanity Checks
187 where /Q msbuild
188 if %ERRORLEVEL% NEQ 0 (
189         if "%BUILD_VS_VER%"=="12" (
190                 rem vs12 not found, try vs14
191                 echo Visual Studio 2013 not found, trying Visual Studio 2015.
192                 set BUILD_VS_VER=14
193                 set BUILD_VS_YEAR=2015
194                 set BUILD_VS_LIBDIRPOST=vc14
195                 goto DetectMSVC
196         ) else (
197                 echo Error: "MSBuild" command not in the PATH.
198                 echo You must have MSVC installed and run this from the "Developer Command Prompt"
199                 echo ^(available from Visual Studio's Start menu entry^), aborting!
200                 goto EOF
201         )
202 )
203
204
205 set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
206 if NOT "%BUILD_DIR_OVERRRIDE%"=="" (
207         set BUILD_DIR=%BUILD_DIR_OVERRRIDE%
208 )
209
210 where /Q cmake
211 if %ERRORLEVEL% NEQ 0 (
212         echo Error: "CMake" command not in the PATH.
213         echo You must have CMake installed and added to your PATH, aborting!
214         goto EOF
215 )
216
217 if "%BUILD_ARCH%"=="x64" (
218         set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
219 ) else if "%BUILD_ARCH%"=="x86" (
220         set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
221 )
222 set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
223
224 if NOT EXIST %BUILD_VS_LIBDIR% (
225         rem libs not found, but svn is on the system
226         if not "%HAS_SVN%"=="" (
227                 echo.
228                 echo The required external libraries in %BUILD_VS_LIBDIR% are missing
229                 echo.
230                 set /p GetLibs= "Would you like to download them? (y/n)"
231                 if /I "!GetLibs!"=="Y" (
232                         echo.
233                         echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
234                         echo.
235                         svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
236                 )
237         )
238 )
239
240 if NOT EXIST %BUILD_VS_LIBDIR% (
241         echo Error: Path to libraries not found "%BUILD_VS_LIBDIR%"
242         echo This is needed for building, aborting!
243         goto EOF
244 )
245
246 if "%TARGET%"=="" (
247         echo Error: Convenience target not set
248         echo This is required for building, aborting!
249         echo .
250         goto HELP
251 )
252
253 set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
254 if NOT EXIST %BUILD_DIR%\nul (
255         mkdir %BUILD_DIR%
256 )
257 if "%MUST_CLEAN%"=="1" (
258         echo Cleaning %BUILD_DIR%
259         msbuild ^
260                 %BUILD_DIR%\Blender.sln ^
261                 /target:clean ^
262                 /property:Configuration=%BUILD_TYPE% ^
263                 /verbosity:minimal ^
264                 /p:platform=%MSBUILD_PLATFORM%
265
266         if %ERRORLEVEL% NEQ 0 (
267                 echo Cleaned "%BUILD_DIR%"
268         )
269         goto EOF
270 )
271 REM Only configure on first run or when called with nobuild
272 if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
273 if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
274
275 if "%MUST_CONFIGURE%"=="1" (
276         cmake ^
277                 %BUILD_CMAKE_ARGS% ^
278                 -H%BLENDER_DIR% ^
279                 -B%BUILD_DIR% ^
280                 %BUILD_CMAKE_ARGS%
281
282         if %ERRORLEVEL% NEQ 0 (
283                 echo "Configuration Failed"
284                 goto EOF
285         )
286 )
287 if DEFINED MSVC_VC_DIR echo call "%MSVC_VC_DIR%\vcvarsall.bat" > %BUILD_DIR%\rebuild.cmd
288 if DEFINED MSVC_VS_DIR echo call "%MSVC_VS_DIR%\Common7\Tools\VsDevCmd.bat" > %BUILD_DIR%\rebuild.cmd
289 echo cmake . >> %BUILD_DIR%\rebuild.cmd
290 echo msbuild ^
291         %BUILD_DIR%\Blender.sln ^
292         /target:build ^
293         /property:Configuration=%BUILD_TYPE% ^
294         /maxcpucount:2 ^
295         /verbosity:minimal ^
296         /p:platform=%MSBUILD_PLATFORM% ^
297         /flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log >> %BUILD_DIR%\rebuild.cmd
298 echo msbuild ^
299         %BUILD_DIR%\INSTALL.vcxproj ^
300         /property:Configuration=%BUILD_TYPE% ^
301         /verbosity:minimal ^
302         /p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd
303
304 if "%NOBUILD%"=="1" goto EOF
305
306 msbuild ^
307         %BUILD_DIR%\Blender.sln ^
308         /target:build ^
309         /property:Configuration=%BUILD_TYPE% ^
310         /maxcpucount:2 ^
311         /verbosity:minimal ^
312         /p:platform=%MSBUILD_PLATFORM% ^
313         /flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log
314
315 if %ERRORLEVEL% NEQ 0 (
316         echo "Build Failed"
317         goto EOF
318 )
319
320 msbuild ^
321         %BUILD_DIR%\INSTALL.vcxproj ^
322         /property:Configuration=%BUILD_TYPE% ^
323         /verbosity:minimal ^
324         /p:platform=%MSBUILD_PLATFORM%
325
326 echo.
327 echo At any point you can optionally modify your build configuration by editing:
328 echo "%BUILD_DIR%\CMakeCache.txt", then run "rebuild.cmd" in the build folder to build with the changes applied.
329 echo.
330 echo Blender successfully built, run from: "%BUILD_DIR%\bin\%BUILD_TYPE%\blender.exe"
331 echo.
332 goto EOF
333 :HELP
334         echo.
335         echo Convenience targets
336         echo - release ^(identical to the official blender.org builds^)
337         echo - full ^(same as release minus the cuda kernels^)
338         echo - lite
339         echo - headless
340         echo - cycles
341         echo - bpy
342         echo.
343         echo Utilities ^(not associated with building^)
344         echo - clean ^(Target must be set^)
345         echo - update
346         echo - nobuild ^(only generate project files^)
347         echo - showhash ^(Show git hashes of source tree^)
348         echo.
349         echo Configuration options
350         echo - with_tests ^(enable building unit tests^)
351         echo - noge ^(disable building game enginge and player^)
352         echo - debug ^(Build an unoptimized debuggable build^)
353         echo - packagename [newname] ^(override default cpack package name^)
354         echo - buildir [newdir] ^(override default build folder^)
355         echo - x86 ^(override host auto-detect and build 32 bit code^)
356         echo - x64 ^(override host auto-detect and build 64 bit code^)
357         echo - 2013 ^(build with visual studio 2013^)
358         echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL]
359         echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL]
360         echo.
361
362 :EOF