mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-24 06:28:34 +03:00
remaining feature flags
This commit is contained in:
@@ -28,7 +28,7 @@ Lan Mouse is an open-source Software KVM sharing mouse/keyboard input across loc
|
|||||||
|
|
||||||
## Feature & cfg discipline
|
## Feature & cfg discipline
|
||||||
|
|
||||||
- Feature flags live in root `Cargo.toml`. Gate OS-specific modules with tight cfgs (e.g., `cfg(all(unix, feature = "layer_shell", not(target_os = "macos")))`).
|
- Feature flags live in root `Cargo.toml`. Gate OS-specific modules with the configs exported in build.rs (e.g., `cfg(layer_shell)`).
|
||||||
- Prefer module-level gating over per-function cfgs to avoid empty stubs.
|
- Prefer module-level gating over per-function cfgs to avoid empty stubs.
|
||||||
- New backends: add feature in `Cargo.toml`, create gated module, log backend selection.
|
- New backends: add feature in `Cargo.toml`, create gated module, log backend selection.
|
||||||
|
|
||||||
|
|||||||
53
build.rs
53
build.rs
@@ -5,4 +5,57 @@ fn main() {
|
|||||||
.deny_const(Default::default())
|
.deny_const(Default::default())
|
||||||
.build()
|
.build()
|
||||||
.expect("shadow build");
|
.expect("shadow build");
|
||||||
|
|
||||||
|
let unix = cfg!(unix);
|
||||||
|
let macos = cfg!(target_os = "macos");
|
||||||
|
|
||||||
|
let layer_shell_capture = cfg!(feature = "layer_shell_capture");
|
||||||
|
let libei_capture = cfg!(feature = "libei_capture");
|
||||||
|
let x11_capture = cfg!(feature = "x11_capture");
|
||||||
|
|
||||||
|
let libei_emulation = cfg!(feature = "libei_emulation");
|
||||||
|
let x11_emulation = cfg!(feature = "x11_emulation");
|
||||||
|
let wlroots_emulation = cfg!(feature = "wlroots_emulation");
|
||||||
|
let rdp_emulation = cfg!(feature = "rdp_emulation");
|
||||||
|
|
||||||
|
let layer_shell_capture = unix && !macos && layer_shell_capture;
|
||||||
|
let libei_capture = unix && !macos && libei_capture;
|
||||||
|
let x11_capture = unix && !macos && x11_capture;
|
||||||
|
|
||||||
|
let libei_emulation = unix && !macos && libei_emulation;
|
||||||
|
let rdp_emulation = unix && !macos && rdp_emulation;
|
||||||
|
let wlroots_emulation = unix && !macos && wlroots_emulation;
|
||||||
|
let x11_emulation = unix && !macos && x11_emulation;
|
||||||
|
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(layer_shell_capture)");
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(libei_capture)");
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(x11_capture)");
|
||||||
|
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(libei_emulation)");
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(rdp_emulation)");
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(wlroots_emulation)");
|
||||||
|
println!("cargo::rustc-check-cfg=cfg(x11_emulation)");
|
||||||
|
|
||||||
|
if layer_shell_capture {
|
||||||
|
println!("cargo::rustc-cfg=layer_shell_capture");
|
||||||
|
}
|
||||||
|
if libei_capture {
|
||||||
|
println!("cargo::rustc-cfg=libei_capture");
|
||||||
|
}
|
||||||
|
if x11_capture {
|
||||||
|
println!("cargo::rustc-cfg=x11_capture");
|
||||||
|
}
|
||||||
|
|
||||||
|
if libei_emulation {
|
||||||
|
println!("cargo::rustc-cfg=libei_emulation");
|
||||||
|
}
|
||||||
|
if rdp_emulation {
|
||||||
|
println!("cargo::rustc-cfg=rdp_emulation");
|
||||||
|
}
|
||||||
|
if wlroots_emulation {
|
||||||
|
println!("cargo::rustc-cfg=wlroots_emulation");
|
||||||
|
}
|
||||||
|
if x11_emulation {
|
||||||
|
println!("cargo::rustc-cfg=x11_emulation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,13 +118,13 @@ pub enum Command {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
|
||||||
pub enum CaptureBackend {
|
pub enum CaptureBackend {
|
||||||
#[cfg(all(unix, feature = "libei_capture", not(target_os = "macos")))]
|
#[cfg(libei_capture)]
|
||||||
#[serde(rename = "input-capture-portal")]
|
#[serde(rename = "input-capture-portal")]
|
||||||
InputCapturePortal,
|
InputCapturePortal,
|
||||||
#[cfg(all(unix, feature = "layer_shell_capture", not(target_os = "macos")))]
|
#[cfg(layer_shell_capture)]
|
||||||
#[serde(rename = "layer-shell")]
|
#[serde(rename = "layer-shell")]
|
||||||
LayerShell,
|
LayerShell,
|
||||||
#[cfg(all(unix, feature = "x11_capture", not(target_os = "macos")))]
|
#[cfg(x11_capture)]
|
||||||
#[serde(rename = "x11")]
|
#[serde(rename = "x11")]
|
||||||
X11,
|
X11,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -140,11 +140,11 @@ pub enum CaptureBackend {
|
|||||||
impl Display for CaptureBackend {
|
impl Display for CaptureBackend {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
#[cfg(all(unix, feature = "libei_capture", not(target_os = "macos")))]
|
#[cfg(libei_capture)]
|
||||||
CaptureBackend::InputCapturePortal => write!(f, "input-capture-portal"),
|
CaptureBackend::InputCapturePortal => write!(f, "input-capture-portal"),
|
||||||
#[cfg(all(unix, feature = "layer_shell_capture", not(target_os = "macos")))]
|
#[cfg(layer_shell_capture)]
|
||||||
CaptureBackend::LayerShell => write!(f, "layer-shell"),
|
CaptureBackend::LayerShell => write!(f, "layer-shell"),
|
||||||
#[cfg(all(unix, feature = "x11_capture", not(target_os = "macos")))]
|
#[cfg(x11_capture)]
|
||||||
CaptureBackend::X11 => write!(f, "X11"),
|
CaptureBackend::X11 => write!(f, "X11"),
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
CaptureBackend::Windows => write!(f, "windows"),
|
CaptureBackend::Windows => write!(f, "windows"),
|
||||||
@@ -158,11 +158,11 @@ impl Display for CaptureBackend {
|
|||||||
impl From<CaptureBackend> for input_capture::Backend {
|
impl From<CaptureBackend> for input_capture::Backend {
|
||||||
fn from(backend: CaptureBackend) -> Self {
|
fn from(backend: CaptureBackend) -> Self {
|
||||||
match backend {
|
match backend {
|
||||||
#[cfg(all(unix, feature = "libei_capture", not(target_os = "macos")))]
|
#[cfg(libei_capture)]
|
||||||
CaptureBackend::InputCapturePortal => Self::InputCapturePortal,
|
CaptureBackend::InputCapturePortal => Self::InputCapturePortal,
|
||||||
#[cfg(all(unix, feature = "layer_shell_capture", not(target_os = "macos")))]
|
#[cfg(layer_shell_capture)]
|
||||||
CaptureBackend::LayerShell => Self::LayerShell,
|
CaptureBackend::LayerShell => Self::LayerShell,
|
||||||
#[cfg(all(unix, feature = "x11_capture", not(target_os = "macos")))]
|
#[cfg(x11_capture)]
|
||||||
CaptureBackend::X11 => Self::X11,
|
CaptureBackend::X11 => Self::X11,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
CaptureBackend::Windows => Self::Windows,
|
CaptureBackend::Windows => Self::Windows,
|
||||||
@@ -175,16 +175,16 @@ impl From<CaptureBackend> for input_capture::Backend {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, ValueEnum)]
|
||||||
pub enum EmulationBackend {
|
pub enum EmulationBackend {
|
||||||
#[cfg(all(unix, feature = "wlroots_emulation", not(target_os = "macos")))]
|
#[cfg(wlroots_emulation)]
|
||||||
#[serde(rename = "wlroots")]
|
#[serde(rename = "wlroots")]
|
||||||
Wlroots,
|
Wlroots,
|
||||||
#[cfg(all(unix, feature = "libei_emulation", not(target_os = "macos")))]
|
#[cfg(libei_emulation)]
|
||||||
#[serde(rename = "libei")]
|
#[serde(rename = "libei")]
|
||||||
Libei,
|
Libei,
|
||||||
#[cfg(all(unix, feature = "rdp_emulation", not(target_os = "macos")))]
|
#[cfg(rdp_emulation)]
|
||||||
#[serde(rename = "xdp")]
|
#[serde(rename = "xdp")]
|
||||||
Xdp,
|
Xdp,
|
||||||
#[cfg(all(unix, feature = "x11_emulation", not(target_os = "macos")))]
|
#[cfg(x11_emulation)]
|
||||||
#[serde(rename = "x11")]
|
#[serde(rename = "x11")]
|
||||||
X11,
|
X11,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -200,13 +200,13 @@ pub enum EmulationBackend {
|
|||||||
impl From<EmulationBackend> for input_emulation::Backend {
|
impl From<EmulationBackend> for input_emulation::Backend {
|
||||||
fn from(backend: EmulationBackend) -> Self {
|
fn from(backend: EmulationBackend) -> Self {
|
||||||
match backend {
|
match backend {
|
||||||
#[cfg(all(unix, feature = "wlroots_emulation", not(target_os = "macos")))]
|
#[cfg(wlroots_emulation)]
|
||||||
EmulationBackend::Wlroots => Self::Wlroots,
|
EmulationBackend::Wlroots => Self::Wlroots,
|
||||||
#[cfg(all(unix, feature = "libei_emulation", not(target_os = "macos")))]
|
#[cfg(libei_emulation)]
|
||||||
EmulationBackend::Libei => Self::Libei,
|
EmulationBackend::Libei => Self::Libei,
|
||||||
#[cfg(all(unix, feature = "rdp_emulation", not(target_os = "macos")))]
|
#[cfg(rdp_emulation)]
|
||||||
EmulationBackend::Xdp => Self::Xdp,
|
EmulationBackend::Xdp => Self::Xdp,
|
||||||
#[cfg(all(unix, feature = "x11_emulation", not(target_os = "macos")))]
|
#[cfg(x11_emulation)]
|
||||||
EmulationBackend::X11 => Self::X11,
|
EmulationBackend::X11 => Self::X11,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
EmulationBackend::Windows => Self::Windows,
|
EmulationBackend::Windows => Self::Windows,
|
||||||
@@ -220,13 +220,13 @@ impl From<EmulationBackend> for input_emulation::Backend {
|
|||||||
impl Display for EmulationBackend {
|
impl Display for EmulationBackend {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
#[cfg(all(unix, feature = "wlroots_emulation", not(target_os = "macos")))]
|
#[cfg(wlroots_emulation)]
|
||||||
EmulationBackend::Wlroots => write!(f, "wlroots"),
|
EmulationBackend::Wlroots => write!(f, "wlroots"),
|
||||||
#[cfg(all(unix, feature = "libei_emulation", not(target_os = "macos")))]
|
#[cfg(libei_emulation)]
|
||||||
EmulationBackend::Libei => write!(f, "libei"),
|
EmulationBackend::Libei => write!(f, "libei"),
|
||||||
#[cfg(all(unix, feature = "rdp_emulation", not(target_os = "macos")))]
|
#[cfg(rdp_emulation)]
|
||||||
EmulationBackend::Xdp => write!(f, "xdg-desktop-portal"),
|
EmulationBackend::Xdp => write!(f, "xdg-desktop-portal"),
|
||||||
#[cfg(all(unix, feature = "x11_emulation", not(target_os = "macos")))]
|
#[cfg(x11_emulation)]
|
||||||
EmulationBackend::X11 => write!(f, "X11"),
|
EmulationBackend::X11 => write!(f, "X11"),
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
EmulationBackend::Windows => write!(f, "windows"),
|
EmulationBackend::Windows => write!(f, "windows"),
|
||||||
|
|||||||
Reference in New Issue
Block a user