move client and test minifb client code to seperate crates
This commit is contained in:
parent
0024f49df9
commit
96329923f6
12 changed files with 131 additions and 39 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
/target
|
||||
/client/target
|
||||
/testclient/target
|
||||
|
||||
# agent
|
||||
/agent/.cache
|
||||
|
|
|
@ -6,10 +6,13 @@ Currently NVIDIA-specific (since we use NvFBC); support for DXGI duplication (fo
|
|||
|
||||
The agent runs on Windows 7 x64 onwards. Lower (or x86) is currently not supported as a target.
|
||||
|
||||
The agent uses IVSHMEM to provide frames to the client in a low-latency fashion. Later on virtio-serial may be considered for low-bandwidth additional functionality, like input. For now, however, the agent is display only.
|
||||
The agent uses IVSHMEM to provide frames to the client in a low-latency fashion.
|
||||
|
||||
Later on virtio-serial may be considered for low-bandwidth additional functionality, like input. For now, however, the agent is display only.
|
||||
|
||||
This repository contains:
|
||||
|
||||
- The agent. Written in C++20.
|
||||
- Shared headers and utility code, used between the agent and the client. Written in C++20, mostly so it can be shared between the agent and client.
|
||||
- A simple client, written mostly in Rust (with some C++ glue since I don't feel like rewriting structures and the shared code in Rust), which displays the framebuffer (in a quick-and-dirty fashion.). Mostly test-only code. Some of it isn't though, and will be turned into a standalone client crate.
|
||||
- A Rust crate for Hazelnut clients to use. Wraps the Shared code.
|
||||
- A test client written in Rust which displays the framebuffer (in a quick-and-dirty fashion.).
|
18
build.rs
18
build.rs
|
@ -1,18 +0,0 @@
|
|||
use cc;
|
||||
|
||||
fn main() {
|
||||
let mut build = cc::Build::new();
|
||||
|
||||
// HACK: cc sucks
|
||||
println!("cargo:rerun-if-changed=src");
|
||||
println!("cargo:rerun-if-changed=shared/src");
|
||||
|
||||
build
|
||||
.emit_rerun_if_env_changed(true)
|
||||
.cpp(true)
|
||||
.std("c++20")
|
||||
.include("shared/src")
|
||||
.file("shared/src/ivshmem.cpp")
|
||||
.file("src/rust_wrapper.cpp")
|
||||
.compile("rust_ivshmem_bare");
|
||||
}
|
69
client/Cargo.lock
generated
Normal file
69
client/Cargo.lock
generated
Normal file
|
@ -0,0 +1,69 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "hazelnut_client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cc",
|
||||
"nix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.167"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "fbcserver"
|
||||
name = "hazelnut_client"
|
||||
description = "Low-level client for the Hazelnut IVSHMEM display protocol"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.93"
|
||||
minifb = "0.27.0"
|
||||
nix = { version = "0.29.0", features = [ "fs" ] }
|
||||
|
||||
[build-dependencies]
|
18
client/build.rs
Normal file
18
client/build.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use cc;
|
||||
|
||||
fn main() {
|
||||
let mut build = cc::Build::new();
|
||||
|
||||
// HACK: cc sucks
|
||||
println!("cargo:rerun-if-changed=src/rust_wrapper.cpp");
|
||||
println!("cargo:rerun-if-changed=../shared/src");
|
||||
|
||||
build
|
||||
.emit_rerun_if_env_changed(true)
|
||||
.cpp(true)
|
||||
.std("c++20")
|
||||
.include("../shared/src")
|
||||
.file("../shared/src/ivshmem.cpp")
|
||||
.file("src/rust_wrapper.cpp")
|
||||
.compile("hazelnut_client_cpp_native");
|
||||
}
|
2
client/src/lib.rs
Normal file
2
client/src/lib.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod client;
|
||||
pub use client::*;
|
28
Cargo.lock → testclient/Cargo.lock
generated
28
Cargo.lock → testclient/Cargo.lock
generated
|
@ -84,16 +84,6 @@ version = "2.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
|
||||
|
||||
[[package]]
|
||||
name = "fbcserver"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cc",
|
||||
"minifb",
|
||||
"nix 0.29.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.31"
|
||||
|
@ -183,6 +173,24 @@ dependencies = [
|
|||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hazelnut_client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cc",
|
||||
"nix 0.29.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hazelnut_testclient"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hazelnut_client",
|
||||
"minifb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.13"
|
9
testclient/Cargo.toml
Normal file
9
testclient/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "hazelnut_testclient"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.93"
|
||||
minifb = "0.27.0"
|
||||
hazelnut_client = { path = "../client" }
|
|
@ -1,13 +1,13 @@
|
|||
use minifb::{Window, WindowOptions};
|
||||
|
||||
mod hzclient;
|
||||
use hazelnut_client::*;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let mut screen_width: u32 = 320;
|
||||
let mut screen_height: u32 = 200;
|
||||
let mut window: Option<Window> = None;
|
||||
|
||||
let mut client = hzclient::HazelnutClient::new();
|
||||
let mut client = HazelnutClient::new();
|
||||
|
||||
let socket_path: String = "/dev/shm/lg-win7".into();
|
||||
|
||||
|
@ -26,8 +26,8 @@ fn main() -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
match client.tick_one() {
|
||||
hzclient::ResultCode::Fail => break,
|
||||
hzclient::ResultCode::Changed => {
|
||||
ResultCode::Fail => break,
|
||||
ResultCode::Changed => {
|
||||
let dims = client.dimensions();
|
||||
|
||||
if screen_width != dims.0 && screen_height != dims.1 {
|
||||
|
@ -58,11 +58,11 @@ fn main() -> anyhow::Result<()> {
|
|||
client.unlock();
|
||||
},
|
||||
|
||||
hzclient::sys::ResultCode::LockContended => {
|
||||
ResultCode::LockContended => {
|
||||
// contended
|
||||
}
|
||||
|
||||
hzclient::ResultCode::Unchanged => match window.as_mut() {
|
||||
ResultCode::Unchanged => match window.as_mut() {
|
||||
Some(window) => {
|
||||
client.unlock();
|
||||
|
Loading…
Reference in a new issue