You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.bat 2.8 kB

4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. SET BASE_PATH=%CD%
  18. SET BUILD_PATH=%BASE_PATH%/build
  19. SET threads=6
  20. SET ENABLE_GITEE=OFF
  21. set VERSION_MAJOR=''
  22. set VERSION_MINOR=''
  23. set ERSION_REVISION=''
  24. for /f "delims=\= tokens=2" %%a in ('findstr /C:"const int ms_version_major = " mindspore\lite\include\version.h') do (set x=%%a)
  25. set VERSION_MAJOR=%x:~1,1%
  26. for /f "delims=\= tokens=2" %%b in ('findstr /C:"const int ms_version_minor = " mindspore\lite\include\version.h') do (set y=%%b)
  27. set VERSION_MINOR=%y:~1,1%
  28. for /f "delims=\= tokens=2" %%c in ('findstr /C:"const int ms_version_revision = " mindspore\lite\include\version.h') do (set z=%%c)
  29. set VERSION_REVISION=%z:~1,1%
  30. ECHO %2%|FINDSTR "^[0-9][0-9]*$"
  31. IF %errorlevel% == 0 (
  32. SET threads=%2%
  33. )
  34. IF "%FROM_GITEE%" == "1" (
  35. echo "DownLoad from gitee"
  36. SET ENABLE_GITEE=ON
  37. )
  38. IF NOT EXIST "%BUILD_PATH%" (
  39. md "build"
  40. )
  41. cd %BUILD_PATH%
  42. IF NOT EXIST "%BUILD_PATH%/mindspore" (
  43. md "mindspore"
  44. )
  45. cd %BUILD_PATH%/mindspore
  46. IF "%1%" == "lite" (
  47. echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======"
  48. rd /s /q "%BASE_PATH%\output"
  49. (git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id
  50. cmake -DPLATFORM_X86_64=on -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^
  51. -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
  52. -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
  53. ) ELSE (
  54. cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
  55. -G "CodeBlocks - MinGW Makefiles" ../..
  56. )
  57. IF NOT %errorlevel% == 0 (
  58. echo "cmake fail."
  59. call :clean
  60. EXIT /b 1
  61. )
  62. cmake --build . --target package -- -j%threads%
  63. IF NOT %errorlevel% == 0 (
  64. echo "build fail."
  65. call :clean
  66. EXIT /b 1
  67. )
  68. call :clean
  69. EXIT /b 0
  70. :clean
  71. IF EXIST "%BASE_PATH%/output" (
  72. cd %BASE_PATH%/output
  73. rd /s /q _CPack_Packages
  74. )
  75. cd %BASE_PATH%