Skip to content

Make gcore a std library, remove std, alloc and more unused features #2724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: editor_gcore_splitup_prep
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ default = ["wasm"]
wasm = ["wasm-bindgen", "graphene-std/wasm", "wasm-bindgen-futures"]
gpu = [
"interpreted-executor/gpu",
"graphene-std/gpu",
"wgpu-executor",
]
tauri = ["ron", "decouple-execution"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,13 +1161,6 @@ pub(crate) fn selective_color_properties(node_id: NodeId, context: &mut NodeProp
]
}

#[cfg(feature = "gpu")]
pub(crate) fn _gpu_map_properties(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<LayoutGroup> {
let map = text_widget(parameter_widgets_info);

vec![LayoutGroup::Row { widgets: map }]
}

pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
let grid_type_index = grid::GridTypeInput::INDEX;
let spacing_index = grid::SpacingInput::<f64>::INDEX;
Expand Down
2 changes: 1 addition & 1 deletion frontend/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ editor = { path = "../../editor", package = "graphite-editor", features = [
# Workspace dependencies
graph-craft = { workspace = true }
log = { workspace = true }
graphene-core = { workspace = true, features = ["std", "alloc"] }
graphene-core = { workspace = true }
serde = { workspace = true, features = ["derive"] }
wasm-bindgen = { workspace = true }
serde-wasm-bindgen = { workspace = true }
Expand Down
42 changes: 13 additions & 29 deletions node-graph/gcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,13 @@ authors = ["Graphite Authors <contact@graphite.rs>"]
license = "MIT OR Apache-2.0"

[features]
default = ["serde", "kurbo", "log", "std", "rand_chacha", "wasm"]
log = ["dep:log"]
gpu = ["spirv-std", "glam/bytemuck", "dyn-any", "glam/libm"]
default = ["serde", "wasm"]
nightly = []
alloc = ["dyn-any", "bezier-rs"]
type_id_logging = []
wasm = ["web-sys"]
wgpu = ["dep:wgpu"]
vello = ["dep:vello", "bezier-rs/kurbo", "wgpu"]
dealloc_nodes = ["reflections"]
std = [
"dyn-any",
"dyn-any/std",
"alloc",
"glam/std",
"specta",
"num-traits/std",
"rustybuzz",
"image",
"reflections",
]
reflections = ["alloc", "ctor"]
dealloc_nodes = []
serde = [
"dep:serde",
"glam/serde",
Expand All @@ -55,31 +40,30 @@ petgraph = { workspace = true, default-features = false, features = [
] }
rustc-hash = { workspace = true }
math-parser = { path = "../../libraries/math-parser" }
dyn-any = { workspace = true }
ctor = { workspace = true }
rand_chacha = { workspace = true }
bezier-rs = { workspace = true }
specta = { workspace = true }
rustybuzz = { workspace = true }
image = { workspace = true, default-features = false, features = [
"png",
] }

# Required dependencies
half = { version = "2.4.1", default-features = false, features = ["bytemuck"] }
tinyvec = { version = "1" }
kurbo = { workspace = true }
log = { workspace = true }

# Optional workspace dependencies
dyn-any = { workspace = true, optional = true }
spirv-std = { workspace = true, optional = true }
serde = { workspace = true, optional = true, features = ["derive"] }
ctor = { workspace = true, optional = true }
log = { workspace = true, optional = true }
rand_chacha = { workspace = true, optional = true }
bezier-rs = { workspace = true, optional = true }
kurbo = { workspace = true, optional = true }
base64 = { workspace = true, optional = true }
vello = { workspace = true, optional = true }
wgpu = { workspace = true, optional = true }
specta = { workspace = true, optional = true }
rustybuzz = { workspace = true, optional = true }
web-sys = { workspace = true, optional = true, features = [
"HtmlCanvasElement",
] }
image = { workspace = true, optional = true, default-features = false, features = [
"png",
] }

[dev-dependencies]
# Workspace dependencies
Expand Down
5 changes: 0 additions & 5 deletions node-graph/gcore/src/application_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ impl Hash for SurfaceFrame {
}
}

#[cfg(feature = "dyn-any")]
unsafe impl StaticType for SurfaceFrame {
type Static = SurfaceFrame;
}
Expand Down Expand Up @@ -82,7 +81,6 @@ impl PartialEq for ImageTexture {
}
}

#[cfg(feature = "dyn-any")]
unsafe impl StaticType for ImageTexture {
type Static = ImageTexture;
}
Expand Down Expand Up @@ -121,7 +119,6 @@ impl<S: Size> Size for SurfaceHandle<S> {
}
}

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

#[cfg(feature = "dyn-any")]
unsafe impl<T: 'static> StaticType for SurfaceHandleFrame<T> {
type Static = SurfaceHandleFrame<T>;
}
Expand Down Expand Up @@ -307,7 +303,6 @@ impl<T> Debug for EditorApi<T> {
}
}

