build_llvm_libraries.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. container_image:
  14. required: false
  15. type: string
  16. outputs:
  17. cache_key:
  18. description: "A cached key of LLVM libraries"
  19. value: ${{ jobs.build_llvm_libraries.outputs.key}}
  20. jobs:
  21. build_llvm_libraries:
  22. runs-on: ${{ inputs.os }}
  23. # Using given container image if it is specified.
  24. # Otherwise, it will be ignored by the runner.
  25. container:
  26. image: ${{ inputs.container_image }}
  27. outputs:
  28. key: ${{ steps.create_lib_cache_key.outputs.key}}
  29. steps:
  30. - name: checkout
  31. uses: actions/checkout@v4
  32. - name: install dependencies
  33. run: /usr/bin/env python3 -m pip install -r requirements.txt
  34. working-directory: build-scripts
  35. - name: retrive the last commit ID
  36. id: get_last_commit
  37. run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
  38. working-directory: build-scripts
  39. # Bump the prefix number to evict all previous caches and
  40. # enforce a clean build, in the unlikely case that some
  41. # weird build error occur and llvm/build becomes a potential
  42. # suspect.
  43. - name: form the cache key of libraries
  44. id: create_lib_cache_key
  45. run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}" >> $GITHUB_OUTPUT
  46. - name: Cache LLVM libraries
  47. id: retrieve_llvm_libs
  48. uses: actions/cache@v4
  49. with:
  50. path: |
  51. ./core/deps/llvm/build/bin
  52. ./core/deps/llvm/build/include
  53. ./core/deps/llvm/build/lib
  54. ./core/deps/llvm/build/libexec
  55. ./core/deps/llvm/build/share
  56. key: ${{ steps.create_lib_cache_key.outputs.key}}
  57. - uses: actions/cache@v4
  58. with:
  59. path: ~/.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-20.04'
  64. - uses: actions/cache@v4
  65. with:
  66. path: ~/.cache/ccache
  67. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  68. restore-keys: |
  69. 0-ccache-${{ inputs.os }}
  70. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
  71. # Don't install dependencies if the cache is hit or running in docker container
  72. - run: sudo apt install -y ccache ninja-build
  73. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') && inputs.container_image == ''
  74. - uses: actions/cache@v4
  75. with:
  76. path: ~/Library/Caches/ccache
  77. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  78. restore-keys: |
  79. 0-ccache-${{ inputs.os }}
  80. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  81. - run: brew install ccache ninja
  82. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  83. - name: Build LLVM libraries
  84. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  85. run: /usr/bin/env python3 ./build_llvm.py --arch ${{ inputs.arch }}
  86. working-directory: build-scripts