From b900ae5a0036dc15d37050df1d0ca5e6a358f3bf Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 21 Nov 2023 12:15:41 -0500 Subject: [PATCH] Disable WSL integration With WSL, objdiff is unable to get filesystem notifications. It's recommended to run objdiff natively on Windows, so having this option is more confusing than useful. --- Cargo.toml | 1 + src/views/config.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 019582f..ebb3315 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ strip = "debuginfo" [features] default = [] wgpu = ["eframe/wgpu"] +wsl = [] [dependencies] anyhow = "1.0.75" diff --git a/src/views/config.rs b/src/views/config.rs index ad35e83..1bec40f 100644 --- a/src/views/config.rs +++ b/src/views/config.rs @@ -1,4 +1,4 @@ -#[cfg(windows)] +#[cfg(feature = "wsl")] use std::string::FromUtf16Error; use std::{ borrow::Cow, @@ -6,7 +6,7 @@ use std::{ path::{PathBuf, MAIN_SEPARATOR}, }; -#[cfg(windows)] +#[cfg(feature = "wsl")] use anyhow::{Context, Result}; use const_format::formatcp; use egui::{ @@ -43,7 +43,7 @@ pub struct ConfigViewState { pub object_search: String, pub filter_diffable: bool, pub filter_incomplete: bool, - #[cfg(windows)] + #[cfg(feature = "wsl")] pub available_wsl_distros: Option>, } @@ -87,7 +87,7 @@ pub const DEFAULT_WATCH_PATTERNS: &[&str] = &[ "*.inc", "*.py", "*.yml", "*.txt", "*.json", ]; -#[cfg(windows)] +#[cfg(feature = "wsl")] fn process_utf16(bytes: &[u8]) -> Result { let u16_bytes: Vec = bytes .chunks_exact(2) @@ -96,7 +96,7 @@ fn process_utf16(bytes: &[u8]) -> Result { String::from_utf16(&u16_bytes) } -#[cfg(windows)] +#[cfg(feature = "wsl")] fn wsl_cmd(args: &[&str]) -> Result { use std::{os::windows::process::CommandExt, process::Command}; let output = Command::new("wsl") @@ -107,7 +107,7 @@ fn wsl_cmd(args: &[&str]) -> Result { process_utf16(&output.stdout).context("Failed to process stdout") } -#[cfg(windows)] +#[cfg(feature = "wsl")] fn fetch_wsl2_distros() -> Vec { wsl_cmd(&["-l", "-q"]) .map(|stdout| { @@ -180,7 +180,7 @@ pub fn config_ui( } ui.separator(); - #[cfg(windows)] + #[cfg(feature = "wsl")] { ui.heading("Build"); if state.available_wsl_distros.is_none() { @@ -196,7 +196,7 @@ pub fn config_ui( }); ui.separator(); } - #[cfg(not(windows))] + #[cfg(not(feature = "wsl"))] { let _ = selected_wsl_distro; }