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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. IF NOT EXIST %BASEPATH%/build (
  19. md "build"
  20. )
  21. cd %BASEPATH%/build
  22. set BUILD_PATH=%CD%
  23. IF NOT EXIST %BUILD_PATH%/mindspore (
  24. md "mindspore"
  25. )
  26. cd %CD%/mindspore
  27. IF "%2%" == "lite" (
  28. call :gene_gtest
  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. goto run_fail
  38. )
  39. ) ELSE (
  40. call :gene_protobuf
  41. call :gene_flatbuffer
  42. )
  43. cd %BUILD_PATH%/mindspore
  44. IF "%1%" == "" (
  45. cmake --build . -- -j6
  46. ) ELSE (
  47. cmake --build . -- -j%1%
  48. )
  49. IF errorlevel 1 (
  50. echo "build fail."
  51. goto run_fail
  52. )
  53. ) ELSE (
  54. cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON ^
  55. -G "CodeBlocks - MinGW Makefiles" ../..
  56. IF NOT %errorlevel% == 0 (
  57. echo "cmake fail."
  58. goto run_fail
  59. )
  60. IF "%1%" == "" (
  61. cmake --build . --target package -- -j6
  62. ) ELSE (
  63. cmake --build . --target package -- -j%1%
  64. )
  65. IF NOT %errorlevel% == 0 (
  66. echo "build fail."
  67. goto run_fail
  68. )
  69. )
  70. cd %BASEPATH%
  71. goto run_eof
  72. :run_cmake
  73. cd %BUILD_PATH%/mindspore
  74. cmake -DBUILD_DEVICE=on -DBUILD_CONVERTER=on -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=off ^
  75. -DCMAKE_BUILD_TYPE=Release -DSUPPORT_GPU=off -DBUILD_MINDDATA=off -DOFFLINE_COMPILE=off ^
  76. -G "CodeBlocks - MinGW Makefiles" %BASEPATH%/mindspore/lite
  77. GOTO:EOF
  78. :gene_gtest
  79. cd %BASEPATH%/third_party
  80. IF EXIST googletest rd /s /q googletest
  81. git submodule update --init --recursive googletest
  82. cd %BUILD_PATH%/mindspore
  83. GOTO:EOF
  84. :gene_protobuf
  85. SET PROTOC=%BASEPATH%/build/mindspore/_deps/protobuf-src/_build/protoc
  86. SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/caffe
  87. cd %PROTO_SRC_DIR%
  88. %PROTOC% *.proto --proto_path=%PROTO_SRC_DIR% --cpp_out=%PROTO_SRC_DIR%
  89. SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/onnx
  90. cd %PROTO_SRC_DIR%
  91. %PROTOC% *.proto --proto_path=%PROTO_SRC_DIR% --cpp_out=%PROTO_SRC_DIR%
  92. cd %BUILD_PATH%/mindspore
  93. GOTO:EOF
  94. :gene_flatbuffer
  95. SET FLATC=%BASEPATH%/build/mindspore/_deps/flatbuffers-src/_build/flatc
  96. SET FLAT_DIR=%BASEPATH%/mindspore/lite/schema
  97. cd %FLAT_DIR%
  98. IF EXIST inner rd /s /q inner
  99. md inner
  100. %FLATC% -c -b *.fbs
  101. %FLATC% -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o %FLAT_DIR%/inner *.fbs
  102. SET FLAT_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/tflite
  103. cd %FLAT_DIR%
  104. %FLATC% -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o %FLAT_DIR% *.fbs
  105. cd %BUILD_PATH%/mindspore
  106. GOTO:EOF
  107. :run_fail
  108. cd %BASEPATH%
  109. set errorlevel=1
  110. :run_eof