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.

apply_patches.sh 2.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # Copyright 2019 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. PWD_PATH=`pwd`
  17. THIRD_PARTY_PATH=$(cd "$(dirname $0)"; pwd)
  18. if [ $# -lt 1 ]; then
  19. echo "Usage: sh apply_patches.sh [build_dir]"
  20. echo " build_dir is the directory where you type \"cmake\""
  21. echo " Open source software incubator-tvm will be copied to build_dir"
  22. echo " where patches will be applied on."
  23. exit 1
  24. fi
  25. BUILD_PATH=$1
  26. if [ -d ${BUILD_PATH}/incubator-tvm ]; then
  27. rm -rf ${BUILD_PATH}/incubator-tvm
  28. fi
  29. DLPACK_PATH=$2
  30. DMLC_PATH=$3
  31. RANG_PATH=$4
  32. TVM_PATH=$5
  33. mkdir ${BUILD_PATH}/incubator-tvm
  34. cp -rf ${TVM_PATH}/* ${BUILD_PATH}/incubator-tvm/
  35. cp -rf ${DLPACK_PATH}/* ${BUILD_PATH}/incubator-tvm/3rdparty/dlpack/
  36. cp -rf ${DMLC_PATH}/* ${BUILD_PATH}/incubator-tvm/3rdparty/dmlc-core/
  37. cp -rf ${RANG_PATH}/* ${BUILD_PATH}/incubator-tvm/3rdparty/rang/
  38. check_dir_not_empty()
  39. {
  40. if [ ! $# -eq 1 ]; then
  41. echo "Usage: check_dir_not_empty dir_path"
  42. exit 1
  43. fi
  44. if [ ! -d $1 ]; then
  45. echo "Directory $1 does not exist."
  46. exit 1
  47. fi
  48. fileCounts=`ls $1 | wc -l`
  49. if [ ${fileCounts} -eq 0 ]; then
  50. echo "Directory $1 is empty."
  51. exit 1
  52. fi
  53. }
  54. apply_patch()
  55. {
  56. if [ ! $# -eq 1 ]; then
  57. echo "Usage: apply_patch patch_name"
  58. exit 1
  59. fi
  60. if [ ! -f $1 ]; then
  61. echo "Patch $1 does not exist."
  62. exit 1
  63. fi
  64. patch -p1 < $1
  65. if [ $? -eq 0 ]; then
  66. echo "Patch $1 applied successfully."
  67. else
  68. echo "Patch $1 not applied."
  69. fi
  70. }
  71. # apply patches on tvm
  72. TVM_PATH=${BUILD_PATH}/incubator-tvm
  73. TVM_PATCH_PATH=${THIRD_PARTY_PATH}/patch/incubator-tvm
  74. check_dir_not_empty "${TVM_PATH}"
  75. check_dir_not_empty "${TVM_PATCH_PATH}"
  76. cd ${TVM_PATH}
  77. apply_patch "${TVM_PATCH_PATH}/cmake.patch"
  78. apply_patch "${TVM_PATCH_PATH}/find_library.patch"
  79. apply_patch "${TVM_PATCH_PATH}/include.patch"
  80. apply_patch "${TVM_PATCH_PATH}/src_pass.patch"
  81. cd ${PWD_PATH}