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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 BASEPATH=%CD%
  18. SET BUILD_PATH=%BASEPATH%/build
  19. IF NOT EXIST "%BUILD_PATH%" (
  20. md "build"
  21. )
  22. cd %BUILD_PATH%
  23. IF NOT EXIST "%BUILD_PATH%/mindspore" (
  24. md "mindspore"
  25. )
  26. cd %CD%/mindspore
  27. IF "%1%" == "lite" (
  28. call :run_cmake
  29. IF errorlevel 1 (
  30. echo "cmake fail one time."
  31. call :gene_protobuf
  32. call :gene_flatbuffer
  33. call :run_cmake
  34. IF errorlevel 1 (
  35. echo "cmake fail."
  36. call :run_fail
  37. )
  38. ) ELSE (
  39. call :gene_protobuf
  40. call :gene_flatbuffer
  41. )
  42. cd %BUILD_PATH%/mindspore
  43. IF "%2%" == "" (
  44. cmake --build . --target package -- -j6
  45. ) ELSE (
  46. cmake --build . --target package -- -j%2%
  47. )
  48. IF errorlevel 1 (
  49. echo "build fail."
  50. call :run_fail
  51. ) ELSE (
  52. cd %BASEPATH%/output
  53. rd /s /q _CPack_Packages
  54. )
  55. ) ELSE (
  56. cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON ^
  57. -G "CodeBlocks - MinGW Makefiles" ../..
  58. IF NOT %errorlevel% == 0 (
  59. echo "cmake fail."
  60. call :run_fail
  61. )
  62. IF "%1%" == "" (
  63. cmake --build . --target package -- -j6
  64. ) ELSE (
  65. cmake --build . --target package -- -j%1%
  66. )
  67. IF NOT %errorlevel% == 0 (
  68. echo "build fail."
  69. call :run_fail
  70. )
  71. )
  72. cd %BASEPATH%
  73. goto run_eof
  74. :run_cmake
  75. cd %BASEPATH%
  76. for /F %%i in ('find "const int ms_version_major =" mindspore\lite\include\version.h ^| tr -dc "[0-9]"') do ( set VERSION_MAJOR=%%i)
  77. for /F %%i in ('find "const int ms_version_minor =" mindspore\lite\include\version.h ^| tr -dc "[0-9]"') do ( set VERSION_MINOR=%%i)
  78. for /F %%i in ('find "const int ms_version_revision =" mindspore\lite\include\version.h ^| tr -dc "[0-9]"') do ( set VERSION_REVISION=%%i)
  79. echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======"
  80. cd %BUILD_PATH%/mindspore
  81. cmake -DBUILD_DEVICE=on -DBUILD_CONVERTER=on -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=off ^
  82. -DCMAKE_BUILD_TYPE=Release -DSUPPORT_GPU=off -DBUILD_MINDDATA=off -DOFFLINE_COMPILE=off ^
  83. -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
  84. -G "CodeBlocks - MinGW Makefiles" "%BASEPATH%/mindspore/lite"
  85. GOTO:EOF
  86. :gene_protobuf
  87. IF NOT DEFINED MSLIBS_CACHE_PATH (
  88. cd /d %BASEPATH%/build/mindspore/_deps/protobuf-src/_build
  89. ) ELSE (
  90. cd /d %MSLIBS_CACHE_PATH%/protobuf_*/bin
  91. )
  92. SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/caffe
  93. protoc "%PROTO_SRC_DIR%/*.proto" --proto_path="%PROTO_SRC_DIR%" --cpp_out="%PROTO_SRC_DIR%"
  94. SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/onnx
  95. protoc "%PROTO_SRC_DIR%/*.proto" --proto_path="%PROTO_SRC_DIR%" --cpp_out="%PROTO_SRC_DIR%"
  96. cd /d %BUILD_PATH%/mindspore
  97. GOTO:EOF
  98. :gene_flatbuffer
  99. IF NOT DEFINED MSLIBS_CACHE_PATH (
  100. cd /d %BASEPATH%/build/mindspore/_deps/flatbuffers-src/_build
  101. ) ELSE (
  102. cd /d %MSLIBS_CACHE_PATH%/flatbuffers_*/bin
  103. )
  104. SET FLAT_DIR=%BASEPATH%/mindspore/lite/schema
  105. flatc -c -b -o "%FLAT_DIR%" "%FLAT_DIR%/*.fbs"
  106. flatc -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "%FLAT_DIR%/inner" "%FLAT_DIR%/*.fbs"
  107. SET FLAT_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/tflite
  108. flatc -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "%FLAT_DIR%" "%FLAT_DIR%/*.fbs"
  109. cd /d %BUILD_PATH%/mindspore
  110. GOTO:EOF
  111. :run_fail
  112. cd %BASEPATH%
  113. set errorlevel=1
  114. EXIT
  115. :run_eof