From de3fe2fdf1b64507bab1d599bfa20a0432e99178 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 5 Sep 2026 13:21:02 +0300 Subject: [PATCH] Remove native and web compiler warnings Reuse the application library from the binary entry point instead of compiling the module tree twice. Keep desktop-only transports and caches out of web builds, remove unused test code, and check executable targets in CI. --- .github/workflows/control.yml | 3 ++- src/app/automation.rs | 8 ++++++++ src/app/mod.rs | 3 +-- src/app/properties.rs | 3 --- src/main.rs | 26 ++++---------------------- src/modules/insert/picker.rs | 6 ------ src/scene/mod.rs | 2 ++ src/scene/selection.rs | 8 ++++---- 8 files changed, 21 insertions(+), 38 deletions(-) diff --git a/.github/workflows/control.yml b/.github/workflows/control.yml index a656c10ba..738ec4e1a 100644 --- a/.github/workflows/control.yml +++ b/.github/workflows/control.yml @@ -20,6 +20,7 @@ jobs: cargo test --lib app::control::tests cargo test --lib io::update_check::tests cargo test --lib scene::pipeline::wire_arena::tests + cargo check --all-targets - name: Validate MCP smoke script if: runner.os != 'Windows' run: python3 -m py_compile docs/automation/mcp_smoke.py @@ -40,4 +41,4 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - - run: cargo check --lib --target wasm32-unknown-unknown + - run: cargo check --lib --bins --target wasm32-unknown-unknown diff --git a/src/app/automation.rs b/src/app/automation.rs index f2156458d..3836ada6b 100644 --- a/src/app/automation.rs +++ b/src/app/automation.rs @@ -14,6 +14,7 @@ //! - `{"op":"save","path":"out.dwg"}` — write the document (path optional //! once opened/saved) +#[cfg(not(target_arch = "wasm32"))] use std::io::{BufRead, Write}; use std::path::PathBuf; @@ -24,6 +25,7 @@ use super::OpenCADStudio; /// Run the headless JSON server. Default transport is stdin/stdout; with /// `--port ` it instead listens on `127.0.0.1:` and serves one client at /// a time (the document session persists across reconnects). +#[cfg(not(target_arch = "wasm32"))] pub fn serve() { let mut app = OpenCADStudio::new(); match port_arg() { @@ -35,6 +37,7 @@ pub fn serve() { /// Headless one-shot format conversion (`--export IN OUT`). Loads `input`, /// writes `output` (format chosen from `output`'s extension), and returns a /// process exit code (0 on success). No window is created. +#[cfg(not(target_arch = "wasm32"))] pub fn export_headless(input: &std::path::Path, output: &std::path::Path) -> i32 { let doc = match crate::io::load_file(input) { Ok(doc) => doc, @@ -56,6 +59,7 @@ pub fn export_headless(input: &std::path::Path, output: &std::path::Path) -> i32 } /// `--port ` if present on the command line. +#[cfg(not(target_arch = "wasm32"))] fn port_arg() -> Option { let mut args = std::env::args(); while let Some(a) = args.next() { @@ -66,10 +70,12 @@ fn port_arg() -> Option { None } +#[cfg(not(target_arch = "wasm32"))] fn ready() -> Value { json!({ "ok": true, "ready": true, "version": env!("OCS_APP_VERSION") }) } +#[cfg(not(target_arch = "wasm32"))] fn serve_stdio(app: &mut OpenCADStudio) { let stdin = std::io::stdin(); let stdout = std::io::stdout(); @@ -91,6 +97,7 @@ fn serve_stdio(app: &mut OpenCADStudio) { } } +#[cfg(not(target_arch = "wasm32"))] fn serve_socket(app: &mut OpenCADStudio, port: u16) { let listener = match std::net::TcpListener::bind(("127.0.0.1", port)) { Ok(l) => l, @@ -192,6 +199,7 @@ fn entity_json(e: &acadrust::EntityType) -> Value { impl OpenCADStudio { /// Handle one JSON request line and return the JSON response. + #[cfg(any(test, not(target_arch = "wasm32")))] pub(crate) fn automation_op(&mut self, line: &str) -> Value { if let Ok(req) = serde_json::from_str::(line) { if req["protocol"].is_number() { diff --git a/src/app/mod.rs b/src/app/mod.rs index 30b27554e..eb89bc04c 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -538,8 +538,6 @@ pub(super) struct OpenCADStudio { /// Last time block-usage was flushed to disk (debounce per 2.4). #[cfg(not(target_arch = "wasm32"))] block_usage_last_persist: Option, - #[cfg(target_arch = "wasm32")] - block_usage_last_persist: Option<()>, /// `true` after a bare `VPORTS` in model space — the next command-line /// entry is treated as the tiled-config option (SIngle/2H/2V/4). awaiting_vports: bool, @@ -3354,6 +3352,7 @@ impl OpenCADStudio { cliprompt_lines: 3, block_mru: Vec::new(), block_freq: std::collections::HashMap::new(), + #[cfg(not(target_arch = "wasm32"))] block_usage_last_persist: None, awaiting_vports: false, pending_setvar: None, diff --git a/src/app/properties.rs b/src/app/properties.rs index 8a02a4fff..55e291820 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -3695,7 +3695,6 @@ mod apply_property_op_tests { use acadrust::types::{Color, Vector3}; fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle { - let i = app.active_tab; let mut line = Line::new(); line.start = Vector3::ZERO; line.end = Vector3::new(1.0, 0.0, 0.0); @@ -3798,7 +3797,6 @@ mod chprop_integration_tests { use acadrust::types::{Color, LineWeight, Vector3}; fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle { - let i = app.active_tab; let mut line = Line::new(); line.start = Vector3::ZERO; line.end = Vector3::new(1.0, 0.0, 0.0); @@ -3957,7 +3955,6 @@ mod chprop_integration_tests { #[test] fn ribbon_lineweight_updates_after_change() { let mut app = OpenCADStudio::new_for_test(); - let i = app.active_tab; let _h = line_handle(&mut app); let _ = app.automation_op(r#"{"op":"select","type":"Line"}"#); diff --git a/src/main.rs b/src/main.rs index 9540e4972..f197aa6f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,29 +4,11 @@ // attached so eprintln! / panics stay visible while developing. #![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] -mod app; -mod config; +use OpenCADStudio::app; #[cfg(not(target_arch = "wasm32"))] -mod cli; -mod command; -mod entities; -mod i18n; -mod io; -#[cfg(not(target_arch = "wasm32"))] -mod network; -#[cfg(not(target_arch = "wasm32"))] -mod mcp; -mod modules; -mod patreon; -mod discussions; -mod videos; -mod plugin; -mod perf; -mod scene; -mod snap; -mod ui; -mod par; -mod sys; +use OpenCADStudio::{cli, io, mcp}; +#[cfg(target_arch = "wasm32")] +use OpenCADStudio::sys; fn main() -> iced::Result { // Web (wasm) uses the single-window entry; native uses the multi-window diff --git a/src/modules/insert/picker.rs b/src/modules/insert/picker.rs index bc141be4a..bf5792f58 100644 --- a/src/modules/insert/picker.rs +++ b/src/modules/insert/picker.rs @@ -129,12 +129,6 @@ impl BlockPicker { ); } - /// Test helper: simulate typing without exact-match handling. - #[cfg(test)] - pub fn set_needle_for_test(&mut self, needle: &str) { - self.set_needle(needle.to_string()); - } - fn filter_ranked_inner( available: &[String], lower_cache: &[String], diff --git a/src/scene/mod.rs b/src/scene/mod.rs index b5fe0efd6..9642523f1 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1632,6 +1632,7 @@ pub struct Scene { /// `geometry_epoch` and re-tessellating the whole model. pub selection_generation: u64, /// Cached fingerprint of `selected`, recomputed lazily after mutations. + #[cfg(any(test, not(target_arch = "wasm32")))] selection_fingerprint_cache: u64, selection_fingerprint_dirty: bool, /// Cached tessellation of all visible entity wires for the current layout. @@ -2026,6 +2027,7 @@ impl Scene { projection_bounds_epoch: std::cell::Cell::new(0), block_epoch: GEOMETRY_EPOCH.fetch_add(1, Ordering::Relaxed), selection_generation: 0, + #[cfg(any(test, not(target_arch = "wasm32")))] selection_fingerprint_cache: 0, selection_fingerprint_dirty: false, wire_cache: RefCell::new(None), diff --git a/src/scene/selection.rs b/src/scene/selection.rs index fb739ce64..590635f04 100644 --- a/src/scene/selection.rs +++ b/src/scene/selection.rs @@ -1,9 +1,5 @@ -// Auto-split from scene/mod.rs. Pure text-move; behaviour unchanged. use super::*; -use std::collections::hash_map::DefaultHasher; -use std::hash::{Hash, Hasher}; - impl Scene { // ── Selection ───────────────────────────────────────────────────────── /// Treat a classic LEADER and its attached annotation as one logical object. @@ -102,7 +98,11 @@ impl Scene { self.selected.len() } + #[cfg(any(test, not(target_arch = "wasm32")))] pub(crate) fn selection_fingerprint(&mut self) -> u64 { + use std::collections::hash_map::DefaultHasher; + use std::hash::{Hash, Hasher}; + if self.selection_fingerprint_dirty { let mut fingerprint = self.selected.len() as u64; for handle in &self.selected {