Skip to content

Commit 9fee645

Browse files
authored
Refactor Cargo.toml (#316)
Put most important information at the top, and add comments. Usage of inline arrays to specify features is also made more consistent.
1 parent 688a216 commit 9fee645

1 file changed

Lines changed: 83 additions & 67 deletions

File tree

Cargo.toml

Lines changed: 83 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,109 @@
1+
[workspace]
2+
members = ["run-wasm"]
3+
14
[package]
25
name = "softbuffer"
36
version = "0.4.8"
47
edition = "2021"
5-
license = "MIT OR Apache-2.0"
68
description = "Cross-platform software buffer"
9+
license = "MIT OR Apache-2.0"
710
documentation = "https://docs.rs/softbuffer"
8-
readme = "README.md"
911
repository = "https://github.com/rust-windowing/softbuffer"
12+
rust-version = "1.71.0"
1013
keywords = ["framebuffer", "windowing"]
1114
categories = ["game-development", "graphics", "gui", "multimedia", "rendering"]
1215
exclude = ["examples"]
13-
rust-version = "1.71.0"
14-
15-
[[bench]]
16-
name = "buffer_mut"
17-
harness = false
1816

1917
[features]
20-
default = ["kms", "x11", "x11-dlopen", "wayland", "wayland-dlopen"]
21-
kms = ["bytemuck", "drm", "rustix"]
18+
default = ["wayland", "wayland-dlopen", "x11", "x11-dlopen", "kms"]
19+
20+
# Enable the Wayland backend.
2221
wayland = [
2322
"wayland-backend",
2423
"wayland-client",
2524
"wayland-sys",
2625
"memmap2",
2726
"rustix",
2827
"fastrand",
28+
# Only used as a dev-dependency.
2929
"winit/wayland",
3030
"winit/wayland-csd-adwaita",
3131
]
3232
wayland-dlopen = ["wayland-sys/dlopen", "winit/wayland-dlopen"]
33+
34+
# Enable the X11 backend.
3335
x11 = [
3436
"as-raw-xcb-connection",
3537
"bytemuck",
3638
"fastrand",
3739
"rustix",
3840
"tiny-xlib",
3941
"x11rb",
42+
# Only used as a dev-dependency.
4043
"winit/x11",
4144
]
4245
x11-dlopen = ["tiny-xlib/dlopen", "x11rb/dl-libxcb"]
4346

47+
# Enable the KMS/DRM backend.
48+
kms = ["bytemuck", "drm", "rustix"]
49+
50+
# Common dependencies.
4451
[dependencies]
45-
raw_window_handle = { package = "raw-window-handle", version = "0.6", features = [
46-
"std",
47-
] }
52+
raw-window-handle = { version = "0.6", features = ["std"] }
4853
tracing = { version = "0.1.41", default-features = false }
4954

55+
# Android dependencies.
5056
[target.'cfg(target_os = "android")'.dependencies]
5157
bytemuck = "1.12.3"
5258
ndk = "0.9.0"
5359

60+
# Wayland, X11 and KMS/DRM dependencies.
5461
[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dependencies]
55-
as-raw-xcb-connection = { version = "1.0.0", optional = true }
62+
# Common
5663
bytemuck = { version = "1.12.3", optional = true }
57-
drm = { version = "0.14.1", default-features = false, optional = true }
5864
fastrand = { version = "2.0.0", optional = true }
59-
memmap2 = { version = "0.9.0", optional = true }
60-
rustix = { version = "1.0.1", features = [
65+
rustix = { version = "1.0.1", default-features = false, optional = true, features = [
6166
"fs",
6267
"mm",
6368
"shm",
6469
"std",
65-
], default-features = false, optional = true }
66-
tiny-xlib = { version = "0.2.1", optional = true }
67-
wayland-backend = { version = "0.3.0", features = [
70+
] }
71+
# Wayland
72+
memmap2 = { version = "0.9.0", optional = true }
73+
wayland-backend = { version = "0.3.0", optional = true, features = [
6874
"client_system",
69-
], optional = true }
75+
] }
7076
wayland-client = { version = "0.31.0", optional = true }
7177
wayland-sys = { version = "0.31.0", optional = true }
72-
x11rb = { version = "0.13.0", features = [
78+
# X11
79+
as-raw-xcb-connection = { version = "1.0.0", optional = true }
80+
tiny-xlib = { version = "0.2.1", optional = true }
81+
x11rb = { version = "0.13.0", optional = true, features = [
7382
"allow-unsafe-code",
7483
"shm",
75-
], optional = true }
84+
] }
85+
# KMS/DRM
86+
drm = { version = "0.14.1", default-features = false, optional = true }
7687

77-
[target.'cfg(target_os = "windows")'.dependencies.windows-sys]
78-
version = "0.61.2"
79-
features = [
88+
# Windows dependencies.
89+
[target.'cfg(target_os = "windows")'.dependencies]
90+
windows-sys = { version = "0.61.2", features = [
8091
"Win32_Graphics_Gdi",
8192
"Win32_UI_Shell",
8293
"Win32_UI_WindowsAndMessaging",
8394
"Win32_Foundation",
84-
]
95+
] }
8596

97+
# CoreGraphics (macOS/iOS/...) dependencies.
8698
[target.'cfg(target_vendor = "apple")'.dependencies]
99+
objc2 = "0.6.0"
87100
objc2-core-graphics = { version = "0.3.2", default-features = false, features = [
88101
"std",
89102
"objc2",
90103
"CGColorSpace",
91104
"CGDataProvider",
92105
"CGImage",
93106
] }
94-
objc2 = "0.6.0"
95107
objc2-core-foundation = { version = "0.3.2", default-features = false, features = [
96108
"std",
97109
"CFCGTypes",
@@ -113,13 +125,11 @@ objc2-quartz-core = { version = "0.3.2", default-features = false, features = [
113125
"CATransaction",
114126
] }
115127

128+
# Web dependencies.
116129
[target.'cfg(target_family = "wasm")'.dependencies]
117130
js-sys = "0.3.63"
118131
wasm-bindgen = "0.2.86"
119-
120-
[target.'cfg(target_family = "wasm")'.dependencies.web-sys]
121-
version = "0.3.55"
122-
features = [
132+
web-sys = { version = "0.3.55", features = [
123133
"CanvasRenderingContext2d",
124134
"Document",
125135
"Element",
@@ -128,66 +138,72 @@ features = [
128138
"OffscreenCanvas",
129139
"OffscreenCanvasRenderingContext2d",
130140
"Window",
131-
]
141+
] }
132142

143+
# Orbital dependencies.
133144
[target.'cfg(target_os = "redox")'.dependencies]
134145
redox_syscall = "0.7"
135146

147+
[package.metadata.docs.rs]
148+
all-features = true
149+
rustdoc-args = ["--cfg", "docsrs"]
150+
default-target = "x86_64-unknown-linux-gnu"
151+
targets = [
152+
"x86_64-pc-windows-msvc",
153+
"x86_64-apple-darwin",
154+
"x86_64-unknown-linux-gnu",
155+
"wasm32-unknown-unknown",
156+
]
157+
158+
##
159+
## Development-related stuff below.
160+
##
161+
162+
[[example]]
163+
# Run with `cargo apk run --example winit_android`
164+
name = "winit_android"
165+
crate-type = ["cdylib"]
166+
167+
[[example]]
168+
# Run with `cargo apk run --example winit_multithread_android`
169+
name = "winit_multithread_android"
170+
crate-type = ["cdylib"]
171+
172+
[[bench]]
173+
name = "buffer_mut"
174+
harness = false
175+
136176
[dev-dependencies]
137177
colorous = "1.0.12"
138178
web-time = "1.0.0"
139179
winit = { version = "0.30.0", default-features = false, features = ["rwh_06"] }
140180
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
141181
glam = { version = "0.30.10", features = ["rand"] }
142182
rand = "0.9.2"
143-
144-
[target.'cfg(target_os = "android")'.dev-dependencies]
145-
winit = { version = "0.30.0", features = ["android-native-activity"] }
146-
android-activity = "0.6"
147-
148-
[dev-dependencies.image]
149-
version = "0.25.0"
150-
# Disable rayon on web
151-
default-features = false
152-
features = ["jpeg"]
183+
# Disable unnecessary formats.
184+
image = { version = "0.25.0", default-features = false, features = ["jpeg"] }
153185

154186
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
155-
# Turn rayon back on everywhere else; creating the separate entry resets the features to default.
187+
# Use rayon in raytracing example on non-web platforms.
156188
rayon = "1.5.1"
189+
# Enable criterion benchmarking on non-web platforms.
157190
criterion = { version = "0.8.1", default-features = false, features = [
158191
"cargo_bench_support",
159192
] }
160193

194+
[target.'cfg(target_os = "android")'.dev-dependencies]
195+
# Use NativeActivity on Android.
196+
winit = { version = "0.30.0", features = ["android-native-activity"] }
197+
android-activity = "0.6"
198+
161199
[target.'cfg(target_family = "wasm")'.dev-dependencies]
200+
# Add extra dependencies for making debugging easier on Web.
162201
wasm-bindgen-test = "0.3"
163202
console_error_panic_hook = "0.1"
164203
tracing-web = "0.1"
165204
# Allow `rand` crate to compile.
166205
getrandom = { version = "0.3.4", features = ["wasm_js"] }
167206

207+
# DRM example.
168208
[target.'cfg(not(any(target_os = "android", target_vendor = "apple", target_os = "redox", target_family = "wasm", target_os = "windows")))'.dev-dependencies]
169209
rustix = { version = "1.0.1", features = ["event"] }
170-
171-
[workspace]
172-
members = ["run-wasm"]
173-
174-
[[example]]
175-
# Run with `cargo apk r --example winit_android`
176-
name = "winit_android"
177-
crate-type = ["cdylib"]
178-
179-
[[example]]
180-
# Run with `cargo apk r --example winit_multithread_android`
181-
name = "winit_multithread_android"
182-
crate-type = ["cdylib"]
183-
184-
[package.metadata.docs.rs]
185-
all-features = true
186-
rustdoc-args = ["--cfg", "docsrs"]
187-
default-target = "x86_64-unknown-linux-gnu"
188-
targets = [
189-
"x86_64-pc-windows-msvc",
190-
"x86_64-apple-darwin",
191-
"x86_64-unknown-linux-gnu",
192-
"wasm32-unknown-unknown",
193-
]

0 commit comments

Comments
 (0)