Skip to content

Commit a7eff2f

Browse files
committed
Merge branch 'rust_new' of github.com:DataEraserC/FileClassificationSolutions into rust_new
2 parents a4feb12 + e910ce6 commit a7eff2f

File tree

1 file changed

+35
-58
lines changed

1 file changed

+35
-58
lines changed

.github/workflows/rust.yml

Lines changed: 35 additions & 58 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,19 @@ 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
138+
- name: Install cargo-ndk
139+
run: cargo install cargo-ndk --locked
140+
- name: Install Android targets
136141
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
142+
rustup target add aarch64-linux-android
143+
rustup target add armv7-linux-androideabi
144+
rustup target add x86_64-linux-android
145+
rustup target add i686-linux-android
146+
- name: Install SQLite development headers
158147
run: |
159148
sudo apt-get update
160149
sudo apt-get install -y libsqlite3-dev
@@ -166,52 +155,36 @@ jobs:
166155
FEATURES="sqlite-bundled"
167156
fi
168157
echo "FEATURES=$FEATURES" >> $GITHUB_ENV
169-
- name: Build for Android
158+
- name: Build for Android target
170159
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
171160
run: |
172161
if [ -n "$FEATURES" ]; then
173-
cargo build --target aarch64-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose
162+
cargo ndk --target ${{ matrix.target }} --platform 21 -- build --release --bin file_classification_cli --features "$FEATURES" --verbose
174163
else
175-
cargo build --target aarch64-linux-android --release --bin file_classification_cli --verbose
164+
cargo ndk --target ${{ matrix.target }} --platform 21 -- build --release --bin file_classification_cli --verbose
176165
fi
177-
- name: Build for other Android targets
178-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
166+
- name: Build WebAPI for Android target
167+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }}
179168
run: |
180169
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
170+
cargo ndk --target ${{ matrix.target }} --platform 21 -- build --release --bin file_classification_webapi --features "$FEATURES" --verbose
184171
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
172+
cargo ndk --target ${{ matrix.target }} --platform 21 -- build --release --bin file_classification_webapi --verbose
188173
fi
189174
- name: Set Android binary name
190175
run: echo "ANDROID_BINARY_NAME=file_classification_cli" >> $GITHUB_ENV
191176
- name: Upload Android artifacts
192177
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }}
193178
uses: actions/upload-artifact@v4
194179
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' }}
180+
name: file_classification_cli-android-${{ matrix.target }}
181+
path: target/${{ matrix.target }}/release/file_classification_cli
182+
- name: Upload Android WebAPI artifacts
183+
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }}
211184
uses: actions/upload-artifact@v4
212185
with:
213-
name: file_classification_cli-android-i686
214-
path: target/i686-linux-android/release/file_classification_cli
186+
name: file_classification_webapi-android-${{ matrix.target }}
187+
path: target/${{ matrix.target }}/release/file_classification_webapi
215188

216189
build-linux:
217190
name: Build Linux binaries
@@ -487,7 +460,11 @@ jobs:
487460
artifacts/file_classification_cli-aarch64-apple-darwin/file_classification_cli
488461
artifacts/file_classification_webapi-x86_64-apple-darwin/file_classification_webapi
489462
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
463+
artifacts/file_classification_cli-android-aarch64-linux-android/file_classification_cli
464+
artifacts/file_classification_cli-android-armv7-linux-androideabi/file_classification_cli
465+
artifacts/file_classification_cli-android-x86_64-linux-android/file_classification_cli
466+
artifacts/file_classification_cli-android-i686-linux-android/file_classification_cli
467+
artifacts/file_classification_webapi-android-aarch64-linux-android/file_classification_webapi
468+
artifacts/file_classification_webapi-android-armv7-linux-androideabi/file_classification_webapi
469+
artifacts/file_classification_webapi-android-x86_64-linux-android/file_classification_webapi
470+
artifacts/file_classification_webapi-android-i686-linux-android/file_classification_webapi

0 commit comments

Comments
 (0)