build_llvm_libraries.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: retrive the last commit ID
  26. id: get_last_commit
  27. run: echo "last_commit=$(/usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
  28. working-directory: build-scripts
  29. # Bump the prefix number to evict all previous caches and
  30. # enforce a clean build, in the unlikely case that some
  31. # weird build error occur and llvm/build becomes a potential
  32. # suspect.
  33. - name: form the cache key of libraries
  34. id: create_lib_cache_key
  35. run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}" >> $GITHUB_OUTPUT
  36. - name: Cache LLVM libraries
  37. id: retrieve_llvm_libs
  38. uses: actions/cache@v3
  39. with:
  40. path: |
  41. ./core/deps/llvm/build/bin
  42. ./core/deps/llvm/build/include
  43. ./core/deps/llvm/build/lib
  44. ./core/deps/llvm/build/libexec
  45. ./core/deps/llvm/build/share
  46. key: ${{ steps.create_lib_cache_key.outputs.key}}
  47. - uses: actions/cache@v3
  48. with:
  49. path: ~/.ccache
  50. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  51. restore-keys: |
  52. 0-ccache-${{ inputs.os }}
  53. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04'
  54. - uses: actions/cache@v3
  55. with:
  56. path: ~/.cache/ccache
  57. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  58. restore-keys: |
  59. 0-ccache-${{ inputs.os }}
  60. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
  61. - run: sudo apt install -y ccache ninja-build
  62. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu')
  63. - uses: actions/cache@v3
  64. with:
  65. path: ~/Library/Caches/ccache
  66. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  67. restore-keys: |
  68. 0-ccache-${{ inputs.os }}
  69. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  70. - run: brew install ccache ninja
  71. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  72. - name: Build LLVM libraries
  73. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  74. run: /usr/bin/env python3 ./build_llvm.py --arch ${{ inputs.arch }}
  75. working-directory: build-scripts