Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / scripts / rust-deps-count.sh
rust-deps-count.sh47 lines · 2.6 KiBRaw
| 1 | #!/usr/bin/env bash |
| 2 | # Rust supply-chain audit – counts what actually gets compiled into the Android .so files. |
| 3 | # Armv8-only: aarch64-linux-android target, normal edges only (no build-deps, no dev-deps, no Windows/WASM cfg). |
| 4 | set -euo pipefail |
| 5 | cd "$(dirname "$0")/.." |
| 6 | |
| 7 | echo "=== Root workspace Cargo.lock total (unfiltered) ===" |
| 8 | grep -c "^\[\[package\]\]" Cargo.lock |
| 9 | echo "unique crates:"; grep 'name = "' Cargo.lock | sed -E 's/name = "([^"]+)".*/\1/' | sort -u | wc -l |
| 10 | |
| 11 | echo "" |
| 12 | echo "=== Filtered compile graph for aarch64-linux-android normal edges ===" |
| 13 | rustup run 1.97.0 cargo tree --workspace --target aarch64-linux-android --edges normal 2>&1 | grep -v warning | wc -l |
| 14 | echo "unique crates in filtered graph:" |
| 15 | rustup run 1.97.0 cargo tree --workspace --target aarch64-linux-android --edges normal 2>&1 | grep -v warning | LC_ALL=C sed -E 's/.* ([a-zA-Z0-9_.-]+) v.*/\1/' | sort -u | wc -l |
| 16 | |
| 17 | echo "" |
| 18 | echo "=== Per-crate filtered normal counts (armv8) ===" |
| 19 | for p in astronomy_engine photos_fx office_engine weather_om pdf_render camera_stitch passwords_kdbx e2ee_pqc; do |
| 20 | cnt=$(rustup run 1.97.0 cargo tree -p "$p" --target aarch64-linux-android --edges normal 2>&1 | grep -v warning | wc -l) |
| 21 | echo "$p: $cnt" |
| 22 | done |
| 23 | |
| 24 | echo "" |
| 25 | echo "=== Banned platform crates check (should be 0 for normal armv8 edges) ===" |
| 26 | if rustup run 1.97.0 cargo tree --workspace --target aarch64-linux-android --edges normal 2>&1 | grep -iE "windows-sys|walkdir|same-file|winapi-util|bindgen|clang-sys|prettyplease|regex" | grep -v "windows-link" ; then |
| 27 | echo "FAIL: banned crates present in normal edges" |
| 28 | exit 1 |
| 29 | else |
| 30 | echo "OK: no banned Windows/bindgen in normal edges" |
| 31 | fi |
| 32 | |
| 33 | echo "" |
| 34 | echo "=== Heavy crates justification ===" |
| 35 | echo "nalgebra 0.33 (camera bundle adjustment SVD/LU/Rodrigues) – justified, cannot replace with glam" |
| 36 | echo "openjp2 (PDF JPEG2000) – justified, no pure-std replacement" |
| 37 | echo "fips203/fips204 (PQC ML-KEM-768/ML-DSA-65) – justified, FIPS standards" |
| 38 | echo "lopdf 0.36 (safe PDF parser) – justified, memory-safe vs pdfium" |
| 39 | |
| 40 | echo "" |
| 41 | echo "=== Biggest reductions done ===" |
| 42 | echo "- om-file-format-sys: pre-generated bindings_android.rs/host.rs, build.rs only cc (saved ~20 crates)" |
| 43 | echo "- weather ureq removed: SliceBackend + Kotlin NetworkClient.performRequestBytes (saved ~90 crates ring/rustls/icu/url/webpki)" |
| 44 | echo "- camera image removed: jpeg-decoder+jpeg-encoder single-function rewrite (saved moxcms/pxfm/bytemuck chain)" |
| 45 | echo "- photos rayon removed: stdlib threads only (saved 6 crates)" |
| 46 | echo "- PDF toolchain: removed x86_64-linux-android target" |
| 47 | echo "- Root workspace Cargo.toml centralized versions (mirrors gradle/libs.versions.toml)" |