Skip to content

Commit f37a05e

Browse files
authored
Make gcore a std library, remove std, alloc and more unused features (#2724)
* gcore: remove features `std`, `alloc`, `gpu` and `reflections`, now always available * gcore: remove non-working features `kurbo` and `log`
1 parent b2700f7 commit f37a05e

File tree

24 files changed

+40
-199
lines changed

24 files changed

+40
-199
lines changed

Cargo.lock

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

editor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ default = ["wasm"]
1515
wasm = ["wasm-bindgen", "graphene-std/wasm", "wasm-bindgen-futures"]
1616
gpu = [
1717
"interpreted-executor/gpu",
18-
"graphene-std/gpu",
1918
"wgpu-executor",
2019
]
2120
tauri = ["ron", "decouple-execution"]

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,13 +1161,6 @@ pub(crate) fn selective_color_properties(node_id: NodeId, context: &mut NodeProp
11611161
]
11621162
}
11631163

1164-
#[cfg(feature = "gpu")]
1165-
pub(crate) fn _gpu_map_properties(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<LayoutGroup> {
1166-
let map = text_widget(parameter_widgets_info);
1167-
1168-
vec![LayoutGroup::Row { widgets: map }]
1169-
}
1170-
11711164
pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
11721165
let grid_type_index = grid::GridTypeInput::INDEX;
11731166
let spacing_index = grid::SpacingInput::<f64>::INDEX;

frontend/wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ editor = { path = "../../editor", package = "graphite-editor", features = [
2929
# Workspace dependencies
3030
graph-craft = { workspace = true }
3131
log = { workspace = true }
32-
graphene-core = { workspace = true, features = ["std", "alloc"] }
32+
graphene-core = { workspace = true }
3333
serde = { workspace = true, features = ["derive"] }
3434
wasm-bindgen = { workspace = true }
3535
serde-wasm-bindgen = { workspace = true }

node-graph/gcore/Cargo.toml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,13 @@ authors = ["Graphite Authors <[email protected]>"]
77
license = "MIT OR Apache-2.0"
88

99
[features]
10-
default = ["serde", "kurbo", "log", "std", "rand_chacha", "wasm"]
11-
log = ["dep:log"]
12-
gpu = ["spirv-std", "glam/bytemuck", "dyn-any", "glam/libm"]
10+
default = ["serde", "wasm"]
1311
nightly = []
14-
alloc = ["dyn-any", "bezier-rs"]
1512
type_id_logging = []
1613
wasm = ["web-sys"]
1714
wgpu = ["dep:wgpu"]
1815
vello = ["dep:vello", "bezier-rs/kurbo", "wgpu"]
19-
dealloc_nodes = ["reflections"]
20-
std = [
21-
"dyn-any",
22-
"dyn-any/std",
23-
"alloc",
24-
"glam/std",
25-
"specta",
26-
"num-traits/std",
27-
"rustybuzz",
28-
"image",
29-
"reflections",
30-
]
31-
reflections = ["alloc", "ctor"]
16+
dealloc_nodes = []
3217
serde = [
3318
"dep:serde",
3419
"glam/serde",
@@ -55,31 +40,30 @@ petgraph = { workspace = true, default-features = false, features = [
5540
] }
5641
rustc-hash = { workspace = true }
5742
math-parser = { path = "../../libraries/math-parser" }
43+
dyn-any = { workspace = true }
44+
ctor = { workspace = true }
45+
rand_chacha = { workspace = true }
46+
bezier-rs = { workspace = true }
47+
specta = { workspace = true }
48+
rustybuzz = { workspace = true }
49+
image = { workspace = true, default-features = false, features = [
50+
"png",
51+
] }
5852

5953
# Required dependencies
6054
half = { version = "2.4.1", default-features = false, features = ["bytemuck"] }
6155
tinyvec = { version = "1" }
56+
kurbo = { workspace = true }
57+
log = { workspace = true }
6258

6359
# Optional workspace dependencies
64-
dyn-any = { workspace = true, optional = true }
65-
spirv-std = { workspace = true, optional = true }
6660
serde = { workspace = true, optional = true, features = ["derive"] }
67-
ctor = { workspace = true, optional = true }
68-
log = { workspace = true, optional = true }
69-
rand_chacha = { workspace = true, optional = true }
70-
bezier-rs = { workspace = true, optional = true }
71-
kurbo = { workspace = true, optional = true }
7261
base64 = { workspace = true, optional = true }
7362
vello = { workspace = true, optional = true }
7463
wgpu = { workspace = true, optional = true }
75-
specta = { workspace = true, optional = true }
76-
rustybuzz = { workspace = true, optional = true }
7764
web-sys = { workspace = true, optional = true, features = [
7865
"HtmlCanvasElement",
7966
] }
80-
image = { workspace = true, optional = true, default-features = false, features = [
81-
"png",
82-
] }
8367

8468
[dev-dependencies]
8569
# Workspace dependencies

node-graph/gcore/src/application_io.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ impl Hash for SurfaceFrame {
3636
}
3737
}
3838

39-
#[cfg(feature = "dyn-any")]
4039
unsafe impl StaticType for SurfaceFrame {
4140
type Static = SurfaceFrame;
4241
}
@@ -82,7 +81,6 @@ impl PartialEq for ImageTexture {
8281
}
8382
}
8483

85-
#[cfg(feature = "dyn-any")]
8684
unsafe impl StaticType for ImageTexture {
8785
type Static = ImageTexture;
8886
}
@@ -121,7 +119,6 @@ impl<S: Size> Size for SurfaceHandle<S> {
121119
}
122120
}
123121

124-
#[cfg(feature = "dyn-any")]
125122
unsafe impl<T: 'static> StaticType for SurfaceHandle<T> {
126123
type Static = SurfaceHandle<T>;
127124
}
@@ -132,7 +129,6 @@ pub struct SurfaceHandleFrame<Surface> {
132129
pub transform: DAffine2,
133130
}
134131

