mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
Allow workspace to be built on wasm (#3840)
This commit is contained in:
parent
3f0aed789d
commit
4aff9b67af
@ -9,7 +9,9 @@ description = "CTS runner for wgpu"
|
|||||||
license.workspace = true
|
license.workspace = true
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
# We make all dependencies conditional on not being wasm,
|
||||||
|
# so the whole workspace can built as wasm.
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
deno_console.workspace = true
|
deno_console.workspace = true
|
||||||
deno_core.workspace = true
|
deno_core.workspace = true
|
||||||
deno_url.workspace = true
|
deno_url.workspace = true
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
mod native {
|
||||||
use std::{
|
use std::{
|
||||||
env, fmt,
|
env, fmt,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
@ -19,12 +21,7 @@ use termcolor::Color::Red;
|
|||||||
use termcolor::ColorSpec;
|
use termcolor::ColorSpec;
|
||||||
use termcolor::WriteColor;
|
use termcolor::WriteColor;
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
pub async fn run() -> Result<(), AnyError> {
|
||||||
async fn main() {
|
|
||||||
unwrap_or_exit(run().await)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run() -> Result<(), AnyError> {
|
|
||||||
let mut args_iter = env::args();
|
let mut args_iter = env::args();
|
||||||
let _ = args_iter.next();
|
let _ = args_iter.next();
|
||||||
let url = args_iter
|
let url = args_iter
|
||||||
@ -131,7 +128,7 @@ fn get_error_class_name(e: &AnyError) -> &'static str {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
|
pub fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
|
||||||
match result {
|
match result {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
@ -166,3 +163,15 @@ impl deno_web::TimersPermission for Permissions {
|
|||||||
|
|
||||||
fn check_unstable(&self, _state: &deno_core::OpState, _api_name: &'static str) {}
|
fn check_unstable(&self, _state: &deno_core::OpState, _api_name: &'static str) {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[tokio::main(flavor = "current_thread")]
|
||||||
|
async fn main() {
|
||||||
|
native::unwrap_or_exit(native::run().await)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
fn main() {
|
||||||
|
panic!("This is a native only module. It can't be run on the web!");
|
||||||
|
}
|
||||||
|
@ -16,14 +16,16 @@ path = "lib.rs"
|
|||||||
[features]
|
[features]
|
||||||
surface = ["wgpu-core/raw-window-handle", "dep:raw-window-handle"]
|
surface = ["wgpu-core/raw-window-handle", "dep:raw-window-handle"]
|
||||||
|
|
||||||
[dependencies]
|
# We make all dependencies conditional on not being wasm,
|
||||||
|
# so the whole workspace can built as wasm.
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
deno_core.workspace = true
|
deno_core.workspace = true
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
tokio = { workspace = true, features = ["full"] }
|
tokio = { workspace = true, features = ["full"] }
|
||||||
wgpu-types = { workspace = true, features = ["trace", "replay", "serde"] }
|
wgpu-types = { workspace = true, features = ["trace", "replay", "serde"] }
|
||||||
raw-window-handle = { workspace = true, optional = true }
|
raw-window-handle = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dependencies.wgpu-core]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgpu-core]
|
||||||
workspace = true
|
workspace = true
|
||||||
features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"]
|
features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"]
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
#![cfg(not(target_arch = "wasm32"))]
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
#![warn(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
Loading…
Reference in New Issue
Block a user