[Bf-blender-cvs] [a554255c132] gsoc-2018-many-light-sampling: make.bat: refactor make.bat

Ray Molenkamp noreply at git.blender.org
Fri Jun 1 16:17:43 CEST 2018


Commit: a554255c1329d17e6d40503393224f72b6360338
Author: Ray Molenkamp
Date:   Fri May 25 17:57:13 2018 -0600
Branches: gsoc-2018-many-light-sampling
https://developer.blender.org/rBa554255c1329d17e6d40503393224f72b6360338

make.bat: refactor make.bat

make.bat was starting to become hard to maintain, this refactors it into separate batch files for each stage of the process.

-Improved detection of msvc2013/2015
-Improved failure handling.
-Added check for working msbuild and C++ compiler
-Added verbose switch to ease trouble shooting.
-Added Check if svn/cmake/git are in the path before using them
-Display the build configuration before asking to download the libraries
-Offer an option to recover an interrupted checkout of the libraries.
-Automatically check out sub-modules in-case they are missing.

===================================================================

A	build_files/windows/autodetect_msvc.cmd
A	build_files/windows/build_msbuild.cmd
A	build_files/windows/check_libraries.cmd
A	build_files/windows/check_spaces_in_path.cmd
A	build_files/windows/check_submodules.cmd
A	build_files/windows/configure_msbuild.cmd
A	build_files/windows/detect_architecture.cmd
A	build_files/windows/detect_msvc2013.cmd
A	build_files/windows/detect_msvc2015.cmd
A	build_files/windows/detect_msvc2017.cmd
A	build_files/windows/detect_msvc_classic.cmd
A	build_files/windows/find_dependencies.cmd
A	build_files/windows/parse_arguments.cmd
A	build_files/windows/reset_variables.cmd
A	build_files/windows/set_build_dir.cmd
A	build_files/windows/show_hashes.cmd
A	build_files/windows/show_help.cmd
A	build_files/windows/update_sources.cmd
M	make.bat

===================================================================

