build_llvm_libraries.yml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: Reusable workflow-build_llvm_libraries
  4. on:
  5. workflow_call:
  6. inputs:
  7. os:
  8. required: true
  9. type: string
  10. arch:
  11. required: true
  12. type: string
  13. outputs:
  14. cache_key:
  15. description: "A cached key of LLVM libraries"
  16. value: ${{ jobs.build_llvm_libraries.outputs.key}}
  17. jobs:
  18. build_llvm_libraries:
  19. runs-on: ${{ inputs.os }}
  20. outputs:
  21. key: ${{ steps.create_lib_cache_key.outputs.key}}
  22. steps:
  23. - name: checkout
  24. uses: actions/checkout@v3
  25. - name: install dependencies
  26. run: /usr/bin/env python3 -m pip install -r requirements.txt
  27. working-directory: build-scripts
  28. - name: retrive the last commit ID
  29. id: get_last_commit
  30. run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
  31. working-directory: build-scripts
  32. # Bump the prefix number to evict all previous caches and
  33. # enforce a clean build, in the unlikely case that some
  34. # weird build error occur and llvm/build becomes a potential
  35. # suspect.
  36. - name: form the cache key of libraries
  37. id: create_lib_cache_key
  38. run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}" >> $GITHUB_OUTPUT
  39. - name: Cache LLVM libraries
  40. id: retrieve_llvm_libs
  41. uses: actions/cache@v3
  42. with:
  43. path: |
  44. ./core/deps/llvm/build/bin
  45. ./core/deps/llvm/build/include
  46. ./core/deps/llvm/build/lib
  47. ./core/deps/llvm/build/libexec
  48. ./core/deps/llvm/build/share
  49. key: ${{ steps.create_lib_cache_key.outputs.key}}
  50. - uses: actions/cache@v3
  51. with:
  52. path: ~/.ccache
  53. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  54. restore-keys: |
  55. 0-ccache-${{ inputs.os }}
  56. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04'
  57. - uses: actions/cache@v3
  58. with:
  59. path: ~/.cache/ccache
  60. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  61. restore-keys: |
  62. 0-ccache-${{ inputs.os }}
  63. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
  64. - run: sudo apt install -y ccache ninja-build
  65. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu')
  66. - uses: actions/cache@v3
  67. with:
  68. path: ~/Library/Caches/ccache
  69. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  70. restore-keys: |
  71. 0-ccache-${{ inputs.os }}
  72. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  73. - run: brew install ccache ninja
  74. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  75. - name: Build LLVM libraries
  76. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  77. run: /usr/bin/env python3 ./build_llvm.py --arch ${{ inputs.arch }}
  78. working-directory: build-scripts