Files
linux_sentry_chassis/justfile
T
2026-09-22 20:05:16 +08:00

49 lines
1.6 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 开发常用命令。未安装 just 时可直接使用 README 中的 cargo 命令。
default:
@just --list
# 格式化全部代码
fmt:
cargo fmt --all
# 本地检查(与 CI 同标准)
lint:
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
# 运行全部单测与集成测试(Linux 专属 vcan 测试自动跳过)
test:
cargo test --workspace
# Linux:搭建 vcan0 并运行真实内核 CAN 栈集成测试
vcan-test:
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan || true
sudo ip link set up vcan0
cargo test -p dji-esc-socketcan -- --ignored --test-threads 1
# 无硬件全链路演示(macOS / Linux 均可)
run-mock:
cargo run -p chassisd -- --mock
# 交叉检查目标板架构
check-aarch64:
cargo check --workspace --target aarch64-unknown-linux-gnu
# 交叉编译 armv7 静态二进制(目标板:创龙 T153 / Buildroot)
build-armv7:
rustup target add armv7-unknown-linux-musleabihf
cargo build --release -p chassisd --target armv7-unknown-linux-musleabihf
# 推送到板子并试运行(默认 mock 模式)
deploy board="root@169.254.63.4" mode="--mock":
just build-armv7
ssh {{board}} "mkdir -p /tmp/chassisd"
scp -q target/armv7-unknown-linux-musleabihf/release/chassisd {{board}}:/tmp/chassisd/chassisd
ssh {{board}} "/tmp/chassisd/chassisd {{mode}}"
# 板端:拉起 CAN 接口(1Mbps,bus-off 后 100ms 自动恢复)
can-up board="root@169.254.63.4" iface="can0":
ssh {{board}} "ip link set {{iface}} down; ip link set {{iface}} up type can bitrate 1000000 restart-ms 100 && ip -br link show {{iface}}"