From ca5d8a9c55dffd06eb34571a0a6042995570cda5 Mon Sep 17 00:00:00 2001 From: funman300 Date: Thu, 14 May 2026 18:50:30 -0700 Subject: [PATCH] fix(engine): silence Android-target dead-code and unused-import warnings All 10 warnings were caused by hotkey/keyboard UI code behind #[cfg(not(target_os = "android"))] call sites whose definitions lacked the matching gate. Fixes: - help_plugin: gate keyboard-chip imports and font_kbd; #[allow(dead_code)] on ControlRow (keys field is data, not dead) - hud_plugin/ui_modal: replace cfg shadow pattern with cfg!() expression so the hotkey parameter is read on every platform - home_plugin: gate fn hotkey behind not(android) - onboarding_plugin: gate HotkeyRow, HOTKEYS, spawn_slide_hotkeys and their exclusive imports behind not(android) - replay_overlay: gate keybind_footer_hint_text behind not(android) Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/docker-build.yml | 12 +++++++----- solitaire_engine/src/help_plugin.rs | 9 +++++---- solitaire_engine/src/home_plugin.rs | 1 + solitaire_engine/src/hud_plugin.rs | 3 +-- solitaire_engine/src/onboarding_plugin.rs | 9 +++++++-- solitaire_engine/src/replay_overlay.rs | 1 + solitaire_engine/src/ui_modal.rs | 3 +-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 6b288d6..9200482 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -3,11 +3,13 @@ name: Build and Deploy on: push: branches: [master] - # Only run when server code changes, not when CI itself updates deploy/. - paths-ignore: - - 'deploy/**' - - 'argocd/**' - - '**.md' + paths: + - 'solitaire_server/**' + - 'solitaire_sync/**' + - 'solitaire_core/**' + - 'Cargo.toml' + - 'Cargo.lock' + - '.gitea/workflows/docker-build.yml' env: REGISTRY: git.aleshym.co diff --git a/solitaire_engine/src/help_plugin.rs b/solitaire_engine/src/help_plugin.rs index 6a04606..cbf47fa 100644 --- a/solitaire_engine/src/help_plugin.rs +++ b/solitaire_engine/src/help_plugin.rs @@ -13,10 +13,9 @@ use crate::ui_modal::{ spawn_modal, spawn_modal_actions, spawn_modal_button, spawn_modal_header, ButtonVariant, ScrimDismissible, }; -use crate::ui_theme::{ - BORDER_SUBTLE, HighContrastBorder, RADIUS_SM, SPACE_2, TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY, - TYPE_CAPTION, VAL_SPACE_1, VAL_SPACE_2, VAL_SPACE_3, Z_MODAL_PANEL, -}; +use crate::ui_theme::{SPACE_2, TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY, VAL_SPACE_2, VAL_SPACE_3, Z_MODAL_PANEL}; +#[cfg(not(target_os = "android"))] +use crate::ui_theme::{BORDER_SUBTLE, HighContrastBorder, RADIUS_SM, TYPE_CAPTION, VAL_SPACE_1}; /// Marker on the help overlay root node. #[derive(Component, Debug)] @@ -123,6 +122,7 @@ fn scroll_help_panel( } /// Each entry in the controls reference table. +#[allow(dead_code)] struct ControlRow { keys: &'static str, description: &'static str, @@ -243,6 +243,7 @@ fn spawn_help_screen(commands: &mut Commands, font_res: Option<&FontResource>) { ..default() }; let font_row = font_section.clone(); + #[cfg(not(target_os = "android"))] let font_kbd = TextFont { font: font_handle, font_size: TYPE_CAPTION, diff --git a/solitaire_engine/src/home_plugin.rs b/solitaire_engine/src/home_plugin.rs index a08704d..8b93e24 100644 --- a/solitaire_engine/src/home_plugin.rs +++ b/solitaire_engine/src/home_plugin.rs @@ -174,6 +174,7 @@ impl HomeMode { /// The keyboard accelerator that dispatches the same launch event, /// shown in a small chip on the card. + #[cfg(not(target_os = "android"))] fn hotkey(self) -> &'static str { match self { HomeMode::Classic => "N", diff --git a/solitaire_engine/src/hud_plugin.rs b/solitaire_engine/src/hud_plugin.rs index 5c71826..ab738a3 100644 --- a/solitaire_engine/src/hud_plugin.rs +++ b/solitaire_engine/src/hud_plugin.rs @@ -799,8 +799,7 @@ fn spawn_action_button( // visibly clutter the narrow-viewport action row. Force the hint // off on Android; the chevrons on Menu/Modes remain because they // indicate dropdown behaviour and still apply on touch. - #[cfg(target_os = "android")] - let hotkey: Option<&'static str> = None; + let hotkey = if cfg!(target_os = "android") { None } else { hotkey }; let hotkey_font = TextFont { font: font.font.clone(), diff --git a/solitaire_engine/src/onboarding_plugin.rs b/solitaire_engine/src/onboarding_plugin.rs index 616cbf0..98391f9 100644 --- a/solitaire_engine/src/onboarding_plugin.rs +++ b/solitaire_engine/src/onboarding_plugin.rs @@ -31,9 +31,11 @@ use crate::ui_modal::{ spawn_modal, spawn_modal_actions, spawn_modal_body_text, spawn_modal_button, spawn_modal_header, ButtonVariant, }; +use crate::ui_theme::{TEXT_SECONDARY, Z_ONBOARDING}; +#[cfg(not(target_os = "android"))] use crate::ui_theme::{ - BORDER_SUBTLE, HighContrastBorder, RADIUS_SM, TEXT_PRIMARY, TEXT_SECONDARY, TYPE_BODY, - TYPE_CAPTION, VAL_SPACE_1, VAL_SPACE_2, VAL_SPACE_3, Z_ONBOARDING, + BORDER_SUBTLE, HighContrastBorder, RADIUS_SM, TEXT_PRIMARY, TYPE_BODY, TYPE_CAPTION, + VAL_SPACE_1, VAL_SPACE_2, VAL_SPACE_3, }; // --------------------------------------------------------------------------- @@ -86,6 +88,7 @@ pub struct OnboardingSlideIndex(pub u8); // --------------------------------------------------------------------------- /// A single `key — description` pair shown on slide 3. +#[cfg(not(target_os = "android"))] struct HotkeyRow { keys: &'static str, description: &'static str, @@ -96,6 +99,7 @@ struct HotkeyRow { /// Updating the list in `help_plugin.rs` should be mirrored here. The /// ARCHITECTURE.md decision log calls out that we copy values rather than /// refactor the help plugin. +#[cfg(not(target_os = "android"))] const HOTKEYS: &[HotkeyRow] = &[ HotkeyRow { keys: "D / Space", description: "Draw from stock" }, HotkeyRow { keys: "U", description: "Undo last move" }, @@ -359,6 +363,7 @@ fn spawn_slide_how_to_play(commands: &mut Commands, font_res: Option<&FontResour } /// Slide 3 — Keyboard shortcuts. +#[cfg(not(target_os = "android"))] fn spawn_slide_hotkeys(commands: &mut Commands, font_res: Option<&FontResource>) { let font_handle = font_res.map(|f| f.0.clone()).unwrap_or_default(); let font_row = TextFont { diff --git a/solitaire_engine/src/replay_overlay.rs b/solitaire_engine/src/replay_overlay.rs index debc2df..fe064f1 100644 --- a/solitaire_engine/src/replay_overlay.rs +++ b/solitaire_engine/src/replay_overlay.rs @@ -1165,6 +1165,7 @@ fn keybind_footer_mode_text() -> &'static str { /// pause/resume, the ESC accelerator for stop, and the ← / → /// accelerators for paused single-move stepping. The footer never /// lists unimplemented keybinds (would lie to users). +#[cfg(not(target_os = "android"))] fn keybind_footer_hint_text() -> &'static str { "[SPACE] pause/resume \u{00B7} [ESC] stop \u{00B7} [\u{2190}\u{2192}] step" // · separator } diff --git a/solitaire_engine/src/ui_modal.rs b/solitaire_engine/src/ui_modal.rs index eb3dad9..0449c01 100644 --- a/solitaire_engine/src/ui_modal.rs +++ b/solitaire_engine/src/ui_modal.rs @@ -335,8 +335,7 @@ pub fn spawn_modal_button( variant: ButtonVariant, font_res: Option<&FontResource>, ) { - #[cfg(target_os = "android")] - let hotkey: Option<&'static str> = None; + let hotkey = if cfg!(target_os = "android") { None } else { hotkey }; let font_handle = font_res.map(|f| f.0.clone()).unwrap_or_default(); let font_label = TextFont { font: font_handle.clone(),