make.bat: Add support for building with ninja.
authorRay Molenkamp <github@lazydodo.com>
Sat, 26 May 2018 03:46:42 +0000 (21:46 -0600)
committerRay Molenkamp <github@lazydodo.com>
Sat, 26 May 2018 03:46:42 +0000 (21:46 -0600)
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
build_files/windows/build_msbuild.cmd
build_files/windows/build_ninja.cmd [new file with mode: 0644]
build_files/windows/configure_msbuild.cmd
build_files/windows/configure_ninja.cmd [new file with mode: 0644]
make.bat

index ef3ef7b..3520ac9 100644 (file)
@@ -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")
 
index 37bd9ab..49958ed 100644 (file)
@@ -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 (file)
index 0000000..f6b266e
--- /dev/null
@@ -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
index 28884ce..135b793 100644 (file)
@@ -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 (file)
index 0000000..1379754
--- /dev/null
@@ -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
index ee65f4a..577f820 100644 (file)
--- a/make.bat
+++ b/make.bat
@@ -52,10 +52,18 @@ if errorlevel 1 goto EOF
 call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd" 
 if errorlevel 1 goto EOF
 
-call "%BLENDER_DIR%\build_files\windows\configure_msbuild.cmd" 
-if errorlevel 1 goto EOF
+if "%BUILD_WITH_NINJA%" == "" (
+       call "%BLENDER_DIR%\build_files\windows\configure_msbuild.cmd" 
+       if errorlevel 1 goto EOF
 
-call "%BLENDER_DIR%\build_files\windows\build_msbuild.cmd" 
-if errorlevel 1 goto EOF
+       call "%BLENDER_DIR%\build_files\windows\build_msbuild.cmd" 
+       if errorlevel 1 goto EOF
+) else (
+       call "%BLENDER_DIR%\build_files\windows\configure_ninja.cmd" 
+       if errorlevel 1 goto EOF
+
+       call "%BLENDER_DIR%\build_files\windows\build_ninja.cmd" 
+       if errorlevel 1 goto EOF
+)
 
 :EOF
\ No newline at end of file