prepare_ccache_symlinks_rc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # Copyright 2022 The gRPC Authors
  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. # Source this rc script to create symlinks to ccache
  16. if [ "${GRPC_BUILD_ENABLE_CCACHE}" != "" ] && [ "${GRPC_BUILD_ENABLE_CCACHE}" != "false" ] && [ "${GRPC_BUILD_ENABLE_CCACHE}" != "0" ]
  17. then
  18. if [ -x "$(command -v ccache)" ]
  19. then
  20. SUPPORTED_COMPILERS=(
  21. # common compiler binaries
  22. "gcc"
  23. "g++"
  24. "clang"
  25. "clang++"
  26. "cc"
  27. "c++"
  28. # ruby artifacts: rake-compiler-dock crosscompilers
  29. # TODO(jtattermusch): ensure that the list of ruby crosscompilers stays up to date.
  30. "x86_64-redhat-linux-gcc"
  31. "x86_64-redhat-linux-g++"
  32. "i686-redhat-linux-gcc"
  33. "i686-redhat-linux-g++"
  34. "x86_64-w64-mingw32-gcc"
  35. "x86_64-w64-mingw32-g++"
  36. "i686-w64-mingw32-gcc"
  37. "i686-w64-mingw32-g++"
  38. "x86_64-apple-darwin-clang"
  39. "x86_64-apple-darwin-clang++"
  40. "aarch64-apple-darwin-clang"
  41. "aarch64-apple-darwin-clang++"
  42. # python artifacts: dockcross crosscompilers
  43. "aarch64-unknown-linux-gnueabi-gcc"
  44. "aarch64-unknown-linux-gnueabi-g++"
  45. "armv7-unknown-linux-gnueabi-gcc"
  46. "armv7-unknown-linux-gnueabi-g++"
  47. )
  48. CCACHE_BINARY_PATH="$(command -v ccache)"
  49. TEMP_CCACHE_BINDIR="$(mktemp -d)"
  50. for compiler in "${SUPPORTED_COMPILERS[@]}"
  51. do
  52. # create a symlink pointing to ccache if compiler binary exists
  53. if [ -x "$(command -v $compiler)" ]
  54. then
  55. ln -s "${CCACHE_BINARY_PATH}" "${TEMP_CCACHE_BINDIR}/${compiler}"
  56. echo "Creating symlink $compiler pointing to ${CCACHE_BINARY_PATH}"
  57. fi
  58. done
  59. echo "Adding ${TEMP_CCACHE_BINDIR} to PATH"
  60. export PATH="${TEMP_CCACHE_BINDIR}:$PATH"
  61. fi
  62. fi