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"}"#);