From 096d3bc6605316c62f75ea5ad5908dd03b2efa4f Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Mon, 3 Apr 2023 06:33:01 +0200 Subject: [PATCH] Publish vulkano-macros (#2175) * Publish vulkano-macros * Document `vulkano-macros` * Make macros dependency optional * Document `macros` feature * Fix outdated docs * Derp --- Cargo.toml | 3 ++- {vulkano/macros => vulkano-macros}/Cargo.toml | 9 ++++++--- .../src/derive_buffer_contents.rs | 0 .../macros => vulkano-macros}/src/derive_vertex.rs | 0 {vulkano/macros => vulkano-macros}/src/lib.rs | 10 ++++++++++ vulkano-shaders/Cargo.toml | 7 +++++-- vulkano-util/Cargo.toml | 2 +- vulkano-win/Cargo.toml | 7 +++++-- vulkano-win/src/lib.rs | 8 ++++---- vulkano/Cargo.toml | 4 +++- vulkano/src/buffer/subbuffer.rs | 1 + vulkano/src/lib.rs | 14 +++++++------- .../src/pipeline/graphics/vertex_input/vertex.rs | 1 + 13 files changed, 45 insertions(+), 21 deletions(-) rename {vulkano/macros => vulkano-macros}/Cargo.toml (72%) rename {vulkano/macros => vulkano-macros}/src/derive_buffer_contents.rs (100%) rename {vulkano/macros => vulkano-macros}/src/derive_vertex.rs (100%) rename {vulkano/macros => vulkano-macros}/src/lib.rs (82%) diff --git a/Cargo.toml b/Cargo.toml index b9243017..108ef6c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,8 @@ members = [ "examples", "vulkano", + "vulkano-macros", "vulkano-shaders", - "vulkano-win", "vulkano-util", + "vulkano-win", ] diff --git a/vulkano/macros/Cargo.toml b/vulkano-macros/Cargo.toml similarity index 72% rename from vulkano/macros/Cargo.toml rename to vulkano-macros/Cargo.toml index 7170cb75..d1ef6d3d 100644 --- a/vulkano/macros/Cargo.toml +++ b/vulkano-macros/Cargo.toml @@ -2,13 +2,16 @@ name = "vulkano-macros" version = "0.33.0" edition = "2021" -authors = ["Pierre Krieger ", "The vulkano contributors"] +authors = [ + "Pierre Krieger ", + "The vulkano contributors", +] repository = "https://github.com/vulkano-rs/vulkano" description = "Macros used by Vulkano" license = "MIT/Apache-2.0" documentation = "https://docs.rs/vulkano" homepage = "https://vulkano.rs" -publish = false +publish = true [lib] proc-macro = true @@ -20,4 +23,4 @@ proc-macro2 = "1.0" proc-macro-crate = "1.2" [dev-dependencies] -vulkano = { path = ".." } +vulkano = { path = "../vulkano" } diff --git a/vulkano/macros/src/derive_buffer_contents.rs b/vulkano-macros/src/derive_buffer_contents.rs similarity index 100% rename from vulkano/macros/src/derive_buffer_contents.rs rename to vulkano-macros/src/derive_buffer_contents.rs diff --git a/vulkano/macros/src/derive_vertex.rs b/vulkano-macros/src/derive_vertex.rs similarity index 100% rename from vulkano/macros/src/derive_vertex.rs rename to vulkano-macros/src/derive_vertex.rs diff --git a/vulkano/macros/src/lib.rs b/vulkano-macros/src/lib.rs similarity index 82% rename from vulkano/macros/src/lib.rs rename to vulkano-macros/src/lib.rs index 4189e0a7..9649f30e 100644 --- a/vulkano/macros/src/lib.rs +++ b/vulkano-macros/src/lib.rs @@ -7,6 +7,10 @@ // notice may not be copied, modified, or distributed except // according to those terms. +//! Macros for [`vulkano`]. +//! +//! [`vulkano`]: https://crates.io/crates/vulkano + use proc_macro::TokenStream; use proc_macro_crate::{crate_name, FoundCrate}; use syn::{parse_macro_input, DeriveInput, Error}; @@ -14,6 +18,9 @@ use syn::{parse_macro_input, DeriveInput, Error}; mod derive_buffer_contents; mod derive_vertex; +/// Derives the [`Vertex`] trait. +/// +/// [`Vertex`]: https://docs.rs/vulkano/latest/vulkano/pipeline/graphics/vertex_input/trait.Vertex.html #[proc_macro_derive(Vertex, attributes(name, format))] pub fn derive_vertex(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); @@ -23,6 +30,9 @@ pub fn derive_vertex(input: TokenStream) -> TokenStream { .into() } +/// Derives the [`BufferContents`] trait. +/// +/// [`BufferContents`]: https://docs.rs/vulkano/latest/vulkano/buffer/trait.BufferContents.html #[proc_macro_derive(BufferContents)] pub fn derive_buffer_contents(input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); diff --git a/vulkano-shaders/Cargo.toml b/vulkano-shaders/Cargo.toml index 255378e3..0c7402d6 100644 --- a/vulkano-shaders/Cargo.toml +++ b/vulkano-shaders/Cargo.toml @@ -2,7 +2,10 @@ name = "vulkano-shaders" version = "0.33.0" edition = "2021" -authors = ["Pierre Krieger ", "The vulkano contributors"] +authors = [ + "Pierre Krieger ", + "The vulkano contributors", +] repository = "https://github.com/vulkano-rs/vulkano" description = "Shaders rust code generation macro" license = "MIT/Apache-2.0" @@ -21,7 +24,7 @@ proc-macro2 = "1.0" quote = "1.0" shaderc = "0.8" syn = { version = "1.0", features = ["full", "extra-traits"] } -vulkano = { version = "0.33.0", path = "../vulkano" } +vulkano = { version = "0.33.0", path = "../vulkano", default-features = false } [features] shaderc-build-from-source = ["shaderc/build-from-source"] diff --git a/vulkano-util/Cargo.toml b/vulkano-util/Cargo.toml index a221829e..bf2e88fc 100644 --- a/vulkano-util/Cargo.toml +++ b/vulkano-util/Cargo.toml @@ -13,6 +13,6 @@ categories = ["rendering::graphics-api"] [dependencies] ahash = "0.8" -vulkano = { version = "0.33.0", path = "../vulkano" } +vulkano = { version = "0.33.0", path = "../vulkano", default-features = false } vulkano-win = { version = "0.33.0", path = "../vulkano-win" } winit = { version = "0.28" } diff --git a/vulkano-win/Cargo.toml b/vulkano-win/Cargo.toml index 7d2b6f3e..22ccc998 100644 --- a/vulkano-win/Cargo.toml +++ b/vulkano-win/Cargo.toml @@ -2,7 +2,10 @@ name = "vulkano-win" version = "0.33.0" edition = "2021" -authors = ["Pierre Krieger ", "The vulkano contributors"] +authors = [ + "Pierre Krieger ", + "The vulkano contributors", +] repository = "https://github.com/vulkano-rs/vulkano" description = "Link between vulkano and winit" license = "MIT/Apache-2.0" @@ -20,7 +23,7 @@ winit_ = ["dep:winit", "dep:objc", "dep:core-graphics-types"] [dependencies] raw-window-handle = { version = "0.5", optional = true } -vulkano = { version = "0.33.0", path = "../vulkano" } +vulkano = { version = "0.33.0", path = "../vulkano", default-features = false } winit = { version = "0.28", optional = true } [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] diff --git a/vulkano-win/src/lib.rs b/vulkano-win/src/lib.rs index a1fa6b44..df0af694 100644 --- a/vulkano-win/src/lib.rs +++ b/vulkano-win/src/lib.rs @@ -1,9 +1,9 @@ //! # Cargo features //! -//! | Feature | Description | -//! |----------------------|----------------------------------------------------------------------------| -//! | `raw_window_handle_` | Include support for the [`raw_window_handle`] library. Enabled by default. | -//! | `winit_` | Include support for the [`winit`] library. Enabled by default. | +//! | Feature | Description | +//! |----------------------|---------------------------------------------------------------------------| +//! | `raw_window_handle` | Include support for the [`raw_window_handle`] library. Enabled by default. | +//! | `winit` | Include support for the [`winit`] library. Enabled by default. | //! //! [`raw_window_handle`]: https://crates.io/crates/raw_window_handle //! [`winit`]: https://crates.io/crates/winit diff --git a/vulkano/Cargo.toml b/vulkano/Cargo.toml index 0b563c15..b83bb096 100644 --- a/vulkano/Cargo.toml +++ b/vulkano/Cargo.toml @@ -30,7 +30,7 @@ parking_lot = { version = "0.12", features = ["send_guard"] } serde = { version = "1.0", optional = true } smallvec = "1.8" thread_local = "1.1" -vulkano-macros = { path = "macros", version = "0.33.0" } +vulkano-macros = { path = "../vulkano-macros", version = "0.33.0", optional = true } [target.'cfg(target_os = "ios")'.dependencies] objc = "0.2.5" @@ -53,4 +53,6 @@ cgmath = "0.18" nalgebra = "0.32" [features] +default = ["macros"] +macros = ["vulkano-macros"] document_unchecked = [] diff --git a/vulkano/src/buffer/subbuffer.rs b/vulkano/src/buffer/subbuffer.rs index 0010a723..84d12182 100644 --- a/vulkano/src/buffer/subbuffer.rs +++ b/vulkano/src/buffer/subbuffer.rs @@ -36,6 +36,7 @@ use std::{ thread, }; +#[cfg(feature = "macros")] pub use vulkano_macros::BufferContents; /// A subpart of a buffer. diff --git a/vulkano/src/lib.rs b/vulkano/src/lib.rs index dc4b7ef6..302dedcb 100644 --- a/vulkano/src/lib.rs +++ b/vulkano/src/lib.rs @@ -96,14 +96,12 @@ //! //! # Cargo features //! -//! | Feature | Description | -//! |----------------------|-------------------------------------------------------------------------------| -//! | `document_unchecked` | Include `_unchecked` functions in the generated documentation. | -//! | `serde` | Enables (de)serialization of certain types using [`serde`]. | +//! | Feature | Description | +//! |----------------------|---------------------------------------------------------------|| +//! | `macros` | Include reexports from [`vulkano-macros`]. Enabled by default. | +//! | `document_unchecked` | Include `_unchecked` functions in the generated documentation. | +//! | `serde` | Enables (de)serialization of certain types using [`serde`]. | //! -//! [`cgmath`]: https://crates.io/crates/cgmath -//! [`nalgebra`]: https://crates.io/crates/nalgebra -//! [`serde`]: https://crates.io/crates/serde //! [`VulkanLibrary`]: crate::VulkanLibrary //! [`Instance`]: crate::instance::Instance //! [`Surface`]: crate::swapchain::Surface @@ -125,6 +123,8 @@ //! [`PipelineLayout`]: crate::pipeline::layout //! [`RenderPass`]: crate::render_pass::RenderPass //! [`Framebuffer`]: crate::render_pass::Framebuffer +//! [`vulkano-macros`]: vulkano_macros +//! [`serde`]: https://crates.io/crates/serde //#![warn(missing_docs)] // TODO: activate #![warn( diff --git a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs index 4464063e..fb500aa4 100644 --- a/vulkano/src/pipeline/graphics/vertex_input/vertex.rs +++ b/vulkano/src/pipeline/graphics/vertex_input/vertex.rs @@ -10,6 +10,7 @@ use super::VertexInputRate; use crate::{buffer::BufferContents, format::Format}; use std::collections::HashMap; +#[cfg(feature = "macros")] pub use vulkano_macros::Vertex; /// Describes an individual `Vertex`. In other words a collection of attributes that can be read