action.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.
  20. # TODO: We can potentially remove this and simplify things when the
  21. # Homebrew version of LLVM updates to 16 here:
  22. # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
  23. - name: Cache Homebrew
  24. id: cache-homebrew-macos
  25. uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
  26. env:
  27. cache-name: cache-homebrew
  28. with:
  29. # Cover all the critical parts of Homebrew here. Homebrew on Arm macOS
  30. # uses its own prefix making this easy to cover, but we need a few
  31. # different paths for Intel.
  32. path: |
  33. ${{
  34. runner.arch == 'ARM64' && '/opt/homebrew' ||
  35. '
  36. /usr/local/Homebrew
  37. /usr/local/Cellar
  38. /usr/local/Frameworks
  39. /usr/local/bin
  40. /usr/local/opt
  41. '
  42. }}
  43. # Note the key needs to include all the packages we're adding.
  44. key: Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}
  45. - name: Install LLVM and Clang with Homebrew
  46. if: steps.cache-homebrew-macos.outputs.cache-hit != 'true'
  47. shell: bash
  48. run: |
  49. echo '*** Prune brew leaves'
  50. # We prune all the leaf packages to have a minimal environment. This
  51. # both minimizes the install space and avoids accidental dependencies
  52. # on installed packages.
  53. brew leaves
  54. LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$')
  55. brew uninstall -f --ignore-dependencies $LEAVES
  56. echo '*** Installing LLVM deps'
  57. brew install --force-bottle --only-dependencies llvm@16
  58. echo '*** Installing LLVM itself'
  59. brew install --force-bottle --force --verbose llvm@16
  60. echo '*** brew info llvm@16'
  61. brew info llvm@16
  62. echo '*** brew autoremove'
  63. brew autoremove
  64. echo '*** brew info'
  65. brew info
  66. echo '*** brew leaves'
  67. brew leaves
  68. echo '*** brew config'
  69. brew config
  70. - name: Setup LLVM and Clang
  71. shell: bash
  72. run: |
  73. LLVM_PATH="$(brew --prefix llvm@16)"
  74. echo "Using ${LLVM_PATH}"
  75. echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
  76. echo '*** ls "${LLVM_PATH}"'
  77. ls "${LLVM_PATH}"
  78. echo '*** ls "${LLVM_PATH}/bin"'
  79. ls "${LLVM_PATH}/bin"