mirror of https://github.com/jackwener/wx-cli.git
fix: Windows build errors (handle_connection, creation_flags, mkdir)
- server.rs: add handle_connection_windows for named pipe connections - transport.rs: import CommandExt trait for creation_flags on Windows - release.yml: mkdir -p before binary copy to npm bin dirspull/2/head
parent
f9bca1f872
commit
59dd6bfa24
|
|
@ -70,12 +70,14 @@ jobs:
|
||||||
if: matrix.os != 'windows-latest'
|
if: matrix.os != 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
cp target/${{ matrix.target }}/release/wx ${{ matrix.asset }}
|
cp target/${{ matrix.target }}/release/wx ${{ matrix.asset }}
|
||||||
|
mkdir -p npm/platforms/${{ matrix.npm_dir }}/bin
|
||||||
cp target/${{ matrix.target }}/release/wx npm/platforms/${{ matrix.npm_dir }}/bin/wx
|
cp target/${{ matrix.target }}/release/wx npm/platforms/${{ matrix.npm_dir }}/bin/wx
|
||||||
|
|
||||||
- name: Copy binary (Windows)
|
- name: Copy binary (Windows)
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
copy target\${{ matrix.target }}\release\wx.exe ${{ matrix.asset }}
|
copy target\${{ matrix.target }}\release\wx.exe ${{ matrix.asset }}
|
||||||
|
if not exist npm\platforms\${{ matrix.npm_dir }}\bin mkdir npm\platforms\${{ matrix.npm_dir }}\bin
|
||||||
copy target\${{ matrix.target }}\release\wx.exe npm\platforms\${{ matrix.npm_dir }}\bin\wx.exe
|
copy target\${{ matrix.target }}\release\wx.exe npm\platforms\${{ matrix.npm_dir }}\bin\wx.exe
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ pbkdf2 = "0.12"
|
||||||
# 解压
|
# 解压
|
||||||
zstd = "0.13"
|
zstd = "0.13"
|
||||||
|
|
||||||
# IPC (Unix socket + Windows named pipe 统一)
|
# IPC Windows named pipe(Unix 直接用 tokio::net::UnixListener)
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
interprocess = { version = "2", features = ["tokio"] }
|
interprocess = { version = "2", features = ["tokio"] }
|
||||||
|
|
||||||
# 错误处理
|
# 错误处理
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ fn start_daemon() -> Result<()> {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
let log_file = std::fs::OpenOptions::new()
|
let log_file = std::fs::OpenOptions::new()
|
||||||
.create(true).append(true)
|
.create(true).append(true)
|
||||||
.open(config::log_path())
|
.open(config::log_path())
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,41 @@ async fn serve_windows(
|
||||||
let names2 = Arc::clone(&names);
|
let names2 = Arc::clone(&names);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Err(e) = handle_connection_generic(conn, db2, names2).await {
|
if let Err(e) = handle_connection_windows(conn, db2, names2).await {
|
||||||
eprintln!("[server] 连接处理错误: {}", e);
|
eprintln!("[server] 连接处理错误: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
async fn handle_connection_windows(
|
||||||
|
conn: interprocess::local_socket::tokio::Stream,
|
||||||
|
db: Arc<DbCache>,
|
||||||
|
names: Arc<std::sync::RwLock<Names>>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let (reader, mut writer) = tokio::io::split(conn);
|
||||||
|
let mut lines = BufReader::new(reader).lines();
|
||||||
|
|
||||||
|
let line = match lines.next_line().await? {
|
||||||
|
Some(l) => l,
|
||||||
|
None => return Ok(()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let req: Request = match serde_json::from_str(&line) {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
let resp = Response::err(format!("JSON 解析错误: {}", e));
|
||||||
|
writer.write_all(resp.to_json_line()?.as_bytes()).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let resp = dispatch(req, &db, &names).await;
|
||||||
|
writer.write_all(resp.to_json_line()?.as_bytes()).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn dispatch(
|
async fn dispatch(
|
||||||
req: Request,
|
req: Request,
|
||||||
db: &DbCache,
|
db: &DbCache,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue