Use target family insted of target arch (#2975)

* Replace cfg target_arch wasm32 with target_family wasm

* Fix warnings in test builds from previous pr
This commit is contained in:
Timon 2025-08-03 12:28:53 +02:00 committed by GitHub
parent 1e3c3da3fe
commit 67123f55dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 106 additions and 96 deletions

View file

@ -2,9 +2,9 @@ use graph_craft::document::value::RenderOutput;
pub use graph_craft::document::value::RenderOutputType;
pub use graph_craft::wasm_application_io::*;
use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig};
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use graphene_core::instances::Instances;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use graphene_core::math::bbox::Bbox;
use graphene_core::raster::image::Image;
use graphene_core::raster_types::{CPU, Raster, RasterDataTable};
@ -14,14 +14,14 @@ use graphene_core::{Color, Context, Ctx, ExtractFootprint, GraphicGroupTable, Ow
use graphene_svg_renderer::RenderMetadata;
use graphene_svg_renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use base64::Engine;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use glam::DAffine2;
use std::sync::Arc;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use wasm_bindgen::JsCast;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
#[cfg(feature = "wgpu")]
@ -32,7 +32,7 @@ async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<W
#[node_macro::node(category("Web Request"))]
async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, discard_result: bool) -> String {
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
{
if discard_result {
wasm_bindgen_futures::spawn_local(async move {
@ -41,7 +41,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc
return String::new();
}
}
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
{
#[cfg(feature = "tokio")]
if discard_result {
@ -62,7 +62,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc
#[node_macro::node(category("Web Request"))]
async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, body: Vec<u8>, discard_result: bool) -> String {
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
{
if discard_result {
wasm_bindgen_futures::spawn_local(async move {
@ -71,7 +71,7 @@ async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, bod
return String::new();
}
}
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
{
#[cfg(feature = "tokio")]
if discard_result {
@ -165,7 +165,7 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p
}
#[cfg(feature = "vello")]
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
#[cfg_attr(not(target_family = "wasm"), allow(dead_code))]
async fn render_canvas(
render_config: RenderConfig,
data: impl GraphicElementRendered,
@ -216,7 +216,7 @@ async fn render_canvas(
}
}
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
#[node_macro::node(category(""))]
async fn rasterize<T: WasmNotSend + 'n>(
_: impl Ctx,
@ -326,13 +326,13 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
let data = data.eval(ctx.clone()).await;
let editor_api = editor_api.eval(None).await;
#[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))]
#[cfg(all(feature = "vello", not(test), target_family = "wasm"))]
let _surface_handle = _surface_handle.eval(None).await;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
let _surface_handle: Option<wgpu_executor::WgpuSurface> = None;
let use_vello = editor_api.editor_preferences.use_vello();
#[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))]
#[cfg(all(feature = "vello", not(test), target_family = "wasm"))]
let use_vello = use_vello && _surface_handle.is_some();
let mut metadata = RenderMetadata::default();