Skip to content

Commit

Permalink
Make Debug impls optional
Browse files Browse the repository at this point in the history
When disabled, this buys us a 12% reduction in buildtime.
  • Loading branch information
Ralith committed Dec 21, 2021
1 parent a7d5c49 commit 93c527f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Device extension `khr::PipelineExecutableProperties` and `khr::TimelineSemaphore` now expose `fn device()` instead of `fn instance()` (#499)
- Changed `khr::PipelineExecutableProperties::new()` and `khr::TimelineSemaphore::new()` to take `instance` and `device` as arguments (#499)
- Vulkan structures only implement `Debug` if the `debug` feature is enabled (#482)

### Removed

Expand Down
2 changes: 2 additions & 0 deletions ash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ default = ["linked"]
linked = []
# Support searching for the Vulkan loader manually at runtime.
loaded = ["libloading"]
# Whether Vulkan structs should implement Debug
debug = []

[package.metadata.release]
no-dev-version = true
Expand Down
6 changes: 4 additions & 2 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,7 @@ pub fn derive_debug(_struct: &vkxml::Struct, union_types: &HashSet<&str>) -> Opt
});
let name_str = name.to_string();
let q = quote! {
#[cfg(feature = "debug")]
impl fmt::Debug for #name {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct(#name_str)
Expand Down Expand Up @@ -2134,7 +2135,7 @@ pub fn generate_struct(
let setter_tokens = derive_setters(_struct, root_structs);
let manual_derive_tokens = manual_derives(_struct);
let dbg_str = if debug_tokens.is_none() {
quote!(Debug,)
quote!(#[cfg_attr(feature = "debug", derive(Debug))])
} else {
quote!()
};
Expand All @@ -2146,7 +2147,8 @@ pub fn generate_struct(
let khronos_link = khronos_link(&_struct.name);
quote! {
#[repr(C)]
#[derive(Copy, Clone, #default_str #dbg_str #manual_derive_tokens)]
#dbg_str
#[derive(Copy, Clone, #default_str #manual_derive_tokens)]
#[doc = #khronos_link]
pub struct #name {
#(#params,)*
Expand Down

0 comments on commit 93c527f

Please sign in to comment.