Skip to content

Commit dc048b4

Browse files
committed
Use target_family = "wasm" instead of target_arch = "wasm32"
This allows using wasm64 as well.
1 parent ae1565b commit dc048b4

File tree

10 files changed

+20
-19
lines changed

10 files changed

+20
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Bump MSRV to Rust 1.71.
55
- Make `Context` cloneable.
66
- Added `Buffer::width()` and `Buffer::height()` getters.
7+
- Added support for `wasm64-*` targets.
78

89
# 0.4.6
910

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ objc2-quartz-core = { version = "0.3.2", default-features = false, features = [
110110
"CATransaction",
111111
] }
112112

113-
[target.'cfg(target_arch = "wasm32")'.dependencies]
113+
[target.'cfg(target_family = "wasm")'.dependencies]
114114
js-sys = "0.3.63"
115115
wasm-bindgen = "0.2.86"
116116

117-
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
117+
[target.'cfg(target_family = "wasm")'.dependencies.web-sys]
118118
version = "0.3.55"
119119
features = [
120120
"CanvasRenderingContext2d",
@@ -151,11 +151,11 @@ version = "0.25.0"
151151
default-features = false
152152
features = ["jpeg"]
153153

154-
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
154+
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
155155
# Turn rayon back on everywhere else; creating the separate entry resets the features to default.
156156
rayon = "1.5.1"
157157

158-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
158+
[target.'cfg(target_family = "wasm")'.dev-dependencies]
159159
wasm-bindgen-test = "0.3"
160160

161161
[target.'cfg(all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))))'.dev-dependencies]

benches/buffer_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use criterion::{criterion_group, criterion_main, Criterion};
44

55
fn buffer_mut(c: &mut Criterion) {
6-
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
6+
#[cfg(target_family = "wasm")]
77
{
88
// Do nothing.
99
let _ = c;
1010
}
1111

12-
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
12+
#[cfg(not(target_family = "wasm"))]
1313
{
1414
use criterion::black_box;
1515
use softbuffer::{Context, Surface};

build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ fn main() {
66

77
cfg_aliases::cfg_aliases! {
88
free_unix: { all(unix, not(any(target_vendor = "apple", target_os = "android", target_os = "redox"))) },
9-
kms_platform: { all(feature = "kms", free_unix, not(target_arch = "wasm32")) },
10-
x11_platform: { all(feature = "x11", free_unix, not(target_arch = "wasm32")) },
11-
wayland_platform: { all(feature = "wayland", free_unix, not(target_arch = "wasm32")) },
9+
kms_platform: { all(feature = "kms", free_unix, not(target_family = "wasm")) },
10+
x11_platform: { all(feature = "x11", free_unix, not(target_family = "wasm")) },
11+
wayland_platform: { all(feature = "wayland", free_unix, not(target_family = "wasm")) },
1212
}
1313
}

examples/animation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(not(target_arch = "wasm32"))]
1+
#[cfg(not(target_family = "wasm"))]
22
use rayon::prelude::*;
33
use std::f64::consts::PI;
44
use std::num::NonZeroU32;
@@ -115,9 +115,9 @@ fn pre_render_frames(width: u32, height: u32) -> Vec<Vec<u32>> {
115115
.collect::<Vec<_>>()
116116
};
117117

118-
#[cfg(target_arch = "wasm32")]
118+
#[cfg(target_family = "wasm")]
119119
return (0..60).map(render).collect();
120120

121-
#[cfg(not(target_arch = "wasm32"))]
121+
#[cfg(not(target_family = "wasm"))]
122122
(0..60).into_par_iter().map(render).collect()
123123
}

examples/utils/winit_app.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use winit::window::{Window, WindowAttributes, WindowId};
1010
/// Run a Winit application.
1111
#[allow(unused_mut)]
1212
pub(crate) fn run_app(event_loop: EventLoop<()>, mut app: impl ApplicationHandler<()> + 'static) {
13-
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
13+
#[cfg(not(target_family = "wasm"))]
1414
event_loop.run_app(&mut app).unwrap();
1515

16-
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
16+
#[cfg(target_family = "wasm")]
1717
winit::platform::web::EventLoopExtWebSys::spawn_app(event_loop, app);
1818
}
1919

@@ -24,7 +24,7 @@ pub(crate) fn make_window(
2424
f: impl FnOnce(WindowAttributes) -> WindowAttributes,
2525
) -> Rc<Window> {
2626
let attributes = f(WindowAttributes::default());
27-
#[cfg(target_arch = "wasm32")]
27+
#[cfg(target_family = "wasm")]
2828
let attributes = winit::platform::web::WindowAttributesExtWebSys::with_append(attributes, true);
2929
let window = elwt.create_window(attributes);
3030
Rc::new(window.unwrap())

examples/winit_multithread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub mod ex {
6565
let app = winit_app::WinitAppBuilder::with_init(
6666
|elwt| {
6767
let attributes = Window::default_attributes();
68-
#[cfg(target_arch = "wasm32")]
68+
#[cfg(target_family = "wasm")]
6969
let attributes =
7070
winit::platform::web::WindowAttributesExtWebSys::with_append(attributes, true);
7171
let window = Arc::new(elwt.create_window(attributes).unwrap());

src/backend_dispatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ make_dispatch! {
211211
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'a, D, W>),
212212
#[cfg(target_vendor = "apple")]
213213
CoreGraphics(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'a, D, W>),
214-
#[cfg(target_arch = "wasm32")]
214+
#[cfg(target_family = "wasm")]
215215
Web(backends::web::WebDisplayImpl<D>, backends::web::WebImpl<D, W>, backends::web::BufferImpl<'a, D, W>),
216216
#[cfg(target_os = "redox")]
217217
Orbital(D, backends::orbital::OrbitalImpl<D, W>, backends::orbital::BufferImpl<'a, D, W>),

src/backends/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) mod kms;
1111
pub(crate) mod orbital;
1212
#[cfg(wayland_platform)]
1313
pub(crate) mod wayland;
14-
#[cfg(target_arch = "wasm32")]
14+
#[cfg(target_family = "wasm")]
1515
pub(crate) mod web;
1616
#[cfg(target_os = "windows")]
1717
pub(crate) mod win32;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use error::SoftBufferError;
2525

2626
use raw_window_handle::{HasDisplayHandle, HasWindowHandle, RawDisplayHandle, RawWindowHandle};
2727

28-
#[cfg(target_arch = "wasm32")]
28+
#[cfg(target_family = "wasm")]
2929
pub use backends::web::SurfaceExtWeb;
3030

3131
/// An instance of this struct contains the platform-specific data that must be managed in order to

0 commit comments

Comments
 (0)