Make Debug impls optional

When disabled, this buys us a 12% reduction in buildtime.
This commit is contained in:
Benjamin Saunders 2021-10-15 20:14:21 -07:00
parent e34f755ece
commit 1700dcdf05
4 changed files with 1464 additions and 717 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- examples: Use `c_char` for pointer to raw string (#521) - examples: Use `c_char` for pointer to raw string (#521)
- Device extension `khr::PipelineExecutableProperties` and `khr::TimelineSemaphore` now expose `fn device()` instead of `fn instance()` (#499) - 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) - Changed `khr::PipelineExecutableProperties::new()` and `khr::TimelineSemaphore::new()` to take `instance` and `device` as arguments (#499)
- To allow faster builds, Vulkan structures only implement `Debug` if the `debug` feature is enabled, which is the default (#482)
### Removed ### Removed

View file

@ -14,11 +14,13 @@ edition = "2018"
libloading = { version = "0.7", optional = true } libloading = { version = "0.7", optional = true }
[features] [features]
default = ["linked"] default = ["linked", "debug"]
# Link the Vulkan loader at compile time. # Link the Vulkan loader at compile time.
linked = [] linked = []
# Support searching for the Vulkan loader manually at runtime. # Support searching for the Vulkan loader manually at runtime.
loaded = ["libloading"] loaded = ["libloading"]
# Whether Vulkan structs should implement Debug
debug = []
[package.metadata.release] [package.metadata.release]
no-dev-version = true no-dev-version = true

File diff suppressed because it is too large Load diff

View file

@ -1710,6 +1710,7 @@ pub fn derive_debug(_struct: &vkxml::Struct, union_types: &HashSet<&str>) -> Opt
}); });
let name_str = name.to_string(); let name_str = name.to_string();
let q = quote! { let q = quote! {
#[cfg(feature = "debug")]
impl fmt::Debug for #name { impl fmt::Debug for #name {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct(#name_str) fmt.debug_struct(#name_str)
@ -2133,7 +2134,7 @@ pub fn generate_struct(
let setter_tokens = derive_setters(_struct, root_structs); let setter_tokens = derive_setters(_struct, root_structs);
let manual_derive_tokens = manual_derives(_struct); let manual_derive_tokens = manual_derives(_struct);
let dbg_str = if debug_tokens.is_none() { let dbg_str = if debug_tokens.is_none() {
quote!(Debug,) quote!(#[cfg_attr(feature = "debug", derive(Debug))])
} else { } else {
quote!() quote!()
}; };
@ -2145,7 +2146,8 @@ pub fn generate_struct(
let khronos_link = khronos_link(&_struct.name); let khronos_link = khronos_link(&_struct.name);
quote! { quote! {
#[repr(C)] #[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] #[doc = #khronos_link]
pub struct #name { pub struct #name {
#(#params,)* #(#params,)*