setenv.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/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. # Exit immediately for non zero status
  18. set +e
  19. SOURCE="${BASH_SOURCE[0]}"
  20. # fix on zsh environment
  21. if [[ "$SOURCE" == "" ]]; then
  22. SOURCE="$0"
  23. fi
  24. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  25. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  26. SOURCE="$(readlink "$SOURCE")"
  27. [[ $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
  28. done
  29. ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
  30. unameOut="$(uname -s)"
  31. case "${unameOut}" in
  32. Linux*)
  33. LIBJEMALLOC=$PWD/internal/core/output/lib/libjemalloc.so
  34. if test -f "$LIBJEMALLOC"; then
  35. export LD_PRELOAD="$LIBJEMALLOC"
  36. else
  37. echo "WARN: Cannot find $LIBJEMALLOC"
  38. fi
  39. export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$ROOT_DIR/internal/core/output/lib/pkgconfig:$ROOT_DIR/internal/core/output/lib64/pkgconfig"
  40. export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$ROOT_DIR/internal/core/output/lib:$ROOT_DIR/internal/core/output/lib64"
  41. export RPATH=$LD_LIBRARY_PATH;;
  42. Darwin*)
  43. # detect llvm version by valid list
  44. for llvm_version in 17 16 15 14 NOT_FOUND ; do
  45. if brew ls --versions llvm@${llvm_version} > /dev/null; then
  46. break
  47. fi
  48. done
  49. if [ "${llvm_version}" = "NOT_FOUND" ] ; then
  50. echo "valid llvm(>=14) not installed"
  51. exit 1
  52. fi
  53. llvm_prefix="$(brew --prefix llvm@${llvm_version})"
  54. export CLANG_TOOLS_PATH="${llvm_prefix}/bin"
  55. export CC="ccache ${llvm_prefix}/bin/clang"
  56. export CXX="ccache ${llvm_prefix}/bin/clang++"
  57. export ASM="${llvm_prefix}/bin/clang"
  58. export CFLAGS="-Wno-deprecated-declarations -I$(brew --prefix libomp)/include"
  59. export CXXFLAGS=${CFLAGS}
  60. export LDFLAGS="-L$(brew --prefix libomp)/lib"
  61. export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$ROOT_DIR/internal/core/output/lib/pkgconfig"
  62. export DYLD_LIBRARY_PATH=$ROOT_DIR/internal/core/output/lib
  63. export RPATH=$DYLD_LIBRARY_PATH;;
  64. MINGW*)
  65. extra_path=$(cygpath -w "$ROOT_DIR/internal/core/output/lib")
  66. export PKG_CONFIG_PATH="${PKG_CONFIG_PATH};${extra_path}\pkgconfig"
  67. export LD_LIBRARY_PATH=$extra_path
  68. export RPATH=$LD_LIBRARY_PATH;;
  69. *)
  70. echo "does not supported"
  71. esac