refactor: 调整模块位置

This commit is contained in:
Del Wang
2026-01-02 10:22:16 +08:00
parent 4d459afd28
commit ef28121f5d
15 changed files with 72 additions and 14 deletions
+4
View File
@@ -11,6 +11,10 @@ panic = "abort"
strip = true
debug = false
[features]
default = []
app = []
[dependencies]
opus = "0.3"
anyhow = "1.0"
+12 -6
View File
@@ -1,10 +1,16 @@
build:
build-server:
cargo build --release --bin server --features app
build-client:
docker run --rm -v $(shell pwd):/app idootop/open-xiaoai-runtime:oh2p \
cargo build --target armv7-unknown-linux-gnueabihf --release
cargo build --target armv7-unknown-linux-gnueabihf --release --bin client --features app
run-server:
cargo run --bin server --features app
# 部署到小爱音箱(调试自用)
deploy:
dd if=target/armv7-unknown-linux-gnueabihf/release/xiao \
| sshpass -p open-xiaoai ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.153 "dd of=/data/xiao"
dd if=target/armv7-unknown-linux-gnueabihf/release/xiao \
| sshpass -p open-xiaoai ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.235 "dd of=/data/xiao"
dd if=target/armv7-unknown-linux-gnueabihf/release/client \
| sshpass -p open-xiaoai ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.153 "dd of=/data/client"
dd if=target/armv7-unknown-linux-gnueabihf/release/client \
| sshpass -p open-xiaoai ssh -o HostKeyAlgorithms=+ssh-rsa root@192.168.31.235 "dd of=/data/client"
@@ -0,0 +1,8 @@
#![cfg(target_os = "linux")]
use anyhow::Result;
pub async fn run_client() -> Result<()> {
println!("Hello, Client!");
Ok(())
}
+1
View File
@@ -0,0 +1 @@
pub mod entry;
+3 -3
View File
@@ -1,3 +1,3 @@
pub mod entry;
pub mod master;
pub mod slave;
pub mod client;
pub mod server;
pub mod stereo;
@@ -0,0 +1,6 @@
use anyhow::Result;
pub async fn run_server() -> Result<()> {
println!("Hello, Server!");
Ok(())
}
+1
View File
@@ -0,0 +1 @@
pub mod entry;
@@ -6,7 +6,7 @@ use crate::net::protocol::ChannelRole;
use anyhow::Result;
use std::env;
pub async fn run_xiao() -> Result<()> {
pub async fn run_stereo() -> Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 3 {
eprintln!("用法: {} [master|slave] [left|right]", args[0]);
+3
View File
@@ -0,0 +1,3 @@
pub mod entry;
pub mod master;
pub mod slave;
+6 -3
View File
@@ -2,10 +2,13 @@ use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
#[cfg(target_os = "linux")]
#[cfg(feature = "app")]
{
xiao::app::entry::run_xiao().await.unwrap();
xiao::app::client::entry::run_client().await?;
}
#[cfg(not(target_os = "linux"))]
{
eprintln!("Only support Linux");
}
println!("Only support Linux");
Ok(())
}
+10
View File
@@ -0,0 +1,10 @@
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
#[cfg(feature = "app")]
{
xiao::app::server::entry::run_server().await?;
}
Ok(())
}
+14
View File
@@ -0,0 +1,14 @@
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
#[cfg(feature = "app")]
{
xiao::app::stereo::entry::run_stereo().await?;
}
#[cfg(not(target_os = "linux"))]
{
eprintln!("Only support Linux");
}
Ok(())
}
+3 -1
View File
@@ -1,4 +1,6 @@
pub mod app;
pub mod audio;
pub mod net;
pub mod utils;
#[cfg(feature = "app")]
pub mod app;