bridge.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # This yaml shares the build bridge steps with ci and nightly.
  2. name: Build flutter-rust-bridge
  3. # 2023-11-23 18:00:00+00:00
  4. on:
  5. workflow_call:
  6. env:
  7. FLUTTER_VERSION: "3.22.3"
  8. FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
  9. RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
  10. jobs:
  11. generate_bridge:
  12. runs-on: ${{ matrix.job.os }}
  13. strategy:
  14. fail-fast: false
  15. matrix:
  16. job:
  17. - {
  18. target: x86_64-unknown-linux-gnu,
  19. os: ubuntu-20.04,
  20. extra-build-args: "",
  21. }
  22. steps:
  23. - name: Checkout source code
  24. uses: actions/checkout@v4
  25. - name: Install prerequisites
  26. run: |
  27. sudo apt-get install ca-certificates -y
  28. sudo apt-get update -y
  29. sudo apt-get install -y \
  30. clang \
  31. cmake \
  32. curl \
  33. gcc \
  34. git \
  35. g++ \
  36. libclang-10-dev \
  37. libgtk-3-dev \
  38. llvm-10-dev \
  39. nasm \
  40. ninja-build \
  41. pkg-config \
  42. wget
  43. - name: Install Rust toolchain
  44. uses: dtolnay/rust-toolchain@v1
  45. with:
  46. toolchain: ${{ env.RUST_VERSION }}
  47. targets: ${{ matrix.job.target }}
  48. components: "rustfmt"
  49. - uses: Swatinem/rust-cache@v2
  50. with:
  51. prefix-key: bridge-${{ matrix.job.os }}
  52. - name: Cache Bridge
  53. id: cache-bridge
  54. uses: actions/cache@v3
  55. with:
  56. path: /tmp/flutter_rust_bridge
  57. key: vcpkg-${{ matrix.job.arch }}
  58. - name: Install flutter
  59. uses: subosito/flutter-action@v2
  60. with:
  61. channel: "stable"
  62. flutter-version: ${{ env.FLUTTER_VERSION }}
  63. cache: true
  64. - name: Install flutter rust bridge deps
  65. shell: bash
  66. run: |
  67. cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid"
  68. pushd flutter && sed -i -e 's/extended_text: 14.0.0/extended_text: 13.0.0/g' pubspec.yaml && flutter pub get && popd
  69. - name: Run flutter rust bridge
  70. run: |
  71. ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart --c-output ./flutter/macos/Runner/bridge_generated.h
  72. cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
  73. - name: Upload Artifact
  74. uses: actions/upload-artifact@master
  75. with:
  76. name: bridge-artifact
  77. path: |
  78. ./src/bridge_generated.rs
  79. ./src/bridge_generated.io.rs
  80. ./flutter/lib/generated_bridge.dart
  81. ./flutter/lib/generated_bridge.freezed.dart
  82. ./flutter/macos/Runner/bridge_generated.h
  83. ./flutter/ios/Runner/bridge_generated.h