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.6 kB

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