chore: silence native and wasm build warnings

Gate target-specific code so neither build warns about the other's items:
native-only helpers (view, window icon, file dialogs, file association, plugin
host/guard/registry, self-update) are cfg'd to non-wasm; the wasm-only font
fallback (script_of / cjk_lang / request) is cfg'd to wasm. Drop an unused mut,
allow the few genuinely-conditional dead items (mesh_click_hit, GPU layout
helpers, parity stubs), and gate the embedded PlotSettings-unrelated dead
constants. Both targets now build clean (only the unavoidable nom/quick-xml
future-incompat dependency notice remains).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-22 02:03:34 +03:00
1 parent 2de5c7668f
commit 10e4c18ba7
20 files changed
+37 -2

No files matched your search

+1
View File
@@ -79,6 +79,7 @@ pub fn plugins_dir() -> Option<PathBuf> {
/// Delete an installed package's folder. It stays loaded for the current
/// session (the library is resident); the removal takes effect on next start.
#[cfg(not(target_arch = "wasm32"))]
pub fn uninstall(id: &str) -> Result<(), String> {
let dir = plugins_dir().ok_or("cannot locate the plugins folder")?.join(id);
if dir.is_dir() {
+1
View File
@@ -4,4 +4,5 @@
// The session adapter the registry wraps `app` in to dispatch to plugins. The
// plugin-facing contract — `BuiltinPlugin` + `HostApi` — lives in
// `ocs_plugin_api`; external cdylibs target it directly.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) use crate::app::plugin_host::HostSession;
+3
View File
@@ -16,6 +16,7 @@ pub(crate) use registry::try_dispatch;
/// the cdylib boundary — it does NOT contain genuine UB (a plugin that
/// segfaults or violates memory safety via `unsafe` can still crash the host;
/// only out-of-process isolation would). (#145)
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn guard<T>(what: &str, f: impl FnOnce() -> T) -> Option<T> {
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) {
Ok(v) => Some(v),
@@ -38,12 +39,14 @@ pub(crate) fn guard<T>(what: &str, f: impl FnOnce() -> T) -> Option<T> {
/// Process-wide queue of plugin-guard errors waiting to surface in the host's
/// command-line history. Flushed by [`drain_errors`] from the app loop.
#[cfg(not(target_arch = "wasm32"))]
fn errors() -> &'static std::sync::Mutex<Vec<String>> {
static E: std::sync::OnceLock<std::sync::Mutex<Vec<String>>> = std::sync::OnceLock::new();
E.get_or_init(|| std::sync::Mutex::new(Vec::new()))
}
/// Take and return every queued plugin-guard error since the last drain.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn drain_errors() -> Vec<String> {
std::mem::take(&mut *errors().lock().unwrap())
}
+1
View File
@@ -15,6 +15,7 @@ pub fn all_ribbon_modules() -> Vec<Box<dyn CadModule>> {
pub fn ribbon_modules_enabled(
disabled: &rustc_hash::FxHashSet<String>,
) -> Vec<Box<dyn CadModule>> {
#[cfg_attr(target_arch = "wasm32", allow(unused_mut))]
let mut core = core_registry::all_modules();
// Dynamically-loaded external plugins contribute tabs (their libraries stay
// resident for the session, so these vtables remain valid).