Skip to content

Commit 0782a48

Browse files
committed
fix(ci): try to fix cli for android platform
1 parent 2529cdf commit 0782a48

1 file changed

Lines changed: 18 additions & 65 deletions

File tree

.github/workflows/rust.yml

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ jobs:
113113
continue-on-error: true
114114
strategy:
115115
fail-fast: false
116+
matrix:
117+
target:
118+
- aarch64-linux-android
119+
- armv7-linux-androideabi
120+
- x86_64-linux-android
121+
- i686-linux-android
116122
steps:
117123
- uses: actions/checkout@v4
118124
- name: Install Rust
@@ -125,36 +131,13 @@ jobs:
125131
~/.cargo/git
126132
target
127133
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
128-
- name: Install Android targets
129-
run: |
130-
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
131134
- name: Install Android NDK
132135
uses: nttld/setup-ndk@v1
133136
with:
134137
ndk-version: r25b
135-
- name: Setup Android environment
136-
run: |
137-
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
138-
echo "NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
139-
- name: Configure cargo for Android
140-
run: |
141-
mkdir -p .cargo
142-
echo '[target.aarch64-linux-android]' > .cargo/config.toml
143-
echo "ar = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
144-
echo "linker = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang\"" >> .cargo/config.toml
145-
echo '' >> .cargo/config.toml
146-
echo '[target.armv7-linux-androideabi]' >> .cargo/config.toml
147-
echo "ar = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
148-
echo "linker = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang\"" >> .cargo/config.toml
149-
echo '' >> .cargo/config.toml
150-
echo '[target.x86_64-linux-android]' >> .cargo/config.toml
151-
echo "ar = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
152-
echo "linker = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang\"" >> .cargo/config.toml
153-
echo '' >> .cargo/config.toml
154-
echo '[target.i686-linux-android]' >> .cargo/config.toml
155-
echo "ar = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar\"" >> .cargo/config.toml
156-
echo "linker = \"$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang\"" >> .cargo/config.toml
157-
- name: Install SQLite for Android
138+
- name: Install cargo-ndk
139+
run: cargo install cargo-ndk --locked
140+
- name: Install SQLite development headers
158141
run: |
159142
sudo apt-get update
160143
sudo apt-get install -y libsqlite3-dev
@@ -166,52 +149,22 @@ jobs:
166149
FEATURES="sqlite-bundled"
167150
fi
168151
echo "FEATURES=$FEATURES" >> $GITHUB_ENV
169-
- name: Build for Android
170-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
171-
run: |
172-
if [ -n "$FEATURES" ]; then
173-
cargo build --target aarch64-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose
174-
else
175-
cargo build --target aarch64-linux-android --release --bin file_classification_cli --verbose
176-
fi
177-
- name: Build for other Android targets
152+
- name: Build for Android target
178153
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
179154
run: |
180155
if [ -n "$FEATURES" ]; then
181-
cargo build --target armv7-linux-androideabi --release --bin file_classification_cli --features "$FEATURES" --verbose
182-
cargo build --target x86_64-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose
183-
cargo build --target i686-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose
156+
cargo ndk --target ${{ matrix.target }} --android-platform 21 -- build --release --bin file_classification_cli --features "$FEATURES" --verbose
184157
else
185-
cargo build --target armv7-linux-androideabi --release --bin file_classification_cli --verbose
186-
cargo build --target x86_64-linux-android --release --bin file_classification_cli --verbose
187-
cargo build --target i686-linux-android --release --bin file_classification_cli --verbose
158+
cargo ndk --target ${{ matrix.target }} --android-platform 21 -- build --release --bin file_classification_cli --verbose
188159
fi
189160
- name: Set Android binary name
190161
run: echo "ANDROID_BINARY_NAME=file_classification_cli" >> $GITHUB_ENV
191162
- name: Upload Android artifacts
192163
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
193164
uses: actions/upload-artifact@v4
194165
with:
195-
name: file_classification_cli-android-aarch64
196-
path: target/aarch64-linux-android/release/file_classification_cli
197-
- name: Upload other Android artifacts
198-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
199-
uses: actions/upload-artifact@v4
200-
with:
201-
name: file_classification_cli-android-armv7
202-
path: target/armv7-linux-androideabi/release/file_classification_cli
203-
- name: Upload other Android artifacts
204-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
205-
uses: actions/upload-artifact@v4
206-
with:
207-
name: file_classification_cli-android-x86_64
208-
path: target/x86_64-linux-android/release/file_classification_cli
209-
- name: Upload other Android artifacts
210-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
211-
uses: actions/upload-artifact@v4
212-
with:
213-
name: file_classification_cli-android-i686
214-
path: target/i686-linux-android/release/file_classification_cli
166+
name: file_classification_cli-android-${{ matrix.target }}
167+
path: target/${{ matrix.target }}/release/file_classification_cli
215168

216169
build-linux:
217170
name: Build Linux binaries
@@ -487,7 +440,7 @@ jobs:
487440
artifacts/file_classification_cli-aarch64-apple-darwin/file_classification_cli
488441
artifacts/file_classification_webapi-x86_64-apple-darwin/file_classification_webapi
489442
artifacts/file_classification_webapi-aarch64-apple-darwin/file_classification_webapi
490-
artifacts/file_classification_cli-android-aarch64/file_classification_cli
491-
artifacts/file_classification_cli-android-armv7/file_classification_cli
492-
artifacts/file_classification_cli-android-x86_64/file_classification_cli
493-
artifacts/file_classification_cli-android-i686/file_classification_cli
443+
artifacts/file_classification_cli-android-aarch64-linux-android/file_classification_cli
444+
artifacts/file_classification_cli-android-armv7-linux-androideabi/file_classification_cli
445+
artifacts/file_classification_cli-android-x86_64-linux-android/file_classification_cli
446+
artifacts/file_classification_cli-android-i686-linux-android/file_classification_cli

0 commit comments

Comments
 (0)