1@rem Copyright 2020 Huawei Technologies Co., Ltd 2@rem 3@rem Licensed under the Apache License, Version 2.0 (the "License"); 4@rem you may not use this file except in compliance with the License. 5@rem You may obtain a copy of the License at 6@rem 7@rem http://www.apache.org/licenses/LICENSE-2.0 8@rem 9@rem Unless required by applicable law or agreed to in writing, software 10@rem distributed under the License is distributed on an "AS IS" BASIS, 11@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12@rem See the License for the specific language governing permissions and 13@rem limitations under the License. 14@rem ============================================================================ 15@echo off 16@title mindspore_build 17 18SET BASE_PATH=%CD% 19SET BUILD_PATH=%BASE_PATH%/build 20 21SET threads=8 22SET ENABLE_GITEE=OFF 23 24set VERSION_MAJOR='' 25set VERSION_MINOR='' 26set ERSION_REVISION='' 27 28for /f "delims=\= tokens=2" %%a in ('findstr /C:"const int ms_version_major = " mindspore\lite\include\version.h') do (set x=%%a) 29set VERSION_MAJOR=%x:~1,1% 30for /f "delims=\= tokens=2" %%b in ('findstr /C:"const int ms_version_minor = " mindspore\lite\include\version.h') do (set y=%%b) 31set VERSION_MINOR=%y:~1,1% 32for /f "delims=\= tokens=2" %%c in ('findstr /C:"const int ms_version_revision = " mindspore\lite\include\version.h') do (set z=%%c) 33set VERSION_REVISION=%z:~1,1% 34 35ECHO %2%|FINDSTR "^[0-9][0-9]*$" 36IF %errorlevel% == 0 ( 37 SET threads=%2% 38) 39 40IF "%FROM_GITEE%" == "1" ( 41 echo "DownLoad from gitee" 42 SET ENABLE_GITEE=ON 43) 44 45IF NOT EXIST "%BUILD_PATH%" ( 46 md "build" 47) 48cd %BUILD_PATH% 49IF NOT EXIST "%BUILD_PATH%/mindspore" ( 50 md "mindspore" 51) 52 53cd %BUILD_PATH%/mindspore 54IF "%1%" == "lite" ( 55 echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======" 56 rd /s /q "%BASE_PATH%\output" 57 (git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id 58 IF defined VisualStudioVersion ( 59 cmake -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^ 60 -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^ 61 -DCMAKE_BUILD_TYPE=Release -G "Ninja" "%BASE_PATH%/mindspore/lite" 62 ) ELSE ( 63 cmake -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^ 64 -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^ 65 -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite" 66 ) 67) ELSE ( 68 cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ 69 -G "CodeBlocks - MinGW Makefiles" ../.. 70) 71IF NOT %errorlevel% == 0 ( 72 echo "cmake fail." 73 call :clean 74 EXIT /b 1 75) 76 77cmake --build . --target package -- -j%threads% 78IF NOT %errorlevel% == 0 ( 79 echo "build fail." 80 call :clean 81 EXIT /b 1 82) 83 84call :clean 85EXIT /b 0 86 87:clean 88 IF EXIST "%BASE_PATH%/output" ( 89 cd %BASE_PATH%/output 90 rd /s /q _CPack_Packages 91 ) 92 cd %BASE_PATH%