From e88db022afa0bae62e90ee834cc48eb3f32b6f52 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 6 Jan 2026 13:34:15 +0100 Subject: [PATCH] Exclude node registry functions from desktop frontend builds (#3584) * Exclude node registry functions from desktop frontend builds This reduces compile times and file sizes * Use early return * Fix branch name in build-linux pipeline --- .github/workflows/build-linux-bundle.yml | 2 +- Cargo.lock | 1 + frontend/wasm/Cargo.toml | 3 ++- node-graph/node-macro/Cargo.toml | 3 +++ node-graph/node-macro/src/codegen.rs | 29 +++++++++++++++--------- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-linux-bundle.yml b/.github/workflows/build-linux-bundle.yml index 25a1e814..fe2e4e4b 100644 --- a/.github/workflows/build-linux-bundle.yml +++ b/.github/workflows/build-linux-bundle.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: {} push: branches: - - main + - master jobs: build: diff --git a/Cargo.lock b/Cargo.lock index 9aad2d2b..ce4bcaf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2481,6 +2481,7 @@ dependencies = [ "js-sys", "log", "math-parser", + "node-macro", "ron", "serde", "serde-wasm-bindgen", diff --git a/frontend/wasm/Cargo.toml b/frontend/wasm/Cargo.toml index a18b3fac..a4d21762 100644 --- a/frontend/wasm/Cargo.toml +++ b/frontend/wasm/Cargo.toml @@ -14,7 +14,7 @@ license = "Apache-2.0" default = ["gpu", "shader-nodes"] gpu = ["editor/gpu"] shader-nodes = ["graphene-std/shader-nodes", "gpu"] -native = [] +native = ["node-macro/disable-registration"] [lib] crate-type = ["cdylib", "rlib"] @@ -39,6 +39,7 @@ wgpu = { workspace = true } web-sys = { workspace = true } ron = { workspace = true } serde_json = { workspace = true } +node-macro = { workspace = true } [package.metadata.wasm-pack.profile.dev] wasm-opt = false diff --git a/node-graph/node-macro/Cargo.toml b/node-graph/node-macro/Cargo.toml index a162ed78..d8f9f5d5 100644 --- a/node-graph/node-macro/Cargo.toml +++ b/node-graph/node-macro/Cargo.toml @@ -13,6 +13,9 @@ license = "Apache-2.0" [lib] proc-macro = true +[features] +disable-registration = [] + [dependencies] # Workspace dependencies syn = { workspace = true } diff --git a/node-graph/node-macro/src/codegen.rs b/node-graph/node-macro/src/codegen.rs index 5758c7c0..aebf163c 100644 --- a/node-graph/node-macro/src/codegen.rs +++ b/node-graph/node-macro/src/codegen.rs @@ -678,18 +678,25 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st } let registry_name = format_ident!("__node_registry_{}_{}", NODE_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst), struct_name); - Ok(quote! { + let native = quote! { + #[cfg_attr(not(target_family = "wasm"), ctor)] + fn register_node() { + let mut registry = NODE_REGISTRY.lock().unwrap(); + registry.insert( + #identifier(), + vec![ + #(#constructors,)* + ] + ); + } + }; + if cfg!(feature = "disable-registration") { + return Ok(native); + } + + Ok(quote! { + #native - #[cfg_attr(not(target_family = "wasm"), ctor)] - fn register_node() { - let mut registry = NODE_REGISTRY.lock().unwrap(); - registry.insert( - #identifier(), - vec![ - #(#constructors,)* - ] - ); - } #[cfg(target_family = "wasm")] #[unsafe(no_mangle)] extern "C" fn #registry_name() {