mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Fix build for wasm32 target
This commit is contained in:
parent
89e585af61
commit
0899bb7207
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -33,6 +33,14 @@ jobs:
|
|||||||
- name: Additional core features
|
- name: Additional core features
|
||||||
run: cargo check --manifest-path wgpu-core/Cargo.toml --features trace --target ${{ env.TARGET }}
|
run: cargo check --manifest-path wgpu-core/Cargo.toml --features trace --target ${{ env.TARGET }}
|
||||||
|
|
||||||
|
webgl_build:
|
||||||
|
name: Web Assembly
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: rustup target add wasm32-unknown-unknown
|
||||||
|
- run: cargo build --manifest-path wgpu-core/Cargo.toml --target wasm32-unknown-unknown
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: ${{ matrix.name }}
|
name: ${{ matrix.name }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|||||||
@ -39,19 +39,22 @@ gpu-descriptor = { git = "https://github.com/zakarumych/gpu-descriptor", rev = "
|
|||||||
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
||||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
|
[target.'cfg(all(not(target_arch = "wasm32"), all(unix, not(target_os = "ios"), not(target_os = "macos"))))'.dependencies]
|
||||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
||||||
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
[target.'cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))'.dependencies]
|
||||||
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
||||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", optional = true }
|
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", optional = true }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(all(not(target_arch = "wasm32"), windows))'.dependencies]
|
||||||
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
||||||
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
||||||
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a" }
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
gfx-backend-gl = { git = "https://github.com/gfx-rs/gfx", rev = "0244e3401e9f127617cb8636397048584e7bfe8a", features = ["naga"] }
|
||||||
|
|
||||||
[dependencies.naga]
|
[dependencies.naga]
|
||||||
git = "https://github.com/gfx-rs/naga"
|
git = "https://github.com/gfx-rs/naga"
|
||||||
tag = "gfx-5"
|
tag = "gfx-5"
|
||||||
|
|||||||
@ -6,13 +6,15 @@ fn main() {
|
|||||||
// Setup cfg aliases
|
// Setup cfg aliases
|
||||||
cfg_aliases::cfg_aliases! {
|
cfg_aliases::cfg_aliases! {
|
||||||
// Vendors/systems
|
// Vendors/systems
|
||||||
|
wasm: { target_arch = "wasm32" },
|
||||||
apple: { any(target_os = "ios", target_os = "macos") },
|
apple: { any(target_os = "ios", target_os = "macos") },
|
||||||
|
unix_wo_apple: {all(unix, not(apple))},
|
||||||
|
|
||||||
// Backends
|
// Backends
|
||||||
vulkan: { any(windows, all(unix, not(apple)), feature = "gfx-backend-vulkan") },
|
vulkan: { all(not(wasm), any(windows, unix_wo_apple, feature = "gfx-backend-vulkan")) },
|
||||||
metal: { apple },
|
metal: { all(not(wasm), apple) },
|
||||||
dx12: { windows },
|
dx12: { all(not(wasm), windows) },
|
||||||
dx11: { windows },
|
dx11: { all(not(wasm), windows) },
|
||||||
gl: { all(unix, not(apple)) },
|
gl: { any(wasm, unix_wo_apple) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -230,15 +230,15 @@ macro_rules! gfx_select {
|
|||||||
// Note: For some reason the cfg aliases defined in build.rs don't succesfully apply in this
|
// Note: For some reason the cfg aliases defined in build.rs don't succesfully apply in this
|
||||||
// macro so we must specify their equivalents manually
|
// macro so we must specify their equivalents manually
|
||||||
match $id.backend() {
|
match $id.backend() {
|
||||||
#[cfg(any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan"))]
|
#[cfg(all(not(target_arch = "wasm32"), any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan")))]
|
||||||
wgt::Backend::Vulkan => $global.$method::<$crate::backend::Vulkan>( $($param),* ),
|
wgt::Backend::Vulkan => $global.$method::<$crate::backend::Vulkan>( $($param),* ),
|
||||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
#[cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))]
|
||||||
wgt::Backend::Metal => $global.$method::<$crate::backend::Metal>( $($param),* ),
|
wgt::Backend::Metal => $global.$method::<$crate::backend::Metal>( $($param),* ),
|
||||||
#[cfg(windows)]
|
#[cfg(all(not(target_arch = "wasm32"), windows))]
|
||||||
wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),* ),
|
wgt::Backend::Dx12 => $global.$method::<$crate::backend::Dx12>( $($param),* ),
|
||||||
#[cfg(windows)]
|
#[cfg(all(not(target_arch = "wasm32"), windows))]
|
||||||
wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),* ),
|
wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),* ),
|
||||||
#[cfg(all(unix, not(any(target_os = "ios", target_os = "macos"))))]
|
#[cfg(any(target_arch = "wasm32", all(unix, not(any(target_os = "ios", target_os = "macos")))))]
|
||||||
wgt::Backend::Gl => $global.$method::<$crate::backend::Gl>( $($param),+ ),
|
wgt::Backend::Gl => $global.$method::<$crate::backend::Gl>( $($param),+ ),
|
||||||
other => panic!("Unexpected backend {:?}", other),
|
other => panic!("Unexpected backend {:?}", other),
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user