build_llvm_libraries.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 for non macos-14
  33. if: inputs.os != 'macos-14'
  34. run: /usr/bin/env python3 -m pip install -r requirements.txt
  35. working-directory: build-scripts
  36. - name: install dependencies for macos-14
  37. if: inputs.os == 'macos-14'
  38. run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
  39. working-directory: build-scripts
  40. - name: retrieve the last commit ID
  41. id: get_last_commit
  42. run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT
  43. working-directory: build-scripts
  44. # Bump the prefix number to evict all previous caches and
  45. # enforce a clean build, in the unlikely case that some
  46. # weird build error occur and llvm/build becomes a potential
  47. # suspect.
  48. - name: form the cache key of libraries
  49. id: create_lib_cache_key
  50. run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}" >> $GITHUB_OUTPUT
  51. - name: Cache LLVM libraries
  52. id: retrieve_llvm_libs
  53. uses: actions/cache@v4
  54. with:
  55. path: |
  56. ./core/deps/llvm/build/bin
  57. ./core/deps/llvm/build/include
  58. ./core/deps/llvm/build/lib
  59. ./core/deps/llvm/build/libexec
  60. ./core/deps/llvm/build/share
  61. key: ${{ steps.create_lib_cache_key.outputs.key}}
  62. - uses: actions/cache@v4
  63. with:
  64. path: ~/.ccache
  65. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  66. restore-keys: |
  67. 0-ccache-${{ inputs.os }}
  68. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04'
  69. - uses: actions/cache@v4
  70. with:
  71. path: ~/.cache/ccache
  72. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  73. restore-keys: |
  74. 0-ccache-${{ inputs.os }}
  75. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
  76. # Don't install dependencies if the cache is hit or running in docker container
  77. - run: sudo apt install -y ccache ninja-build
  78. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') && inputs.container_image == ''
  79. - uses: actions/cache@v4
  80. with:
  81. path: ~/Library/Caches/ccache
  82. key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
  83. restore-keys: |
  84. 0-ccache-${{ inputs.os }}
  85. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  86. - run: brew install ccache ninja
  87. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
  88. - name: Build LLVM libraries
  89. if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
  90. run: /usr/bin/env python3 ./build_llvm.py --arch ${{ inputs.arch }}
  91. working-directory: build-scripts