3rdparty_build.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env bash
  2. # Licensed to the LF AI & Data foundation under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Skip the installation and compilation of third-party code,
  18. # if the developer is certain that it has already been done.
  19. if [[ ${SKIP_3RDPARTY} -eq 1 ]]; then
  20. exit 0
  21. fi
  22. SOURCE="${BASH_SOURCE[0]}"
  23. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  24. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  25. SOURCE="$(readlink "$SOURCE")"
  26. [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  27. done
  28. BUILD_OPENDAL="OFF"
  29. while getopts "o:" arg; do
  30. case $arg in
  31. o)
  32. BUILD_OPENDAL=$OPTARG
  33. ;;
  34. esac
  35. done
  36. ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
  37. CPP_SRC_DIR="${ROOT_DIR}/internal/core"
  38. BUILD_OUTPUT_DIR="${ROOT_DIR}/cmake_build"
  39. if [[ ! -d ${BUILD_OUTPUT_DIR} ]]; then
  40. mkdir ${BUILD_OUTPUT_DIR}
  41. fi
  42. source ${ROOT_DIR}/scripts/setenv.sh
  43. pushd ${BUILD_OUTPUT_DIR}
  44. export CONAN_REVISIONS_ENABLED=1
  45. export CXXFLAGS="-Wno-error=address -Wno-error=deprecated-declarations"
  46. export CFLAGS="-Wno-error=address -Wno-error=deprecated-declarations"
  47. if [[ ! `conan remote list` == *default-conan-local* ]]; then
  48. conan remote add default-conan-local https://milvus01.jfrog.io/artifactory/api/conan/default-conan-local
  49. fi
  50. unameOut="$(uname -s)"
  51. case "${unameOut}" in
  52. Darwin*)
  53. conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler=clang -s compiler.version=${llvm_version} -s compiler.libcxx=libc++ -s compiler.cppstd=17 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
  54. ;;
  55. Linux*)
  56. echo "Running on ${OS_NAME}"
  57. export CPU_TARGET=avx
  58. GCC_VERSION=`gcc -dumpversion`
  59. if [[ `gcc -v 2>&1 | sed -n 's/.*\(--with-default-libstdcxx-abi\)=\(\w*\).*/\2/p'` == "gcc4" ]]; then
  60. conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler.version=${GCC_VERSION} -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
  61. else
  62. conan install ${CPP_SRC_DIR} --install-folder conan --build=missing -s compiler.version=${GCC_VERSION} -s compiler.libcxx=libstdc++11 -r default-conan-local -u || { echo 'conan install failed'; exit 1; }
  63. fi
  64. ;;
  65. *)
  66. echo "Cannot build on windows"
  67. ;;
  68. esac
  69. popd
  70. mkdir -p ${ROOT_DIR}/internal/core/output/lib
  71. mkdir -p ${ROOT_DIR}/internal/core/output/include
  72. pushd ${ROOT_DIR}/cmake_build/thirdparty
  73. if command -v cargo >/dev/null 2>&1; then
  74. echo "cargo exists"
  75. unameOut="$(uname -s)"
  76. case "${unameOut}" in
  77. Darwin*)
  78. echo "running on mac os, reinstall rust 1.73"
  79. # github will install rust 1.74 by default.
  80. # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
  81. rustup install 1.73
  82. rustup default 1.73;;
  83. *)
  84. echo "not running on mac os, no need to reinstall rust";;
  85. esac
  86. else
  87. bash -c "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=1.73 -y" || { echo 'rustup install failed'; exit 1;}
  88. source $HOME/.cargo/env
  89. fi