#[cfg(feature = "dyn-any")]
unsafe impl<T: StaticTypeSized> StaticType for EditorApi<T> {
type Static = EditorApi<T::Static>;
}
20 changes: 0 additions & 20 deletions node-graph/gcore/src/gpu.rs

This file was deleted.

1 change: 0 additions & 1 deletion node-graph/gcore/src/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ impl<T: PartialEq> PartialEq for Instances<T> {
}
}

#[cfg(feature = "dyn-any")]
unsafe impl<T: StaticType + 'static> StaticType for Instances<T> {
type Static = Instances<T>;
}
Expand Down
31 changes: 2 additions & 29 deletions node-graph/gcore/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
use core::future::Future;

#[cfg_attr(feature = "log", macro_use)]
#[cfg(feature = "log")]
#[macro_use]
extern crate log;
pub use crate as graphene_core;
pub use num_traits;

#[cfg(feature = "reflections")]
pub use ctor;

pub mod animation;
Expand All @@ -23,37 +16,26 @@ pub mod logic;
pub mod misc;
pub mod ops;
pub mod structural;
#[cfg(feature = "std")]
pub mod text;
#[cfg(feature = "std")]
pub mod uuid;
pub mod value;

#[cfg(feature = "gpu")]
pub mod gpu;

#[cfg(feature = "alloc")]
pub mod memo;

pub mod raster;
#[cfg(feature = "alloc")]
pub mod transform;

#[cfg(feature = "alloc")]
mod graphic_element;
#[cfg(feature = "alloc")]
pub use graphic_element::*;
#[cfg(feature = "alloc")]
pub mod vector;

#[cfg(feature = "alloc")]
pub mod application_io;

#[cfg(feature = "reflections")]
pub mod registry;

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

#[cfg(feature = "alloc")]
mod types;
#[cfg(feature = "alloc")]
pub use types::*;

pub trait NodeIO<'i, Input>: Node<'i, Input>
Expand All @@ -103,15 +82,13 @@ where
fn output_type_name(&self) -> &'static str {
core::any::type_name::<Self::Output>()
}
#[cfg(feature = "alloc")]
fn to_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes {
NodeIOTypes {
call_argument: concrete!(<Input as StaticTypeSized>::Static),
return_value: concrete!(<Self::Output as StaticTypeSized>::Static),
inputs,
}
}
#[cfg(feature = "alloc")]
fn to_async_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes
where
<Self::Output as Future>::Output: StaticTypeSized,
Expand All @@ -138,22 +115,19 @@ impl<'i, I: 'i, N: Node<'i, I> + ?Sized> Node<'i, I> for &'i N {
(*self).eval(input)
}
}
#[cfg(feature = "alloc")]
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box<N> {
type Output = O;
fn eval(&'i self, input: I) -> O {
(**self).eval(input)
}
}
#[cfg(feature = "alloc")]
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc<N> {
type Output = O;
fn eval(&'i self, input: I) -> O {
(**self).eval(input)
}
}

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

#[cfg(feature = "alloc")]
pub use crate::application_io::{SurfaceFrame, SurfaceId};
#[cfg(feature = "wasm")]
pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasElement>;
Expand Down
5 changes: 0 additions & 5 deletions node-graph/gcore/src/memo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{Node, WasmNotSend};
#[cfg(feature = "alloc")]
use alloc::sync::Arc;
use core::future::Future;
use core::ops::Deref;
Expand Down Expand Up @@ -106,7 +105,6 @@ pub struct IORecord<I, O> {
pub output: O,
}

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

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

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

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