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

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