安装与编译
前置
- Rust toolchain (edition 2024)
- 与
sync-core同级目录(如native/cr4sync+native/sync-core),靠path = "../sync-core"复用同步内核
编译
cd path/to/cr4sync
# 仅 CLI(默认), 体积小, 无 axum/tower 依赖
cargo build --release
# CLI + HTTP server 子命令
cargo build --release --features server
# 产物
ls target/release/cr4sync
cr4sync 是独立 cargo workspace(
Cargo.toml自带空[workspace]表),不并入上级 native 工作区,不共享其Cargo.lock。
feature 矩阵
| feature | 包含 | 二进制大小 | 额外依赖 |
|---|---|---|---|
| (默认) | CLI: login/sync/up/dl/del/ls/migrate | 较小 | reqwest, rusqlite, indicatif 等 |
server | 上述 + cr4sync serve | 大约 +30% | axum 0.7, tower-http, moka, ulid, tokio-stream |
CI 矩阵建议两条都跑:
cargo test # CLI only
cargo clippy --all-targets -- -D warnings
cargo test --features server # CLI + server
cargo clippy --all-targets --features server -- -D warnings
安装到系统
install -Dm755 target/release/cr4sync /usr/local/bin/cr4sync
文档构建(本文档本身)
cd path/to/cr4sync/doc
mdbook build # 输出到 ./book/
mdbook serve --open # 本地预览, 自动 reload
需要 mdbook:
cargo install mdbook