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

+8
View File
@@ -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 <N>` it instead listens on `127.0.0.1:<N>` 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 <N>` if present on the command line.
#[cfg(not(target_arch = "wasm32"))]
fn port_arg() -> Option<u16> {
let mut args = std::env::args();
while let Some(a) = args.next() {
@@ -66,10 +70,12 @@ fn port_arg() -> Option<u16> {
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::<Value>(line) {
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).
#[cfg(not(target_arch = "wasm32"))]
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
/// 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,
-3
View File
@@ -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"}"#);
+4 -22
View File
@@ -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
-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(
available: &[String],
lower_cache: &[String],
+2
View File
@@ -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),
+4 -4
View File
@@ -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 {