Skip to content

Commit

Permalink
Avoid introducing spurious features for optional dependencies (#5691)
Browse files Browse the repository at this point in the history
* Avoid introducing spurious features for optional dependencies

If a feature depends on an optional dependency without using the dep:
prefix, a feature with the same name as the optional dependency is
introduced. This feature almost certainly won't have any effect when
enabled other than increasing compile times and polutes the feature list
shown by cargo add. Consistently use dep: for all optional dependencies
to avoid this problem.

* Add changelog entry
  • Loading branch information
bjorn3 authored May 12, 2024
1 parent ebbf901 commit fa48562
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ By @stefnotch in [#5410](https://github.com/gfx-rs/wgpu/pull/5410)

#### Naga

### Changes

#### General

- Avoid introducing spurious features for optional dependencies. By @bjorn3 in [#5691](https://github.com/gfx-rs/wgpu/pull/5691)

### Bug Fixes

#### GLES / OpenGL
Expand Down
12 changes: 6 additions & 6 deletions naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ all-features = true
[features]
default = []
dot-out = []
glsl-in = ["pp-rs"]
glsl-in = ["dep:pp-rs"]
glsl-out = []
msl-out = []
serialize = ["serde", "bitflags/serde", "indexmap/serde"]
deserialize = ["serde", "bitflags/serde", "indexmap/serde"]
serialize = ["dep:serde", "bitflags/serde", "indexmap/serde"]
deserialize = ["dep:serde", "bitflags/serde", "indexmap/serde"]
arbitrary = ["dep:arbitrary", "bitflags/arbitrary", "indexmap/arbitrary"]
spv-in = ["petgraph", "spirv"]
spv-out = ["spirv"]
wgsl-in = ["hexf-parse", "unicode-xid", "compact"]
spv-in = ["dep:petgraph", "dep:spirv"]
spv-out = ["dep:spirv"]
wgsl-in = ["dep:hexf-parse", "dep:unicode-xid", "compact"]
wgsl-out = []
hlsl-out = []
compact = []
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ strict_asserts = ["wgt/strict_asserts"]
serde = ["dep:serde", "wgt/serde", "arrayvec/serde"]

## Enable API tracing.
trace = ["ron", "serde", "naga/serialize"]
trace = ["dep:ron", "serde", "naga/serialize"]

## Enable API replaying
replay = ["serde", "naga/deserialize"]
Expand Down
38 changes: 19 additions & 19 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ targets = [

[features]
default = ["link"]
metal = ["naga/msl-out", "block"]
metal = ["naga/msl-out", "dep:block"]
vulkan = [
"naga/spv-out",
"ash",
"gpu-alloc",
"gpu-descriptor",
"libloading",
"smallvec",
"android_system_properties",
"dep:ash",
"dep:gpu-alloc",
"dep:gpu-descriptor",
"dep:libloading",
"dep:smallvec",
"dep:android_system_properties",
]
gles = [
"naga/glsl-out",
"glow",
"glutin_wgl_sys",
"khronos-egl",
"libloading",
"ndk-sys",
"dep:glow",
"dep:glutin_wgl_sys",
"dep:khronos-egl",
"dep:libloading",
"dep:ndk-sys",
]
dx12 = [
"naga/hlsl-out",
"d3d12",
"bit-set",
"libloading",
"range-alloc",
"dep:d3d12",
"dep:bit-set",
"dep:libloading",
"dep:range-alloc",
"winapi/std",
"winapi/winbase",
"winapi/d3d12",
Expand All @@ -66,9 +66,9 @@ dx12 = [
"winapi/dxgi1_6",
]
# TODO: This is a separate feature until Mozilla okays windows-rs, see https://github.com/gfx-rs/wgpu/issues/3207 for the tracking issue.
windows_rs = ["gpu-allocator"]
dxc_shader_compiler = ["hassle-rs"]
renderdoc = ["libloading", "renderdoc-sys"]
windows_rs = ["dep:gpu-allocator"]
dxc_shader_compiler = ["dep:hassle-rs"]
renderdoc = ["dep:libloading", "dep:renderdoc-sys"]
fragile-send-sync-non-atomic-wasm = ["wgt/fragile-send-sync-non-atomic-wasm"]
link = ["metal/link"]
# Panic when running into an out-of-memory error (for debugging purposes).
Expand Down
4 changes: 2 additions & 2 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vulkan-portability = ["wgc?/vulkan"]
## Enables the GLES backend on Wasm
##
## * ⚠️ WIP: Currently will also enable GLES dependencies on any other targets.
webgl = ["hal", "wgc/gles"]
webgl = ["dep:hal", "wgc/gles"]

#! **Note:** In the documentation, if you see that an item depends on a backend,
#! it means that the item is only available when that backend is enabled _and_ the backend
Expand All @@ -69,7 +69,7 @@ glsl = ["naga/glsl-in", "wgc/glsl"]
wgsl = ["wgc?/wgsl"]

## Enable accepting naga IR shaders as input.
naga-ir = ["naga"]
naga-ir = ["dep:naga"]

#! ### Logging & Tracing
# --------------------------------------------------------------------
Expand Down

0 comments on commit fa48562

Please sign in to comment.