135-
#[cfg(feature = "dyn-any")]
136132
unsafe impl<T: 'static> StaticType for SurfaceHandleFrame<T> {
137133
type Static = SurfaceHandleFrame<T>;
138134
}
@@ -307,7 +303,6 @@ impl<T> Debug for EditorApi<T> {
307303
}
308304
}
309305

310-
#[cfg(feature = "dyn-any")]
311306
unsafe impl<T: StaticTypeSized> StaticType for EditorApi<T> {
312307
type Static = EditorApi<T::Static>;
313308
}

node-graph/gcore/src/gpu.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

node-graph/gcore/src/instances.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ impl<T: PartialEq> PartialEq for Instances<T> {
142142
}
143143
}
144144

145-
#[cfg(feature = "dyn-any")]
146145
unsafe impl<T: StaticType + 'static> StaticType for Instances<T> {
147146
type Static = Instances<T>;
148147
}

node-graph/gcore/src/lib.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
#![cfg_attr(not(feature = "std"), no_std)]
2-
3-
#[cfg(feature = "alloc")]
41
extern crate alloc;
5-
#[cfg(feature = "alloc")]
6-
use core::future::Future;
72

8-
#[cfg_attr(feature = "log", macro_use)]
9-
#[cfg(feature = "log")]
3+
#[macro_use]
104
extern crate log;
115
pub use crate as graphene_core;
126
pub use num_traits;
137

14-
#[cfg(feature = "reflections")]
158
pub use ctor;
169

1710
pub mod animation;
@@ -23,37 +16,26 @@ pub mod logic;
2316
pub mod misc;
2417
pub mod ops;
2518
pub mod structural;
26-
#[cfg(feature = "std")]
2719
pub mod text;
28-
#[cfg(feature = "std")]
2920
pub mod uuid;
3021
pub mod value;
3122

32-
#[cfg(feature = "gpu")]
33-
pub mod gpu;
34-
35-
#[cfg(feature = "alloc")]
3623
pub mod memo;
3724

3825
pub mod raster;
39-
#[cfg(feature = "alloc")]
4026
pub mod transform;
4127

42-
#[cfg(feature = "alloc")]
4328
mod graphic_element;
44-
#[cfg(feature = "alloc")]
4529
pub use graphic_element::*;
46-
#[cfg(feature = "alloc")]
4730
pub mod vector;
4831

49-
#[cfg(feature = "alloc")]
5032
pub mod application_io;
5133

52-
#[cfg(feature = "reflections")]
5334
pub mod registry;
5435

