From 857e4e04d89f30727d60e16c7320a72718a76d1a Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 25 May 2018 17:57:13 -0600 Subject: 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. --- build_files/windows/autodetect_msvc.cmd | 17 ++++++ build_files/windows/build_msbuild.cmd | 26 ++++++++++ build_files/windows/check_libraries.cmd | 54 +++++++++++++++++++ build_files/windows/check_spaces_in_path.cmd | 6 +++ build_files/windows/check_submodules.cmd | 20 +++++++ build_files/windows/configure_msbuild.cmd | 57 ++++++++++++++++++++ build_files/windows/detect_architecture.cmd | 16 ++++++ build_files/windows/detect_msvc2013.cmd | 3 ++ build_files/windows/detect_msvc2015.cmd | 3 ++ build_files/windows/detect_msvc2017.cmd | 70 +++++++++++++++++++++++++ build_files/windows/detect_msvc_classic.cmd | 69 ++++++++++++++++++++++++ build_files/windows/find_dependencies.cmd | 13 +++++ build_files/windows/parse_arguments.cmd | 78 ++++++++++++++++++++++++++++ build_files/windows/reset_variables.cmd | 23 ++++++++ build_files/windows/set_build_dir.cmd | 4 ++ build_files/windows/show_hashes.cmd | 12 +++++ build_files/windows/show_help.cmd | 29 +++++++++++ build_files/windows/update_sources.cmd | 16 ++++++ 18 files changed, 516 insertions(+) create mode 100644 build_files/windows/autodetect_msvc.cmd create mode 100644 build_files/windows/build_msbuild.cmd create mode 100644 build_files/windows/check_libraries.cmd create mode 100644 build_files/windows/check_spaces_in_path.cmd create mode 100644 build_files/windows/check_submodules.cmd create mode 100644 build_files/windows/configure_msbuild.cmd create mode 100644 build_files/windows/detect_architecture.cmd create mode 100644 build_files/windows/detect_msvc2013.cmd create mode 100644 build_files/windows/detect_msvc2015.cmd create mode 100644 build_files/windows/detect_msvc2017.cmd create mode 100644 build_files/windows/detect_msvc_classic.cmd create mode 100644 build_files/windows/find_dependencies.cmd create mode 100644 build_files/windows/parse_arguments.cmd create mode 100644 build_files/windows/reset_variables.cmd create mode 100644 build_files/windows/set_build_dir.cmd create mode 100644 build_files/windows/show_hashes.cmd create mode 100644 build_files/windows/show_help.cmd create mode 100644 build_files/windows/update_sources.cmd (limited to 'build_files') 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 Visual Studio %BUILD_VS_YEAR% on Win64 detected at "%MSVC_VC_DIR%" + ) + goto msvc_detect_finally +) + +REM Check 32 bits +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\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 Visual Studio %BUILD_VS_YEAR% on Win32 detected at "%MSVC_VC_DIR%" + ) + goto msvc_detect_finally +) +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% not found. +) +goto FAIL +:msvc_detect_finally +set VCVARS=%MSVC_VC_DIR%\vcvarsall.bat +if not exist "%VCVARS%" ( + echo "%VCVARS%" not found. + goto FAIL +) + +call "%vcvars%" %BUILD_ARCH% + +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 +) +goto DetectionComplete + +:FAIL +exit /b 1 + +:DetectionComplete +if NOT "%verbose%" == "" ( + echo Visual Studio %BUILD_VS_YEAR% Detected successfuly +) +exit /b 0 diff --git a/build_files/windows/find_dependencies.cmd b/build_files/windows/find_dependencies.cmd new file mode 100644 index 00000000000..219e9801831 --- /dev/null +++ b/build_files/windows/find_dependencies.cmd @@ -0,0 +1,13 @@ +REM find all dependencies and set the corresponding environement variables. +for %%X in (svn.exe) do (set SVN=%%~$PATH:X) +for %%X in (cmake.exe) do (set CMAKE=%%~$PATH:X) +for %%X in (git.exe) do (set GIT=%%~$PATH:X) +if NOT "%verbose%" == "" ( + echo svn : %SVN% + echo cmake : %CMAKE% + echo git : %GIT% +) +if "%CMAKE%" == "" ( + echo Cmake not found in path, required for building, exiting... + exit /b 1 +) \ No newline at end of file diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd new file mode 100644 index 00000000000..5a82bf3cf04 --- /dev/null +++ b/build_files/windows/parse_arguments.cmd @@ -0,0 +1,78 @@ +set BUILD_DIR=%BLENDER_DIR%..\build_windows +set BUILD_TYPE=Release +:argv_loop +if NOT "%1" == "" ( + + REM Help Message + if "%1" == "help" ( + set SHOW_HELP=1 + goto EOF + ) + REM Build Types + if "%1" == "debug" ( + set BUILD_TYPE=Debug + REM Build Configurations + ) else if "%1" == "noge" ( + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_GAMEENGINE=OFF -DWITH_PLAYER=OFF + set BUILD_NGE=_noge + ) else if "%1" == "builddir" ( + set BUILD_DIR_OVERRRIDE="%BLENDER_DIR%..\%2" + shift /1 + ) else if "%1" == "with_tests" ( + set TESTS_CMAKE_ARGS=-DWITH_GTESTS=On + ) else if "%1" == "full" ( + set TARGET=Full + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% ^ + -C"%BLENDER_DIR%\build_files\cmake\config\blender_full.cmake" + ) else if "%1" == "lite" ( + set TARGET=Lite + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_lite.cmake" + ) else if "%1" == "cycles" ( + set TARGET=Cycles + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\cycles_standalone.cmake" + ) else if "%1" == "headless" ( + set TARGET=Headless + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_headless.cmake" + ) else if "%1" == "bpy" ( + set TARGET=Bpy + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\bpy_module.cmake" + ) else if "%1" == "release" ( + set TARGET=Release + ) else if "%1" == "x86" ( + set BUILD_ARCH=x86 + ) else if "%1" == "x64" ( + set BUILD_ARCH=x64 + ) else if "%1" == "2017" ( + set BUILD_VS_YEAR=2017 + ) else if "%1" == "2017pre" ( + set BUILD_VS_YEAR=2017 + set VSWHERE_ARGS=-prerelease + ) else if "%1" == "2015" ( + set BUILD_VS_YEAR=2015 + ) else if "%1" == "2013" ( + set BUILD_VS_YEAR=2013 + ) else if "%1" == "packagename" ( + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2" + shift /1 + ) else if "%1" == "nobuild" ( + set NOBUILD=1 + ) else if "%1" == "showhash" ( + SET BUILD_SHOW_HASHES=1 + REM Non-Build Commands + ) else if "%1" == "update" ( + SET BUILD_UPDATE=1 + ) else if "%1" == "ninja" ( + SET BUILD_WITH_NINJA=1 + ) else if "%1" == "clean" ( + set MUST_CLEAN=1 + ) else if "%1" == "verbose" ( + set VERBOSE=1 + ) else ( + echo Command "%1" unknown, aborting! + exit /b 1 + ) + shift /1 + goto argv_loop +) +:EOF +exit /b 0 \ No newline at end of file diff --git a/build_files/windows/reset_variables.cmd b/build_files/windows/reset_variables.cmd new file mode 100644 index 00000000000..34af3ff9389 --- /dev/null +++ b/build_files/windows/reset_variables.cmd @@ -0,0 +1,23 @@ +rem reset all variables so they do not get accidentally get carried over from previous builds +set BUILD_DIR_OVERRRIDE= +set BUILD_CMAKE_ARGS= +set BUILD_ARCH= +set BUILD_VS_VER= +set BUILD_VS_YEAR= +set BUILD_VS_LIBDIRPOST= +set BUILD_VS_LIBDIR= +set BUILD_VS_SVNDIR= +set BUILD_NGE= +set KEY_NAME= +set MSBUILD_PLATFORM= +set MUST_CLEAN= +set NOBUILD= +set TARGET= +set VERBOSE= +set WINDOWS_ARCH= +set TESTS_CMAKE_ARGS= +set VSWHERE_ARGS= +set BUILD_UPDATE= +set BUILD_SHOW_HASHES= +set SHOW_HELP= +set BUILD_WITH_NINJA= diff --git a/build_files/windows/set_build_dir.cmd b/build_files/windows/set_build_dir.cmd new file mode 100644 index 00000000000..8842a52eb5b --- /dev/null +++ b/build_files/windows/set_build_dir.cmd @@ -0,0 +1,4 @@ +set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE% +if NOT "%BUILD_DIR_OVERRRIDE%"=="" ( + set BUILD_DIR=%BUILD_DIR_OVERRRIDE% +) \ No newline at end of file diff --git a/build_files/windows/show_hashes.cmd b/build_files/windows/show_hashes.cmd new file mode 100644 index 00000000000..ff036733946 --- /dev/null +++ b/build_files/windows/show_hashes.cmd @@ -0,0 +1,12 @@ +if "%GIT%" == "" ( + echo Git not found, cannot show hashes. + goto EOF +) +cd "%BLENDER_DIR%" +for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Branch_hash=%%i +cd "%BLENDER_DIR%/release/datafiles/locale" +for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Locale_hash=%%i +cd "%BLENDER_DIR%/release/scripts/addons" +for /f "delims=" %%i in ('%GIT% rev-parse HEAD') do echo Addons_Hash=%%i +cd "%BLENDER_DIR%" +:EOF \ No newline at end of file diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd new file mode 100644 index 00000000000..0524e8a84fc --- /dev/null +++ b/build_files/windows/show_help.cmd @@ -0,0 +1,29 @@ +echo. +echo Convenience targets +echo - release ^(identical to the official blender.org builds^) +echo - full ^(same as release minus the cuda kernels^) +echo - lite +echo - headless +echo - cycles +echo - bpy +echo. +echo Utilities ^(not associated with building^) +echo - clean ^(Target must be set^) +echo - update +echo - nobuild ^(only generate project files^) +echo - showhash ^(Show git hashes of source tree^) +echo. +echo Configuration options +echo - verbose ^(enable diagnostic output during configuration^) +echo - with_tests ^(enable building unit tests^) +echo - noge ^(disable building game enginge and player^) +echo - debug ^(Build an unoptimized debuggable build^) +echo - packagename [newname] ^(override default cpack package name^) +echo - buildir [newdir] ^(override default build folder^) +echo - x86 ^(override host auto-detect and build 32 bit code^) +echo - x64 ^(override host auto-detect and build 64 bit code^) +echo - 2013 ^(build with visual studio 2013^) +echo - 2015 ^(build with visual studio 2015^) [EXPERIMENTAL] +echo - 2017 ^(build with visual studio 2017^) [EXPERIMENTAL] +echo - 2017pre ^(build with visual studio 2017 pre-release^) [EXPERIMENTAL] +echo. diff --git a/build_files/windows/update_sources.cmd b/build_files/windows/update_sources.cmd new file mode 100644 index 00000000000..22d93fabb95 --- /dev/null +++ b/build_files/windows/update_sources.cmd @@ -0,0 +1,16 @@ +if "%SVN%" == "" ( + echo svn not found, cannot update libraries + goto UPDATE_GIT +) +"%SVN%" up "%BLENDER_DIR%/../lib/*" + +:UPDATE_GIT + +if "%GIT%" == "" ( + echo Git not found, cannot update code + goto EOF +) +"%GIT%" pull --rebase +"%GIT%" submodule foreach git pull --rebase origin master + +:EOF \ No newline at end of file -- cgit v1.2.3 From c9db7ceff2546e0fc2967bafa279cf352d30c510 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Fri, 25 May 2018 21:46:42 -0600 Subject: make.bat: Add support for building with ninja. ninja is an alternative to msbuild designed for fast rebuilds. However there is no IDE support, builds only from the command line. Comparison between msbuild and ninja for a full build, build time in seconds. Full Clean Build msbuild 867.5 Ninja 801.2 Difference -66.3 (-7.6%) Minor Change msbuild 43.0 Ninja 14.9 Difference -28.1 (-64.4%) No Changes msbuild 23.0 Ninja 6.1 Difference -16.9 (-73.5%) --- build_files/cmake/platform/platform_win32.cmake | 2 ++ build_files/windows/build_msbuild.cmd | 4 +-- build_files/windows/build_ninja.cmd | 16 +++++++++++ build_files/windows/configure_msbuild.cmd | 2 ++ build_files/windows/configure_ninja.cmd | 35 +++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 build_files/windows/build_ninja.cmd create mode 100644 build_files/windows/configure_ninja.cmd (limited to 'build_files') diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index ef3ef7b6517..3520ac9c075 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -119,6 +119,8 @@ set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP}) set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .) include(InstallRequiredSystemLibraries) +remove_cc_flag("/MDd" "/MD") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP") diff --git a/build_files/windows/build_msbuild.cmd b/build_files/windows/build_msbuild.cmd index 37bd9abfe71..49958ed67c5 100644 --- a/build_files/windows/build_msbuild.cmd +++ b/build_files/windows/build_msbuild.cmd @@ -1,5 +1,5 @@ if "%NOBUILD%"=="1" goto EOF - +echo %TIME% > buildtime.txt msbuild ^ %BUILD_DIR%\Blender.sln ^ /target:build ^ @@ -22,5 +22,5 @@ msbuild ^ echo Error during install phase exit /b 1 ) - +echo %TIME% >>buildtime.txt :EOF \ No newline at end of file diff --git a/build_files/windows/build_ninja.cmd b/build_files/windows/build_ninja.cmd new file mode 100644 index 00000000000..f6b266e206d --- /dev/null +++ b/build_files/windows/build_ninja.cmd @@ -0,0 +1,16 @@ +if "%NOBUILD%"=="1" goto EOF +set HAS_ERROR= +cd %BUILD_DIR% +echo %TIME% > buildtime.txt +ninja install +if errorlevel 1 ( + set HAS_ERROR=1 + ) +echo %TIME% >>buildtime.txt +cd %BLENDER_DIR% + +if "%HAS_ERROR%" == "1" ( + echo Error during build, see %BUILD_DIR%\Build.log for details + 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 index 28884ce2fd7..135b7933ab2 100644 --- a/build_files/windows/configure_msbuild.cmd +++ b/build_files/windows/configure_msbuild.cmd @@ -42,6 +42,7 @@ if "%MUST_CONFIGURE%"=="1" ( echo call "%VCVARS%" %BUILD_ARCH% > %BUILD_DIR%\rebuild.cmd echo "%CMAKE%" . >> %BUILD_DIR%\rebuild.cmd +echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd echo msbuild ^ %BUILD_DIR%\Blender.sln ^ /target:build ^ @@ -55,3 +56,4 @@ echo msbuild ^ /property:Configuration=%BUILD_TYPE% ^ /verbosity:minimal ^ /p:platform=%MSBUILD_PLATFORM% >> %BUILD_DIR%\rebuild.cmd +echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd \ No newline at end of file diff --git a/build_files/windows/configure_ninja.cmd b/build_files/windows/configure_ninja.cmd new file mode 100644 index 00000000000..13797543bcc --- /dev/null +++ b/build_files/windows/configure_ninja.cmd @@ -0,0 +1,35 @@ +set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -G "Ninja" %TESTS_CMAKE_ARGS% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% +:DetectionComplete +if NOT "%verbose%" == "" ( + echo BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% +) + +if NOT EXIST %BUILD_DIR%\nul ( + mkdir %BUILD_DIR% +) + +if "%MUST_CLEAN%"=="1" ( + echo Cleaning %BUILD_DIR% + cd %BUILD_DIR% + %CMAKE% cmake --build . --config Clean +) + +if NOT EXIST %BUILD_DIR%\Blender.sln set MUST_CONFIGURE=1 +if "%NOBUILD%"=="1" set MUST_CONFIGURE=1 + +if "%MUST_CONFIGURE%"=="1" ( + 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 echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd +echo ninja install >> %BUILD_DIR%\rebuild.cmd +echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd \ No newline at end of file -- cgit v1.2.3 From 7a0699db34aa20d96e317202fee7d1266ff3b274 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Sat, 26 May 2018 19:20:07 -0600 Subject: make.bat : Fix builtime.txt being written in the wrong folder. --- build_files/windows/build_msbuild.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'build_files') diff --git a/build_files/windows/build_msbuild.cmd b/build_files/windows/build_msbuild.cmd index 49958ed67c5..6ca5f1b0df8 100644 --- a/build_files/windows/build_msbuild.cmd +++ b/build_files/windows/build_msbuild.cmd @@ -1,5 +1,5 @@ if "%NOBUILD%"=="1" goto EOF -echo %TIME% > buildtime.txt +echo %TIME% > %BUILD_DIR%\buildtime.txt msbuild ^ %BUILD_DIR%\Blender.sln ^ /target:build ^ @@ -22,5 +22,5 @@ msbuild ^ echo Error during install phase exit /b 1 ) -echo %TIME% >>buildtime.txt +echo %TIME% >> %BUILD_DIR%\buildtime.txt :EOF \ No newline at end of file -- cgit v1.2.3