diff --git a/build.bat b/build.bat index da9af092e05..07f9676a1a2 100644 --- a/build.bat +++ b/build.bat @@ -15,6 +15,8 @@ @echo off @title mindspore_build +setlocal EnableDelayedExpansion + @echo off echo Start build at: %date% %time% @@ -23,7 +25,6 @@ SET BUILD_PATH=%BASE_PATH%/build SET threads=8 SET ENABLE_GITEE=OFF -SET ENABLE_INCREDIBUILD=OFF SET ENABLE_MSVC=OFF set BUILD_TYPE=Release set VERSION_STR='' @@ -47,14 +48,6 @@ IF %errorlevel% == 0 ( echo "use mingw compiler" ) -where buildconsole -IF %errorlevel% == 0 ( - echo "use buildconsole to speed up compile" - SET ENABLE_INCREDIBUILD=ON -) else ( - echo "fail to find buildconsole" -) - IF NOT EXIST "%BUILD_PATH%" ( md "build" ) @@ -82,8 +75,17 @@ IF "%1%" == "lite" ( -G "Visual Studio 16 2019" -A x64 ../.. ) ELSE IF "%1%" == "ms_vs_cpu" ( echo "======Start gen VS2019 Project for MS cpu ======" - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ - -G "Visual Studio 16 2019" -A x64 ../.. + for /f "delims=" %%i in ('powershell.exe -ExecutionPolicy Bypass -Command "Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | foreach { Get-ItemProperty $_.PsPath } | where { $_.DisplayName -like '*Visual Studio*' -and $_.InstallLocation.Length -gt 0 } | sort InstallDate -Descending | foreach { Join-Path $_.InstallLocation 'VC\Auxiliary\Build'}"') do (call "%%i\vcvars64.bat") + where sccache + IF !errorlevel! == 0 ( + echo "use sccache to speed up compile" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ + -G Ninja ../.. + ) ELSE ( + echo "fail to find sccache" + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ + -G Ninja ../.. + ) ) ELSE IF "%1%" == "ms_vs_cpu_debug" ( echo "======Start gen VS2019 Project for MS cpu debug======" cmake -DCMAKE_BUILD_TYPE=Debug -DDEBUG_MODE=ON -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ @@ -102,11 +104,7 @@ IF NOT %errorlevel% == 0 ( ) IF ON == %ENABLE_MSVC% ( - IF ON == %ENABLE_INCREDIBUILD% ( - buildconsole /command="cmake --build . --config %BUILD_TYPE% --target package" - ) ELSE ( - cmake --build . --config %BUILD_TYPE% --target package - ) + cmake --build . --config %BUILD_TYPE% --target package ) ELSE ( cmake --build . --target package -- -j%threads% ) diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt index f55440fbb51..7cbe4ace453 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/nnacl/CMakeLists.txt @@ -281,6 +281,8 @@ if(PLATFORM_ARM) set(nnacl_static_obj ${nnacl_static_obj} $) endif() endif() -add_library(nnacl_static STATIC ${nnacl_static_obj}) -set_target_properties(nnacl_static PROPERTIES OUTPUT_NAME "nnacl") -set_target_properties(nnacl_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +if(NOT ${CMAKE_GENERATOR} MATCHES "Ninja") + add_library(nnacl_static STATIC ${nnacl_static_obj}) + set_target_properties(nnacl_static PROPERTIES OUTPUT_NAME "nnacl") + set_target_properties(nnacl_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +endif()