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.sh 2.4 kB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # Copyright 2021 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ============================================================================
  16. display_usage()
  17. {
  18. echo -e "\nUsage: build.sh [-r release.tar.gz]\n"
  19. }
  20. checkopts()
  21. {
  22. TARBALL=""
  23. while getopts 'r:' opt
  24. do
  25. case "${opt}" in
  26. r)
  27. TARBALL=$OPTARG
  28. ;;
  29. *)
  30. echo "Unknown option ${opt}!"
  31. display_usage
  32. exit 1
  33. esac
  34. done
  35. }
  36. checkopts "$@"
  37. BASEPATH=$(cd "$(dirname $0)" || exit; pwd)
  38. get_version() {
  39. VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
  40. VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
  41. VERSION_REVISION=$(grep "const int ms_version_revision =" ${BASEPATH}/../../include/version.h | tr -dc "[0-9]")
  42. VERSION_STR=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}
  43. }
  44. get_version
  45. MINDSPORE_FILE_NAME="mindspore-lite-${VERSION_STR}-linux-x64"
  46. MINDSPORE_FILE="${MINDSPORE_FILE_NAME}.tar.gz"
  47. MINDSPORE_LITE_DOWNLOAD_URL="https://ms-release.obs.cn-north-4.myhuaweicloud.com/${VERSION_STR}/MindSpore/lite/release/linux/${MINDSPORE_FILE}"
  48. mkdir -p build/${MINDSPORE_FILE_NAME}
  49. mkdir -p lib
  50. if [ -n "$TARBALL" ]; then
  51. cp ${TARBALL} ${BASEPATH}/build/${MINDSPORE_FILE}
  52. fi
  53. if [ ! -e ${BASEPATH}/build/${MINDSPORE_FILE} ]; then
  54. wget -c -O ${BASEPATH}/build/${MINDSPORE_FILE} --no-check-certificate ${MINDSPORE_LITE_DOWNLOAD_URL}
  55. fi
  56. tar xzvf ${BASEPATH}/build/${MINDSPORE_FILE} -C ${BASEPATH}/build/${MINDSPORE_FILE_NAME} --strip-components=1
  57. cp -r ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/runtime/lib/* ${BASEPATH}/lib
  58. cp ${BASEPATH}/build/${MINDSPORE_FILE_NAME}/runtime/third_party/libjpeg-turbo/lib/libjpeg.so.62 ${BASEPATH}/lib
  59. cd ${BASEPATH}/ || exit
  60. mvn package