cache-toolchain.yml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: Reusable workflow example
  2. on: workflow_call
  3. jobs:
  4. build:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v3
  8. - name: Cache DragonOS GCC
  9. id: cache-dragonos-gcc
  10. uses: actions/cache@v3
  11. env:
  12. cache-name: cache-dragonos-gcc
  13. with:
  14. path: |
  15. ~/opt
  16. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
  17. - if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
  18. name: build dragonos-gcc
  19. continue-on-error: true
  20. run: bash tools/build_gcc_toolchain.sh -f
  21. - name: Cache build tools
  22. id: cache-build-tools
  23. uses: actions/cache@v3
  24. env:
  25. cache-name: cache-build-tools
  26. dadk_version: 0.1.2
  27. with:
  28. path: |
  29. ~/.cargo
  30. ~/.rustup
  31. ~/.bashrc
  32. key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
  33. - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
  34. name: Install toolchain
  35. continue-on-error: true
  36. run: |
  37. sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config"
  38. cargo install cargo-binutils
  39. rustup toolchain install nightly
  40. rustup toolchain install nightly-2023-01-21-x86_64-unknown-linux-gnu
  41. rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu
  42. rustup default nightly
  43. rustup component add rust-src
  44. rustup component add llvm-tools-preview
  45. rustup target add x86_64-unknown-none
  46. rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
  47. rustup component add rust-src --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
  48. rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
  49. rustup component add rustfmt
  50. rustup component add rustfmt --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
  51. rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
  52. cargo install dadk --version 0.1.6
  53. # Create custom Rust toolchain
  54. fork_toolchain_from="nightly-2023-08-15-x86_64-unknown-linux-gnu"
  55. custom_toolchain="nightly-2023-08-15-x86_64-unknown-linux_dragonos-gnu"
  56. custom_toolchain_dir="$(dirname $(rustc --print sysroot))/${custom_toolchain}"
  57. echo "Custom toolchain does not exist, creating..."
  58. rustup toolchain install ${fork_toolchain_from}
  59. rustup component add --toolchain ${fork_toolchain_from} rust-src
  60. rustup target add --toolchain ${fork_toolchain_from} x86_64-unknown-linux-musl
  61. cp -r $(dirname $(rustc --print sysroot))/${fork_toolchain_from} ${custom_toolchain_dir}
  62. self_contained_dir=${custom_toolchain_dir}/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained
  63. cp -f ${self_contained_dir}/crt1.o ${self_contained_dir}/rcrt1.o