diff --git a/build_files/windows/autodetect_msvc.cmd b/build_files/windows/autodetect_msvc.cmd
new file mode 100644
index 00000000000..6fce3829e7b
--- /dev/null
+++ b/build_files/windows/autodetect_msvc.cmd
@@ -0,0 +1,17 @@
+echo No explicit msvc version requested, autodetecting version.
+
+call "%~dp0\detect_msvc2013.cmd"
+if %ERRORLEVEL% EQU 0 goto DetectionComplete
+
+call "%~dp0\detect_msvc2015.cmd"
+if %ERRORLEVEL% EQU 0 goto DetectionComplete
+
+call "%~dp0\detect_msvc2017.cmd"
+if %ERRORLEVEL% EQU 0 goto DetectionComplete
+
+echo Compiler Detection failed. Use verbose switch for more information. 
+exit /b 1
+
+:DetectionComplete
+echo Compiler Detection successfull, detected VS%BUILD_VS_YEAR%
+exit /b 0
\ No newline at end of file
diff --git a/build_files/windows/build_msbuild.cmd b/build_files/windows/build_msbuild.cmd
new file mode 100644
index 00000000000..37bd9abfe71
--- /dev/null
+++ b/build_files/windows/build_msbuild.cmd
@@ -0,0 +1,26 @@
+if "%NOBUILD%"=="1" goto EOF
+
+msbuild ^
+	%BUILD_DIR%\Blender.sln ^
+	/target:build ^
+	/property:Configuration=%BUILD_TYPE% ^
+	/maxcpucount:2 ^
+	/verbosity:minimal ^
+	/p:platform=%MSBUILD_PLATFORM% ^
+	/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log 
+	if errorlevel 1 (
+		echo Error during build, see %BUILD_DIR%\Build.log for details 
+		exit /b 1
+	)
+
+msbuild ^
+	%BUILD_DIR%\INSTALL.vcxproj ^
+	/property:Configuration=%BUILD_TYPE% ^
+	/verbosity:minimal ^
+	/p:platform=%MSBUILD_PLATFORM% 
+	if errorlevel 1 (
+		echo Error during install phase
+		exit /b 1
+	)
+
+:EOF
\ No newline at end of file
diff --git a/build_files/windows/check_libraries.cmd b/build_files/windows/check_libraries.cmd
new file mode 100644
index 00000000000..c8aad7c9adb
--- /dev/null
+++ b/build_files/windows/check_libraries.cmd
@@ -0,0 +1,54 @@
+if "%BUILD_VS_YEAR%"=="2013" set BUILD_VS_LIBDIRPOST=vc12
+if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14
+if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14
+
+if "%BUILD_ARCH%"=="x64" (
+	set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
+) else if "%BUILD_ARCH%"=="x86" (
+	set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
+)
+set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
+
+if NOT "%verbose%" == "" (
+	echo Library Directory = "%BUILD_VS_LIBDIR%"
+)
+if NOT EXIST %BUILD_VS_LIBDIR% (
+	rem libs not found, but svn is on the system
+	echo 
+	if not "%SVN%"=="" (
+		echo.
+		echo The required external libraries in %BUILD_VS_LIBDIR% are missing
+		echo.
+		set /p GetLibs= "Would you like to download them? (y/n)"
+		if /I "!GetLibs!"=="Y" (
+			echo.
+			echo Downloading %BUILD_VS_SVNDIR% libraries, please wait.
+			echo.
+:RETRY			
+			"%SVN%" checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/%BUILD_VS_SVNDIR% %BUILD_VS_LIBDIR%
+			if errorlevel 1 (
+				set /p LibRetry= "Error during donwload, retry? y/n"
+				if /I "!LibRetry!"=="Y" (
+					cd %BUILD_VS_LIBDIR%
+					"%SVN%" cleanup 
+					cd %BLENDER_DIR%
+					goto RETRY
+				)
+				echo.
+				echo Error: Download of external libraries failed. 
+				echo This is needed for building, please manually run 'svn cleanup' and 'svn update' in
+				echo %BUILD_VS_LIBDIR% , until this is resolved you CANNOT make a successfull blender build
+				echo.
+				exit /b 1
+			)
+		)
+	)
+)
+
+if NOT EXIST %BUILD_VS_LIBDIR% (
+	echo.
+	echo Error: Required libraries not found at "%BUILD_VS_LIBDIR%"
+	echo This is needed for building, aborting!
+	echo.
+	exit /b 1
+)
\ No newline at end of file
diff --git a/build_files/windows/check_spaces_in_path.cmd b/build_files/windows/check_spaces_in_path.cmd
new file mode 100644
index 00000000000..2e9300ae6d5
--- /dev/null
+++ b/build_files/windows/check_spaces_in_path.cmd
@@ -0,0 +1,6 @@
+set BLENDER_DIR_NOSPACES=%BLENDER_DIR: =%
+
+if not "%BLENDER_DIR%"=="%BLENDER_DIR_NOSPACES%" (
+	echo There are spaces detected in the build path "%BLENDER_DIR%", this is currently not supported, exiting....
+	exit /b 1
+)
\ No newline at end of file
diff --git a/build_files/windows/check_submodules.cmd b/build_files/windows/check_submodules.cmd
new file mode 100644
index 00000000000..c0c64148dd7
--- /dev/null
+++ b/build_files/windows/check_submodules.cmd
@@ -0,0 +1,20 @@
+if NOT exist "%BLENDER_DIR%/source/tools" (
+	echo Checking out sub-modules 
+	if not "%GIT%" == "" (
+		"%GIT%" submodule update --init --recursive --progress
+		if errorlevel 1 goto FAIL
+		"%GIT%" submodule foreach git checkout master
+		if errorlevel 1 goto FAIL
+		"%GIT%" submodule foreach git pull --rebase origin master
+		if errorlevel 1 goto FAIL
+		goto EOF
+	) else (
+		echo Blender submodules not found, and git not found in path to retrieve them.
+		goto FAIL
+	)
+)
+goto EOF
+
+:FAIL
+exit /b 1
+:EOF
\ No newline at end of file
diff --git a/build_files/windows/configure_msbuild.cmd b/build_files/windows/configure_msbuild.cmd
new file mode 100644
index 00000000000..28884ce2fd7
--- /dev/null
+++ b/build_files/windows/configure_msbuild.cmd
@@ -0,0 +1,57 @@
+set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Visual Studio %BUILD_VS_VER% %BUILD_VS_YEAR%%WINDOWS_ARCH%" %TESTS_CMAKE_ARGS%
+
+if "%BUILD_ARCH%"=="x64" (
+	set MSBUILD_PLATFORM=x64
+) else if "%BUILD_ARCH%"=="x86" (
+	set MSBUILD_PLATFORM=win32
+)
+
+if NOT EXIST %BUILD_DIR%\nul (
+	mkdir %BUILD_DIR%
+)
+
+if "%MUST_CLEAN%"=="1" (
+	echo Cleaning %BUILD_DIR%
+	msbuild ^
+		%BUILD_DIR%\Blender.sln ^
+		/target:clean ^
+		/property:Configuration=%BUILD_TYPE% ^
+		/verbosity:minimal ^
+		/p:platform=%MSBUILD_PLATFORM%
+)
+
+if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1
+if "%NOBUILD%"=="1" set MUST_CONFIGURE=1
+
+if "%MUST_CONFIGURE%"=="1" (
+
+	if NOT "%verbose%" == "" (
+		echo %CMAKE% %BUILD_CMAKE_ARGS% -H%BLENDER_DIR% -B%BUILD_DIR% 
+	)
+
+	cmake ^
+		%BUILD_CMAKE_ARGS% ^
+		-H%BLENDER_DIR% ^
+		-B%BUILD_DIR% 
+
+	if %ERRORLEVEL% NEQ 0 (
+		echo "Configuration Failed"
+		exit /b 1
+	)
+)
+
+echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd
+echo "%CMAKE%" . >> %BUILD_DIR%\rebuild.cmd
+echo msbuild ^
+	%BUILD_DIR%\Blender.sln ^
+	/target:build ^
+	/property:Configuration=%BUILD_TYPE% ^
+	/maxcpucount:2 ^
+	/verbosity:minimal ^
+	/p:platform=%MSBUILD_PLATFORM% ^
+	/flp:Summary;Verbosity=minimal;LogFile=%BUILD_DIR%\Build.log >> %BUILD_DIR%\rebuild.cmd
+echo msbuild ^
+	%BUILD_DIR%\INSTALL.vcxproj ^
+	/property:Configuration=%BUILD_TYPE% ^
+	/verbosity:minimal ^
+	/p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd
diff --git a/build_files/windows/detect_architecture.cmd b/build_files/windows/detect_architecture.cmd
new file mode 100644
index 00000000000..cd211668b7f
--- /dev/null
+++ b/build_files/windows/detect_architecture.cmd
@@ -0,0 +1,16 @@
+if "%BUILD_ARCH%"=="" (
+	if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
+		set WINDOWS_ARCH= Win64
+		set BUILD_ARCH=x64
+	) else if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
+		set WINDOWS_ARCH= Win64
+		set BUILD_ARCH=x64
+	) else (
+		set WINDOWS_ARCH=
+		set BUILD_ARCH=x86
+	)
+) else if "%BUILD_ARCH%"=="x64" (
+	set WINDOWS_ARCH= Win64
+) else if "%BUILD_ARCH%"=="x86" (
+	set WINDOWS_ARCH=
+)
diff --git a/build_files/windows/detect_msvc2013.cmd b/build_files/windows/detect_msvc2013.cmd
new file mode 100644
index 00000000000..5688d31c4b6
--- /dev/null
+++ b/build_files/windows/detect_msvc2013.cmd
@@ -0,0 +1,3 @@
+set BUILD_VS_VER=12
+set BUILD_VS_YEAR=2013
+call "%~dp0\detect_msvc_classic.cmd"
\ No newline at end of file
diff --git a/build_files/windows/detect_msvc2015.cmd b/build_files/windows/detect_msvc2015.cmd
new file mode 100644
index 00000000000..0818d1dfffc
--- /dev/null
+++ b/build_files/windows/detect_msvc2015.cmd
@@ -0,0 +1,3 @@
+set BUILD_VS_VER=14
+set BUILD_VS_YEAR=2015
+call "%~dp0\detect_msvc_classic.cmd"
\ No newline at end of file
diff --git a/build_files/windows/detect_msvc2017.cmd b/build_files/windows/detect_msvc2017.cmd
new file mode 100644
index 00000000000..6a82adb5a4d
--- /dev/null
+++ b/build_files/windows/detect_msvc2017.cmd
@@ -0,0 +1,70 @@
+if NOT "%verbose%" == "" (
+	echo Detecting msvc 2017
+)
+set BUILD_VS_VER=15
+set ProgramFilesX86=%ProgramFiles(x86)%
+if not exist "%ProgramFilesX86%" set ProgramFilesX86=%ProgramFiles%
+
+set vs_where=%ProgramFilesX86%\Microsoft Visual Studio\Installer\vswhere.exe
+if not exist "%vs_where%" (
+	if NOT "%verbose%" == "" (
+		echo Visual Studio 2017 ^(15.2 or newer^) is not detected
+		goto FAIL
+	)
+)
+for /f "usebackq tokens=1* delims=: " %%i in (`"%vs_where%" -latest %VSWHERE_ARGS% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`) do (
+	if /i "%%i"=="installationPath" set VS_InstallDir=%%j
+)
+
+if "%VS_InstallDir%"=="" (
+	if NOT "%verbose%" == "" (
+		echo Visual Studio is detected but the "Desktop development with C++" workload has not been instlled
+		goto FAIL
+	)
+)
+
+set VCVARS=%VS_InstallDir%\VC\Auxiliary\Build\vcvarsall.bat
+if exist "%VCVARS%" (
+	call "%VCVARS%" %BUILD_ARCH%
+) else (
+	if NOT "%verbose%" == "" (
+		echo "%VCVARS%" not found
+	)
+	goto FAIL
+)
+
+rem try msbuild
+msbuild /version > NUL 
+if errorlevel 1 (
+	if NOT "%verbose%" == "" (
+		echo Visual Studio %BUILD_VS_YEAR% msbuild not found
+	)
+	goto FAIL
+)
+
+if NOT "%verbose%" == "" (
+		echo Visual Studio %BUILD_VS_YEAR% msbuild found 
+)
+
+REM try the c++ compiler
+cl 2> NUL 1>&2
+if errorlevel 1 (
+	if NOT "%verbose%" == "" (
+		echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found
+	)
+	goto FAIL
+)
+
+if NOT "%verbose%" == "" (
+		echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found
+)
+
+if NOT "%verbose%" == "" (
+	echo Visual Studio 2017 is detected successfully  
+)
+goto EOF
+
+:FAIL
+exit /b 1 
+
+:EOF
diff --git a/build_files/windows/detect_msvc_classic.cmd b/build_files/windows/detect_msvc_classic.cmd
new file mode 100644
index 00000000000..61bfcf92ddf
--- /dev/null
+++ b/build_files/windows/detect_msvc_classic.cmd
@@ -0,0 +1,69 @@
+if NOT "%verbose%" == "" (
+	echo Detecting msvc %BUILD_VS_YEAR%
+)
+set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%BUILD_VS_VER%.0\Setup\VC"
+for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v ProductDir 2^>nul`) DO set MSVC_VC_DIR=%%C
+if DEFINED MSVC_VC_DIR (
+	if NOT "%verbose%" == "" (
+		echo Vis

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list