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
This commit is contained in:
Dennis Kobert 2026-01-06 13:34:15 +01:00 committed by GitHub
parent 02e3293e72
commit e88db022af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 13 deletions

View File

@ -4,7 +4,7 @@ on:
workflow_dispatch: {} workflow_dispatch: {}
push: push:
branches: branches:
- main - master
jobs: jobs:
build: build:

1
Cargo.lock generated
View File

@ -2481,6 +2481,7 @@ dependencies = [
"js-sys", "js-sys",
"log", "log",
"math-parser", "math-parser",
"node-macro",
"ron", "ron",
"serde", "serde",
"serde-wasm-bindgen", "serde-wasm-bindgen",

View File

@ -14,7 +14,7 @@ license = "Apache-2.0"
default = ["gpu", "shader-nodes"] default = ["gpu", "shader-nodes"]
gpu = ["editor/gpu"] gpu = ["editor/gpu"]
shader-nodes = ["graphene-std/shader-nodes", "gpu"] shader-nodes = ["graphene-std/shader-nodes", "gpu"]
native = [] native = ["node-macro/disable-registration"]
[lib] [lib]
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
@ -39,6 +39,7 @@ wgpu = { workspace = true }
web-sys = { workspace = true } web-sys = { workspace = true }
ron = { workspace = true } ron = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
node-macro = { workspace = true }
[package.metadata.wasm-pack.profile.dev] [package.metadata.wasm-pack.profile.dev]
wasm-opt = false wasm-opt = false

View File

@ -13,6 +13,9 @@ license = "Apache-2.0"
[lib] [lib]
proc-macro = true proc-macro = true
[features]
disable-registration = []
[dependencies] [dependencies]
# Workspace dependencies # Workspace dependencies
syn = { workspace = true } syn = { workspace = true }

View File

@ -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); 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")] #[cfg(target_family = "wasm")]
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
extern "C" fn #registry_name() { extern "C" fn #registry_name() {