action.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: Setup build environment (macOS)
  5. inputs:
  6. matrix_runner:
  7. required: true
  8. runs:
  9. using: composite
  10. steps:
  11. # Free up disk space as the macOS runners end up using most for Xcode
  12. # versions we don't need and iOS simulators.
  13. - name: Free up disk space
  14. shell: bash
  15. run: |
  16. echo '*** Delete iOS simulators'
  17. xcrun simctl delete all
  18. sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/*
  19. # Install and cache LLVM 16 from Homebrew. Some runners may have LLVM 16,
  20. # but this is reliable (including with libc++), and gives us testing at the
  21. # minimum supported LLVM version.
  22. - name: Cache Homebrew
  23. id: cache-homebrew-macos
  24. uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
  25. env:
  26. cache-name: cache-homebrew
  27. with:
  28. # Cover all the critical parts of Homebrew here. Homebrew on Arm macOS
  29. # uses its own prefix making this easy to cover, but we need a few
  30. # different paths for Intel.
  31. path: |
  32. ${{
  33. runner.arch == 'ARM64' && '/opt/homebrew' ||
  34. '
  35. /usr/local/Homebrew
  36. /usr/local/Cellar
  37. /usr/local/Frameworks
  38. /usr/local/bin
  39. /usr/local/opt
  40. '
  41. }}
  42. # Note the key needs to include all the packages we're adding.
  43. key: Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}
  44. - name: Install LLVM and Clang with Homebrew
  45. if: steps.cache-homebrew-macos.outputs.cache-hit != 'true'
  46. shell: bash
  47. run: |
  48. echo '*** Prune brew leaves'
  49. # We prune all the leaf packages to have a minimal environment. This
  50. # both minimizes the install space and avoids accidental dependencies
  51. # on installed packages.
  52. brew leaves
  53. LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$')
  54. brew uninstall -f --ignore-dependencies $LEAVES
  55. echo '*** Installing LLVM deps'
  56. brew install --force-bottle --only-dependencies llvm@16
  57. echo '*** Installing LLVM itself'
  58. brew install --force-bottle --force --verbose llvm@16
  59. echo '*** brew info llvm@16'
  60. brew info llvm@16
  61. echo '*** brew autoremove'
  62. brew autoremove
  63. echo '*** brew info'
  64. brew info
  65. echo '*** brew leaves'
  66. brew leaves
  67. echo '*** brew config'
  68. brew config
  69. - name: Setup LLVM and Clang
  70. shell: bash
  71. run: |
  72. LLVM_PATH="$(brew --prefix llvm@16)"
  73. echo "Using ${LLVM_PATH}"
  74. echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
  75. echo '*** ls "${LLVM_PATH}"'
  76. ls "${LLVM_PATH}"
  77. echo '*** ls "${LLVM_PATH}/bin"'
  78. ls "${LLVM_PATH}/bin"