mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +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
|
||||
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_core.workspace = true
|
||||
deno_url.workspace = true
|
||||
|
@ -1,3 +1,5 @@
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod native {
|
||||
use std::{
|
||||
env, fmt,
|
||||
io::{Read, Write},
|
||||
@ -19,12 +21,7 @@ use termcolor::Color::Red;
|
||||
use termcolor::ColorSpec;
|
||||
use termcolor::WriteColor;
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
unwrap_or_exit(run().await)
|
||||
}
|
||||
|
||||
async fn run() -> Result<(), AnyError> {
|
||||
pub async fn run() -> Result<(), AnyError> {
|
||||
let mut args_iter = env::args();
|
||||
let _ = args_iter.next();
|
||||
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 {
|
||||
Ok(value) => value,
|
||||
Err(error) => {
|
||||
@ -166,3 +163,15 @@ impl deno_web::TimersPermission for Permissions {
|
||||
|
||||
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]
|
||||
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
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
wgpu-types = { workspace = true, features = ["trace", "replay", "serde"] }
|
||||
raw-window-handle = { workspace = true, optional = true }
|
||||
|
||||
[dependencies.wgpu-core]
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgpu-core]
|
||||
workspace = true
|
||||
features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![cfg(not(target_arch = "wasm32"))]
|
||||
#![warn(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
|
Loading…
Reference in New Issue
Block a user