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

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