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.
This commit is contained in:
Hakan Seven committed 2026-09-05 13:21:02 +03:00
1 parent 3253965194
commit de3fe2fdf1
8 files changed
+21 -38

No files matched your search

+2 -1
View File
@@ -20,6 +20,7 @@ jobs:
cargo test --lib app::control::tests cargo test --lib app::control::tests
cargo test --lib io::update_check::tests cargo test --lib io::update_check::tests
cargo test --lib scene::pipeline::wire_arena::tests cargo test --lib scene::pipeline::wire_arena::tests
cargo check --all-targets
- name: Validate MCP smoke script - name: Validate MCP smoke script
if: runner.os != 'Windows' if: runner.os != 'Windows'
run: python3 -m py_compile docs/automation/mcp_smoke.py run: python3 -m py_compile docs/automation/mcp_smoke.py
@@ -40,4 +41,4 @@ jobs:
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
with: with:
targets: wasm32-unknown-unknown targets: wasm32-unknown-unknown
- run: cargo check --lib --target wasm32-unknown-unknown - run: cargo check --lib --bins --target wasm32-unknown-unknown
+8
View File
@@ -14,6 +14,7 @@
//! - `{"op":"save","path":"out.dwg"}` — write the document (path optional //! - `{"op":"save","path":"out.dwg"}` — write the document (path optional
//! once opened/saved) //! once opened/saved)
#[cfg(not(target_arch = "wasm32"))]
use std::io::{BufRead, Write}; use std::io::{BufRead, Write};
use std::path::PathBuf; use std::path::PathBuf;
@@ -24,6 +25,7 @@ use super::OpenCADStudio;
/// Run the headless JSON server. Default transport is stdin/stdout; with /// Run the headless JSON server. Default transport is stdin/stdout; with
/// `--port <N>` it instead listens on `127.0.0.1:<N>` and serves one client at /// `--port <N>` it instead listens on `127.0.0.1:<N>` and serves one client at
/// a time (the document session persists across reconnects). /// a time (the document session persists across reconnects).
#[cfg(not(target_arch = "wasm32"))]
pub fn serve() { pub fn serve() {
let mut app = OpenCADStudio::new(); let mut app = OpenCADStudio::new();
match port_arg() { match port_arg() {
@@ -35,6 +37,7 @@ pub fn serve() {
/// Headless one-shot format conversion (`--export IN OUT`). Loads `input`, /// Headless one-shot format conversion (`--export IN OUT`). Loads `input`,
/// writes `output` (format chosen from `output`'s extension), and returns a /// writes `output` (format chosen from `output`'s extension), and returns a
/// process exit code (0 on success). No window is created. /// 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 { pub fn export_headless(input: &std::path::Path, output: &std::path::Path) -> i32 {
let doc = match crate::io::load_file(input) { let doc = match crate::io::load_file(input) {
Ok(doc) => doc, Ok(doc) => doc,
@@ -56,6 +59,7 @@ pub fn export_headless(input: &std::path::Path, output: &std::path::Path) -> i32
} }
/// `--port <N>` if present on the command line. /// `--port <N>` if present on the command line.
#[cfg(not(target_arch = "wasm32"))]
fn port_arg() -> Option<u16> { fn port_arg() -> Option<u16> {
let mut args = std::env::args(); let mut args = std::env::args();
while let Some(a) = args.next() { while let Some(a) = args.next() {
@@ -66,10 +70,12 @@ fn port_arg() -> Option<u16> {
None None
} }
#[cfg(not(target_arch = "wasm32"))]
fn ready() -> Value { fn ready() -> Value {
json!({ "ok": true, "ready": true, "version": env!("OCS_APP_VERSION") }) json!({ "ok": true, "ready": true, "version": env!("OCS_APP_VERSION") })
} }
#[cfg(not(target_arch = "wasm32"))]
fn serve_stdio(app: &mut OpenCADStudio) { fn serve_stdio(app: &mut OpenCADStudio) {
let stdin = std::io::stdin(); let stdin = std::io::stdin();
let stdout = std::io::stdout(); 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) { fn serve_socket(app: &mut OpenCADStudio, port: u16) {
let listener = match std::net::TcpListener::bind(("127.0.0.1", port)) { let listener = match std::net::TcpListener::bind(("127.0.0.1", port)) {
Ok(l) => l, Ok(l) => l,
@@ -192,6 +199,7 @@ fn entity_json(e: &acadrust::EntityType) -> Value {
impl OpenCADStudio { impl OpenCADStudio {
/// Handle one JSON request line and return the JSON response. /// 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 { pub(crate) fn automation_op(&mut self, line: &str) -> Value {
if let Ok(req) = serde_json::from_str::<Value>(line) { if let Ok(req) = serde_json::from_str::<Value>(line) {
if req["protocol"].is_number() { if req["protocol"].is_number() {
+1 -2
View File
@@ -538,8 +538,6 @@ pub(super) struct OpenCADStudio {
/// Last time block-usage was flushed to disk (debounce per 2.4). /// Last time block-usage was flushed to disk (debounce per 2.4).
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
block_usage_last_persist: Option<std::time::Instant>, block_usage_last_persist: Option<std::time::Instant>,
#[cfg(target_arch = "wasm32")]
block_usage_last_persist: Option<()>,
/// `true` after a bare `VPORTS` in model space — the next command-line /// `true` after a bare `VPORTS` in model space — the next command-line
/// entry is treated as the tiled-config option (SIngle/2H/2V/4). /// entry is treated as the tiled-config option (SIngle/2H/2V/4).
awaiting_vports: bool, awaiting_vports: bool,
@@ -3354,6 +3352,7 @@ impl OpenCADStudio {
cliprompt_lines: 3, cliprompt_lines: 3,
block_mru: Vec::new(), block_mru: Vec::new(),
block_freq: std::collections::HashMap::new(), block_freq: std::collections::HashMap::new(),
#[cfg(not(target_arch = "wasm32"))]
block_usage_last_persist: None, block_usage_last_persist: None,
awaiting_vports: false, awaiting_vports: false,
pending_setvar: None, pending_setvar: None,
-3
View File
@@ -3695,7 +3695,6 @@ mod apply_property_op_tests {
use acadrust::types::{Color, Vector3}; use acadrust::types::{Color, Vector3};
fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle { fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle {
let i = app.active_tab;
let mut line = Line::new(); let mut line = Line::new();
line.start = Vector3::ZERO; line.start = Vector3::ZERO;
line.end = Vector3::new(1.0, 0.0, 0.0); line.end = Vector3::new(1.0, 0.0, 0.0);
@@ -3798,7 +3797,6 @@ mod chprop_integration_tests {
use acadrust::types::{Color, LineWeight, Vector3}; use acadrust::types::{Color, LineWeight, Vector3};
fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle { fn line_handle(app: &mut OpenCADStudio) -> acadrust::Handle {
let i = app.active_tab;
let mut line = Line::new(); let mut line = Line::new();
line.start = Vector3::ZERO; line.start = Vector3::ZERO;
line.end = Vector3::new(1.0, 0.0, 0.0); line.end = Vector3::new(1.0, 0.0, 0.0);
@@ -3957,7 +3955,6 @@ mod chprop_integration_tests {
#[test] #[test]
fn ribbon_lineweight_updates_after_change() { fn ribbon_lineweight_updates_after_change() {
let mut app = OpenCADStudio::new_for_test(); let mut app = OpenCADStudio::new_for_test();
let i = app.active_tab;
let _h = line_handle(&mut app); let _h = line_handle(&mut app);
let _ = app.automation_op(r#"{"op":"select","type":"Line"}"#); let _ = app.automation_op(r#"{"op":"select","type":"Line"}"#);
+4 -22
View File
@@ -4,29 +4,11 @@
// attached so eprintln! / panics stay visible while developing. // attached so eprintln! / panics stay visible while developing.
#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")] #![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
mod app; use OpenCADStudio::app;
mod config;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
mod cli; use OpenCADStudio::{cli, io, mcp};
mod command; #[cfg(target_arch = "wasm32")]
mod entities; use OpenCADStudio::sys;
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;
fn main() -> iced::Result { fn main() -> iced::Result {
// Web (wasm) uses the single-window entry; native uses the multi-window // Web (wasm) uses the single-window entry; native uses the multi-window
-6
View File
@@ -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( fn filter_ranked_inner(
available: &[String], available: &[String],
lower_cache: &[String], lower_cache: &[String],
+2
View File
@@ -1632,6 +1632,7 @@ pub struct Scene {
/// `geometry_epoch` and re-tessellating the whole model. /// `geometry_epoch` and re-tessellating the whole model.
pub selection_generation: u64, pub selection_generation: u64,
/// Cached fingerprint of `selected`, recomputed lazily after mutations. /// Cached fingerprint of `selected`, recomputed lazily after mutations.
#[cfg(any(test, not(target_arch = "wasm32")))]
selection_fingerprint_cache: u64, selection_fingerprint_cache: u64,
selection_fingerprint_dirty: bool, selection_fingerprint_dirty: bool,
/// Cached tessellation of all visible entity wires for the current layout. /// 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), projection_bounds_epoch: std::cell::Cell::new(0),
block_epoch: GEOMETRY_EPOCH.fetch_add(1, Ordering::Relaxed), block_epoch: GEOMETRY_EPOCH.fetch_add(1, Ordering::Relaxed),
selection_generation: 0, selection_generation: 0,
#[cfg(any(test, not(target_arch = "wasm32")))]
selection_fingerprint_cache: 0, selection_fingerprint_cache: 0,
selection_fingerprint_dirty: false, selection_fingerprint_dirty: false,
wire_cache: RefCell::new(None), wire_cache: RefCell::new(None),
+4 -4
View File
@@ -1,9 +1,5 @@
// Auto-split from scene/mod.rs. Pure text-move; behaviour unchanged.
use super::*; use super::*;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
impl Scene { impl Scene {
// ── Selection ───────────────────────────────────────────────────────── // ── Selection ─────────────────────────────────────────────────────────
/// Treat a classic LEADER and its attached annotation as one logical object. /// Treat a classic LEADER and its attached annotation as one logical object.
@@ -102,7 +98,11 @@ impl Scene {
self.selected.len() self.selected.len()
} }
#[cfg(any(test, not(target_arch = "wasm32")))]
pub(crate) fn selection_fingerprint(&mut self) -> u64 { pub(crate) fn selection_fingerprint(&mut self) -> u64 {
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
if self.selection_fingerprint_dirty { if self.selection_fingerprint_dirty {
let mut fingerprint = self.selected.len() as u64; let mut fingerprint = self.selected.len() as u64;
for handle in &self.selected { for handle in &self.selected {