Skip to content

Commit e88db02

Browse files
authored
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
1 parent 02e3293 commit e88db02

5 files changed

Lines changed: 24 additions & 12 deletions

File tree

.github/workflows/build-linux-bundle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch: {}
55
push:
66
branches:
7-
- main
7+
- master
88

99
jobs:
1010
build:

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/wasm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ license = "Apache-2.0"
1414
default = ["gpu", "shader-nodes"]
1515
gpu = ["editor/gpu"]
1616
shader-nodes = ["graphene-std/shader-nodes", "gpu"]
17-
native = []
17+
native = ["node-macro/disable-registration"]
1818

1919
[lib]
2020
crate-type = ["cdylib", "rlib"]
@@ -39,6 +39,7 @@ wgpu = { workspace = true }
3939
web-sys = { workspace = true }
4040
ron = { workspace = true }
4141
serde_json = { workspace = true }
42+
node-macro = { workspace = true }
4243

4344
[package.metadata.wasm-pack.profile.dev]
4445
wasm-opt = false

node-graph/node-macro/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ license = "Apache-2.0"
1313
[lib]
1414
proc-macro = true
1515

16+
[features]
17+
disable-registration = []
18+
1619
[dependencies]
1720
# Workspace dependencies
1821
syn = { workspace = true }

node-graph/node-macro/src/codegen.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,18 +678,25 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st
678678
}
679679
let registry_name = format_ident!("__node_registry_{}_{}", NODE_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst), struct_name);
680680

681+
let native = quote! {
682+
#[cfg_attr(not(target_family = "wasm"), ctor)]
683+
fn register_node() {
684+
let mut registry = NODE_REGISTRY.lock().unwrap();
685+
registry.insert(
686+
#identifier(),
687+
vec![
688+
#(#constructors,)*
689+
]
690+
);
691+
}
692+
};
693+
if cfg!(feature = "disable-registration") {
694+
return Ok(native);
695+
}
696+
681697
Ok(quote! {
698+
#native
682699

683-
#[cfg_attr(not(target_family = "wasm"), ctor)]
684-
fn register_node() {
685-
let mut registry = NODE_REGISTRY.lock().unwrap();
686-
registry.insert(
687-
#identifier(),
688-
vec![
689-
#(#constructors,)*
690-
]
691-
);
692-
}
693700
#[cfg(target_family = "wasm")]
694701
#[unsafe(no_mangle)]
695702
extern "C" fn #registry_name() {

0 commit comments

Comments
 (0)