diff --git a/Cargo.toml b/Cargo.toml index e560eb0..f9d6d4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,23 @@ +[workspace] +members = ["run-wasm"] + [package] name = "softbuffer" version = "0.4.8" edition = "2021" -license = "MIT OR Apache-2.0" description = "Cross-platform software buffer" +license = "MIT OR Apache-2.0" documentation = "https://docs.rs/softbuffer" -readme = "README.md" repository = "https://github.com/rust-windowing/softbuffer" +rust-version = "1.71.0" keywords = ["framebuffer", "windowing"] categories = ["game-development", "graphics", "gui", "multimedia", "rendering"] exclude = ["examples"] -rust-version = "1.71.0" - -[[bench]] -name = "buffer_mut" -harness = false [features] -default = ["kms", "x11", "x11-dlopen", "wayland", "wayland-dlopen"] -kms = ["bytemuck", "drm", "rustix"] +default = ["wayland", "wayland-dlopen", "x11", "x11-dlopen", "kms"] + +# Enable the Wayland backend. wayland = [ "wayland-backend", "wayland-client", @@ -26,10 +25,13 @@ wayland = [ "memmap2", "rustix", "fastrand", + # Only used as a dev-dependency. "winit/wayland", "winit/wayland-csd-adwaita", ] wayland-dlopen = ["wayland-sys/dlopen", "winit/wayland-dlopen"] + +# Enable the X11 backend. x11 = [ "as-raw-xcb-connection", "bytemuck", @@ -37,53 +39,64 @@ x11 = [ "rustix", "tiny-xlib", "x11rb", + # Only used as a dev-dependency. "winit/x11", ] x11-dlopen = ["tiny-xlib/dlopen", "x11rb/dl-libxcb"] +# Enable the KMS/DRM backend. +kms = ["bytemuck", "drm", "rustix"] + +# Common dependencies. [dependencies] -raw_window_handle = { package = "raw-window-handle", version = "0.6", features = [ - "std", -] } +raw-window-handle = { version = "0.6", features = ["std"] } tracing = { version = "0.1.41", default-features = false } +# Android dependencies. [target.'cfg(target_os = "android")'.dependencies] bytemuck = "1.12.3" ndk = "0.9.0" +# Wayland, X11 and KMS/DRM dependencies. [target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dependencies] -as-raw-xcb-connection = { version = "1.0.0", optional = true } +# Common bytemuck = { version = "1.12.3", optional = true } -drm = { version = "0.14.1", default-features = false, optional = true } fastrand = { version = "2.0.0", optional = true } -memmap2 = { version = "0.9.0", optional = true } -rustix = { version = "1.0.1", features = [ +rustix = { version = "1.0.1", default-features = false, optional = true, features = [ "fs", "mm", "shm", "std", -], default-features = false, optional = true } -tiny-xlib = { version = "0.2.1", optional = true } -wayland-backend = { version = "0.3.0", features = [ +] } +# Wayland +memmap2 = { version = "0.9.0", optional = true } +wayland-backend = { version = "0.3.0", optional = true, features = [ "client_system", -], optional = true } +] } wayland-client = { version = "0.31.0", optional = true } wayland-sys = { version = "0.31.0", optional = true } -x11rb = { version = "0.13.0", features = [ +# X11 +as-raw-xcb-connection = { version = "1.0.0", optional = true } +tiny-xlib = { version = "0.2.1", optional = true } +x11rb = { version = "0.13.0", optional = true, features = [ "allow-unsafe-code", "shm", -], optional = true } +] } +# KMS/DRM +drm = { version = "0.14.1", default-features = false, optional = true } -[target.'cfg(target_os = "windows")'.dependencies.windows-sys] -version = "0.61.2" -features = [ +# Windows dependencies. +[target.'cfg(target_os = "windows")'.dependencies] +windows-sys = { version = "0.61.2", features = [ "Win32_Graphics_Gdi", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_Foundation", -] +] } +# CoreGraphics (macOS/iOS/...) dependencies. [target.'cfg(target_vendor = "apple")'.dependencies] +objc2 = "0.6.0" objc2-core-graphics = { version = "0.3.2", default-features = false, features = [ "std", "objc2", @@ -91,7 +104,6 @@ objc2-core-graphics = { version = "0.3.2", default-features = false, features = "CGDataProvider", "CGImage", ] } -objc2 = "0.6.0" objc2-core-foundation = { version = "0.3.2", default-features = false, features = [ "std", "CFCGTypes", @@ -113,13 +125,11 @@ objc2-quartz-core = { version = "0.3.2", default-features = false, features = [ "CATransaction", ] } +# Web dependencies. [target.'cfg(target_family = "wasm")'.dependencies] js-sys = "0.3.63" wasm-bindgen = "0.2.86" - -[target.'cfg(target_family = "wasm")'.dependencies.web-sys] -version = "0.3.55" -features = [ +web-sys = { version = "0.3.55", features = [ "CanvasRenderingContext2d", "Document", "Element", @@ -128,11 +138,41 @@ features = [ "OffscreenCanvas", "OffscreenCanvasRenderingContext2d", "Window", -] +] } +# Orbital dependencies. [target.'cfg(target_os = "redox")'.dependencies] redox_syscall = "0.7" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "x86_64-pc-windows-msvc", + "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", + "wasm32-unknown-unknown", +] + +## +## Development-related stuff below. +## + +[[example]] +# Run with `cargo apk run --example winit_android` +name = "winit_android" +crate-type = ["cdylib"] + +[[example]] +# Run with `cargo apk run --example winit_multithread_android` +name = "winit_multithread_android" +crate-type = ["cdylib"] + +[[bench]] +name = "buffer_mut" +harness = false + [dev-dependencies] colorous = "1.0.12" web-time = "1.0.0" @@ -140,54 +180,30 @@ winit = { version = "0.30.0", default-features = false, features = ["rwh_06"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } glam = { version = "0.30.10", features = ["rand"] } rand = "0.9.2" - -[target.'cfg(target_os = "android")'.dev-dependencies] -winit = { version = "0.30.0", features = ["android-native-activity"] } -android-activity = "0.6" - -[dev-dependencies.image] -version = "0.25.0" -# Disable rayon on web -default-features = false -features = ["jpeg"] +# Disable unnecessary formats. +image = { version = "0.25.0", default-features = false, features = ["jpeg"] } [target.'cfg(not(target_family = "wasm"))'.dev-dependencies] -# Turn rayon back on everywhere else; creating the separate entry resets the features to default. +# Use rayon in raytracing example on non-web platforms. rayon = "1.5.1" +# Enable criterion benchmarking on non-web platforms. criterion = { version = "0.8.1", default-features = false, features = [ "cargo_bench_support", ] } +[target.'cfg(target_os = "android")'.dev-dependencies] +# Use NativeActivity on Android. +winit = { version = "0.30.0", features = ["android-native-activity"] } +android-activity = "0.6" + [target.'cfg(target_family = "wasm")'.dev-dependencies] +# Add extra dependencies for making debugging easier on Web. wasm-bindgen-test = "0.3" console_error_panic_hook = "0.1" tracing-web = "0.1" # Allow `rand` crate to compile. getrandom = { version = "0.3.4", features = ["wasm_js"] } +# DRM example. [target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dev-dependencies] rustix = { version = "1.0.1", features = ["event"] } - -[workspace] -members = ["run-wasm"] - -[[example]] -# Run with `cargo apk r --example winit_android` -name = "winit_android" -crate-type = ["cdylib"] - -[[example]] -# Run with `cargo apk r --example winit_multithread_android` -name = "winit_multithread_android" -crate-type = ["cdylib"] - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] -default-target = "x86_64-unknown-linux-gnu" -targets = [ - "x86_64-pc-windows-msvc", - "x86_64-apple-darwin", - "x86_64-unknown-linux-gnu", - "wasm32-unknown-unknown", -]