使用rust的宏来控制编译,是的可以适配本地调试环境和公司的正式环境

This commit is contained in:
Ekko.bao 2024-09-20 08:54:02 +08:00
parent ed30319430
commit db28e8525c
3 changed files with 14 additions and 4 deletions

View File

@ -30,4 +30,5 @@ env = { "RUST_LOG" = "debug" }
[features] [features]
atime_read = [] ekko_simulated = [] # 开启本地模拟用于debug测试开发
# default = ["ekko_simulated"]

View File

@ -235,14 +235,16 @@ impl MsgSyncPipe {
} }
pub fn reply_msg(&mut self) { pub fn reply_msg(&mut self) {
// read pipe file to update access time // read pipe file to update access time
#[cfg(features = "atime_read")] #[cfg(not(feature = "ekko_simulated"))]
{ {
print!("read pipe file to update access time");
let mut file = File::options().read(true).open(&self.pipe_file).unwrap(); let mut file = File::options().read(true).open(&self.pipe_file).unwrap();
let mut buffer = Vec::new(); let mut buffer = Vec::new();
let _ = file.read_to_end(&mut buffer); let _ = file.read_to_end(&mut buffer);
} }
#[cfg(not(features = "atime_read"))] #[cfg(feature = "ekko_simulated")]
{ {
print!("write pipe file to update access time");
let mut file = File::options().write(true).open(&self.pipe_file).unwrap(); let mut file = File::options().write(true).open(&self.pipe_file).unwrap();
let _ = file.write("sstar_l0l3clip_sync".as_bytes()); let _ = file.write("sstar_l0l3clip_sync".as_bytes());
drop(file); drop(file);
@ -283,6 +285,7 @@ impl MsgSyncPipe {
let sub_path = path.next().unwrap().to_string(); let sub_path = path.next().unwrap().to_string();
for drive in 'C'..='Z' { for drive in 'C'..='Z' {
let sub_path = format!("{}:{}", drive, sub_path); let sub_path = format!("{}:{}", drive, sub_path);
#[cfg(feature = "ekko_simulated")]
let sub_path = sub_path.replace("baoyucang", "BYC10"); let sub_path = sub_path.replace("baoyucang", "BYC10");
log::trace!("trying to find pipe file in {}", sub_path); log::trace!("trying to find pipe file in {}", sub_path);
let sync_pipe = Path::new(&sub_path).join("sync_pipe"); let sync_pipe = Path::new(&sub_path).join("sync_pipe");
@ -294,7 +297,10 @@ impl MsgSyncPipe {
return Err("You should mapping l0 c:\\ to l3".into()) return Err("You should mapping l0 c:\\ to l3".into())
} }
} }
#[cfg(feature = "ekko_simulated")]
static VM_EXE_NAME:&str = "mstsc.exe"; static VM_EXE_NAME:&str = "mstsc.exe";
#[cfg(not(feature = "ekko_simulated"))]
static VM_EXE_NAME:&str = "vmware_view.exe";
// 同步获取消息的线程 // 同步获取消息的线程
async fn msg_reciver(ctx:Arc<Mutex<ClipboardSync>>) { async fn msg_reciver(ctx:Arc<Mutex<ClipboardSync>>) {
let mut ctx = ctx.lock().await; let mut ctx = ctx.lock().await;

View File

@ -9,8 +9,11 @@ use tokio::sync::Mutex;
use std::sync::Arc; use std::sync::Arc;
use clap::{App, Arg}; use clap::{App, Arg};
// const SERVER:&str = "172.19.36.79";
#[cfg(feature = "ekko_simulated")]
const SERVER:&str = "192.168.0.116:5000"; const SERVER:&str = "192.168.0.116:5000";
#[cfg(not(feature = "ekko_simulated"))]
const SERVER:&str = "172.19.36.79";
fn param_parser() -> (Character, String) { fn param_parser() -> (Character, String) {
let mut character = Character::Consumer; let mut character = Character::Consumer;