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

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