5536
pub use context::*;
5637
use core::any::TypeId;
38+
use core::future::Future;
5739
use core::pin::Pin;
5840
pub use dyn_any::{StaticTypeSized, WasmNotSend, WasmNotSync};
5941
pub use memo::MemoHash;
@@ -74,16 +56,13 @@ pub trait Node<'i, Input> {
7456
core::any::type_name::<Self>()
7557
}
7658
/// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes.
77-
#[cfg(feature = "std")]
7859
fn serialize(&self) -> Option<std::sync::Arc<dyn core::any::Any + Send + Sync>> {
7960
log::warn!("Node::serialize not implemented for {}", core::any::type_name::<Self>());
8061
None
8162
}
8263
}
8364

84-
#[cfg(feature = "alloc")]
8565
mod types;
86-
#[cfg(feature = "alloc")]
8766
pub use types::*;
8867

8968
pub trait NodeIO<'i, Input>: Node<'i, Input>
@@ -103,15 +82,13 @@ where
10382
fn output_type_name(&self) -> &'static str {
10483
core::any::type_name::<Self::Output>()
10584
}
106-
#[cfg(feature = "alloc")]
10785
fn to_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes {
10886
NodeIOTypes {
10987
call_argument: concrete!(<Input as StaticTypeSized>::Static),
11088
return_value: concrete!(<Self::Output as StaticTypeSized>::Static),
11189
inputs,
11290
}
11391
}
114-
#[cfg(feature = "alloc")]
11592
fn to_async_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes
11693
where
11794
<Self::Output as Future>::Output: StaticTypeSized,
@@ -138,22 +115,19 @@ impl<'i, I: 'i, N: Node<'i, I> + ?Sized> Node<'i, I> for &'i N {
138115
(*self).eval(input)
139116
}
140117
}
141-
#[cfg(feature = "alloc")]
142118
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box<N> {
143119
type Output = O;
144120
fn eval(&'i self, input: I) -> O {
145121
(**self).eval(input)
146122
}
147123
}
148-
#[cfg(feature = "alloc")]
149124
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc<N> {
150125
type Output = O;
151126
fn eval(&'i self, input: I) -> O {
152127
(**self).eval(input)
153128
}
154129
}
155130

156-
#[cfg(feature = "alloc")]
157131
impl<'i, I, O: 'i> Node<'i, I> for Pin<Box<dyn Node<'i, I, Output = O> + 'i>> {
158132
type Output = O;
159133
fn eval(&'i self, input: I) -> O {
@@ -167,7 +141,6 @@ impl<'i, I, O: 'i> Node<'i, I> for Pin<&'i (dyn NodeIO<'i, I, Output = O> + 'i)>
167141
}
168142
}
169143

170-
#[cfg(feature = "alloc")]
171144
pub use crate::application_io::{SurfaceFrame, SurfaceId};
172145
#[cfg(feature = "wasm")]
173146
pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasElement>;

node-graph/gcore/src/memo.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::{Node, WasmNotSend};
2-
#[cfg(feature = "alloc")]
32
use alloc::sync::Arc;
43
use core::future::Future;
54
use core::ops::Deref;
@@ -106,7 +105,6 @@ pub struct IORecord<I, O> {
106105
pub output: O,
107106
}
108107

109-
#[cfg(feature = "alloc")]
110108
/// Caches the output of the last graph evaluation for introspection
111109
#[derive(Default)]
112110
pub struct MonitorNode<I, T, N> {
@@ -115,7 +113,6 @@ pub struct MonitorNode<I, T, N> {
115113
node: N,
116114
}
117115

118-
#[cfg(feature = "alloc")]
119116
impl<'i, T, I, N> Node<'i, I> for MonitorNode<I, T, N>
120117
where
121118
I: Clone + 'static + Send + Sync,
@@ -139,7 +136,6 @@ where
139136
}
140137
}
141138

142-
#[cfg(feature = "alloc")]
143139
impl<I, T, N> MonitorNode<I, T, N> {
144140
pub fn new(node: N) -> MonitorNode<I, T, N> {
145141
MonitorNode { io: Arc::new(Mutex::new(None)), node }
@@ -173,7 +169,6 @@ impl<T: Hash + serde::Serialize> serde::Serialize for MemoHash<T> {
173169
}
174170
}
175171

176-
#[cfg(feature = "std")]
177172
impl<T: Hash> MemoHash<T> {
178173
pub fn new(value: T) -> Self {
179174
let hash = Self::calc_hash(&value);

0 commit comments

Comments
 (0)