|
| 1 | +name: Dart SDK Android Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "dart-sdk@*" |
| 9 | + paths: |
| 10 | + - "dart-sdk/rust/**" |
| 11 | + - "eppo_core/**" |
| 12 | + - ".github/workflows/android.yml" |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - "dart-sdk/rust/**" |
| 16 | + - "eppo_core/**" |
| 17 | + - ".github/workflows/android.yml" |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +env: |
| 24 | + CI: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-android: |
| 28 | + name: Build Android (${{ matrix.target }}) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + target: |
| 34 | + [aarch64-linux-android, x86_64-linux-android, armv7-linux-androideabi] |
| 35 | + include: |
| 36 | + - target: aarch64-linux-android |
| 37 | + android_abi: arm64-v8a |
| 38 | + - target: x86_64-linux-android |
| 39 | + android_abi: x86_64 |
| 40 | + - target: armv7-linux-androideabi |
| 41 | + android_abi: armeabi-v7a |
| 42 | + - target: i686-linux-android |
| 43 | + android_abi: x86 |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + submodules: true |
| 49 | + |
| 50 | + - uses: dart-lang/setup-dart@v1 |
| 51 | + with: |
| 52 | + sdk: 3.6 |
| 53 | + |
| 54 | + - name: Setup Rust |
| 55 | + uses: dtolnay/rust-toolchain@stable |
| 56 | + |
| 57 | + - name: Install cross |
| 58 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 59 | + |
| 60 | + - name: Cache Rust dependencies |
| 61 | + uses: Swatinem/rust-cache@v2 |
| 62 | + with: |
| 63 | + workspaces: dart-sdk/rust -> target |
| 64 | + key: ${{ matrix.target }} |
| 65 | + |
| 66 | + - name: Override eppo_core for testing |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + mkdir -p "${CARGO_HOME:-$HOME/.cargo}" |
| 70 | + echo "[patch.crates-io.eppo_core]" >> "${CARGO_HOME:-$HOME/.cargo}/config.toml" |
| 71 | + echo "path = '${{ github.workspace }}/eppo_core'" >> "${CARGO_HOME:-$HOME/.cargo}/config.toml" |
| 72 | +
|
| 73 | + - name: Setup Docker |
| 74 | + uses: docker/setup-buildx-action@v3 |
| 75 | + |
| 76 | + - name: Create logs directory |
| 77 | + run: mkdir -p dart-sdk/rust/logs |
| 78 | + |
| 79 | + - name: Install flutter_rust_bridge_codegen |
| 80 | + run: cargo install flutter_rust_bridge_codegen@=2.8.0 cargo-expand |
| 81 | + |
| 82 | + - name: Run flutter codegen |
| 83 | + working-directory: dart-sdk |
| 84 | + run: flutter_rust_bridge_codegen generate --config-file flutter_rust_bridge.yaml |
| 85 | + |
| 86 | + - name: Build for ${{ matrix.target }} |
| 87 | + env: |
| 88 | + RING_PREGENERATE_ASM: "1" |
| 89 | + CARGO_BUILD_TARGET: ${{ matrix.target }} |
| 90 | + working-directory: dart-sdk/rust |
| 91 | + run: cross build --release --target ${{ matrix.target }} -p eppo_sdk |
| 92 | + |
| 93 | + - name: Create output directory |
| 94 | + run: mkdir -p android-libs/${{ matrix.android_abi }} |
| 95 | + |
| 96 | + - name: Copy library to output directory |
| 97 | + run: | |
| 98 | + cp dart-sdk/rust/target/${{ matrix.target }}/release/libeppo_sdk.so android-libs/${{ matrix.android_abi }}/ |
| 99 | +
|
| 100 | + - name: Upload Android libraries |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: android-libs-${{ matrix.android_abi }} |
| 104 | + path: android-libs/${{ matrix.android_abi }} |
| 105 | + |
| 106 | + collect-artifacts: |
| 107 | + name: Collect Android Artifacts |
| 108 | + runs-on: ubuntu-latest |
| 109 | + needs: build-android |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + submodules: true |
| 114 | + |
| 115 | + - name: Download all artifacts |
| 116 | + uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + path: android-libs |
| 119 | + pattern: android-libs-* |
| 120 | + merge-multiple: true |
| 121 | + |
| 122 | + - name: Display structure of downloaded files |
| 123 | + run: ls -R android-libs |
| 124 | + |
| 125 | + - name: Create jniLibs directory structure |
| 126 | + run: | |
| 127 | + mkdir -p dart-sdk/android/src/main/jniLibs |
| 128 | + cp -r android-libs/* dart-sdk/android/src/main/jniLibs/ |
| 129 | +
|
| 130 | + - name: Upload combined artifacts |
| 131 | + uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: android-jniLibs |
| 134 | + path: dart-sdk/android/src/main/jniLibs |
0 commit comments