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 3.5 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 X86_64_SIMD=off
  21. SET ENABLE_GITEE=OFF
  22. set VERSION_MAJOR=''
  23. set VERSION_MINOR=''
  24. set ERSION_REVISION=''
  25. for /f "delims=\= tokens=2" %%a in ('findstr /C:"const int ms_version_major = " mindspore\lite\include\version.h') do (set x=%%a)
  26. set VERSION_MAJOR=%x:~1,1%
  27. for /f "delims=\= tokens=2" %%b in ('findstr /C:"const int ms_version_minor = " mindspore\lite\include\version.h') do (set y=%%b)
  28. set VERSION_MINOR=%y:~1,1%
  29. for /f "delims=\= tokens=2" %%c in ('findstr /C:"const int ms_version_revision = " mindspore\lite\include\version.h') do (set z=%%c)
  30. set VERSION_REVISION=%z:~1,1%
  31. echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======"
  32. ECHO %2%|FINDSTR "^[0-9][0-9]*$"
  33. IF %errorlevel% == 0 (
  34. SET threads=%2%
  35. ) ELSE (
  36. IF NOT "%2%" == "" (
  37. IF "%2%" == "avx" (
  38. SET X86_64_SIMD=avx
  39. ) ELSE IF "%2%" == "sse" (
  40. SET X86_64_SIMD=sse
  41. ) ELSE IF "%2%" == "off" (
  42. SET X86_64_SIMD=off
  43. ) ELSE IF "%2%" == "avx512" (
  44. SET X86_64_SIMD=avx512
  45. ) ELSE (
  46. echo "MindSpore_lite the second parameter must in [avx, avx512, sse, off], but now is [%2%]"
  47. call :clean
  48. EXIT /b 1
  49. )
  50. IF NOT "%3%" == "" (
  51. SET threads=%3%
  52. )
  53. )
  54. )
  55. IF "%FROM_GITEE%" == "1" (
  56. echo "DownLoad from gitee"
  57. SET ENABLE_GITEE=ON
  58. )
  59. IF NOT EXIST "%BUILD_PATH%" (
  60. md "build"
  61. )
  62. cd %BUILD_PATH%
  63. IF NOT EXIST "%BUILD_PATH%/mindspore" (
  64. md "mindspore"
  65. )
  66. cd %BUILD_PATH%/mindspore
  67. IF "%1%" == "lite" (
  68. cmake --build "%BUILD_PATH%\mindspore" --target clean
  69. rd /s /q "%BASE_PATH%\output"
  70. (git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id
  71. cmake -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=off ^
  72. -DENABLE_TOOLS=on -DENABLE_CONVERTER=on -DBUILD_TESTCASES=off ^
  73. -DCMAKE_BUILD_TYPE=Release -DSUPPORT_GPU=off -DBUILD_MINDDATA=off -DOFFLINE_COMPILE=off ^
  74. -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
  75. -DX86_64_SIMD=%X86_64_SIMD% ^
  76. -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
  77. ) ELSE (
  78. cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
  79. -G "CodeBlocks - MinGW Makefiles" ../..
  80. )
  81. IF NOT %errorlevel% == 0 (
  82. echo "cmake fail."
  83. call :clean
  84. EXIT /b 1
  85. )
  86. cmake --build . --target package -- -j%threads%
  87. IF NOT %errorlevel% == 0 (
  88. echo "build fail."
  89. call :clean
  90. EXIT /b 1
  91. )
  92. call :clean
  93. EXIT /b 0
  94. :clean
  95. IF EXIST "%BASE_PATH%/output" (
  96. cd %BASE_PATH%/output
  97. rd /s /q _CPack_Packages
  98. )
  99. cd %BASE_PATH%