From 0ad6d44fe9d2f72a55eec3ddd45de2e054e484aa Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 11 May 2024 22:06:22 +0200 Subject: [PATCH 1/2] 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. --- naga/Cargo.toml | 12 ++++++------ wgpu-core/Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 38 +++++++++++++++++++------------------- wgpu/Cargo.toml | 4 ++-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 67116a0532..41049f4d53 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -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 = [] diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 7f099da5ca..42278afbc6 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -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"] diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 9cf095bbdb..fd0fadb196 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -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", @@ -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). diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 41da38ed3c..8d8ab17aab 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -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 @@ -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 # -------------------------------------------------------------------- From 9dcd36058e652508b4445ea9b3eeacc9975a18d9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 11 May 2024 22:09:08 +0200 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f8aade9f..021d39413a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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